From e04b34ef1c5a5703109d2bce1a97ab79669b829c Mon Sep 17 00:00:00 2001 From: hedger Date: Tue, 9 Jul 2024 15:18:04 +0300 Subject: [PATCH] Args processing fix (#47) * reworked command line construction; deps: added oslex for commandline manipulation * fixed Python executable name --- .github/workflows/test.yml | 2 +- VERSION.txt | 2 +- pyproject.toml | 2 +- ufbt/__init__.py | 34 +++++++++++++++++++++------------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16dc11f..e6bc91e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.11] + python-version: [3.8, 3.11, 3.12] steps: - uses: actions/checkout@v2 diff --git a/VERSION.txt b/VERSION.txt index 3a4036f..53a75d6 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.2.5 +0.2.6 diff --git a/pyproject.toml b/pyproject.toml index 8c56ea8..b9d16ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ authors = [{ name = "Flipper Devices Inc.", email = "pypi@flipperdevices.com" }] description = "uFBT - micro Flipper Build Tool. Tool for building and developing applications (.fap) for Flipper Zero and its device family." readme = "README.md" requires-python = ">=3.8" +dependencies = ["oslex>=0.1.3"] keywords = ["ufbt", "flipperzero", "fbt", "stm32", "fap"] license = { text = "GPL-3.0" } classifiers = [ @@ -26,7 +27,6 @@ classifiers = [ "Operating System :: POSIX :: Linux", ] - [project.urls] homepage = "https://github.com/flipperdevices/flipperzero-ufbt" documentation = "https://github.com/flipperdevices/flipperzero-ufbt" diff --git a/ufbt/__init__.py b/ufbt/__init__.py index f066a2e..da5a068 100644 --- a/ufbt/__init__.py +++ b/ufbt/__init__.py @@ -21,6 +21,7 @@ import pathlib import platform import sys +import oslex from .bootstrap import ( DEFAULT_UFBT_HOME, @@ -83,30 +84,37 @@ def ufbt_cli(): if not os.path.exists(ufbt_state_dir / "current"): bootstrap_cli(["update"]) - if not (ufbt_state_dir / "current" / "scripts" / "ufbt").exists(): + if not ( + ufbt_script_root := ufbt_state_dir / "current" / "scripts" / "ufbt" + ).exists(): print("SDK is missing scripts distribution!") print("You might be trying to use an SDK in an outdated format.") - print("Run `ufbt update -h` for more information on how to update.") + print("You can clean up current state with `ufbt clean --purge`.") + print("Run `ufbt update -h` for more information on SDK installation.") return 1 UFBT_APP_DIR = os.getcwd() if platform.system() == "Windows": - commandline = ( - r'call "%UFBT_STATE_DIR%/current/scripts/toolchain/fbtenv.cmd" env & ' - "python -m SCons -Q --warn=target-not-built " - r'-C "%UFBT_STATE_DIR%/current/scripts/ufbt" ' - f'"UFBT_APP_DIR={UFBT_APP_DIR}" ' + " ".join(sys.argv[1:]) - ) - + commandline = r'call "%UFBT_STATE_DIR%/current/scripts/toolchain/fbtenv.cmd" env & python ' else: commandline = ( - '. "$UFBT_STATE_DIR/current/scripts/toolchain/fbtenv.sh" && ' - "python3 -m SCons -Q --warn=target-not-built " - '-C "$UFBT_STATE_DIR/current/scripts/ufbt" ' - f'"UFBT_APP_DIR={UFBT_APP_DIR}" ' + " ".join(sys.argv[1:]) + '. "$UFBT_STATE_DIR/current/scripts/toolchain/fbtenv.sh" && python3 ' ) + commandline += oslex.join( + [ + "-m", + "SCons", + "-Q", + "--warn=target-not-built", + "-C", + str(ufbt_script_root), + f"UFBT_APP_DIR={UFBT_APP_DIR}", + *sys.argv[1:], + ] + ) + # print(commandline) retcode = os.system(commandline) if platform.system() != "Windows":