diff options
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_loader/loadelement.py | 55 | ||||
-rw-r--r-- | buildstream/_loader/types.py | 2 | ||||
-rw-r--r-- | buildstream/_versions.py | 2 |
3 files changed, 40 insertions, 19 deletions
diff --git a/buildstream/_loader/loadelement.py b/buildstream/_loader/loadelement.py index 065364a87..4104dfd59 100644 --- a/buildstream/_loader/loadelement.py +++ b/buildstream/_loader/loadelement.py @@ -71,6 +71,7 @@ class LoadElement(): 'kind', 'depends', 'sources', 'sandbox', 'variables', 'environment', 'environment-nocache', 'config', 'public', 'description', + 'build-depends', 'runtime-depends', ]) # Extract the Dependencies @@ -127,28 +128,46 @@ class LoadElement(): # Returns: # (list): a list of Dependency objects # -def _extract_depends_from_node(node): - depends = _yaml.node_get(node, list, Symbol.DEPENDS, default_value=[]) +def _extract_depends_from_node(node, *, key=None): + if key is None: + build_depends = _extract_depends_from_node(node, key=Symbol.BUILD_DEPENDS) + runtime_depends = _extract_depends_from_node(node, key=Symbol.RUNTIME_DEPENDS) + depends = _extract_depends_from_node(node, key=Symbol.DEPENDS) + return build_depends + runtime_depends + depends + elif key == Symbol.BUILD_DEPENDS: + default_dep_type = Symbol.BUILD + elif key == Symbol.RUNTIME_DEPENDS: + default_dep_type = Symbol.RUNTIME + elif key == Symbol.DEPENDS: + default_dep_type = None + else: + assert False, "Unexpected value of key '{}'".format(key) + + depends = _yaml.node_get(node, list, key, default_value=[]) output_deps = [] for dep in depends: - dep_provenance = _yaml.node_get_provenance(node, key=Symbol.DEPENDS, indices=[depends.index(dep)]) + dep_provenance = _yaml.node_get_provenance(node, key=key, indices=[depends.index(dep)]) if isinstance(dep, str): - dependency = Dependency(dep, provenance=dep_provenance) + dependency = Dependency(dep, provenance=dep_provenance, dep_type=default_dep_type) elif isinstance(dep, Mapping): - _yaml.node_validate(dep, ['filename', 'type', 'junction']) - - # Make type optional, for this we set it to None - dep_type = _yaml.node_get(dep, str, Symbol.TYPE, default_value=None) - if dep_type is None or dep_type == Symbol.ALL: - dep_type = None - elif dep_type not in [Symbol.BUILD, Symbol.RUNTIME]: - provenance = _yaml.node_get_provenance(dep, key=Symbol.TYPE) - raise LoadError(LoadErrorReason.INVALID_DATA, - "{}: Dependency type '{}' is not 'build', 'runtime' or 'all'" - .format(provenance, dep_type)) + if default_dep_type: + _yaml.node_validate(dep, ['filename', 'junction']) + dep_type = default_dep_type + else: + _yaml.node_validate(dep, ['filename', 'type', 'junction']) + + # Make type optional, for this we set it to None + dep_type = _yaml.node_get(dep, str, Symbol.TYPE, default_value=None) + if dep_type is None or dep_type == Symbol.ALL: + dep_type = None + elif dep_type not in [Symbol.BUILD, Symbol.RUNTIME]: + provenance = _yaml.node_get_provenance(dep, key=Symbol.TYPE) + raise LoadError(LoadErrorReason.INVALID_DATA, + "{}: Dependency type '{}' is not 'build', 'runtime' or 'all'" + .format(provenance, dep_type)) filename = _yaml.node_get(dep, str, Symbol.FILENAME) junction = _yaml.node_get(dep, str, Symbol.JUNCTION, default_value=None) @@ -159,13 +178,13 @@ def _extract_depends_from_node(node): else: index = depends.index(dep) - p = _yaml.node_get_provenance(node, key=Symbol.DEPENDS, indices=[index]) + p = _yaml.node_get_provenance(node, key=key, indices=[index]) raise LoadError(LoadErrorReason.INVALID_DATA, "{}: Dependency is not specified as a string or a dictionary".format(p)) output_deps.append(dependency) - # Now delete "depends", we dont want it anymore - del node[Symbol.DEPENDS] + # Now delete the field, we dont want it anymore + del node[key] return output_deps diff --git a/buildstream/_loader/types.py b/buildstream/_loader/types.py index 000925a6e..25b785532 100644 --- a/buildstream/_loader/types.py +++ b/buildstream/_loader/types.py @@ -26,6 +26,8 @@ class Symbol(): FILENAME = "filename" KIND = "kind" DEPENDS = "depends" + BUILD_DEPENDS = "build-depends" + RUNTIME_DEPENDS = "runtime-depends" SOURCES = "sources" CONFIG = "config" VARIABLES = "variables" diff --git a/buildstream/_versions.py b/buildstream/_versions.py index 6d5077a2a..3f32847ae 100644 --- a/buildstream/_versions.py +++ b/buildstream/_versions.py @@ -23,7 +23,7 @@ # This version is bumped whenever enhancements are made # to the `project.conf` format or the core element format. # -BST_FORMAT_VERSION = 13 +BST_FORMAT_VERSION = 14 # The base BuildStream artifact version |