Override any option from board manifest in Project Configuration File "platformio.ini" // Resolve #1612

This commit is contained in:
Ivan Kravets
2018-05-26 01:02:52 +03:00
parent 5011c3e21c
commit 9ba5dc0a60
6 changed files with 40 additions and 21 deletions

View File

@ -15,6 +15,8 @@ PlatformIO 3.0
* Simplify configuration for `PIO Unit Testing <http://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 `Project Configuration File "platformio.ini" <http://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 <http://docs.platformio.org/page/projectconf/section_env_debug.html#debug-svd-path>`__
option
* Custom project `description <http://docs.platformio.org/en/latest/projectconf/section_platformio.html#description>`_

2
docs

Submodule docs updated: 4ccbe4a41e...bea5f7fa6c

View File

@ -54,10 +54,12 @@ commonvars.AddVariables(
# board options
("BOARD",),
# deprecated options, use board_{object.path} instead
("BOARD_MCU",),
("BOARD_F_CPU",),
("BOARD_F_FLASH",),
("BOARD_FLASH_MODE",),
# end of deprecated options
# upload options
("UPLOAD_PORT",),

View File

@ -14,6 +14,7 @@
from __future__ import absolute_import
import base64
import sys
from os.path import isdir, isfile, join
@ -83,16 +84,23 @@ def LoadPioPlatform(env, variables):
if "BOARD" not in env:
return
# update board manifest with a custom data
board_config = env.BoardConfig()
for k in variables.keys():
if k in env or \
not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")]):
for key, value in variables.UnknownVariables().items():
if not key.startswith("BOARD_"):
continue
_opt, _val = k.lower().split("_", 1)
board_config.update(key.lower()[6:], base64.b64decode(value))
# update default environment variables
for key in variables.keys():
if key in env or \
not any([key.startswith("BOARD_"), key.startswith("UPLOAD_")]):
continue
_opt, _val = key.lower().split("_", 1)
if _opt == "board":
_opt = "build"
if _val in board_config.get(_opt):
env.Replace(**{k: board_config.get("%s.%s" % (_opt, _val))})
env.Replace(**{key: board_config.get("%s.%s" % (_opt, _val))})
if "build.ldscript" in board_config:
env.Replace(LDSCRIPT_PATH=board_config.get("build.ldscript"))

View File

@ -20,7 +20,7 @@ from glob import glob
from os import sep, walk
from os.path import basename, dirname, isdir, join, realpath
from SCons import Action, Builder, Util
from SCons import Builder, Util
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild,
DefaultEnvironment, SConscript)
@ -108,8 +108,8 @@ def BuildProgram(env):
program = env.Program(
join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES'])
checksize_action = Action.Action(env.CheckUploadSize,
"Checking program size")
checksize_action = env.VerboseAction(env.CheckUploadSize,
"Checking program size")
AlwaysBuild(env.Alias("checkprogsize", program, checksize_action))
if set(["upload", "program"]) & set(COMMAND_LINE_TARGETS):
env.AddPostAction(program, checksize_action)

View File

@ -131,16 +131,15 @@ class EnvironmentProcessor(object):
"src_dir", "build_dir", "data_dir", "test_dir",
"boards_dir", "lib_extra_dirs")
KNOWN_ENV_OPTIONS = ("platform", "framework", "board", "board_mcu",
"board_f_cpu", "board_f_flash", "board_flash_mode",
"build_flags", "src_build_flags", "build_unflags",
"src_filter", "extra_scripts", "targets",
"upload_port", "upload_protocol", "upload_speed",
"upload_flags", "upload_resetmethod", "lib_deps",
"lib_ignore", "lib_extra_dirs", "lib_ldf_mode",
"lib_compat_mode", "lib_archive", "piotest",
"test_transport", "test_filter", "test_ignore",
"test_port", "test_speed", "debug_tool", "debug_port",
KNOWN_ENV_OPTIONS = ("platform", "framework", "board", "build_flags",
"src_build_flags", "build_unflags", "src_filter",
"extra_scripts", "targets", "upload_port",
"upload_protocol", "upload_speed", "upload_flags",
"upload_resetmethod", "lib_deps", "lib_ignore",
"lib_extra_dirs", "lib_ldf_mode", "lib_compat_mode",
"lib_archive", "piotest", "test_transport",
"test_filter", "test_ignore", "test_port",
"test_speed", "debug_tool", "debug_port",
"debug_init_cmds", "debug_extra_cmds", "debug_server",
"debug_init_break", "debug_load_cmd",
"debug_load_mode", "debug_svd_path", "monitor_port",
@ -160,7 +159,11 @@ class EnvironmentProcessor(object):
"lib_use": "lib_deps",
"lib_force": "lib_deps",
"extra_script": "extra_scripts",
"monitor_baud": "monitor_speed"
"monitor_baud": "monitor_speed",
"board_mcu": "board_build.mcu",
"board_f_cpu": "board_build.f_cpu",
"board_f_flash": "board_build.f_flash",
"board_flash_mode": "board_build.flash_mode"
}
RENAMED_PLATFORMS = {"espressif": "espressif8266"}
@ -238,7 +241,11 @@ class EnvironmentProcessor(object):
v = self.RENAMED_PLATFORMS[v]
# warn about unknown options
if k not in self.KNOWN_ENV_OPTIONS and not k.startswith("custom_"):
unknown_conditions = [
k not in self.KNOWN_ENV_OPTIONS, not k.startswith("custom_"),
not k.startswith("board_")
]
if all(unknown_conditions):
click.secho(
"Detected non-PlatformIO `%s` option in `[env:%s]` section"
% (k, self.name),