mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 05:06:30 +04:00
fbt fixes for mfbt pt2 (#1951)
* fbt: split sdk management code * scripts: fixed import handling * fbt: sdk: reformatted paths * scrips: dist: bundling libs as a build artifact * fbt: sdk: better path management * typo fix * fbt: sdk: minor path handling fixes * toolchain: fixed windows toolchain download * fbt: minor refactorin * fbt: moved sdk management code to extapps.scons * fbt: fixed sdk symbols header path; disabled -fstack-usage * fbt: changed pathing for .py scripts * fbt: changed SDK_HEADERS pathing; added libusb to SDK; added icon_i.h to SDK; added hw target to SDK meta * fbt: added libusb headers to SDK * picopass: include cleanup; api: added subghz/registry.h; api: added mbedtls to exported headers * picopass: fixed formatting * fbt: fixed COPRO_ASSETS_SCRIPT * sdk: added basic infrared apis * toolchain: added ufbt to list of legal fbtenv callers; updated error messages * fbt: changed manifest collection & icon processing code * fbt: simpler srcdir lookup * toolchain: path management fixes; fbt: fixes for fap private libs paths * scripts: toolchain: reworked download on Windows * toolchain: v17 * scripts: added colorlog for logging * Github: fix unit tests Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -46,7 +46,9 @@ def prebuild_sdk_emitter(target, source, env):
|
||||
def prebuild_sdk_create_origin_file(target, source, env):
|
||||
mega_file = env.subst("${TARGET}.c", target=target[0])
|
||||
with open(mega_file, "wt") as sdk_c:
|
||||
sdk_c.write("\n".join(f"#include <{h.path}>" for h in env["SDK_HEADERS"]))
|
||||
sdk_c.write(
|
||||
"\n".join(f"#include <{h.srcnode().path}>" for h in env["SDK_HEADERS"])
|
||||
)
|
||||
|
||||
|
||||
class SdkMeta:
|
||||
@@ -62,18 +64,25 @@ class SdkMeta:
|
||||
"cc_args": self._wrap_scons_vars("$CCFLAGS $_CCCOMCOM"),
|
||||
"cpp_args": self._wrap_scons_vars("$CXXFLAGS $CCFLAGS $_CCCOMCOM"),
|
||||
"linker_args": self._wrap_scons_vars("$LINKFLAGS"),
|
||||
"linker_script": self.env.subst("${LINKER_SCRIPT_PATH}"),
|
||||
"linker_libs": self.env.subst("${LIBS}"),
|
||||
"app_ep_subst": self.env.subst("${APP_ENTRY}"),
|
||||
"sdk_path_subst": self.env.subst("${SDK_DIR_SUBST}"),
|
||||
"hardware": self.env.subst("${TARGET_HW}"),
|
||||
}
|
||||
with open(json_manifest_path, "wt") as f:
|
||||
json.dump(meta_contents, f, indent=4)
|
||||
|
||||
def _wrap_scons_vars(self, vars: str):
|
||||
expanded_vars = self.env.subst(vars, target=Entry("dummy"))
|
||||
expanded_vars = self.env.subst(
|
||||
vars,
|
||||
target=Entry("dummy"),
|
||||
)
|
||||
return expanded_vars.replace("\\", "/")
|
||||
|
||||
|
||||
class SdkTreeBuilder:
|
||||
SDK_DIR_SUBST = "SDK_ROOT_DIR"
|
||||
SDK_APP_EP_SUBST = "SDK_APP_EP_SUBST"
|
||||
|
||||
def __init__(self, env, target, source) -> None:
|
||||
self.env = env
|
||||
@@ -87,6 +96,11 @@ class SdkTreeBuilder:
|
||||
self.sdk_root_dir = target[0].Dir(".")
|
||||
self.sdk_deploy_dir = self.sdk_root_dir.Dir(self.target_sdk_dir_name)
|
||||
|
||||
self.sdk_env = self.env.Clone(
|
||||
APP_ENTRY=self.SDK_APP_EP_SUBST,
|
||||
SDK_DIR_SUBST=self.SDK_DIR_SUBST,
|
||||
)
|
||||
|
||||
def _parse_sdk_depends(self):
|
||||
deps_file = self.source[0]
|
||||
with open(deps_file.path, "rt") as deps_f:
|
||||
@@ -95,38 +109,36 @@ class SdkTreeBuilder:
|
||||
self.header_depends = list(
|
||||
filter(lambda fname: fname.endswith(".h"), depends.split()),
|
||||
)
|
||||
self.header_depends.append(self.env.subst("${LINKER_SCRIPT_PATH}"))
|
||||
self.header_depends.append(self.env.subst("${SDK_DEFINITION}"))
|
||||
self.header_depends.append(self.sdk_env.subst("${LINKER_SCRIPT_PATH}"))
|
||||
self.header_depends.append(self.sdk_env.subst("${SDK_DEFINITION}"))
|
||||
self.header_dirs = sorted(
|
||||
set(map(os.path.normpath, map(os.path.dirname, self.header_depends)))
|
||||
)
|
||||
|
||||
def _generate_sdk_meta(self):
|
||||
filtered_paths = [self.target_sdk_dir_name]
|
||||
filtered_paths = ["."]
|
||||
full_fw_paths = list(
|
||||
map(
|
||||
os.path.normpath,
|
||||
(self.env.Dir(inc_dir).relpath for inc_dir in self.env["CPPPATH"]),
|
||||
(
|
||||
self.sdk_env.Dir(inc_dir).relpath
|
||||
for inc_dir in self.sdk_env["CPPPATH"]
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
sdk_dirs = ", ".join(f"'{dir}'" for dir in self.header_dirs)
|
||||
filtered_paths.extend(
|
||||
map(
|
||||
self.build_sdk_file_path,
|
||||
filter(lambda path: path in sdk_dirs, full_fw_paths),
|
||||
)
|
||||
filter(lambda path: path in sdk_dirs, full_fw_paths),
|
||||
)
|
||||
filtered_paths = list(map(self.build_sdk_file_path, filtered_paths))
|
||||
|
||||
sdk_env = self.env.Clone()
|
||||
sdk_env.Replace(
|
||||
self.sdk_env.Replace(
|
||||
CPPPATH=filtered_paths,
|
||||
LINKER_SCRIPT=self.env.subst("${APP_LINKER_SCRIPT}"),
|
||||
ORIG_LINKER_SCRIPT_PATH=self.env["LINKER_SCRIPT_PATH"],
|
||||
LINKER_SCRIPT_PATH=self.build_sdk_file_path("${ORIG_LINKER_SCRIPT_PATH}"),
|
||||
)
|
||||
|
||||
meta = SdkMeta(sdk_env, self)
|
||||
meta = SdkMeta(self.sdk_env, self)
|
||||
meta.save_to(self.target[0].path)
|
||||
|
||||
def build_sdk_file_path(self, orig_path: str) -> str:
|
||||
@@ -211,7 +223,7 @@ def validate_sdk_cache(source, target, env):
|
||||
current_sdk = SdkCollector()
|
||||
current_sdk.process_source_file_for_sdk(source[0].path)
|
||||
for h in env["SDK_HEADERS"]:
|
||||
current_sdk.add_header_to_sdk(pathlib.Path(h.path).as_posix())
|
||||
current_sdk.add_header_to_sdk(pathlib.Path(h.srcnode().path).as_posix())
|
||||
|
||||
sdk_cache = SdkCache(target[0].path)
|
||||
sdk_cache.validate_api(current_sdk.get_api())
|
||||
|
||||
Reference in New Issue
Block a user