mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 04:41:28 +00:00
qmk new-keymap
now locates the new keymap inside userspace if set.
This commit is contained in:
parent
b441da6a85
commit
5477193489
@ -7,7 +7,7 @@ from pathlib import Path
|
||||
from subprocess import DEVNULL
|
||||
from milc import cli
|
||||
|
||||
from qmk.constants import QMK_FIRMWARE, QMK_USERSPACE
|
||||
from qmk.constants import QMK_FIRMWARE, QMK_USERSPACE, HAS_QMK_USERSPACE
|
||||
from qmk.commands import _find_make, get_make_parallel_args
|
||||
from qmk.keyboard import resolve_keyboard
|
||||
from qmk.search import search_keymap_targets
|
||||
@ -51,7 +51,7 @@ def mass_compile(cli):
|
||||
with open(makefile, "w") as f:
|
||||
|
||||
userspace_suffix = ''
|
||||
if Path(QMK_FIRMWARE).resolve() != Path(QMK_USERSPACE).resolve():
|
||||
if HAS_QMK_USERSPACE:
|
||||
userspace_suffix = f'QMK_USERSPACE={Path(QMK_USERSPACE).resolve()}'
|
||||
|
||||
for target in sorted(targets):
|
||||
|
@ -1,10 +1,12 @@
|
||||
"""This script automates the copying of the default keymap into your own keymap.
|
||||
"""
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from milc import cli
|
||||
from milc.questions import question
|
||||
|
||||
from qmk.constants import HAS_QMK_USERSPACE, QMK_USERSPACE, QMK_FIRMWARE
|
||||
from qmk.path import is_keyboard, keymaps, keymap
|
||||
from qmk.git import git_get_username
|
||||
from qmk.decorators import automagic_keyboard, automagic_keymap
|
||||
@ -54,6 +56,9 @@ def new_keymap(cli):
|
||||
keymap_path_default = keymap(kb_name, 'default')
|
||||
keymap_path_new = keymaps_dirs[0] / user_name
|
||||
|
||||
if HAS_QMK_USERSPACE:
|
||||
keymap_path_new = Path(QMK_USERSPACE) / keymaps_dirs[0].relative_to(QMK_FIRMWARE) / user_name
|
||||
|
||||
if not keymap_path_default.exists():
|
||||
cli.log.error(f'Default keymap {{fg_cyan}}{keymap_path_default}{{fg_reset}} does not exist!')
|
||||
return False
|
||||
|
@ -9,7 +9,7 @@ from pathlib import Path
|
||||
from milc import cli
|
||||
import jsonschema
|
||||
|
||||
from qmk.constants import INTERMEDIATE_OUTPUT_PREFIX, QMK_FIRMWARE, QMK_USERSPACE
|
||||
from qmk.constants import INTERMEDIATE_OUTPUT_PREFIX, QMK_USERSPACE, HAS_QMK_USERSPACE
|
||||
from qmk.json_schema import json_load, validate
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ def create_make_target(target, dry_run=False, parallel=1, **env_vars):
|
||||
for key, value in env_vars.items():
|
||||
env.append(f'{key}={value}')
|
||||
|
||||
if Path(QMK_FIRMWARE).resolve() != Path(QMK_USERSPACE).resolve():
|
||||
if HAS_QMK_USERSPACE:
|
||||
env.append(f'QMK_USERSPACE={Path(QMK_USERSPACE).resolve()}')
|
||||
|
||||
if cli.config.general.verbose:
|
||||
|
@ -25,6 +25,9 @@ def _detect_qmk_userspace():
|
||||
# The detected userspace tree
|
||||
QMK_USERSPACE = _detect_qmk_userspace()
|
||||
|
||||
# Whether or not we have a separate userspace directory
|
||||
HAS_QMK_USERSPACE = True if Path(QMK_USERSPACE).resolve() != Path(QMK_FIRMWARE).resolve() else False
|
||||
|
||||
# Upstream repo url
|
||||
QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware'
|
||||
|
||||
|
@ -12,7 +12,7 @@ from pygments.token import Token
|
||||
from pygments import lex
|
||||
|
||||
import qmk.path
|
||||
from qmk.constants import QMK_FIRMWARE, QMK_USERSPACE
|
||||
from qmk.constants import QMK_FIRMWARE, QMK_USERSPACE, HAS_QMK_USERSPACE
|
||||
from qmk.keyboard import find_keyboard_from_dir, keyboard_folder
|
||||
from qmk.errors import CppError
|
||||
from qmk.info import info_json
|
||||
@ -218,7 +218,7 @@ def find_keymap_from_dir():
|
||||
return relative_cwd.parts[1], 'users_directory'
|
||||
return None, None
|
||||
|
||||
if Path(QMK_FIRMWARE).resolve() != Path(QMK_USERSPACE).resolve():
|
||||
if HAS_QMK_USERSPACE:
|
||||
name, source = _impl_find_keymap_from_dir(qmk.path.under_qmk_userspace())
|
||||
if name and source:
|
||||
return name, source
|
||||
@ -430,7 +430,7 @@ def locate_keymap(keyboard, keymap):
|
||||
# Check the keyboard folder first, last match wins
|
||||
keymap_path = ''
|
||||
|
||||
for search_dir in [QMK_FIRMWARE, QMK_USERSPACE]:
|
||||
for search_dir in [QMK_FIRMWARE, QMK_USERSPACE] if HAS_QMK_USERSPACE else [QMK_FIRMWARE]:
|
||||
checked_dirs = ''
|
||||
for dir in keyboard_folder(keyboard).split('/'):
|
||||
if checked_dirs:
|
||||
@ -452,7 +452,7 @@ def locate_keymap(keyboard, keymap):
|
||||
info = info_json(keyboard)
|
||||
|
||||
community_parents = list(Path('layouts').glob('*/'))
|
||||
if Path(QMK_FIRMWARE).resolve() != Path(QMK_USERSPACE).resolve() and (Path(QMK_USERSPACE) / "layouts").exists():
|
||||
if HAS_QMK_USERSPACE and (Path(QMK_USERSPACE) / "layouts").exists():
|
||||
community_parents.append(Path(QMK_USERSPACE) / "layouts")
|
||||
|
||||
for community_parent in community_parents:
|
||||
@ -509,7 +509,7 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
|
||||
info = info_json(keyboard)
|
||||
|
||||
community_parents = list(Path('layouts').glob('*/'))
|
||||
if Path(QMK_FIRMWARE).resolve() != Path(QMK_USERSPACE).resolve() and (Path(QMK_USERSPACE) / "layouts").exists():
|
||||
if HAS_QMK_USERSPACE and (Path(QMK_USERSPACE) / "layouts").exists():
|
||||
community_parents.append(Path(QMK_USERSPACE) / "layouts")
|
||||
|
||||
for community_parent in community_parents:
|
||||
|
Loading…
Reference in New Issue
Block a user