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

[buildstream] branch issue_640-Build-All created (now 3997698)

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

root pushed a change to branch issue_640-Build-All
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 3997698  Updated NEWS to reflect changes to bst build

This branch includes the following new commits:

     new 62e418c  projectconfig.yaml: Add default-element var
     new 74965bc  _project.py: Add config variable to node_validate
     new 676d8f9  _frontend/cli.py: Add call to get_default_elements
     new 7b257fb  frontend/buildcheckout.py: build default element
     new 3997698  Updated NEWS to reflect changes to bst build

The 5 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] 04/05: frontend/buildcheckout.py: build default element

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

root pushed a commit to branch issue_640-Build-All
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 7b257fb203bcb54af1bcaabc05382a6f84ee3a75
Author: Phillip Smyth <ph...@codethink.co.uk>
AuthorDate: Mon Nov 12 10:28:36 2018 +0000

    frontend/buildcheckout.py: build default element
    
    Added supporting files for build default element tests
---
 tests/frontend/buildcheckout.py                    | 30 ++++++++++++++++++++++
 tests/frontend/project_default/elements/target.bst |  4 +++
 .../frontend/project_default/elements/target2.bst  |  4 +++
 tests/frontend/project_default/project.conf        | 10 ++++++++
 .../project_world/elements/compose-all.bst         | 12 +++++++++
 .../project_world/elements/compose-exclude-dev.bst | 16 ++++++++++++
 .../project_world/elements/compose-include-bin.bst | 16 ++++++++++++
 .../frontend/project_world/elements/import-bin.bst |  4 +++
 .../frontend/project_world/elements/import-dev.bst |  4 +++
 .../project_world/elements/rebuild-target.bst      |  4 +++
 .../elements/source-bundle/source-bundle-hello.bst |  6 +++++
 tests/frontend/project_world/elements/target.bst   |  8 ++++++
 tests/frontend/project_world/files/bar             |  0
 .../project_world/files/bin-files/usr/bin/hello    |  3 +++
 .../files/build-files/buildstream/build/test       |  1 +
 .../files/dev-files/usr/include/pony.h             | 12 +++++++++
 tests/frontend/project_world/files/foo             |  0
 .../project_world/files/source-bundle/llamas.txt   |  1 +
 tests/frontend/project_world/project.conf          |  4 +++
 19 files changed, 139 insertions(+)

diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 03bba0b..d1440a3 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -2,6 +2,7 @@ import os
 import tarfile
 import hashlib
 import pytest
+import subprocess
 from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
 
 from buildstream import _yaml
@@ -60,6 +61,35 @@ def test_build_checkout(datafiles, cli, strict, hardlinks):
     assert os.path.exists(filename)
 
 
