summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildstream/data/projectconfig.yaml112
-rw-r--r--buildstream/project.py77
2 files changed, 47 insertions, 142 deletions
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index 2e47aa87b..aca021618 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -1,70 +1,8 @@
# Default BuildStream project configuration.
-# Project name
-#
-# name: myproject
-
-# Format version requirements
-#
-# Indicates the minimum required format version the
-# project requires.
-#
-required-versions:
-
- # The minimum base BuildStream format
- project: 0
-
- # A minimum plugin format version for each individual
- # plugin (as advertized by the plugin BST_FORMAT_VERSION
- # class attributes), may be asserted here.
- #
- # E.g., to require version 3 of the the autotools
- # element format:
- #
- # elements:
- # autotools: 3
- #
- elements: {}
- sources: {}
-
-# Base project relative element path, elements will be loaded
-# from this base.
-
-element-path: .
-
-# Alias configuration
-#
-# Aliases are entirely project specific, they are
-# configured as a simple dictionary, example:
-#
-# aliases:
-# baserock: git://git.baserock.org/baserock/
-# freedesktop: git://anongit.freedesktop.org/
-
-
-# Plugin path configuration
-#
-# You may specify one or more project relative paths to
-# subdirectories where plugins should be loaded from.
-#
-# plugins:
-#
-# elements:
-# - plugins/local-elements
-# - plugins/shared-elements
-#
-# sources:
-# - plugins/local-sources
-
# Variable Configuration
#
-# You may override the defaults of variables on a project wide
-# basis by specifying the 'variables' attribute.
-#
-# The defaults for this version of buildstream are listed
-# below.
-#
variables:
# Maximum number of parallel build processes within a given
@@ -147,18 +85,6 @@ environment-nocache: []
# Defaults for the 'split-rules' public data found on elements
# in the 'bst' domain.
#
-# These define patterns for categorizing the output of build
-# elements so that selective composition can be performed by
-# plugins later on.
-#
-# Elements may extend these rules by adding entries to the
-# various split domains either in a plugin definition or
-# in a project element declaration.
-#
-# Note that the split rules reported by
-# Element.get_public_data('bst') will have any variables for
-# the given element already expanded.
-#
split-rules:
# The runtime domain includes whatever is needed for the
@@ -233,41 +159,3 @@ split-rules:
%{datadir}/zoneinfo
- |
%{datadir}/zoneinfo/**
-
-#
-# Artifacts
-#
-artifacts:
-
- # A url from which to download prebuilt artifacts
- pull-url: ''
-
- # A url to upload built artifacts to
- # (must point to the same repository as pull-url)
- push-url: ''
-
- # Specify the port number for pushing artifacts, if it's
- # not the default port 22
- push-port: 22
-
-# Element Overrides
-#
-# Base attributes declared by element default yaml files
-# can be overridden on a project wide basis. The elements
-# dictionary can be used to override variables, environments
-# or plugin specific configuration data as shown below.
-#
-#
-# elements:
-#
-# autotools:
-#
-# variables:
-# bindir: "%{prefix}/bin"
-#
-# config:
-# configure-commands: ...
-#
-# environment:
-# PKG_CONFIG_PATH=%{libdir}/pkgconfig
-#
diff --git a/buildstream/project.py b/buildstream/project.py
index dcf1c1e1f..d3d8dc525 100644
--- a/buildstream/project.py
+++ b/buildstream/project.py
@@ -37,6 +37,7 @@ from . import _yaml
from . import _loader # For resolve_arch()
from ._profile import Topics, profile_start, profile_end
from . import LoadError, LoadErrorReason
+from ._options import OptionPool
BST_FORMAT_VERSION = 0
"""The base BuildStream format version
@@ -60,17 +61,11 @@ _ALIAS_SEPARATOR = ':'
class Project():
- """Project Configuration
+ """Project()
- Args:
- directory (str): The project directory
- host_arch (str): Symbolic host machine architecture name
- target_arch (str): Symbolic target machine architecture name
-
- Raises:
- :class:`.LoadError`
+ The Project Configuration
"""
- def __init__(self, directory, host_arch, target_arch=None):
+ def __init__(self, directory, context):
self.name = None
"""str: The project name"""
@@ -81,16 +76,16 @@ class Project():
self.element_path = None
"""str: Absolute path to where elements are loaded from within the project"""
- self._variables = {} # The default variables overridden with project wide overrides
- self._environment = {} # The base sandbox environment
- self._elements = {} # Element specific configurations
- self._aliases = {} # Aliases dictionary
- self._workspaces = {} # Workspaces
+ self._context = context # The invocation Context
+ self._variables = {} # The default variables overridden with project wide overrides
+ self._environment = {} # The base sandbox environment
+ self._elements = {} # Element specific configurations
+ self._aliases = {} # Aliases dictionary
+ self._workspaces = {} # Workspaces
self._plugin_source_paths = [] # Paths to custom sources
self._plugin_element_paths = [] # Paths to custom plugins
+ self._options = None # Project options, the OptionPool
self._cache_key = None
- self._host_arch = host_arch
- self._target_arch = target_arch or host_arch
self._source_format_versions = {}
self._element_format_versions = {}
@@ -137,12 +132,12 @@ class Project():
variables = _yaml.node_get(config, Mapping, 'variables')
variables['max-jobs'] = multiprocessing.cpu_count()
- variables['bst-host-arch'] = self._host_arch
- variables['bst-target-arch'] = self._target_arch
+ 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._host_arch
+ variables['bst-arch'] = self._context.host_arch
# Load project local config and override the builtin
project_conf = _yaml.load(projectfile)
@@ -154,25 +149,47 @@ class Project():
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'arches', 'host-arches',
- 'artifacts',
+ 'artifacts', 'options',
])
+ # The project name, element path and option declarations
+ # are constant and cannot be overridden by option conditional statements
+ self.name = _yaml.node_get(config, str, 'name')
+ self.element_path = os.path.join(
+ self.directory,
+ _yaml.node_get(config, str, 'element-path', default_value='.')
+ )
+
+ # Load project options
+ options_node = _yaml.node_get(config, Mapping, 'options', default_value={})
+ self._options = OptionPool(self.element_path)
+ self._options.load(options_node)
+
+ # Collect option values specified in the user configuration
+ overrides = self._context._get_overrides(self.name)
+ override_options = _yaml.node_get(overrides, Mapping, 'options', default_value={})
+ self._options.load_values(override_options, self._context._cli_options)
+
+ # We're done modifying options, now we can use them for substitutions
+ self._options.resolve()
+
+ #
+ # Now resolve any conditionals in the remaining configuration,
+ # any conditionals specified for project option declarations,
+ # or conditionally specifying the project name; will be ignored.
+ #
+ self._options.process_node(config)
+
# Resolve arches keyword, project may have arch conditionals
- _loader.resolve_arch(config, self._host_arch, self._target_arch)
+ _loader.resolve_arch(config, self._context.host_arch, self._context.target_arch)
#
# Now all YAML composition is done, from here on we just load
# the values from our loaded configuration dictionary.
#
- self.name = _yaml.node_get(config, str, 'name')
- self.element_path = os.path.join(
- self.directory,
- _yaml.node_get(config, str, 'element-path')
- )
-
# Load artifacts pull/push configuration for this project
- artifacts = _yaml.node_get(config, Mapping, 'artifacts')
+ artifacts = _yaml.node_get(config, Mapping, 'artifacts', default_value={})
_yaml.node_validate(artifacts, ['pull-url', 'push-url', 'push-port'])
self.artifact_pull = _yaml.node_get(artifacts, str, 'pull-url', default_value='') or None
self.artifact_push = _yaml.node_get(artifacts, str, 'push-url', default_value='') or None
@@ -182,11 +199,11 @@ class Project():
self._workspaces = self._load_workspace_config()
# Version requirements
- versions = _yaml.node_get(config, Mapping, 'required-versions')
+ versions = _yaml.node_get(config, Mapping, 'required-versions', default_value={})
_yaml.node_validate(versions, ['project', 'elements', 'sources'])
# Assert project version first
- format_version = _yaml.node_get(versions, int, 'project')
+ format_version = _yaml.node_get(versions, int, 'project', default_value=0)
if BST_FORMAT_VERSION < format_version:
major, minor = utils.get_bst_version()
raise LoadError(