From dfffd5e97bb5370eeaea6ad035c9e268453e24c2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 8 Aug 2022 17:39:36 +0300 Subject: [PATCH] =?UTF-8?q?Warn=20about=20calling=20=E2=80=9Cenv.BuildSour?= =?UTF-8?q?ces=E2=80=9D=20in=20a=20POST-type=20script=20//=20Resolve=20#43?= =?UTF-8?q?85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.rst | 1 + platformio/builder/tools/piobuild.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index b6bd269b..d51051d0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,7 @@ PlatformIO Core 6 * Improved project dependency resolving when using the `pio project init --ide `__ command * Upgraded build engine to the SCons 4.4.0 (`release notes `__) * Do not resolve project dependencies on for the ``cleanall`` target (`issue #4344 `_) +* Warn about calling "env.BuildSources" in a POST-type script (`issue #4385 `_) * Fixed an issue when escaping macros/defines for IDE integration (`issue #4360 `_) 6.1.3 (2022-07-18) diff --git a/platformio/builder/tools/piobuild.py b/platformio/builder/tools/piobuild.py index 9652eabe..69359a32 100644 --- a/platformio/builder/tools/piobuild.py +++ b/platformio/builder/tools/piobuild.py @@ -341,6 +341,14 @@ def BuildLibrary(env, variant_dir, src_dir, src_filter=None, nodes=None): def BuildSources(env, variant_dir, src_dir, src_filter=None): + if env.get("PIOMAINPROG"): + sys.stderr.write( + "Error: The main program is already constructed and the inline " + "source files are not allowed. Please use `env.BuildLibrary(...)` " + "or PRE-type script instead." + ) + env.Exit(1) + nodes = env.CollectBuildFiles(variant_dir, src_dir, src_filter) DefaultEnvironment().Append( PIOBUILDFILES=[