mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Configure platform instance with project packages using "configure_project_packages" API
This commit is contained in:
@@ -33,12 +33,8 @@ from platformio.project.config import ProjectOptions
|
||||
|
||||
@util.memoized()
|
||||
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 = PlatformFactory.new(os.path.dirname(env["PLATFORM_MANIFEST"]))
|
||||
p.configure_default_packages(variables, COMMAND_LINE_TARGETS)
|
||||
p.configure_project_packages(env["PIOENV"], COMMAND_LINE_TARGETS)
|
||||
return p
|
||||
|
||||
|
||||
|
@@ -65,7 +65,7 @@ class PlatformPackagesMixin(object):
|
||||
result.append(item)
|
||||
return result
|
||||
|
||||
def autoinstall_runtime_packages(self):
|
||||
def autoinstall_required_packages(self):
|
||||
for name, options in self.packages.items():
|
||||
if options.get("optional", False):
|
||||
continue
|
||||
|
@@ -52,14 +52,10 @@ class PlatformRunMixin(object):
|
||||
|
||||
self.ensure_engine_compatible()
|
||||
|
||||
options = self.config.items(env=variables["pioenv"], as_dict=True)
|
||||
if "framework" in options:
|
||||
# support PIO Core 3.0 dev/platforms
|
||||
options["pioframework"] = options["framework"]
|
||||
self.configure_default_packages(options, targets)
|
||||
self.autoinstall_runtime_packages()
|
||||
self.configure_project_packages(variables["pioenv"], targets)
|
||||
self.autoinstall_required_packages()
|
||||
|
||||
self._report_non_sensitive_data(options, targets)
|
||||
self._report_non_sensitive_data(variables["pioenv"], targets)
|
||||
|
||||
self.silent = silent
|
||||
self.verbose = verbose or app.get_setting("force_verbose")
|
||||
@@ -79,14 +75,14 @@ class PlatformRunMixin(object):
|
||||
|
||||
return result
|
||||
|
||||
def _report_non_sensitive_data(self, options, targets):
|
||||
topts = options.copy()
|
||||
topts["platform_packages"] = [
|
||||
def _report_non_sensitive_data(self, env, targets):
|
||||
options = self.config.items(env=env, as_dict=True)
|
||||
options["platform_packages"] = [
|
||||
dict(name=item["name"], version=item["version"])
|
||||
for item in self.dump_used_packages()
|
||||
]
|
||||
topts["platform"] = {"name": self.name, "version": self.version}
|
||||
telemetry.send_run_environment(topts, targets)
|
||||
options["platform"] = {"name": self.name, "version": self.version}
|
||||
telemetry.send_run_environment(options, targets)
|
||||
|
||||
def _run_scons(self, variables, targets, jobs):
|
||||
scons_dir = get_core_package_dir("tool-scons")
|
||||
|
@@ -178,10 +178,16 @@ class PlatformBase( # pylint: disable=too-many-instance-attributes,too-many-pub
|
||||
def get_package_type(self, name):
|
||||
return self.packages[name].get("type")
|
||||
|
||||
def configure_default_packages(self, options, targets):
|
||||
def configure_project_packages(self, env, targets=None):
|
||||
options = self.config.items(env=env, as_dict=True)
|
||||
if "framework" in options:
|
||||
# support PIO Core 3.0 dev/platforms
|
||||
options["pioframework"] = options["framework"]
|
||||
# override user custom packages
|
||||
self._custom_packages = options.get("platform_packages")
|
||||
self.configure_default_packages(options, targets)
|
||||
|
||||
def configure_default_packages(self, options, targets):
|
||||
# enable used frameworks
|
||||
for framework in options.get("framework", []):
|
||||
if not self.frameworks:
|
||||
|
Reference in New Issue
Block a user