summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-14 18:16:59 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-14 18:16:59 +0900
commite59802de35eaae0da2ee17bf191b98a8c7d2c581 (patch)
treec3368543b299ed042b8ba3bc4a3a1e64cbbc6815
parentedc1f2020d78a8e0ac5b107f153adac0ed7332d3 (diff)
downloadbuildstream-e59802de35eaae0da2ee17bf191b98a8c7d2c581.tar.gz
project.py: Export options as variables if that was asked for
Here we just use the new exporting mechanics to apply to the base variable dictionary defined by the project.
-rw-r--r--buildstream/project.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/buildstream/project.py b/buildstream/project.py
index d3d8dc525..64aefd772 100644
--- a/buildstream/project.py
+++ b/buildstream/project.py
@@ -127,18 +127,6 @@ class Project():
projectfile = os.path.join(self.directory, "project.conf")
config = _yaml.load(_site.default_project_config)
- # Special variables which have a computed default value must
- # be processed here before compositing any overrides
- variables = _yaml.node_get(config, Mapping, 'variables')
- variables['max-jobs'] = multiprocessing.cpu_count()
-
- variables['bst-host-arch'] = self._context.host_arch
- variables['bst-target-arch'] = self._context.target_arch
-
- # This is kept around for compatibility with existing definitions,
- # but we should probably remove it due to being ambiguous.
- variables['bst-arch'] = self._context.host_arch
-
# Load project local config and override the builtin
project_conf = _yaml.load(projectfile)
_yaml.composite(config, project_conf, typesafe=True)
@@ -235,6 +223,19 @@ class Project():
# Load base variables
self._variables = _yaml.node_get(config, Mapping, 'variables')
+ # Extend variables with automatic variables and option exports
+ self._variables['max-jobs'] = multiprocessing.cpu_count()
+
+ # Export options into variables, if that was requested
+ for _, option in self._options.options.items():
+ if option.variable:
+ self._variables[option.variable] = option.get_value()
+
+ # This is to be removed with arches
+ self._variables['bst-host-arch'] = self._context.host_arch
+ self._variables['bst-target-arch'] = self._context.target_arch
+ self._variables['bst-arch'] = self._context.host_arch
+
# Load sandbox configuration
self._environment = _yaml.node_get(config, Mapping, 'environment')
self._env_nocache = _yaml.node_get(config, list, 'environment-nocache')