1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 20:49:49 +04:00

Merge branch 'ofw_dev' into dev

This commit is contained in:
MX
2023-12-19 16:27:23 +03:00
8 changed files with 63 additions and 59 deletions

View File

@@ -343,7 +343,7 @@ bool nfc_load_file(NfcApp* instance, FuriString* path, bool show_dialog) {
nfc_supported_cards_load_cache(instance->nfc_supported_cards); nfc_supported_cards_load_cache(instance->nfc_supported_cards);
FuriString* load_path = furi_string_alloc(); FuriString* load_path = furi_string_alloc();
if(nfc_has_shadow_file_internal(instance, path)) { if(nfc_has_shadow_file_internal(instance, path)) { //-V1051
nfc_set_shadow_file_path(path, load_path); nfc_set_shadow_file_path(path, load_path);
} else if(furi_string_end_with(path, NFC_APP_SHADOW_EXTENSION)) { } else if(furi_string_end_with(path, NFC_APP_SHADOW_EXTENSION)) {
size_t path_len = furi_string_size(path); size_t path_len = furi_string_size(path);

View File

@@ -108,7 +108,7 @@ KeysDict* keys_dict_alloc(const char* path, KeysDictMode mode, size_t key_size)
} }
} }
stream_rewind(instance->stream); stream_rewind(instance->stream);
FURI_LOG_I(TAG, "Loaded dictionary with %u keys", instance->total_keys); FURI_LOG_I(TAG, "Loaded dictionary with %zu keys", instance->total_keys);
furi_string_free(line); furi_string_free(line);
@@ -299,13 +299,12 @@ bool keys_dict_delete_key(KeysDict* instance, const uint8_t* key, size_t key_siz
furi_assert(key); furi_assert(key);
bool key_removed = false; bool key_removed = false;
bool is_endfile = false;
uint8_t* temp_key = malloc(key_size); uint8_t* temp_key = malloc(key_size);
stream_rewind(instance->stream); stream_rewind(instance->stream);
while(!key_removed && !is_endfile) { while(!key_removed) {
if(!keys_dict_get_next_key(instance, temp_key, key_size)) { if(!keys_dict_get_next_key(instance, temp_key, key_size)) {
break; break;
} }
@@ -332,4 +331,4 @@ bool keys_dict_delete_key(KeysDict* instance, const uint8_t* key, size_t key_siz
free(temp_key); free(temp_key);
return key_removed; return key_removed;
} }

View File

@@ -11,6 +11,28 @@ WINPATHSEP_RE = re.compile(r"\\([^\"'\\]|$)")
# Excludes all files ending with ~, usually created by editors as backup files # Excludes all files ending with ~, usually created by editors as backup files
GLOB_FILE_EXCLUSION = ["*~"] GLOB_FILE_EXCLUSION = ["*~"]
# List of environment variables to proxy to child processes
FORWARDED_ENV_VARIABLES = [
# CI/CD variables
"WORKFLOW_BRANCH_OR_TAG",
"DIST_SUFFIX",
"FORCE_NO_DIRTY",
# Python & other tools
"HOME",
"APPDATA",
"PYTHONHOME",
"PYTHONNOUSERSITE",
"TMP",
"TEMP",
# ccache
"CCACHE_DISABLE",
# Colors for tools
"TERM",
# Toolchain
"FBT_TOOLCHAIN_PATH",
"UFBT_HOME",
]
def tempfile_arg_esc_func(arg): def tempfile_arg_esc_func(arg):
arg = quote_spaces(arg) arg = quote_spaces(arg)

View File

@@ -25,33 +25,10 @@ forward_os_env = {
"PATH": os.environ["PATH"], "PATH": os.environ["PATH"],
} }
# Proxying environment to child processes & scripts
variables_to_forward = [
# CI/CD variables
"WORKFLOW_BRANCH_OR_TAG",
"DIST_SUFFIX",
# Python & other tools
"HOME",
"APPDATA",
"PYTHONHOME",
"PYTHONNOUSERSITE",
"TMP",
"TEMP",
# Colors for tools
"TERM",
]
if proxy_env := GetOption("proxy_env"):
variables_to_forward.extend(proxy_env.split(","))
for env_value_name in variables_to_forward:
if environ_value := os.environ.get(env_value_name, None):
forward_os_env[env_value_name] = environ_value
# Core environment init - loads SDK state, sets up paths, etc. # Core environment init - loads SDK state, sets up paths, etc.
core_env = Environment( core_env = Environment(
variables=ufbt_variables, variables=ufbt_variables,
ENV=forward_os_env,
UFBT_STATE_DIR=ufbt_state_dir, UFBT_STATE_DIR=ufbt_state_dir,
UFBT_CURRENT_SDK_DIR=ufbt_current_sdk_dir, UFBT_CURRENT_SDK_DIR=ufbt_current_sdk_dir,
UFBT_SCRIPT_DIR=ufbt_script_dir, UFBT_SCRIPT_DIR=ufbt_script_dir,
@@ -69,6 +46,7 @@ core_env.Append(CPPDEFINES=GetOption("extra_defines"))
from fbt.appmanifest import FlipperApplication, FlipperAppType from fbt.appmanifest import FlipperApplication, FlipperAppType
from fbt.sdk.cache import SdkCache from fbt.sdk.cache import SdkCache
from fbt.util import ( from fbt.util import (
FORWARDED_ENV_VARIABLES,
path_as_posix, path_as_posix,
resolve_real_dir_node, resolve_real_dir_node,
single_quote, single_quote,
@@ -76,8 +54,19 @@ from fbt.util import (
wrap_tempfile, wrap_tempfile,
) )
variables_to_forward = list(FORWARDED_ENV_VARIABLES)
if proxy_env := GetOption("proxy_env"):
variables_to_forward.extend(proxy_env.split(","))
for env_value_name in variables_to_forward:
if environ_value := os.environ.get(env_value_name, None):
forward_os_env[env_value_name] = environ_value
# Base environment with all tools loaded from SDK # Base environment with all tools loaded from SDK
env = core_env.Clone( env = core_env.Clone(
ENV=forward_os_env,
toolpath=[core_env["FBT_SCRIPT_DIR"].Dir("fbt_tools")], toolpath=[core_env["FBT_SCRIPT_DIR"].Dir("fbt_tools")],
tools=[ tools=[
"fbt_tweaks", "fbt_tweaks",
@@ -477,9 +466,12 @@ else:
dist_env.PhonyTarget("dolphin_ext", Action(missing_dolphin_folder, None)) dist_env.PhonyTarget("dolphin_ext", Action(missing_dolphin_folder, None))
# print(env.Dump())
dist_env.PhonyTarget( dist_env.PhonyTarget(
"env", "env",
"@echo $( ${FBT_SCRIPT_DIR.abspath}/toolchain/fbtenv.sh $)", '@echo "FBT_TOOLCHAIN_PATH='
+ forward_os_env["FBT_TOOLCHAIN_PATH"]
+ '" source $( "${FBT_SCRIPT_DIR.abspath}/toolchain/fbtenv.sh" $)',
) )
dist_env.PostConfigureUfbtEnvionment() dist_env.PostConfigureUfbtEnvionment()

View File

@@ -1,4 +1,6 @@
dist/* dist/*
.vscode .vscode
.clang-format .clang-format
.editorconfig .editorconfig
.env
.ufbt

View File

@@ -44,7 +44,11 @@ How to create a new application:
4. Run `ufbt launch` to build and upload your application. 4. Run `ufbt launch` to build and upload your application.
How to open a shell with toolchain environment and other build tools: How to open a shell with toolchain environment and other build tools:
In your shell, type "source `ufbt -s env`". You can also use "." instead of "source". In your shell, type "eval `ufbt -s env`".
How to update uFBT SDK:
Run "ufbt update" to fetch latest SDK.
You can also specify branch, target and/or channel options. See "ufbt update -h" for details.
""" """

View File

@@ -1,6 +1,5 @@
import json import json
import os import os
import pathlib
import sys import sys
from functools import reduce from functools import reduce

View File

@@ -1,13 +1,14 @@
from SCons.Platform import TempFileMunge
from fbt.util import (
tempfile_arg_esc_func,
single_quote,
wrap_tempfile,
resolve_real_dir_node,
)
import os
import multiprocessing import multiprocessing
import os
from fbt.util import (
FORWARDED_ENV_VARIABLES,
resolve_real_dir_node,
single_quote,
tempfile_arg_esc_func,
wrap_tempfile,
)
from SCons.Platform import TempFileMunge
Import("VAR_ENV") Import("VAR_ENV")
@@ -15,24 +16,9 @@ forward_os_env = {
# Import PATH from OS env - scons doesn't do that by default # Import PATH from OS env - scons doesn't do that by default
"PATH": os.environ["PATH"], "PATH": os.environ["PATH"],
} }
# Proxying CI environment to child processes & scripts
variables_to_forward = [ variables_to_forward = list(FORWARDED_ENV_VARIABLES)
# CI/CD variables
"WORKFLOW_BRANCH_OR_TAG",
"DIST_SUFFIX",
"FORCE_NO_DIRTY",
# Python & other tools
"HOME",
"APPDATA",
"PYTHONHOME",
"PYTHONNOUSERSITE",
"TMP",
"TEMP",
# ccache
"CCACHE_DISABLE",
# Colors for tools
"TERM",
]
if proxy_env := GetOption("proxy_env"): if proxy_env := GetOption("proxy_env"):
variables_to_forward.extend(proxy_env.split(",")) variables_to_forward.extend(proxy_env.split(","))