mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Fix issue which did not allow to override runtime build environment using extra POST script
This commit is contained in:
@ -21,6 +21,8 @@ PlatformIO 3.0
|
|||||||
systems (Windows)
|
systems (Windows)
|
||||||
* Fixed issue with ``build_unflags`` option when a macro contains value
|
* Fixed issue with ``build_unflags`` option when a macro contains value
|
||||||
(e.g., ``-DNAME=VALUE``)
|
(e.g., ``-DNAME=VALUE``)
|
||||||
|
* Fixed issue which did not allow to override runtime build environment using
|
||||||
|
extra POST script
|
||||||
|
|
||||||
3.5.2 (2018-03-13)
|
3.5.2 (2018-03-13)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -156,7 +156,7 @@ env.LoadPioPlatform(commonvars)
|
|||||||
env.SConscriptChdir(0)
|
env.SConscriptChdir(0)
|
||||||
env.SConsignFile(join("$PROJECTBUILD_DIR", ".sconsign.dblite"))
|
env.SConsignFile(join("$PROJECTBUILD_DIR", ".sconsign.dblite"))
|
||||||
|
|
||||||
for item in env.GetPreExtraScripts():
|
for item in env.GetExtraScripts("pre"):
|
||||||
env.SConscript(item, exports="env")
|
env.SConscript(item, exports="env")
|
||||||
|
|
||||||
env.SConscript("$BUILD_SCRIPT")
|
env.SConscript("$BUILD_SCRIPT")
|
||||||
@ -167,7 +167,7 @@ AlwaysBuild(env.Alias("__test", DEFAULT_TARGETS + ["size"]))
|
|||||||
if "UPLOAD_FLAGS" in env:
|
if "UPLOAD_FLAGS" in env:
|
||||||
env.Append(UPLOADERFLAGS=["$UPLOAD_FLAGS"])
|
env.Append(UPLOADERFLAGS=["$UPLOAD_FLAGS"])
|
||||||
|
|
||||||
for item in env.GetPostExtraScripts():
|
for item in env.GetExtraScripts("post"):
|
||||||
env.SConscript(item, exports="env")
|
env.SConscript(item, exports="env")
|
||||||
|
|
||||||
if "envdump" in COMMAND_LINE_TARGETS:
|
if "envdump" in COMMAND_LINE_TARGETS:
|
||||||
|
@ -18,7 +18,7 @@ import atexit
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from os import environ, remove, walk
|
from os import environ, remove, walk
|
||||||
from os.path import basename, isdir, isfile, join, relpath, sep
|
from os.path import basename, isdir, isfile, join, realpath, relpath, sep
|
||||||
from tempfile import mkstemp
|
from tempfile import mkstemp
|
||||||
|
|
||||||
from SCons.Action import Action
|
from SCons.Action import Action
|
||||||
@ -302,18 +302,17 @@ def ProcessTest(env):
|
|||||||
duplicate=False)
|
duplicate=False)
|
||||||
|
|
||||||
|
|
||||||
def GetPreExtraScripts(env):
|
def GetExtraScripts(env, scope):
|
||||||
return [
|
items = []
|
||||||
item[4:] for item in env.get("EXTRA_SCRIPTS", [])
|
for item in env.get("EXTRA_SCRIPTS", []):
|
||||||
if item.startswith("pre:")
|
if scope == "post" and ":" not in item:
|
||||||
]
|
items.append(item)
|
||||||
|
elif item.startswith("%s:" % scope):
|
||||||
|
items.append(item[len(scope) + 1:])
|
||||||
def GetPostExtraScripts(env):
|
if not items:
|
||||||
return [
|
return items
|
||||||
item[5:] if item.startswith("post:") else item
|
with util.cd(env.subst("$PROJECT_DIR")):
|
||||||
for item in env.get("EXTRA_SCRIPTS", []) if not item.startswith("pre:")
|
return [realpath(item) for item in items]
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def exists(_):
|
def exists(_):
|
||||||
@ -328,6 +327,5 @@ def generate(env):
|
|||||||
env.AddMethod(PioClean)
|
env.AddMethod(PioClean)
|
||||||
env.AddMethod(ProcessDebug)
|
env.AddMethod(ProcessDebug)
|
||||||
env.AddMethod(ProcessTest)
|
env.AddMethod(ProcessTest)
|
||||||
env.AddMethod(GetPreExtraScripts)
|
env.AddMethod(GetExtraScripts)
|
||||||
env.AddMethod(GetPostExtraScripts)
|
|
||||||
return env
|
return env
|
||||||
|
@ -289,15 +289,14 @@ def BuildFrameworks(env, frameworks):
|
|||||||
|
|
||||||
|
|
||||||
def BuildLibrary(env, variant_dir, src_dir, src_filter=None):
|
def BuildLibrary(env, variant_dir, src_dir, src_filter=None):
|
||||||
lib = env.Clone()
|
return env.StaticLibrary(
|
||||||
return lib.StaticLibrary(
|
env.subst(variant_dir),
|
||||||
lib.subst(variant_dir),
|
env.CollectBuildFiles(variant_dir, src_dir, src_filter))
|
||||||
lib.CollectBuildFiles(variant_dir, src_dir, src_filter))
|
|
||||||
|
|
||||||
|
|
||||||
def BuildSources(env, variant_dir, src_dir, src_filter=None):
|
def BuildSources(env, variant_dir, src_dir, src_filter=None):
|
||||||
DefaultEnvironment().Append(PIOBUILDFILES=env.Clone().CollectBuildFiles(
|
DefaultEnvironment().Append(
|
||||||
variant_dir, src_dir, src_filter))
|
PIOBUILDFILES=env.CollectBuildFiles(variant_dir, src_dir, src_filter))
|
||||||
|
|
||||||
|
|
||||||
def exists(_):
|
def exists(_):
|
||||||
|
@ -24,9 +24,15 @@ def test_build_flags(clirunner, validate_cliresult, tmpdir):
|
|||||||
tmpdir.join("platformio.ini").write("""
|
tmpdir.join("platformio.ini").write("""
|
||||||
[env:native]
|
[env:native]
|
||||||
platform = native
|
platform = native
|
||||||
|
extra_scripts = extra.py
|
||||||
build_flags = %s
|
build_flags = %s
|
||||||
""" % " ".join([f[0] for f in build_flags]))
|
""" % " ".join([f[0] for f in build_flags]))
|
||||||
|
|
||||||
|
tmpdir.join("extra.py").write("""
|
||||||
|
Import("env")
|
||||||
|
env.Append(CPPDEFINES="POST_SCRIPT_MACRO")
|
||||||
|
""")
|
||||||
|
|
||||||
tmpdir.mkdir("src").join("main.cpp").write("""
|
tmpdir.mkdir("src").join("main.cpp").write("""
|
||||||
#if !defined(TEST_INT) || TEST_INT != 13
|
#if !defined(TEST_INT) || TEST_INT != 13
|
||||||
#error "TEST_INT"
|
#error "TEST_INT"
|
||||||
@ -36,6 +42,10 @@ build_flags = %s
|
|||||||
#error "TEST_STR_SPACE"
|
#error "TEST_STR_SPACE"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef POST_SCRIPT_MACRO
|
||||||
|
#error "POST_SCRIPT_MACRO"
|
||||||
|
#endif
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
Reference in New Issue
Block a user