Skip to content

Commit

Permalink
Fix an issue when $PROJECT_HASH template was not expanded for the…
Browse files Browse the repository at this point in the history
… other directory ``***_dir`` options in "platformio.ini" // Resolve #2170
  • Loading branch information
ivankravets committed Mar 7, 2019
1 parent b994946 commit 9639626
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
32 changes: 17 additions & 15 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ PlatformIO 3.0
* Fixed an issue with slow updating of PlatformIO Core packages on Windows
* Fixed an issue when `platformio ci <https://docs.platformio.org/en/latest/userguide/cmd_ci.html>`__ recompiles project if ``--keep-build-dir`` option is passed
(`issue #2109 <https://github.com/platformio/platformio-core/issues/2109>`_)
* Fixed an issue when ``$PROJECT_HASH`` template was not expanded for the other directory ``***_dir`` options in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
(`issue #2170 <https://github.com/platformio/platformio-core/issues/2170>`_)

3.6.4 (2019-01-23)
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -55,8 +57,8 @@ PlatformIO 3.0
~~~~~~~~~~~~~~~~~~

* Generate an `include <http://docs.platformio.org/page/projectconf/section_platformio.html#include-dir>`__ and `test <http://docs.platformio.org/page/projectconf/section_platformio.html#test-dir>`__ directories with a README file when initializing a new project
* Support in-line comments for multi-line value (``lib_deps``, ``build_flags``, etc) in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
* Added ``$PROJECT_HASH`` template variable for `build_dir <http://docs.platformio.org/en/latest/projectconf/section_platformio.html#projectconf-pio-build-dir>`__. One of the use cases is setting a global storage for project artifacts using `PLATFORMIO_BUILD_DIR <http://docs.platformio.org/en/latest/envvars.html#envvar-PLATFORMIO_BUILD_DIR>`__ system environment variable. For example, ``/tmp/pio-build/$PROJECT_HASH`` (Unix) or ``%TEMP%/pio-build/$PROJECT_HASH`` (Windows)
* Support in-line comments for multi-line value (``lib_deps``, ``build_flags``, etc) in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
* Added ``$PROJECT_HASH`` template variable for `build_dir <http://docs.platformio.org/en/latest/projectconf/section_platformio.html#projectconf-pio-build-dir>`__. One of the use cases is setting a global storage for project artifacts using `PLATFORMIO_BUILD_DIR <http://docs.platformio.org/en/latest/envvars.html#envvar-PLATFORMIO_BUILD_DIR>`__ system environment variable. For example, ``/tmp/pio-build/$PROJECT_HASH`` (Unix) or ``$[sysenv.TEMP}/pio-build/$PROJECT_HASH`` (Windows)
* Improved a loading speed of PIO Home "Recent News"
* Improved `PIO Unified Debugger <https://docs.platformio.org/en/page/plus/debugging.html>`__ for "mbed" framework and fixed issue with missed local variables
* Introduced `"Release" and "Debug" Build Configurations <http://docs.platformio.org/page/projectconf/build_configurations.html>`__
Expand Down Expand Up @@ -140,7 +142,7 @@ PlatformIO 3.0

