From ca3567df1e100b4bef4d9afa3a639f7016c7907a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 29 Jun 2018 19:55:29 +0300 Subject: [PATCH 1/3] Replace "env" pattern by "sysenv" in "platformio.ini" // Resolve #1705 --- HISTORY.rst | 2 ++ docs | 2 +- platformio/util.py | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8267d040..10b921bc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,8 @@ PlatformIO 3.0 (`issue #1665 `_) * Handle "architectures" data from "library.properties" manifest in `lib_compat_mode = strict `__ +* Replaced conflicted "env" pattern by "sysenv" for `"platformio.ini" Dynamic Variables" `__ + (`issue #1705 `_) * Removed "date&time" when processing project with `platformio run `__ command (`issue #1343 `_) * Fixed issue with invalid LD script if path contains space diff --git a/docs b/docs index 6d29169d..ae2968e5 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 6d29169d6e29c48561b58fa1505cc70d259e00e6 +Subproject commit ae2968e52ac2bc86ec7e7fe67073ceb37c47f577 diff --git a/platformio/util.py b/platformio/util.py index 98c3cbc1..eab6512f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -63,7 +63,13 @@ class ProjectConfig(ConfigParser.ConfigParser): def _re_sub_handler(self, match): section, option = match.group(1), match.group(2) - if section == "env" and not self.has_section(section): + if section in ("env", "sysenv") and not self.has_section(section): + if section == "env": + click.secho( + "Warning! Access to system environment variable via " + "`${{env.{0}}}` is deprecated. Please use " + "`${{sysenv.{0}}}` instead".format(option), + fg="yellow") return os.getenv(option) return self.get(section, option) From 357e70e5bbe38700c8808407229742916f98842b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 30 Jun 2018 18:24:50 +0300 Subject: [PATCH 2/3] Export ``LIBS``, ``LIBPATH``, and ``LINKFLAGS`` data from project dependent libraries to the global build environment --- HISTORY.rst | 5 ++++- platformio/builder/tools/piolib.py | 7 +++---- platformio/builder/tools/platformio.py | 15 +++++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 10b921bc..9adb24f5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,7 +7,10 @@ PlatformIO 3.0 3.5.4 (2018-??-??) ~~~~~~~~~~~~~~~~~~ -* Don't export ``CPPPATH`` of project dependent libraries to frameworks +* Export ``LIBS``, ``LIBPATH``, and ``LINKFLAGS`` data from project dependent + libraries to the global build environment +* Don't export ``CPPPATH`` data of project dependent libraries to framework's + build environment (`issue #1665 `_) * Handle "architectures" data from "library.properties" manifest in `lib_compat_mode = strict `__ diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 2523287e..787b3bdf 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -824,7 +824,7 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches return items -def BuildProjectLibraries(env): +def ConfigureProjectLibBuilder(env): def correct_found_libs(lib_builders): # build full dependency graph @@ -879,8 +879,7 @@ def BuildProjectLibraries(env): else: print "No dependencies" - libs = project.build() - return dict(LIBS=libs, CPPPATH=project.env.get("CPPPATH")) + return project def exists(_): @@ -889,5 +888,5 @@ def exists(_): def generate(env): env.AddMethod(GetLibBuilders) - env.AddMethod(BuildProjectLibraries) + env.AddMethod(ConfigureProjectLibBuilder) return env diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index e60e41aa..ac3dda2b 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -42,9 +42,16 @@ def scons_patched_match_splitext(path, suffixes=None): def _build_project_deps(env): - deps = env.BuildProjectLibraries() - # prepend dependent libs before built-in - env.Prepend(LIBS=deps['LIBS']) + project_lib_builder = env.ConfigureProjectLibBuilder() + + # append project libs to the beginning of list + env.Prepend(LIBS=project_lib_builder.build()) + # append extra linker related options from libs + env.AppendUnique( + **{ + key: project_lib_builder.env.get(key) + for key in ("LIBS", "LIBPATH", "LINKFLAGS") + }) if "__test" in COMMAND_LINE_TARGETS: env.ProcessTest() @@ -57,7 +64,7 @@ def _build_project_deps(env): env.get("SRC_FILTER")) # CPPPATH from dependencies - projenv.PrependUnique(CPPPATH=deps['CPPPATH']) + projenv.PrependUnique(CPPPATH=project_lib_builder.env.get("CPPPATH")) # extra build flags from `platformio.ini` projenv.ProcessFlags(env.get("SRC_BUILD_FLAGS")) From 4adc73ebe2cd933b5bc91af9d785f7ff10d666e5 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 30 Jun 2018 19:34:24 +0300 Subject: [PATCH 3/3] Improve removing of default build flags using `build_unflags` option // Resolve #1712 --- HISTORY.rst | 2 ++ platformio/builder/tools/platformio.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 9adb24f5..8b0336e6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,8 @@ PlatformIO 3.0 3.5.4 (2018-??-??) ~~~~~~~~~~~~~~~~~~ +* Improved removing of default build flags using `build_unflags `__ option + (`issue #1712 `_) * Export ``LIBS``, ``LIBPATH``, and ``LINKFLAGS`` data from project dependent libraries to the global build environment * Don't export ``CPPPATH`` data of project dependent libraries to framework's diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index ac3dda2b..0d82bbed 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -190,7 +190,18 @@ def ProcessFlags(env, flags): # pylint: disable=too-many-branches def ProcessUnFlags(env, flags): if not flags: return - for key, unflags in env.ParseFlagsExtended(flags).items(): + parsed = env.ParseFlagsExtended(flags) + + # get all flags and copy them to each "*FLAGS" variable + all_flags = [] + for key, unflags in parsed.items(): + if key.endswith("FLAGS"): + all_flags.extend(unflags) + for key, unflags in parsed.items(): + if key.endswith("FLAGS"): + parsed[key].extend(all_flags) + + for key, unflags in parsed.items(): for unflag in unflags: for current in env.get(key, []): conditions = [