mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -07:00
fbt: removed assets rebuild on git commit id change; added explicit dependency for SDK source on compiled assets parts; removed unneeded sdk regeneration runs
This commit is contained in:
@@ -1,16 +1,5 @@
|
|||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
from fbt.version import get_fast_git_version_id
|
|
||||||
|
|
||||||
# HACHHACK
|
|
||||||
# Currently injected to CPPPATH by libs - since they are built earlier and depend on assets
|
|
||||||
# env.Append(
|
|
||||||
# CPPPATH=[
|
|
||||||
# Dir("./compiled"),
|
|
||||||
# ]
|
|
||||||
# )
|
|
||||||
version_value = Value(get_fast_git_version_id())
|
|
||||||
|
|
||||||
assetsenv = env.Clone(
|
assetsenv = env.Clone(
|
||||||
tools=["fbt_assets"],
|
tools=["fbt_assets"],
|
||||||
FW_LIB_NAME="assets",
|
FW_LIB_NAME="assets",
|
||||||
@@ -77,7 +66,6 @@ assetsenv.Alias("proto_ver", proto_ver)
|
|||||||
|
|
||||||
# Gather everything into a static lib
|
# Gather everything into a static lib
|
||||||
assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
|
assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
|
||||||
assetsenv.Depends(assets_parts, version_value)
|
|
||||||
|
|
||||||
assetslib = assetsenv.Library("${FW_LIB_NAME}", assets_parts)
|
assetslib = assetsenv.Library("${FW_LIB_NAME}", assets_parts)
|
||||||
assetsenv.Install("${LIB_DIST_DIR}", assetslib)
|
assetsenv.Install("${LIB_DIST_DIR}", assetslib)
|
||||||
@@ -113,6 +101,7 @@ if assetsenv["IS_BASE_FIRMWARE"]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Exporting resources node to external environment
|
# Exporting resources node to external environment
|
||||||
|
env["FW_ASSETS_HEADERS"] = assets_parts
|
||||||
env["FW_RESOURCES"] = resources
|
env["FW_RESOURCES"] = resources
|
||||||
assetsenv.Alias("resources", resources)
|
assetsenv.Alias("resources", resources)
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ if fwenv["IS_BASE_FIRMWARE"]:
|
|||||||
"-D__inline__=inline",
|
"-D__inline__=inline",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
Depends(sdk_source, fwenv["SDK_HEADERS"])
|
Depends(sdk_source, (fwenv["SDK_HEADERS"], fwenv["FW_ASSETS_HEADERS"]))
|
||||||
|
|
||||||
sdk_tree = fwenv.SDKTree("sdk/sdk.opts", "sdk_origin")
|
sdk_tree = fwenv.SDKTree("sdk/sdk.opts", "sdk_origin")
|
||||||
AlwaysBuild(sdk_tree)
|
AlwaysBuild(sdk_tree)
|
||||||
|
|||||||
@@ -329,7 +329,6 @@ class SdkCache:
|
|||||||
self.sdk = ApiEntries()
|
self.sdk = ApiEntries()
|
||||||
self.disabled_entries = set()
|
self.disabled_entries = set()
|
||||||
self.new_entries = set()
|
self.new_entries = set()
|
||||||
self.loaded_dirty = False
|
|
||||||
self.loaded_dirty_version = False
|
self.loaded_dirty_version = False
|
||||||
|
|
||||||
self.version_action = VersionBump.NONE
|
self.version_action = VersionBump.NONE
|
||||||
@@ -340,8 +339,7 @@ class SdkCache:
|
|||||||
return (
|
return (
|
||||||
self.version != SdkVersion(0, 0)
|
self.version != SdkVersion(0, 0)
|
||||||
and self.version_action == VersionBump.NONE
|
and self.version_action == VersionBump.NONE
|
||||||
and not self.loaded_dirty
|
and not self._have_pending_entries()
|
||||||
and not self.new_entries
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _filter_enabled(self, sdk_entries):
|
def _filter_enabled(self, sdk_entries):
|
||||||
@@ -388,21 +386,12 @@ class SdkCache:
|
|||||||
if self._load_version_only:
|
if self._load_version_only:
|
||||||
raise Exception("Only SDK version was loaded, cannot save")
|
raise Exception("Only SDK version was loaded, cannot save")
|
||||||
|
|
||||||
version_is_clean = True
|
|
||||||
if self.loaded_dirty:
|
|
||||||
# There are still new entries and version was already updated
|
|
||||||
version_is_clean = False
|
|
||||||
|
|
||||||
if self.version_action == VersionBump.MINOR:
|
if self.version_action == VersionBump.MINOR:
|
||||||
self.version = SdkVersion(self.version.major, self.version.minor + 1)
|
self.version = SdkVersion(self.version.major, self.version.minor + 1)
|
||||||
version_is_clean = False
|
|
||||||
elif self.version_action == VersionBump.MAJOR:
|
elif self.version_action == VersionBump.MAJOR:
|
||||||
self.version = SdkVersion(self.version.major + 1, 0)
|
self.version = SdkVersion(self.version.major + 1, 0)
|
||||||
version_is_clean = False
|
|
||||||
|
|
||||||
if version_is_clean:
|
if self._have_pending_entries():
|
||||||
print(f"API version {self.version} is up to date")
|
|
||||||
else:
|
|
||||||
self.new_entries.add(self.version)
|
self.new_entries.add(self.version)
|
||||||
print(
|
print(
|
||||||
f"API version is still WIP: {self.version}. Review the changes and re-run command."
|
f"API version is still WIP: {self.version}. Review the changes and re-run command."
|
||||||
@@ -418,16 +407,23 @@ class SdkCache:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
print(f"API version {self.version} is up to date")
|
||||||
|
|
||||||
if not version_is_clean or self.loaded_dirty_version:
|
regenerate_csv = (
|
||||||
# Regenerate cache file
|
self.loaded_dirty_version
|
||||||
|
or self._have_pending_entries()
|
||||||
|
or self.version_action != VersionBump.NONE
|
||||||
|
)
|
||||||
|
|
||||||
|
if regenerate_csv:
|
||||||
str_cache_entries = [self.version]
|
str_cache_entries = [self.version]
|
||||||
name_getter = operator.attrgetter("name")
|
name_getter = operator.attrgetter("name")
|
||||||
str_cache_entries.extend(sorted(self.sdk.headers, key=name_getter))
|
str_cache_entries.extend(sorted(self.sdk.headers, key=name_getter))
|
||||||
str_cache_entries.extend(sorted(self.sdk.functions, key=name_getter))
|
str_cache_entries.extend(sorted(self.sdk.functions, key=name_getter))
|
||||||
str_cache_entries.extend(sorted(self.sdk.variables, key=name_getter))
|
str_cache_entries.extend(sorted(self.sdk.variables, key=name_getter))
|
||||||
|
|
||||||
with open(self.cache_file_name, "w", newline="") as f:
|
with open(self.cache_file_name, "wt", newline="") as f:
|
||||||
writer = csv.DictWriter(f, fieldnames=SdkCache.CSV_FIELD_NAMES)
|
writer = csv.DictWriter(f, fieldnames=SdkCache.CSV_FIELD_NAMES)
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
|
|
||||||
@@ -476,13 +472,20 @@ class SdkCache:
|
|||||||
f"Cannot load symbol cache '{self.cache_file_name}'! File does not exist"
|
f"Cannot load symbol cache '{self.cache_file_name}'! File does not exist"
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(self.cache_file_name, "r") as f:
|
with open(self.cache_file_name, "rt") as f:
|
||||||
reader = csv.DictReader(f)
|
reader = csv.DictReader(f)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
self._process_entry(row)
|
self._process_entry(row)
|
||||||
if self._load_version_only and row.get("entry") == SdkVersion.csv_type:
|
if self._load_version_only and row.get("entry") == SdkVersion.csv_type:
|
||||||
break
|
break
|
||||||
self.loaded_dirty = bool(self.new_entries)
|
|
||||||
|
def _have_pending_entries(self) -> bool:
|
||||||
|
return any(
|
||||||
|
filter(
|
||||||
|
lambda e: not isinstance(e, SdkVersion),
|
||||||
|
self.new_entries,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def sync_sets(
|
def sync_sets(
|
||||||
self, known_set: Set[Any], new_set: Set[Any], update_version: bool = True
|
self, known_set: Set[Any], new_set: Set[Any], update_version: bool = True
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from fbt.sdk import SdkCollector, SdkCache
|
|||||||
|
|
||||||
def prebuild_sdk_emitter(target, source, env):
|
def prebuild_sdk_emitter(target, source, env):
|
||||||
target.append(env.ChangeFileExtension(target[0], ".d"))
|
target.append(env.ChangeFileExtension(target[0], ".d"))
|
||||||
|
target.append(env.ChangeFileExtension(target[0], ".i.c"))
|
||||||
return target, source
|
return target, source
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user