* Simplify configuration for `PIO Unit Testing <https://docs.platformio.org/page/plus/unit-testing.html>`__: separate main program from a test build process, drop
requirement for ``#ifdef UNIT_TEST`` guard
* Override any option from board manifest in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_env_board.html#more-options>`__
* Override any option from board manifest in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_env_board.html#more-options>`__
(`issue #1612 <https://github.com/platformio/platformio-core/issues/1612>`_)
* Configure a custom path to SVD file using `debug_svd_path <https://docs.platformio.org/page/projectconf/section_env_debug.html#debug-svd-path>`__
option
Expand Down Expand Up @@ -203,7 +205,7 @@ PlatformIO 3.0
(`issue #1274 <https://github.com/platformio/platformio-core/issues/1274>`_)
* Configure a custom firmware/program name in build directory (`example <https://docs.platformio.org/page/projectconf/advanced_scripting.html#custom-firmware-program-name>`__)
* Renamed ``envs_dir`` option to ``build_dir``
in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_platformio.html#build-dir>`__
in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_platformio.html#build-dir>`__
* Refactored code without "arrow" dependency (resolve issue with "ImportError:
No module named backports.functools_lru_cache")
* Improved support of PIO Unified Debugger for Eclipse Oxygen
Expand Down Expand Up @@ -238,7 +240,7 @@ PlatformIO 3.0
folder for project's header files
(`issue #1107 <https://github.com/platformio/platformio-core/issues/1107>`_)
* Depend on development platform using VCS URL (Git, Mercurial and Subversion)
instead of a name in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_env_general.html#platform>`__.
instead of a name in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_env_general.html#platform>`__.
Drop support for ``*_stage`` dev/platform names (use VCS URL instead).
* Reinstall/redownload package with a new ``-f, --force`` option for
`platformio lib install <https://docs.platformio.org/page/userguide/lib/cmd_install.html>`__
Expand All @@ -259,7 +261,7 @@ PlatformIO 3.0
- Parse library source file in pair with a header when they have the same name
(`issue #1175 <https://github.com/platformio/platformio-core/issues/1175>`_)
- Handle library dependencies defined as VCS or SemVer in
`platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_env_general.html#platform>`__
`"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf/section_env_general.html#platform>`__
(`issue #1155 <https://github.com/platformio/platformio-core/issues/1155>`_)
- Added option to configure library `Compatible Mode <https://docs.platformio.org/page/librarymanager/ldf.html#compatibility-mode>`__
using `library.json <https://docs.platformio.org/page/librarymanager/config.html>`__
Expand Down Expand Up @@ -295,7 +297,7 @@ PlatformIO 3.0
* Use a root of library when filtering source code using
`library.json <https://docs.platformio.org/page/librarymanager/config.html>`__
and ``srcFilter`` field
* Added ``monitor_*`` options to white-list for `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
* Added ``monitor_*`` options to white-list for `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
(`issue #982 <https://github.com/platformio/platformio-core/issues/982>`_)
* Do not ask for board ID when initialize project for desktop platform
* Handle broken PIO Core state and create new one
Expand All @@ -316,18 +318,18 @@ PlatformIO 3.0
- Integration with `Eclipse <https://docs.platformio.org/page/ide/eclipse.html>`__ and `Sublime Text <https://docs.platformio.org/page/ide/sublimetext.html>`__

* Filter `PIO Unit Testing <https://docs.platformio.org/page/plus/unit-testing.html>`__
tests using a new ``test_filter`` option in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
tests using a new ``test_filter`` option in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
or `platformio test --filter <https://docs.platformio.org/page/userguide/cmd_test.html#cmdoption-platformio-test-f>`__ command
(`issue #934 <https://github.com/platformio/platformio-core/issues/934>`_)
* Custom ``test_transport`` for `PIO Unit Testing <https://docs.platformio.org/page/plus/unit-testing.html>`__ Engine
* Configure Serial Port Monitor in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
* Configure Serial Port Monitor in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
(`issue #787 <https://github.com/platformio/platformio-core/issues/787>`_)
* New `monitor <https://docs.platformio.org/page/userguide/cmd_run.html#cmdoption-platformio-run-t>`__
target which allows to launch Serial Monitor automatically after successful
"build" or "upload" operations
(`issue #788 <https://github.com/platformio/platformio-core/issues/788>`_)
* Project generator for `VIM <https://docs.platformio.org/page/ide/vim.html>`__
* Multi-line support for the different options in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__,
* Multi-line support for the different options in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__,
such as: ``build_flags``, ``build_unflags``, etc.
(`issue #889 <https://github.com/platformio/platformio-core/issues/889>`_)
* Handle dynamic ``SRC_FILTER`` environment variable from
Expand All @@ -339,7 +341,7 @@ PlatformIO 3.0
that were installed from repository
* Add support for ``.*cc`` extension
(`issue #939 <https://github.com/platformio/platformio-core/issues/939>`_)
* Handle ``env_default`` in `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
* Handle ``env_default`` in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
when re-initializing a project
(`issue #950 <https://github.com/platformio/platformio-core/issues/950>`_)
* Use root directory for PIO Home when path contains non-ascii characters
Expand Down Expand Up @@ -437,10 +439,10 @@ PlatformIO 3.0
(`issue #808 <https://github.com/platformio/platformio-core/issues/808>`_,
`issue #467 <https://github.com/platformio/platformio-core/issues/467>`_)
* Inject system environment variables to configuration settings in
`platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
`"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
(`issue #792 <https://github.com/platformio/platformio-core/issues/792>`_)
* Custom boards per project with ``boards_dir`` option in
`platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
`"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
(`issue #515 <https://github.com/platformio/platformio-core/issues/515>`_)
* Unix shell-style wildcards for `upload_port <https://docs.platformio.org/page/projectconf/section_env_upload.html#upload-port>`_
(`issue #839 <https://github.com/platformio/platformio-core/issues/839>`_)
Expand All @@ -451,7 +453,7 @@ PlatformIO 3.0
* Added new `LDF Modes <https://docs.platformio.org/page/librarymanager/ldf.html#ldf-mode>`__:
``chain+`` and ``deep+`` and set ``chain+`` as default
* Added global ``lib_extra_dirs`` option to ``[platformio]`` section for
`platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
`"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
(`issue #842 <https://github.com/platformio/platformio-core/issues/842>`_)
* Enabled caching by default for API requests and Library Manager (see `enable_cache <https://docs.platformio.org/page/userguide/cmd_settings.html#enable-cache>`__ setting)
* Native integration with VIM/Neovim using `neomake-platformio <https://github.com/coddingtonbear/neomake-platformio>`__ plugin
Expand All @@ -474,7 +476,7 @@ PlatformIO 3.0
3.1.0 (2016-09-19)
~~~~~~~~~~~~~~~~~~

* New! Dynamic variables/templates for `platformio.ini (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
* New! Dynamic variables/templates for `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__
(`issue #705 <https://github.com/platformio/platformio-core/issues/705>`_)
* Summary about processed environments
(`issue #777 <https://github.com/platformio/platformio-core/issues/777>`_)
Expand Down
2 changes: 1 addition & 1 deletion docs
Submodule docs updated 584 files
21 changes: 12 additions & 9 deletions platformio/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,28 +203,34 @@ def pioversion_to_intstr():


def get_project_optional_dir(name, default=None):
data = None
paths = None
var_name = "PLATFORMIO_%s" % name.upper()
if var_name in os.environ:
data = os.getenv(var_name)
paths = os.getenv(var_name)
else:
try:
config = load_project_config()
if (config.has_section("platformio")
and config.has_option("platformio", name)):
data = config.get("platformio", name)
paths = config.get("platformio", name)
except exception.NotPlatformIOProject:
pass

if not data:
if not paths:
return default

items = []
for item in data.split(", "):
for item in paths.split(", "):
if item.startswith("~"):
item = expanduser(item)
items.append(abspath(item))
return ", ".join(items)
paths = ", ".join(items)

while "$PROJECT_HASH" in paths:
paths = paths.replace("$PROJECT_HASH",
sha1(get_project_dir()).hexdigest()[:10])

return paths


def get_home_dir():
Expand Down Expand Up @@ -314,9 +320,6 @@ def get_projectboards_dir():
def get_projectbuild_dir(force=False):
path = get_project_optional_dir("build_dir",
join(get_project_dir(), ".pioenvs"))
if "$PROJECT_HASH" in path:
path = path.replace("$PROJECT_HASH",
sha1(get_project_dir()).hexdigest()[:10])
try:
if not isdir(path):
os.makedirs(path)
Expand Down

0 comments on commit 9639626

Please sign in to comment.