forked from platformio/platformio-core
Override any option from board manifest in Project Configuration File "platformio.ini" // Resolve #1612
This commit is contained in:
@ -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
|
* 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
|
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>`__
|
* 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
|
option
|
||||||
* Custom project `description <http://docs.platformio.org/en/latest/projectconf/section_platformio.html#description>`_
|
* Custom project `description <http://docs.platformio.org/en/latest/projectconf/section_platformio.html#description>`_
|
||||||
|
2
docs
2
docs
Submodule docs updated: 4ccbe4a41e...bea5f7fa6c
@ -54,10 +54,12 @@ commonvars.AddVariables(
|
|||||||
|
|
||||||
# board options
|
# board options
|
||||||
("BOARD",),
|
("BOARD",),
|
||||||
|
# deprecated options, use board_{object.path} instead
|
||||||
("BOARD_MCU",),
|
("BOARD_MCU",),
|
||||||
("BOARD_F_CPU",),
|
("BOARD_F_CPU",),
|
||||||
("BOARD_F_FLASH",),
|
("BOARD_F_FLASH",),
|
||||||
("BOARD_FLASH_MODE",),
|
("BOARD_FLASH_MODE",),
|
||||||
|
# end of deprecated options
|
||||||
|
|
||||||
# upload options
|
# upload options
|
||||||
("UPLOAD_PORT",),
|
("UPLOAD_PORT",),
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import base64
|
||||||
import sys
|
import sys
|
||||||
from os.path import isdir, isfile, join
|
from os.path import isdir, isfile, join
|
||||||
|
|
||||||
@ -83,16 +84,23 @@ def LoadPioPlatform(env, variables):
|
|||||||
if "BOARD" not in env:
|
if "BOARD" not in env:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# update board manifest with a custom data
|
||||||
board_config = env.BoardConfig()
|
board_config = env.BoardConfig()
|
||||||
for k in variables.keys():
|
for key, value in variables.UnknownVariables().items():
|
||||||
if k in env or \
|
if not key.startswith("BOARD_"):
|
||||||
not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")]):
|
|
||||||
continue
|
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":
|
if _opt == "board":
|
||||||
_opt = "build"
|
_opt = "build"
|
||||||
if _val in board_config.get(_opt):
|
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:
|
if "build.ldscript" in board_config:
|
||||||
env.Replace(LDSCRIPT_PATH=board_config.get("build.ldscript"))
|
env.Replace(LDSCRIPT_PATH=board_config.get("build.ldscript"))
|
||||||
|
@ -20,7 +20,7 @@ from glob import glob
|
|||||||
from os import sep, walk
|
from os import sep, walk
|
||||||
from os.path import basename, dirname, isdir, join, realpath
|
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,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild,
|
||||||
DefaultEnvironment, SConscript)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
@ -108,8 +108,8 @@ def BuildProgram(env):
|
|||||||
program = env.Program(
|
program = env.Program(
|
||||||
join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES'])
|
join("$BUILD_DIR", env.subst("$PROGNAME")), env['PIOBUILDFILES'])
|
||||||
|
|
||||||
checksize_action = Action.Action(env.CheckUploadSize,
|
checksize_action = env.VerboseAction(env.CheckUploadSize,
|
||||||
"Checking program size")
|
"Checking program size")
|
||||||
AlwaysBuild(env.Alias("checkprogsize", program, checksize_action))
|
AlwaysBuild(env.Alias("checkprogsize", program, checksize_action))
|
||||||
if set(["upload", "program"]) & set(COMMAND_LINE_TARGETS):
|
if set(["upload", "program"]) & set(COMMAND_LINE_TARGETS):
|
||||||
env.AddPostAction(program, checksize_action)
|
env.AddPostAction(program, checksize_action)
|
||||||
|
@ -131,16 +131,15 @@ class EnvironmentProcessor(object):
|
|||||||
"src_dir", "build_dir", "data_dir", "test_dir",
|
"src_dir", "build_dir", "data_dir", "test_dir",
|
||||||
"boards_dir", "lib_extra_dirs")
|
"boards_dir", "lib_extra_dirs")
|
||||||
|
|
||||||
KNOWN_ENV_OPTIONS = ("platform", "framework", "board", "board_mcu",
|
KNOWN_ENV_OPTIONS = ("platform", "framework", "board", "build_flags",
|
||||||
"board_f_cpu", "board_f_flash", "board_flash_mode",
|
"src_build_flags", "build_unflags", "src_filter",
|
||||||
"build_flags", "src_build_flags", "build_unflags",
|
"extra_scripts", "targets", "upload_port",
|
||||||
"src_filter", "extra_scripts", "targets",
|
"upload_protocol", "upload_speed", "upload_flags",
|
||||||
"upload_port", "upload_protocol", "upload_speed",
|
"upload_resetmethod", "lib_deps", "lib_ignore",
|
||||||
"upload_flags", "upload_resetmethod", "lib_deps",
|
"lib_extra_dirs", "lib_ldf_mode", "lib_compat_mode",
|
||||||
"lib_ignore", "lib_extra_dirs", "lib_ldf_mode",
|
"lib_archive", "piotest", "test_transport",
|
||||||
"lib_compat_mode", "lib_archive", "piotest",
|
"test_filter", "test_ignore", "test_port",
|
||||||
"test_transport", "test_filter", "test_ignore",
|
"test_speed", "debug_tool", "debug_port",
|
||||||
"test_port", "test_speed", "debug_tool", "debug_port",
|
|
||||||
"debug_init_cmds", "debug_extra_cmds", "debug_server",
|
"debug_init_cmds", "debug_extra_cmds", "debug_server",
|
||||||
"debug_init_break", "debug_load_cmd",
|
"debug_init_break", "debug_load_cmd",
|
||||||
"debug_load_mode", "debug_svd_path", "monitor_port",
|
"debug_load_mode", "debug_svd_path", "monitor_port",
|
||||||
@ -160,7 +159,11 @@ class EnvironmentProcessor(object):
|
|||||||
"lib_use": "lib_deps",
|
"lib_use": "lib_deps",
|
||||||
"lib_force": "lib_deps",
|
"lib_force": "lib_deps",
|
||||||
"extra_script": "extra_scripts",
|
"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"}
|
RENAMED_PLATFORMS = {"espressif": "espressif8266"}
|
||||||
@ -238,7 +241,11 @@ class EnvironmentProcessor(object):
|
|||||||
v = self.RENAMED_PLATFORMS[v]
|
v = self.RENAMED_PLATFORMS[v]
|
||||||
|
|
||||||
# warn about unknown options
|
# 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(
|
click.secho(
|
||||||
"Detected non-PlatformIO `%s` option in `[env:%s]` section"
|
"Detected non-PlatformIO `%s` option in `[env:%s]` section"
|
||||||
% (k, self.name),
|
% (k, self.name),
|
||||||
|
Reference in New Issue
Block a user