forked from flipperdevices/flipperzero-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FL-3330] fbt: added hooks for build & dist environments; added FW_OR…
…IGIN_* macro for apps & SDK (flipperdevices#2705) * fbt: added hooks for build & dist environments * Moved env hooks to an optional file * Fixed var name * Added fw origin to device info * Bumped device info version * fbt: added FIRMWARE_ORIGIN option. Different implementation for FW_ORIGIN_* C macro. * api: bumped versions * fbt: added fbt_options_local.py * gitignore: cleanup Co-authored-by: あく <[email protected]>
- Loading branch information
Showing
16 changed files
with
206 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
""" | ||
To introduce changes to firmware build environment that are specific to your fork: | ||
create a file "scripts/fbt/fbt_hooks.py" | ||
With it, you can define functions that will be called at specific points of | ||
firmware build configuration, with environment as an argument. | ||
For example, you can define a function `PreConfigureFwEnvionment(env)` that | ||
defines that will be a part of SDK build, so applications can | ||
use them for conditional compilation. | ||
Here is a list of all available hooks: | ||
PreConfigureFwEnvionment(env): | ||
This function is called on firmware environment (incl. updater) | ||
before any major configuration is done. | ||
PostConfigureFwEnvionment(env): | ||
This function is called on firmware environment (incl. updater) | ||
after all configuration is done. | ||
PreConfigureUfbtEnvionment(env): | ||
This function is called on ufbt environment at the beginning of | ||
its configuration, before dist environment is created. | ||
PostConfigureUfbtEnvionment(env): | ||
This function is called on ufbt dist_env environment after all | ||
configuration and target creation is done. | ||
""" | ||
|
||
|
||
class DefaultFbtHooks: | ||
pass | ||
|
||
|
||
try: | ||
from fbt import fbt_hooks | ||
except ImportError: | ||
fbt_hooks = DefaultFbtHooks() | ||
|
||
|
||
def generate(env): | ||
stub_hook = lambda env: None | ||
control_hooks = [ | ||
"PreConfigureFwEnvionment", | ||
"PostConfigureFwEnvionment", | ||
"PreConfigureUfbtEnvionment", | ||
"PostConfigureUfbtEnvionment", | ||
] | ||
|
||
if ( | ||
isinstance(fbt_hooks, DefaultFbtHooks) | ||
and env.subst("${FIRMWARE_ORIGIN}") != "Official" | ||
): | ||
# If fbt_hooks.py is not present, but we are not building official firmware, | ||
# create "scripts/fbt/fbt_hooks.py" to implement changes to firmware build environment. | ||
pass | ||
|
||
for hook_name in control_hooks: | ||
hook_fn = getattr(fbt_hooks, hook_name, stub_hook) | ||
env.AddMethod(hook_fn, hook_name) | ||
|
||
|
||
def exists(): | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.