You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:13:58 UTC

[buildstream] branch 463-make-dependency-type-default-to-build created (now 670fb00)

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a change to branch 463-make-dependency-type-default-to-build
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 670fb00  docs: Add documentation of build-depends and runtime-depends fields

This branch includes the following new commits:

     new be7b57e  Add 'build-depends' and 'runtime-depends' fields to elements
     new 80b174f  tests: Add tests for loading builddeps and runtime deps
     new b733e10  versions: Bump format version to 14
     new 670fb00  docs: Add documentation of build-depends and runtime-depends fields

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 03/04: versions: Bump format version to 14

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch 463-make-dependency-type-default-to-build
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit b733e10a5560e16e8f247baa7c667201ce5b7e71
Author: Jonathan Maw <jo...@codethink.co.uk>
AuthorDate: Fri Aug 10 14:40:14 2018 +0100

    versions: Bump format version to 14
    
    Format version raised because of a change to the core element format.
---
 buildstream/_versions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildstream/_versions.py b/buildstream/_versions.py
index d774e57..905d5a3 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


[buildstream] 02/04: tests: Add tests for loading builddeps and runtime deps

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch 463-make-dependency-type-default-to-build
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 80b174fe48a85ab21732f93c854b8c9632c43978
Author: Jonathan Maw <jo...@codethink.co.uk>
AuthorDate: Thu Aug 9 17:57:51 2018 +0100

    tests: Add tests for loading builddeps and runtime deps
---
 tests/loader/dependencies.py                       | 53 ++++++++++++++++++++--
 .../loader/dependencies/elements/builddep-list.bst |  4 ++
 tests/loader/dependencies/elements/firstdep.bst    |  2 +-
 .../loader/dependencies/elements/list-combine.bst  |  8 ++++
 .../loader/dependencies/elements/list-overlap.bst  |  7 +++
 .../dependencies/elements/runtimedep-list.bst      |  4 ++
 tests/loader/dependencies/elements/seconddep.bst   |  2 +
 tests/loader/dependencies/elements/thirddep.bst    |  2 +
 8 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py
index 4bb13a3..cb750fc 100644
--- a/tests/loader/dependencies.py
+++ b/tests/loader/dependencies.py
@@ -3,6 +3,7 @@ import pytest
 
 from buildstream._exceptions import LoadError, LoadErrorReason
 from buildstream._loader import Loader, MetaElement
