mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Merge branch 'ofw-dev' into dev
This commit is contained in:
@@ -328,10 +328,7 @@ class AppBuildset:
|
||||
sdk_headers.extend(
|
||||
[
|
||||
src._appdir.File(header)
|
||||
for src in [
|
||||
app,
|
||||
*(plugin for plugin in app._plugins),
|
||||
]
|
||||
for src in [app, *app._plugins]
|
||||
for header in src.sdk_headers
|
||||
]
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ import os
|
||||
import pathlib
|
||||
import shutil
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional
|
||||
from typing import Optional, Dict, List
|
||||
|
||||
import SCons.Warnings
|
||||
from ansi.color import fg
|
||||
@@ -400,22 +400,26 @@ def generate_embed_app_metadata_actions(source, target, env, for_signature):
|
||||
return Action(actions)
|
||||
|
||||
|
||||
def AddAppLaunchTarget(env, appname, launch_target_name):
|
||||
deploy_sources, flipp_dist_paths, validators = [], [], []
|
||||
run_script_extra_ars = ""
|
||||
@dataclass
|
||||
class AppDeploymentComponents:
|
||||
deploy_sources: Dict[str, object] = field(default_factory=dict)
|
||||
validators: List[object] = field(default_factory=list)
|
||||
extra_launch_args: str = ""
|
||||
|
||||
def _add_dist_targets(app_artifacts):
|
||||
validators.append(app_artifacts.validator)
|
||||
def add_app(self, app_artifacts):
|
||||
for _, ext_path in app_artifacts.dist_entries:
|
||||
deploy_sources.append(app_artifacts.compact)
|
||||
flipp_dist_paths.append(f"/ext/{ext_path}")
|
||||
return app_artifacts
|
||||
self.deploy_sources[f"/ext/{ext_path}"] = app_artifacts.compact
|
||||
self.validators.append(app_artifacts.validator)
|
||||
|
||||
|
||||
def _gather_app_components(env, appname) -> AppDeploymentComponents:
|
||||
components = AppDeploymentComponents()
|
||||
|
||||
def _add_host_app_to_targets(host_app):
|
||||
artifacts_app_to_run = env["EXT_APPS"].get(host_app.appid, None)
|
||||
_add_dist_targets(artifacts_app_to_run)
|
||||
components.add_app(artifacts_app_to_run)
|
||||
for plugin in host_app._plugins:
|
||||
_add_dist_targets(env["EXT_APPS"].get(plugin.appid, None))
|
||||
components.add_app(env["EXT_APPS"].get(plugin.appid, None))
|
||||
|
||||
artifacts_app_to_run = env.GetExtAppByIdOrPath(appname)
|
||||
if artifacts_app_to_run.app.apptype == FlipperAppType.PLUGIN:
|
||||
@@ -427,25 +431,35 @@ def AddAppLaunchTarget(env, appname, launch_target_name):
|
||||
FlipperAppType.EXTERNAL,
|
||||
FlipperAppType.MENUEXTERNAL,
|
||||
]:
|
||||
_add_host_app_to_targets(host_app)
|
||||
components.add_app(host_app)
|
||||
else:
|
||||
# host app is a built-in app
|
||||
run_script_extra_ars = f"-a {host_app.name}"
|
||||
_add_dist_targets(artifacts_app_to_run)
|
||||
components.add_app(artifacts_app_to_run)
|
||||
components.extra_launch_args = f"-a {host_app.name}"
|
||||
else:
|
||||
raise UserError("Host app is unknown")
|
||||
else:
|
||||
_add_host_app_to_targets(artifacts_app_to_run.app)
|
||||
return components
|
||||
|
||||
# print(deploy_sources, flipp_dist_paths)
|
||||
env.PhonyTarget(
|
||||
|
||||
def AddAppLaunchTarget(env, appname, launch_target_name):
|
||||
components = _gather_app_components(env, appname)
|
||||
target = env.PhonyTarget(
|
||||
launch_target_name,
|
||||
'${PYTHON3} "${APP_RUN_SCRIPT}" -p ${FLIP_PORT} ${EXTRA_ARGS} -s ${SOURCES} -t ${FLIPPER_FILE_TARGETS}',
|
||||
source=deploy_sources,
|
||||
FLIPPER_FILE_TARGETS=flipp_dist_paths,
|
||||
EXTRA_ARGS=run_script_extra_ars,
|
||||
source=components.deploy_sources.values(),
|
||||
FLIPPER_FILE_TARGETS=components.deploy_sources.keys(),
|
||||
EXTRA_ARGS=components.extra_launch_args,
|
||||
)
|
||||
env.Alias(launch_target_name, validators)
|
||||
env.Alias(launch_target_name, components.validators)
|
||||
return target
|
||||
|
||||
|
||||
def AddAppBuildTarget(env, appname, build_target_name):
|
||||
components = _gather_app_components(env, appname)
|
||||
env.Alias(build_target_name, components.validators)
|
||||
env.Alias(build_target_name, components.deploy_sources.values())
|
||||
|
||||
|
||||
def generate(env, **kw):
|
||||
@@ -474,6 +488,7 @@ def generate(env, **kw):
|
||||
env.AddMethod(BuildAppElf)
|
||||
env.AddMethod(GetExtAppByIdOrPath)
|
||||
env.AddMethod(AddAppLaunchTarget)
|
||||
env.AddMethod(AddAppBuildTarget)
|
||||
|
||||
env.Append(
|
||||
BUILDERS={
|
||||
|
||||
@@ -4,15 +4,16 @@ targets_help = """Configuration variables:
|
||||
tail_help = """
|
||||
|
||||
TASKS:
|
||||
Building:
|
||||
Firmware & apps:
|
||||
firmware_all, fw_dist:
|
||||
Build firmware; create distribution package
|
||||
faps, fap_dist:
|
||||
Build all FAP apps
|
||||
fap_{APPID}, launch_app APPSRC={APPID}:
|
||||
fap_{APPID}, build APPSRC={APPID}; launch APPSRC={APPID}:
|
||||
Build FAP app with appid={APPID}; upload & start it over USB
|
||||
fap_deploy:
|
||||
Build and upload all FAP apps over USB
|
||||
|
||||
|
||||
Flashing & debugging:
|
||||
flash, flash_blackmagic, jflash:
|
||||
|
||||
@@ -336,8 +336,10 @@ def ambiguous_app_call(**kw):
|
||||
|
||||
if app_to_launch:
|
||||
appenv.AddAppLaunchTarget(app_to_launch, "launch")
|
||||
appenv.AddAppBuildTarget(app_to_launch, "build")
|
||||
else:
|
||||
dist_env.PhonyTarget("launch", Action(ambiguous_app_call, None))
|
||||
dist_env.PhonyTarget("build", Action(ambiguous_app_call, None))
|
||||
|
||||
# cli handler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user