mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Custom platform_packages per a build environment with an option to override default // Resolve #1367
This commit is contained in:
@ -34,6 +34,7 @@ PlatformIO 4.0
|
||||
|
||||
- Switched to workspace ``.pio/build`` folder for build artifacts instead of ``.pioenvs``
|
||||
- Switch between `Build Configurations <http://docs.platformio.org/page/projectconf/build_configurations.html>`__ (``release`` and ``debug``) with a new project configuration option `build_type <http://docs.platformio.org/page/projectconf/section_env_build.html#build-type>`__
|
||||
- Custom `platform_packages <http://docs.platformio.org/page/projectconf/section_env_general.html#platform>`__ per a build environment with an option to override default (`issue #1367 <https://github.com/platformio/platformio-core/issues/1367>`_)
|
||||
- Print platform package details, such as version, VSC source and commit (`issue #2155 <https://github.com/platformio/platformio-core/issues/2155>`_)
|
||||
- Override default `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__ with a custom using ``-c, --project-conf`` option for `platformio run <http://docs.platformio.org/page/userguide/cmd_run.html>`__, `platformio debug <http://docs.platformio.org/page/userguide/cmd_debug.html>`__, or `platformio test <http://docs.platformio.org/page/userguide/cmd_test.html>`__ commands (`issue #1913 <https://github.com/platformio/platformio-core/issues/1913>`_)
|
||||
- Override default development platform upload command with a custom `upload_command <http://docs.platformio.org/page/projectconf/section_env_upload.html#upload-command>`__ (`issue #2599 <https://github.com/platformio/platformio-core/issues/2599>`_)
|
||||
|
2
docs
2
docs
Submodule docs updated: 66e4193767...7ea74ad006
@ -29,22 +29,18 @@ from platformio.project.config import ProjectOptions
|
||||
|
||||
|
||||
@util.memoized()
|
||||
def initPioPlatform(name):
|
||||
return PlatformFactory.newPlatform(name)
|
||||
|
||||
|
||||
def PioPlatform(env):
|
||||
variables = env.GetProjectOptions(as_dict=True)
|
||||
if "framework" in variables:
|
||||
# support PIO Core 3.0 dev/platforms
|
||||
variables['pioframework'] = variables['framework']
|
||||
p = initPioPlatform(env['PLATFORM_MANIFEST'])
|
||||
p = PlatformFactory.newPlatform(env['PLATFORM_MANIFEST'])
|
||||
p.configure_default_packages(variables, COMMAND_LINE_TARGETS)
|
||||
return p
|
||||
|
||||
|
||||
def BoardConfig(env, board=None):
|
||||
p = initPioPlatform(env['PLATFORM_MANIFEST'])
|
||||
p = env.PioPlatform()
|
||||
try:
|
||||
board = board or env.get("BOARD")
|
||||
assert board, "BoardConfig: Board is not defined"
|
||||
|
@ -490,16 +490,17 @@ class PlatformBase( # pylint: disable=too-many-public-methods
|
||||
_BOARDS_CACHE = {}
|
||||
|
||||
def __init__(self, manifest_path):
|
||||
self._BOARDS_CACHE = {}
|
||||
self.manifest_path = manifest_path
|
||||
self.silent = False
|
||||
self.verbose = False
|
||||
|
||||
self._BOARDS_CACHE = {}
|
||||
self._manifest = util.load_json(manifest_path)
|
||||
self._custom_packages = None
|
||||
|
||||
self.pm = PackageManager(get_project_packages_dir(),
|
||||
self.package_repositories)
|
||||
|
||||
self.silent = False
|
||||
self.verbose = False
|
||||
|
||||
# if self.engines and "platformio" in self.engines:
|
||||
# if self.PIO_VERSION not in semantic_version.Spec(
|
||||
# self.engines['platformio']):
|
||||
@ -560,9 +561,20 @@ class PlatformBase( # pylint: disable=too-many-public-methods
|
||||
|
||||
@property
|
||||
def packages(self):
|
||||
if "packages" not in self._manifest:
|
||||
self._manifest['packages'] = {}
|
||||
return self._manifest['packages']
|
||||
packages = self._manifest.get("packages", {})
|
||||
for item in (self._custom_packages or []):
|
||||
name = item
|
||||
version = "*"
|
||||
if "@" in item:
|
||||
name, version = item.split("@", 2)
|
||||
name = name.strip()
|
||||
if name not in packages:
|
||||
packages[name] = {}
|
||||
packages[name].update({
|
||||
"version": version.strip(),
|
||||
"optional": False
|
||||
})
|
||||
return packages
|
||||
|
||||
def get_dir(self):
|
||||
return dirname(self.manifest_path)
|
||||
@ -626,6 +638,9 @@ class PlatformBase( # pylint: disable=too-many-public-methods
|
||||
return self.packages[name].get("type")
|
||||
|
||||
def configure_default_packages(self, options, targets):
|
||||
# override user custom packages
|
||||
self._custom_packages = options.get("platform_packages")
|
||||
|
||||
# enable used frameworks
|
||||
for framework in options.get("framework", []):
|
||||
if not self.frameworks:
|
||||
|
@ -91,9 +91,9 @@ ProjectOptions = OrderedDict([
|
||||
|
||||
# Generic
|
||||
ConfigEnvOption(name="platform", buildenvvar="PIOPLATFORM"),
|
||||
ConfigEnvOption(name="platform_packages", multiple=True),
|
||||
ConfigEnvOption(
|
||||
name="framework", multiple=True, buildenvvar="PIOFRAMEWORK"),
|
||||
ConfigEnvOption(name="targets", multiple=True),
|
||||
|
||||
# Board
|
||||
ConfigEnvOption(name="board", buildenvvar="BOARD"),
|
||||
@ -129,6 +129,7 @@ ProjectOptions = OrderedDict([
|
||||
multiple=True,
|
||||
sysenvvar="PLATFORMIO_SRC_FILTER",
|
||||
buildenvvar="SRC_FILTER"),
|
||||
ConfigEnvOption(name="targets", multiple=True),
|
||||
|
||||
# Upload
|
||||
ConfigEnvOption(name="upload_port",
|
||||
|
Reference in New Issue
Block a user