1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-12 04:41:26 +04:00

fbt/ufbt: Ensure POSIX paths are passed to GDB on all platforms (#3360)

* fbt/ufbt: Ensure POSIX paths are passed to GDB on all platforms
  GDB heavily dislikes forward slashes from Windows paths and strips
  them internally instead of normalizing them. Account for this by
  passing POSIX paths explicitly.
* fbt: different approach for posix path handling
* fbt, ufbt: further fixes for path handling
* fbt: explicit path stringification
* linter fixes

Co-authored-by: hedger <hedger@users.noreply.github.com>
Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Silent
2024-03-20 23:36:38 +01:00
committed by GitHub
parent 0c465f7eb3
commit 4039ccbcca
6 changed files with 53 additions and 33 deletions

View File

@@ -47,7 +47,7 @@ from fbt.appmanifest import FlipperApplication, FlipperAppType
from fbt.sdk.cache import SdkCache
from fbt.util import (
FORWARDED_ENV_VARIABLES,
path_as_posix,
PosixPathWrapper,
resolve_real_dir_node,
single_quote,
tempfile_arg_esc_func,
@@ -89,6 +89,7 @@ env = core_env.Clone(
("compilation_db", {"COMPILATIONDB_COMSTR": "\tCDB\t${TARGET}"}),
],
FBT_FAP_DEBUG_ELF_ROOT=ufbt_build_dir,
POSIXPATH=PosixPathWrapper,
TEMPFILE=TempFileMunge,
MAXLINELENGTH=2048,
PROGSUFFIX=".elf",
@@ -128,7 +129,7 @@ dist_env = env.Clone(
"-c",
"transport select hla_swd",
"-f",
"${FBT_DEBUG_DIR}/stm32wbx.cfg",
"${POSIXPATH('$FBT_DEBUG_DIR')}/stm32wbx.cfg",
"-c",
"stm32wbx.cpu configure -rtos auto",
],
@@ -161,7 +162,6 @@ firmware_debug = dist_env.PhonyTarget(
source=dist_env["FW_ELF"],
GDBOPTS="${GDBOPTS_BASE}",
GDBREMOTE="${OPENOCD_GDB_PIPE}",
FBT_FAP_DEBUG_ELF_ROOT=path_as_posix(dist_env.subst("$FBT_FAP_DEBUG_ELF_ROOT")),
)
dist_env.PhonyTarget(
@@ -170,15 +170,14 @@ dist_env.PhonyTarget(
source=dist_env["FW_ELF"],
GDBOPTS="${GDBOPTS_BASE} ${GDBOPTS_BLACKMAGIC}",
GDBREMOTE="${BLACKMAGIC_ADDR}",
FBT_FAP_DEBUG_ELF_ROOT=path_as_posix(dist_env.subst("$FBT_FAP_DEBUG_ELF_ROOT")),
)
# Debug alien elf
debug_other_opts = [
"-ex",
"source ${FBT_DEBUG_DIR}/PyCortexMDebug/PyCortexMDebug.py",
"source ${POSIXPATH('FBT_DEBUG_DIR')}/PyCortexMDebug/PyCortexMDebug.py",
"-ex",
"source ${FBT_DEBUG_DIR}/flipperversion.py",
"source ${POSIXPATH('FBT_DEBUG_DIR')}/flipperversion.py",
"-ex",
"fw-version",
]
@@ -371,10 +370,6 @@ dist_env.PhonyTarget(
# Prepare vscode environment
def _path_as_posix(path):
return pathlib.Path(path).as_posix()
vscode_dist = []
project_template_dir = dist_env["UFBT_SCRIPT_ROOT"].Dir("project_template")
for template_file in project_template_dir.Dir(".vscode").glob("*"):
@@ -387,20 +382,24 @@ for template_file in project_template_dir.Dir(".vscode").glob("*"):
"@UFBT_TOOLCHAIN_ARM_TOOLCHAIN_DIR@": pathlib.Path(
dist_env.WhereIs("arm-none-eabi-gcc")
).parent.as_posix(),
"@UFBT_TOOLCHAIN_GCC@": _path_as_posix(
"@UFBT_TOOLCHAIN_GCC@": PosixPathWrapper.fix_path(
dist_env.WhereIs("arm-none-eabi-gcc")
),
"@UFBT_TOOLCHAIN_GDB_PY@": _path_as_posix(
"@UFBT_TOOLCHAIN_GDB_PY@": PosixPathWrapper.fix_path(
dist_env.WhereIs("arm-none-eabi-gdb-py3")
),
"@UFBT_TOOLCHAIN_OPENOCD@": _path_as_posix(dist_env.WhereIs("openocd")),
"@UFBT_APP_DIR@": _path_as_posix(original_app_dir.abspath),
"@UFBT_ROOT_DIR@": _path_as_posix(Dir("#").abspath),
"@UFBT_DEBUG_DIR@": _path_as_posix(dist_env["FBT_DEBUG_DIR"].abspath),
"@UFBT_DEBUG_ELF_DIR@": _path_as_posix(
"@UFBT_TOOLCHAIN_OPENOCD@": PosixPathWrapper.fix_path(
dist_env.WhereIs("openocd")
),
"@UFBT_APP_DIR@": PosixPathWrapper.fix_path(original_app_dir.abspath),
"@UFBT_ROOT_DIR@": PosixPathWrapper.fix_path(Dir("#").abspath),
"@UFBT_DEBUG_DIR@": dist_env.subst("FBT_DEBUG_DIR"),
"@UFBT_DEBUG_ELF_DIR@": PosixPathWrapper.fix_path(
dist_env["FBT_FAP_DEBUG_ELF_ROOT"].abspath
),
"@UFBT_FIRMWARE_ELF@": _path_as_posix(dist_env["FW_ELF"].abspath),
"@UFBT_FIRMWARE_ELF@": PosixPathWrapper.fix_path(
dist_env["FW_ELF"].abspath
),
},
)
)