aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/python/qmk/cli/__init__.py2
-rwxr-xr-xlib/python/qmk/cli/generate/rules_mk.py4
-rw-r--r--lib/python/qmk/path.py24
3 files changed, 26 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index 3f2ba9ce3c..cb949d9a71 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -215,7 +215,7 @@ if sys.version_info[0] != 3 or sys.version_info[1] < 9:
milc_version = __VERSION__.split('.')
-if int(milc_version[0]) < 2 and int(milc_version[1]) < 4:
+if int(milc_version[0]) < 2 and int(milc_version[1]) < 9:
requirements = Path('requirements.txt').resolve()
_eprint(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')
diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py
index cae9b07c3e..ef4101d77f 100755
--- a/lib/python/qmk/cli/generate/rules_mk.py
+++ b/lib/python/qmk/cli/generate/rules_mk.py
@@ -10,7 +10,7 @@ from qmk.info import info_json, get_modules
from qmk.json_schema import json_load
from qmk.keyboard import keyboard_completer, keyboard_folder
from qmk.commands import dump_lines, parse_configurator_json
-from qmk.path import normpath, FileType
+from qmk.path import normpath, unix_style_path, FileType
from qmk.constants import GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE
from qmk.community_modules import find_module_path, load_module_jsons
@@ -63,7 +63,7 @@ def generate_modules_rules(keyboard, filename):
lines.append('')
lines.append('OPT_DEFS += -DCOMMUNITY_MODULES_ENABLE=TRUE')
for module in modules:
- module_path = find_module_path(module)
+ module_path = unix_style_path(find_module_path(module))
if not module_path:
raise FileNotFoundError(f"Module '{module}' not found.")
lines.append('')
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py
index 61daad585f..c47ed18362 100644
--- a/lib/python/qmk/path.py
+++ b/lib/python/qmk/path.py
@@ -3,7 +3,7 @@
import logging
import os
import argparse
-from pathlib import Path
+from pathlib import Path, PureWindowsPath, PurePosixPath
from qmk.constants import MAX_KEYBOARD_SUBFOLDERS, QMK_FIRMWARE, QMK_USERSPACE, HAS_QMK_USERSPACE
from qmk.errors import NoSuchKeyboardError
@@ -146,6 +146,28 @@ def normpath(path):
return Path(os.environ['ORIG_CWD']) / path
+def unix_style_path(path):
+ """Converts a Windows-style path with drive letter to a Unix path.
+
+ Path().as_posix() normally returns the path with drive letter and forward slashes, so is inappropriate for `Makefile` paths.
+
+ Passes through unadulterated if the path is not a Windows-style path.
+
+ Args:
+
+ path
+ The path to convert.
+
+ Returns:
+ The input path converted to Unix format.
+ """
+ if isinstance(path, PureWindowsPath):
+ p = list(path.parts)
+ p[0] = f'/{p[0][0].lower()}' # convert from `X:/` to `/x`
+ path = PurePosixPath(*p)
+ return path
+
+
class FileType(argparse.FileType):
def __init__(self, *args, **kwargs):
# Use UTF8 by default for stdin