+@pytest.mark.datafiles(DATA_DIR + "_world")
+def test_build_default_all(datafiles, cli):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+    result = cli.run(project=project, silent=True, args=['build'])
+
+    result.assert_success()
+    target_dir = os.path.join(cli.directory, DATA_DIR + "_world", "elements")
+    output_dir = os.path.join(cli.directory, "logs", "test")
+
+    expected = subprocess.Popen(('ls', target_dir), stdout=subprocess.PIPE)
+    expected = subprocess.check_output(("wc", "-w"), stdin=expected.stdout)
+
+    results = subprocess.Popen(('ls', output_dir), stdout=subprocess.PIPE)
+    results = subprocess.check_output(("wc", "-w"), stdin=results.stdout)
+
+    assert results == expected
+
+
+@pytest.mark.datafiles(DATA_DIR + "_default")
+def test_build_default(cli, datafiles):
+    project = os.path.join(datafiles.dirname, datafiles.basename)
+    result = cli.run(project=project, silent=True, args=['build'])
+
+    result.assert_success()
+    results = cli.get_element_state(project, "target2.bst")
+    expected = "cached"
+    assert results == expected
+
+
 @pytest.mark.datafiles(DATA_DIR)
 @pytest.mark.parametrize("strict,hardlinks", [
     ("non-strict", "hardlinks"),
diff --git a/tests/frontend/project_default/elements/target.bst b/tests/frontend/project_default/elements/target.bst
new file mode 100644
index 0000000..d644c89
--- /dev/null
+++ b/tests/frontend/project_default/elements/target.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: |
+
+  Main stack target for the bst build test
diff --git a/tests/frontend/project_default/elements/target2.bst b/tests/frontend/project_default/elements/target2.bst
new file mode 100644
index 0000000..d644c89
--- /dev/null
+++ b/tests/frontend/project_default/elements/target2.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: |
+
+  Main stack target for the bst build test
diff --git a/tests/frontend/project_default/project.conf b/tests/frontend/project_default/project.conf
new file mode 100644
index 0000000..0b2cff7
--- /dev/null
+++ b/tests/frontend/project_default/project.conf
@@ -0,0 +1,10 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements
+
+fatal-warnings:
+- bad-element-suffix
+
+defaults:
+  target-element: target2.bst
diff --git a/tests/frontend/project_world/elements/compose-all.bst b/tests/frontend/project_world/elements/compose-all.bst
new file mode 100644
index 0000000..ba47081
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-all.bst
@@ -0,0 +1,12 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+  type: build
+- filename: import-dev.bst
+  type: build
+
+config:
+  # Dont try running the sandbox, we dont have a
+  # runtime to run anything in this context.
+  integrate: False
diff --git a/tests/frontend/project_world/elements/compose-exclude-dev.bst b/tests/frontend/project_world/elements/compose-exclude-dev.bst
new file mode 100644
index 0000000..75c1437
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-exclude-dev.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+  type: build
+- filename: import-dev.bst
+  type: build
+
+config:
+  # Dont try running the sandbox, we dont have a
+  # runtime to run anything in this context.
+  integrate: False
+
+  # Exclude the dev domain
+  exclude:
+  - devel
diff --git a/tests/frontend/project_world/elements/compose-include-bin.bst b/tests/frontend/project_world/elements/compose-include-bin.bst
new file mode 100644
index 0000000..9571203
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-include-bin.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+  type: build
+- filename: import-dev.bst
+  type: build
+
+config:
+  # Dont try running the sandbox, we dont have a
+  # runtime to run anything in this context.
+  integrate: False
+
+  # Only include the runtim
+  include:
+  - runtime
diff --git a/tests/frontend/project_world/elements/import-bin.bst b/tests/frontend/project_world/elements/import-bin.bst
new file mode 100644
index 0000000..a847c0c
--- /dev/null
+++ b/tests/frontend/project_world/elements/import-bin.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+  path: files/bin-files
diff --git a/tests/frontend/project_world/elements/import-dev.bst b/tests/frontend/project_world/elements/import-dev.bst
new file mode 100644
index 0000000..152a546
--- /dev/null
+++ b/tests/frontend/project_world/elements/import-dev.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+  path: files/dev-files
diff --git a/tests/frontend/project_world/elements/rebuild-target.bst b/tests/frontend/project_world/elements/rebuild-target.bst
new file mode 100644
index 0000000..49a02c2
--- /dev/null
+++ b/tests/frontend/project_world/elements/rebuild-target.bst
@@ -0,0 +1,4 @@
+kind: compose
+
+build-depends:
+- target.bst
diff --git a/tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst b/tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst
new file mode 100644
index 0000000..98c3a95
--- /dev/null
+++ b/tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst
@@ -0,0 +1,6 @@
+kind: import
+description: the kind of this element must implement generate_script() method
+
+sources:
+- kind: local
+  path: files/source-bundle
diff --git a/tests/frontend/project_world/elements/target.bst b/tests/frontend/project_world/elements/target.bst
new file mode 100644
index 0000000..b9432fa
--- /dev/null
+++ b/tests/frontend/project_world/elements/target.bst
@@ -0,0 +1,8 @@
+kind: stack
+description: |
+
+  Main stack target for the bst build test
+
+depends:
+- import-bin.bst
+- compose-all.bst
diff --git a/tests/frontend/project_world/files/bar b/tests/frontend/project_world/files/bar
new file mode 100644
index 0000000..e69de29
diff --git a/tests/frontend/project_world/files/bin-files/usr/bin/hello b/tests/frontend/project_world/files/bin-files/usr/bin/hello
new file mode 100755
index 0000000..f534a40
--- /dev/null
+++ b/tests/frontend/project_world/files/bin-files/usr/bin/hello
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello !"
diff --git a/tests/frontend/project_world/files/build-files/buildstream/build/test b/tests/frontend/project_world/files/build-files/buildstream/build/test
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/frontend/project_world/files/build-files/buildstream/build/test
@@ -0,0 +1 @@
+test
diff --git a/tests/frontend/project_world/files/dev-files/usr/include/pony.h b/tests/frontend/project_world/files/dev-files/usr/include/pony.h
new file mode 100644
index 0000000..40bd0c2
--- /dev/null
+++ b/tests/frontend/project_world/files/dev-files/usr/include/pony.h
@@ -0,0 +1,12 @@
+#ifndef __PONY_H__
+#define __PONY_H__
+
+#define PONY_BEGIN "Once upon a time, there was a pony."
+#define PONY_END "And they lived happily ever after, the end."
+
+#define MAKE_PONY(story)  \
+  PONY_BEGIN \
+  story \
+  PONY_END
+
+#endif /* __PONY_H__ */
diff --git a/tests/frontend/project_world/files/foo b/tests/frontend/project_world/files/foo
new file mode 100644
index 0000000..e69de29
diff --git a/tests/frontend/project_world/files/source-bundle/llamas.txt b/tests/frontend/project_world/files/source-bundle/llamas.txt
new file mode 100644
index 0000000..f98b248
--- /dev/null
+++ b/tests/frontend/project_world/files/source-bundle/llamas.txt
@@ -0,0 +1 @@
+llamas
diff --git a/tests/frontend/project_world/project.conf b/tests/frontend/project_world/project.conf
new file mode 100644
index 0000000..854e386
--- /dev/null
+++ b/tests/frontend/project_world/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements


[buildstream] 05/05: Updated NEWS to reflect changes to bst build

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

root pushed a commit to branch issue_640-Build-All
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 3997698fcd13fb97710131a3fa4be03c9e0cd4f6
Author: Phillip Smyth <ph...@codethink.co.uk>
AuthorDate: Wed Dec 12 11:23:51 2018 +0000

    Updated NEWS to reflect changes to bst build
---
 NEWS | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/NEWS b/NEWS
index 91897f6..3e96b42 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ buildstream 1.3.1
     specific. Recommendation if you are building in Linux is to use the
     ones being used in freedesktop-sdk project, for example
 
+  o Running `bst build` without elements specified will now attempt to build
+    the default element defined in the projcet configuration.
+    If no default element is defined, all elements in the project will be built
+
   o All elements must now be suffixed with `.bst`
     Attempting to use an element that does not have the `.bst` extension,
     will result in a warning.


[buildstream] 02/05: _project.py: Add config variable to node_validate

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

root pushed a commit to branch issue_640-Build-All
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 74965bceb280227ceb5876cd04fe69d70b87f56e
Author: Phillip Smyth <ph...@codethink.co.uk>
AuthorDate: Wed Dec 12 16:03:10 2018 +0000

    _project.py: Add config variable to node_validate
    
    _project.py: Added `get_default_elements()`
    This function either returns the default element, or all elements
---
 buildstream/_project.py | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/buildstream/_project.py b/buildstream/_project.py
index 90ed58e..f1b2cd4 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -228,7 +228,7 @@ class Project():
             'element-path', 'variables',
             'environment', 'environment-nocache',
             'split-rules', 'elements', 'plugins',
-            'aliases', 'name',
+            'aliases', 'name', 'defaults',
             'artifacts', 'options',
             'fail-on-overlap', 'shell', 'fatal-warnings',
             'ref-storage', 'sandbox', 'mirrors', 'remote-execution',
@@ -391,6 +391,36 @@ class Project():
         # Reset the element loader state
         Element._reset_load_state()
 
+
+    # get_default_elements()
+    #
+    # This function is used to gather either:
+    # The project default element (if defined in project.conf)
+    # or
+    # All elements in the project
+    #
+    def get_default_elements(self):
+        output = []
+
+        # The project is not required to have an element-path
+        element_directory = self._project_conf.get('element-path')
+
+        # The project may have a default element defined
+        default_element = self._project_conf.get("defaults", {}).get("target-element", None)
+
+        if default_element:
+            return (default_element,)
+
+        directory = os.path.join(self.directory, element_directory)
+        for root, _, files in os.walk(directory):
+            for file in files:
+                if file.endswith(".bst"):
+                    rel_dir = os.path.relpath(root, directory)
+                    rel_file = os.path.join(rel_dir, file).lstrip("./")
+                    output.append(rel_file)
+        return tuple(output)
+
+
     # _load():
     #
     # Loads the project configuration file in the project


[buildstream] 03/05: _frontend/cli.py: Add call to get_default_elements

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

root pushed a commit to branch issue_640-Build-All
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 676d8f9730799311093b1c90d0291f1fb694d367
Author: Phillip Smyth <ph...@codethink.co.uk>
AuthorDate: Wed Dec 12 16:03:42 2018 +0000

    _frontend/cli.py: Add call to get_default_elements
---
 buildstream/_frontend/cli.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index f2f87e7..c99a30d 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -306,7 +306,11 @@ def init(app, project_name, format_version, element_path, force):
                 type=click.Path(readable=False))
 @click.pass_obj
 def build(app, elements, all_, track_, track_save, track_all, track_except, track_cross_junctions):
-    """Build elements in a pipeline"""
+    """Build elements in a pipeline
+
+       Declaring no elements with result in building a default element if one is declared in the project configuration.
+
+       If no default is declared, all elements in the project will be built"""
 
     if (track_except or track_cross_junctions) and not (track_ or track_all):
         click.echo("ERROR: The --track-except and --track-cross-junctions options "
@@ -321,6 +325,8 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac
             guessed_target = app.context.guess_element()
             if guessed_target:
                 elements = (guessed_target,)
+            else:
+                app.project.get_default_elements()
 
         if track_all:
             track_ = elements


[buildstream] 01/05: projectconfig.yaml: Add default-element var

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

root pushed a commit to branch issue_640-Build-All
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 62e418cb5cbe2e4d664777aeda7dd944e955c115
Author: Phillip Smyth <ph...@codethink.co.uk>
AuthorDate: Wed Dec 12 16:02:57 2018 +0000

    projectconfig.yaml: Add default-element var
---
 buildstream/data/projectconfig.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index e9bdaa1..dc5acfb 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -167,3 +167,10 @@ shell:
   # Command to run when `bst shell` does not provide a command
   #
   command: [ 'sh', '-i' ]
+
+# Default Targets
+#
+defaults:
+
+  # Set a Default element to build when none are defined 
+  target-element: None