2022-06-26 15:00:03 +03:00
|
|
|
from SCons.Platform import TempFileMunge
|
2022-11-02 18:15:40 +03:00
|
|
|
from fbt.util import (
|
|
|
|
tempfile_arg_esc_func,
|
|
|
|
single_quote,
|
|
|
|
wrap_tempfile,
|
2023-08-10 19:21:56 +03:00
|
|
|
resolve_real_dir_node,
|
2022-11-02 18:15:40 +03:00
|
|
|
)
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
import os
|
|
|
|
import multiprocessing
|
|
|
|
|
|
|
|
Import("VAR_ENV")
|
|
|
|
|
|
|
|
forward_os_env = {
|
|
|
|
# Import PATH from OS env - scons doesn't do that by default
|
|
|
|
"PATH": os.environ["PATH"],
|
|
|
|
}
|
|
|
|
# Proxying CI environment to child processes & scripts
|
2022-10-06 16:55:57 +03:00
|
|
|
variables_to_forward = [
|
2022-10-12 19:12:05 +03:00
|
|
|
# CI/CD variables
|
2022-09-24 14:30:19 +03:00
|
|
|
"WORKFLOW_BRANCH_OR_TAG",
|
|
|
|
"DIST_SUFFIX",
|
2022-12-29 01:41:23 +03:00
|
|
|
"FORCE_NO_DIRTY",
|
2022-10-12 19:12:05 +03:00
|
|
|
# Python & other tools
|
2022-09-24 14:30:19 +03:00
|
|
|
"HOME",
|
|
|
|
"APPDATA",
|
|
|
|
"PYTHONHOME",
|
|
|
|
"PYTHONNOUSERSITE",
|
2022-10-06 16:55:57 +03:00
|
|
|
"TMP",
|
|
|
|
"TEMP",
|
2023-11-15 19:27:35 +03:00
|
|
|
# ccache
|
|
|
|
"CCACHE_DISABLE",
|
2022-10-12 19:12:05 +03:00
|
|
|
# Colors for tools
|
|
|
|
"TERM",
|
2022-10-06 16:55:57 +03:00
|
|
|
]
|
|
|
|
if proxy_env := GetOption("proxy_env"):
|
|
|
|
variables_to_forward.extend(proxy_env.split(","))
|
|
|
|
|
|
|
|
for env_value_name in variables_to_forward:
|
2022-06-26 15:00:03 +03:00
|
|
|
if environ_value := os.environ.get(env_value_name, None):
|
|
|
|
forward_os_env[env_value_name] = environ_value
|
|
|
|
|
|
|
|
|
|
|
|
coreenv = VAR_ENV.Clone(
|
|
|
|
tools=[
|
2022-10-26 01:15:02 +03:00
|
|
|
"fbt_tweaks",
|
2022-06-26 15:00:03 +03:00
|
|
|
(
|
|
|
|
"crosscc",
|
|
|
|
{
|
|
|
|
"toolchain_prefix": "arm-none-eabi-",
|
|
|
|
"versions": VAR_ENV["FBT_TOOLCHAIN_VERSIONS"],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
"python3",
|
|
|
|
"sconsmodular",
|
|
|
|
"sconsrecursiveglob",
|
|
|
|
"ccache",
|
|
|
|
],
|
|
|
|
TEMPFILE=TempFileMunge,
|
|
|
|
MAXLINELENGTH=2048,
|
|
|
|
PROGSUFFIX=".elf",
|
|
|
|
ENV=forward_os_env,
|
2022-11-02 18:15:40 +03:00
|
|
|
SINGLEQUOTEFUNC=single_quote,
|
2023-08-10 19:21:56 +03:00
|
|
|
ABSPATHGETTERFUNC=resolve_real_dir_node,
|
2022-11-02 18:15:40 +03:00
|
|
|
# Setting up temp file parameters - to overcome command line length limits
|
|
|
|
TEMPFILEARGESCFUNC=tempfile_arg_esc_func,
|
|
|
|
ROOT_DIR=Dir("#"),
|
2023-11-15 19:27:35 +03:00
|
|
|
FBT_SCRIPT_DIR=Dir("#/scripts"),
|
2022-06-26 15:00:03 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
# If DIST_SUFFIX is set in environment, is has precedence (set by CI)
|
|
|
|
if os_suffix := os.environ.get("DIST_SUFFIX", None):
|
|
|
|
coreenv.Replace(
|
|
|
|
DIST_SUFFIX=os_suffix,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Default value for commandline options
|
|
|
|
|
|
|
|
SetOption("num_jobs", multiprocessing.cpu_count())
|
2022-10-26 01:15:02 +03:00
|
|
|
## NB - disabled both caches since they seem to do more harm then good in our case
|
2022-06-26 15:00:03 +03:00
|
|
|
# Avoiding re-scan of all sources on every startup
|
2022-10-26 01:15:02 +03:00
|
|
|
# SetOption("implicit_cache", True)
|
2022-10-12 19:12:05 +03:00
|
|
|
# SetOption("implicit_deps_unchanged", True)
|
2022-06-26 15:00:03 +03:00
|
|
|
# More aggressive caching
|
|
|
|
SetOption("max_drift", 1)
|
|
|
|
# Random task queue - to discover isses with build logic faster
|
|
|
|
# SetOption("random", 1)
|
|
|
|
|
2022-10-12 19:12:05 +03:00
|
|
|
wrap_tempfile(coreenv, "LINKCOM")
|
|
|
|
wrap_tempfile(coreenv, "ARCOM")
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
Return("coreenv")
|