Browse Source

pio: experiment with cachedir

network/test
Maxim Prokhorov 1 year ago
parent
commit
cfab435275
3 changed files with 38 additions and 1 deletions
  1. +2
    -0
      code/scripts/espurna_utils/__init__.py
  2. +27
    -0
      code/scripts/espurna_utils/build.py
  3. +9
    -1
      code/scripts/pio_main.py

+ 2
- 0
code/scripts/espurna_utils/__init__.py View File

@ -25,6 +25,7 @@ from .build import (
app_add_target_build_and_copy,
app_add_gzip_file,
app_add_target_build_re2c,
app_patch_cachedir,
)
from .checks import check_env, check_binsize
from .flags import app_inject_flags
@ -41,6 +42,7 @@ __all__ = [
"app_inject_flags",
"app_inject_version",
"app_version",
"app_patch_cachedir",
"check_env",
"check_binsize",
"disable_postmortem_output",


+ 27
- 0
code/scripts/espurna_utils/build.py View File

@ -185,3 +185,30 @@ def app_add_target_build_re2c(env):
[env.File(target)], [env.File(target.replace(".re.ipp", ".re"))], env
)
env.Exit(0)
# c/p giant hack from https://github.com/platformio/platformio-core/issues/4574
# force node path used for signature to be relative to `BUILD_DIR` instead of `PROJECT_DIR`
# thus, forcing CacheDir to share results between multiple environments
def app_patch_cachedir(env):
from SCons.Node.FS import hash_collect, File
build_dir = env["BUILD_DIR"]
def patched_get_cachedir_bsig(self):
try:
return self.cachesig
except AttributeError:
pass
children = self.children()
sigs = [n.get_cachedir_csig() for n in children]
sigs.append(self.get_contents_sig())
sigs.append(self.get_path(build_dir))
result = self.cachesig = hash_collect(sigs)
return result
File.get_cachedir_bsig = patched_get_cachedir_bsig

+ 9
- 1
code/scripts/pio_main.py View File

@ -17,7 +17,9 @@ from espurna_utils import (
app_inject_flags,
app_inject_version,
app_add_gzip_file,
app_patch_cachedir,
check_binsize,
check_env,
disable_postmortem_output,
ldscripts_inject_libpath,
remove_float_support,
@ -29,7 +31,7 @@ Import("env", "projenv")
env = globals()["env"]
projenv = globals()["projenv"]
CI = "true" == os.environ.get("CI")
CI = check_env("CI")
# See what happens in-between linking .cpp.o + .a into the resulting .elf
env.Append(ESPURNA_BUILD_FIRMWARE_MAP="${BUILD_DIR}/${PROGNAME}.map")
@ -75,3 +77,9 @@ app_add_gzip_file(projenv)
pre_process = env.get("ESPURNA_SINGLE_SOURCE_TARGET")
if pre_process:
projenv.PreProcess(pre_process)
# hijack SCons signature generation to exclude BUILD_DIR, making our builds faster
# when using different environments (i.e. itead-sonoff-basic, itead-sonoff-pow, etc.)
cachefix_fix = check_env("ESPURNA_FIX_CACHEDIR_PATH")
if cachedir_fix:
app_patch_cachedir(projenv)

Loading…
Cancel
Save