+from tests.testutils import cli
 from . import make_loader
 
 DATA_DIR = os.path.join(
@@ -27,7 +28,7 @@ def test_two_files(datafiles):
     assert(len(element.dependencies) == 1)
     firstdep = element.dependencies[0]
     assert(isinstance(firstdep, MetaElement))
-    assert(firstdep.kind == 'thefirstdep')
+    assert(firstdep.kind == 'manual')
 
 
 @pytest.mark.datafiles(DATA_DIR)
@@ -47,7 +48,7 @@ def test_shared_dependency(datafiles):
     #
     firstdep = element.dependencies[0]
     assert(isinstance(firstdep, MetaElement))
-    assert(firstdep.kind == 'thefirstdep')
+    assert(firstdep.kind == 'manual')
     assert(len(firstdep.dependencies) == 0)
 
     # The second specified dependency is 'shareddep'
@@ -86,7 +87,7 @@ def test_dependency_dict(datafiles):
     assert(len(element.dependencies) == 1)
     firstdep = element.dependencies[0]
     assert(isinstance(firstdep, MetaElement))
-    assert(firstdep.kind == 'thefirstdep')
+    assert(firstdep.kind == 'manual')
 
 
 @pytest.mark.datafiles(DATA_DIR)
@@ -186,3 +187,49 @@ def test_all_dependency(datafiles):
     assert(isinstance(firstdep, MetaElement))
     firstbuilddep = element.build_dependencies[0]
     assert(firstdep == firstbuilddep)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_list_build_dependency(cli, datafiles):
+    project = str(datafiles)
+
+    # Check that the pipeline includes the build dependency
+    deps = cli.get_pipeline(project, ['elements/builddep-list.bst'], scope="build")
+    assert "elements/firstdep.bst" in deps
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_list_runtime_dependency(cli, datafiles):
+    project = str(datafiles)
+
+    # Check that the pipeline includes the runtime dependency
+    deps = cli.get_pipeline(project, ['elements/runtimedep-list.bst'], scope="run")
+    assert "elements/firstdep.bst" in deps
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_list_dependencies_combined(cli, datafiles):
+    project = str(datafiles)
+
+    # Check that runtime deps get combined
+    rundeps = cli.get_pipeline(project, ['elements/list-combine.bst'], scope="run")
+    assert "elements/firstdep.bst" not in rundeps
+    assert "elements/seconddep.bst" in rundeps
+    assert "elements/thirddep.bst" in rundeps
+
+    # Check that build deps get combined
+    builddeps = cli.get_pipeline(project, ['elements/list-combine.bst'], scope="build")
+    assert "elements/firstdep.bst" in builddeps
+    assert "elements/seconddep.bst" not in builddeps
+    assert "elements/thirddep.bst" in builddeps
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_list_overlap(cli, datafiles):
+    project = str(datafiles)
+
+    # Check that dependencies get merged
+    rundeps = cli.get_pipeline(project, ['elements/list-overlap.bst'], scope="run")
+    assert "elements/firstdep.bst" in rundeps
+    builddeps = cli.get_pipeline(project, ['elements/list-overlap.bst'], scope="build")
+    assert "elements/firstdep.bst" in builddeps
diff --git a/tests/loader/dependencies/elements/builddep-list.bst b/tests/loader/dependencies/elements/builddep-list.bst
new file mode 100644
index 0000000..925de3a
--- /dev/null
+++ b/tests/loader/dependencies/elements/builddep-list.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: This element has a build-only dependency specified via build-depends
+build-depends:
+  - elements/firstdep.bst
diff --git a/tests/loader/dependencies/elements/firstdep.bst b/tests/loader/dependencies/elements/firstdep.bst
index 9b6a578..5c9c1c1 100644
--- a/tests/loader/dependencies/elements/firstdep.bst
+++ b/tests/loader/dependencies/elements/firstdep.bst
@@ -1,2 +1,2 @@
-kind: thefirstdep
+kind: manual
 description: This is the first dependency
diff --git a/tests/loader/dependencies/elements/list-combine.bst b/tests/loader/dependencies/elements/list-combine.bst
new file mode 100644
index 0000000..2010d70
--- /dev/null
+++ b/tests/loader/dependencies/elements/list-combine.bst
@@ -0,0 +1,8 @@
+kind: stack
+description: This element depends on three elements in different ways
+build-depends:
+- elements/firstdep.bst
+runtime-depends:
+- elements/seconddep.bst
+depends:
+- elements/thirddep.bst
diff --git a/tests/loader/dependencies/elements/list-overlap.bst b/tests/loader/dependencies/elements/list-overlap.bst
new file mode 100644
index 0000000..1e98a20
--- /dev/null
+++ b/tests/loader/dependencies/elements/list-overlap.bst
@@ -0,0 +1,7 @@
+kind: stack
+description: This element depends on two elements in different ways
+build-depends:
+- elements/firstdep.bst
+depends:
+- filename: elements/firstdep.bst
+  type: runtime
diff --git a/tests/loader/dependencies/elements/runtimedep-list.bst b/tests/loader/dependencies/elements/runtimedep-list.bst
new file mode 100644
index 0000000..790fa4d
--- /dev/null
+++ b/tests/loader/dependencies/elements/runtimedep-list.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: This element has a runtime-only dependency
+runtime-depends:
+  - elements/firstdep.bst
diff --git a/tests/loader/dependencies/elements/seconddep.bst b/tests/loader/dependencies/elements/seconddep.bst
new file mode 100644
index 0000000..93ded43
--- /dev/null
+++ b/tests/loader/dependencies/elements/seconddep.bst
@@ -0,0 +1,2 @@
+kind: manual
+description: This is the second dependency
diff --git a/tests/loader/dependencies/elements/thirddep.bst b/tests/loader/dependencies/elements/thirddep.bst
new file mode 100644
index 0000000..39b58e5
--- /dev/null
+++ b/tests/loader/dependencies/elements/thirddep.bst
@@ -0,0 +1,2 @@
+kind: manual
+description: This is the third dependency


[buildstream] 04/04: docs: Add documentation of build-depends and runtime-depends fields

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch 463-make-dependency-type-default-to-build
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 670fb0086a3ce344db03a159bf782a6a69871ed5
Author: Jonathan Maw <jo...@codethink.co.uk>
AuthorDate: Fri Aug 10 14:52:12 2018 +0100

    docs: Add documentation of build-depends and runtime-depends fields
---
 doc/source/format_declaring.rst | 68 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 66 insertions(+), 2 deletions(-)

diff --git a/doc/source/format_declaring.rst b/doc/source/format_declaring.rst
index 013e2c8..38c107c 100644
--- a/doc/source/format_declaring.rst
+++ b/doc/source/format_declaring.rst
@@ -98,6 +98,68 @@ relative filename to the elements they depend on here.
 See :ref:`format_dependencies` for more information on the dependency model.
 
 
+.. _format_build_depends:
+
+Build-Depends
+~~~~~~~~~~~~~
+
+.. code:: yaml
+
+   # Specify some build-dependencies
+   build-depends:
+   - element1.bst
+   - element2.bst
+
+Build dependencies between elements can be specified with the ``build-depends`` attribute.
+The above code snippet is equivalent to:
+
+.. code:: yaml
+
+   # Specify some build-dependencies
+   depends:
+   - filename: element1.bst
+     type: build
+   - filename: element2.bst
+     type: build
+
+See :ref:`format_dependencies` for more information on the dependency model.
+
+.. note::
+
+   The ``build-depends`` configuration is available since :ref:`format version 14 <project_format_version>`
+
+
+.. _format_runtime_depends:
+
+Runtime-Depends
+~~~~~~~~~~~~~~~
+
+.. code:: yaml
+
+   # Specify some runtime-dependencies
+   runtime-depends:
+   - element1.bst
+   - element2.bst
+
+Runtime dependencies between elements can be specified with the ``runtime-depends`` attribute.
+The above code snippet is equivalent to:
+
+.. code:: yaml
+
+   # Specify some runtime-dependencies
+   depends:
+   - filename: element1.bst
+     type: runtime
+   - filename: element2.bst
+     type: runtime
+
+See :ref:`format_dependencies` for more information on the dependency model.
+
+.. note::
+
+   The ``runtime-depends`` configuration is available since :ref:`format version 14 <project_format_version>`
+
+
 .. _format_sources:
 
 Sources
@@ -276,8 +338,8 @@ attributes are suitable.
 
 .. note::
 
-   Note the order in which element dependencies are declared in the ``depends``
-   list is not meaningful.
+   Note the order in which element dependencies are declared in the ``depends``,
+   ``build-depends`` and ``runtime-depends`` lists are not meaningful.
 
 Dependency dictionary:
 
@@ -299,6 +361,8 @@ Attributes:
 * ``type``
 
   This attribute is used to express the :ref:`dependency type <format_dependencies_types>`.
+  This field is not permitted in :ref:`Build-Depends <format_build_depends>` or
+  :ref:`Runtime-Depends <format_runtime_depends>`.
 
 * ``junction``
 


[buildstream] 01/04: Add 'build-depends' and 'runtime-depends' fields to elements

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch 463-make-dependency-type-default-to-build
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit be7b57ea39deb7d6f95f599f49d99fb49a7fca73
Author: Jonathan Maw <jo...@codethink.co.uk>
AuthorDate: Thu Aug 9 12:29:41 2018 +0100

    Add 'build-depends' and 'runtime-depends' fields to elements
---
 buildstream/_loader/loadelement.py | 53 +++++++++++++++++++++++++-------------
 buildstream/_loader/types.py       |  2 ++
 2 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/buildstream/_loader/loadelement.py b/buildstream/_loader/loadelement.py
index 065364a..d7de665 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,44 @@ 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
+
+    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 +176,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 000925a..25b7855 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"