Skip to content

Commit

Permalink
reworked command line construction; deps: added oslex for commandline…
Browse files Browse the repository at this point in the history
… manipulation
  • Loading branch information
hedger committed Jul 9, 2024
1 parent 9a45f3c commit b15efe5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.5
0.2.6
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ authors = [{ name = "Flipper Devices Inc.", email = "[email protected]" }]
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 = [
Expand All @@ -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"
Expand Down
33 changes: 21 additions & 12 deletions ufbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import pathlib
import platform
import sys
import oslex

from .bootstrap import (
DEFAULT_UFBT_HOME,
Expand Down Expand Up @@ -83,29 +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:])
)

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:])
)
commandline = '. "$UFBT_STATE_DIR/current/scripts/toolchain/fbtenv.sh" && '

commandline += oslex.join(
[
"python3",
"-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)
Expand Down

0 comments on commit b15efe5

Please sign in to comment.