ufbt: changed toolchain environment invocation; updated .gitignore for app template (#3300)

This commit is contained in:
hedger 2023-12-19 16:43:06 +04:00 committed by GitHub
parent 6f6074dc01
commit 1e1d9fcb69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 53 deletions

View file

@ -11,6 +11,27 @@ 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",
# 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

@ -2,3 +2,5 @@ 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,23 +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",
# 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(","))