From c46643f0fd4ac78c4d35fa29a0887ab56a919b87 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 20 May 2019 17:07:59 +0300 Subject: [PATCH] =?UTF-8?q?Custom=20project=20"***=5Fdir"=20options=20decl?= =?UTF-8?q?ared=20in=20=E2=80=9Cplatformio=E2=80=9D=20section=20of=20?= =?UTF-8?q?=E2=80=9Cplatformio.ini=E2=80=9D=20have=20higher=20priority=20t?= =?UTF-8?q?han=20Environment=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.rst | 3 ++- platformio/project/helpers.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e9936d1d..a9397d32 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,10 +10,11 @@ PlatformIO 4.0 * **PlatformIO-based Project** - Implemented unified project workspace storage (`workspace_dir `__ -> ``.pio``) for PlatformIO Build System, Library Dependency Finder, and other internal services (`issue #1778 `_) - - Moved ``.pioenvs`` build directory to workspace storage ``.pio/build`` - Share common (global) options between build environments using ``[env]`` section in `"platformio.ini" (Project Configuration File) `__ (`issue #1643 `_) - Include external configuration files in `"platformio.ini" (Project Configuration File) `__ with `extra_configs `__ option (`issue #1590 `_) - Override default `"platformio.ini" (Project Configuration File) `__ with a custom using ``-c, --project-conf`` option for `platformio run `__, `platformio debug `__, or `platformio test `__ commands (`issue #1913 `_) + - Custom project ``***_dir`` options declared in "platformio" section of `"platformio.ini" (Project Configuration File) `__ have higher priority than `Environment variables `__ + - Moved ``.pioenvs`` build directory to workspace storage ``.pio/build`` * **Infrastructure** diff --git a/platformio/project/helpers.py b/platformio/project/helpers.py index 4112f352..ec72b213 100644 --- a/platformio/project/helpers.py +++ b/platformio/project/helpers.py @@ -44,15 +44,18 @@ def find_project_dir_above(path): def get_project_optional_dir(name, default=None): paths = None + + # check for system environment variable var_name = "PLATFORMIO_%s" % name.upper() if var_name in os.environ: paths = os.getenv(var_name) - else: - config = ProjectConfig.get_instance( - join(get_project_dir(), "platformio.ini")) - if (config.has_section("platformio") - and config.has_option("platformio", name)): - paths = config.get("platformio", name) + + config = ProjectConfig.get_instance( + join(get_project_dir(), "platformio.ini")) + if (config.has_section("platformio") + and config.has_option("platformio", name)): + paths = config.get("platformio", name) + if not paths: return default