summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Smyth <phillip.smyth@codethink.co.uk>2018-03-07 15:02:01 +0000
committerPhillip Smyth <phillip.smyth@codethink.co.uk>2018-03-26 15:27:47 +0000
commitb0e6a45e7d34ef969734bc5c607ce97a229a4f77 (patch)
treef87ede105b8912851530a702f945aa614d344516
parente91dc8336074d22126e559a29e23ef2d52c5506a (diff)
downloadbuildstream-b0e6a45e7d34ef969734bc5c607ce97a229a4f77.tar.gz
Generate unique subdirs for built elements
Based on issue 89 (https://gitlab.com/BuildStream/buildstream/issues/89) Ensuring that elements are staged into unique subdirs while building. This patch supports that by doing the following: * Modify project config to add 2 new variables ("project-name" and "element-name") * Changed the default install-root from "/buildstream/install" to "/buildstream-install" * Update the tests to accommodate these changes * Update the expected cache keys in the tests This fixes #89
-rw-r--r--buildstream/buildelement.py4
-rw-r--r--buildstream/data/projectconfig.yaml8
-rw-r--r--buildstream/element.py1
-rw-r--r--buildstream/plugins/elements/script.yaml8
-rw-r--r--tests/cachekey/project/elements/build1.expected2
-rw-r--r--tests/cachekey/project/elements/build2.expected2
-rw-r--r--tests/cachekey/project/elements/script1.expected2
-rw-r--r--tests/cachekey/project/target.expected2
-rw-r--r--tests/integration/project/elements/stack/another-hi.bst4
-rw-r--r--tests/integration/project/elements/stack/hi.bst4
-rw-r--r--tests/integration/script.py12
-rw-r--r--tests/variables/variables.py10
12 files changed, 28 insertions, 31 deletions
diff --git a/buildstream/buildelement.py b/buildstream/buildelement.py
index c275cfb9d..5a986bd11 100644
--- a/buildstream/buildelement.py
+++ b/buildstream/buildelement.py
@@ -90,7 +90,7 @@ of the staged sources.
Result collection
~~~~~~~~~~~~~~~~~
Finally, the resulting build *artifact* is collected from the the ``%{install-root}``
-directory (which is normally configured as ``/buildstream/install``) inside the sandbox.
+directory (which is normally configured as ``/buildstream-install``) inside the sandbox.
All build elements must install into the ``%{install-root}`` using whatever
semantic the given build system provides to do this. E.g. for standard autotools
@@ -222,7 +222,7 @@ class BuildElement(Element):
"will not be allowed to stage to %{build-root}.")
# Return the payload, this is configurable but is generally
- # always the /buildstream/install directory
+ # always the /buildstream-install directory
return self.get_variable('install-root')
def _get_commands(self, node, name):
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index 408304544..b4ad2dcb9 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -29,6 +29,10 @@ variables:
# Note: this value defaults to the number of cores available
max-jobs: 4
+ # Note: These variables are defined later on in element.py and _project.py
+ element-name: ""
+ project-name: ""
+
# Path configuration, to be used in build instructions.
#
prefix: "/usr"
@@ -50,10 +54,10 @@ variables:
# Indicates the default build directory where input is
# normally staged
- build-root: /buildstream/build
+ build-root: /buildstream/%{project-name}/%{element-name}
# Indicates the build installation directory in the sandbox
- install-root: /buildstream/install
+ install-root: /buildstream-install
# Arguments for tooling used when stripping debug symbols
objcopy-link-args: --add-gnu-debuglink
diff --git a/buildstream/element.py b/buildstream/element.py
index 8532f995c..131a834e1 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -173,6 +173,7 @@ class Element(Plugin):
# Collect the composited variables and resolve them
variables = self.__extract_variables(meta)
+ variables['element-name'] = self.name
self.__variables = Variables(variables)
# Collect the composited environment now that we have variables
diff --git a/buildstream/plugins/elements/script.yaml b/buildstream/plugins/elements/script.yaml
index 56a656cf6..b388378da 100644
--- a/buildstream/plugins/elements/script.yaml
+++ b/buildstream/plugins/elements/script.yaml
@@ -1,15 +1,7 @@
# Common script element variables
variables:
- # Defines the directory that output is collected from once commands
- # have been run.
- install-root: /buildstream/install
- #
# Defines the directory commands will be run from.
cwd: /
- #
- # Not directly used, but expected to be used when staging elements to be
- # worked on.
- build-root: /buildstream/build
# Script element configuration
config:
diff --git a/tests/cachekey/project/elements/build1.expected b/tests/cachekey/project/elements/build1.expected
index aeab7df30..a5d0bdba8 100644
--- a/tests/cachekey/project/elements/build1.expected
+++ b/tests/cachekey/project/elements/build1.expected
@@ -1 +1 @@
-4fa7a6fd4c7a499208be4ce0deb26f7ae2fad3bfe2a0579f95207e01189731f4 \ No newline at end of file
+e627300631f39b713fc5aac9446efeda96b1c3f92ef3f2200a074539e49beaf7
diff --git a/tests/cachekey/project/elements/build2.expected b/tests/cachekey/project/elements/build2.expected
index 265cc2e6c..02e4b5577 100644
--- a/tests/cachekey/project/elements/build2.expected
+++ b/tests/cachekey/project/elements/build2.expected
@@ -1 +1 @@
-851f173aad27a6636489ddc20cb3d7396ebba60d10c1c657309451df1a3fdf24 \ No newline at end of file
+b5ba1cfe2e4cce33baf793c5d69c840c4339ad57bbc8fee1fb7adef44d4821d0
diff --git a/tests/cachekey/project/elements/script1.expected b/tests/cachekey/project/elements/script1.expected
index bdcdc75fd..e2b80ddb4 100644
--- a/tests/cachekey/project/elements/script1.expected
+++ b/tests/cachekey/project/elements/script1.expected
@@ -1 +1 @@
-465988b4812a13871f2c3e840a3b9ae6d95e04f2f0a5e4b5a61f45a8b3a4098d \ No newline at end of file
+b8d8400afa31654600cb5eb3f1fbc7165e2316ba759cca197e6e5f54fd4cfd04
diff --git a/tests/cachekey/project/target.expected b/tests/cachekey/project/target.expected
index 498765dc1..5ecbc0a3a 100644
--- a/tests/cachekey/project/target.expected
+++ b/tests/cachekey/project/target.expected
@@ -1 +1 @@
-19ef59d28a4af5995c099190ec4f146069c1f7219fc83faf10f71ee88f083da1 \ No newline at end of file
+8eabd313b3c2c744450fef4c5b52d68babe6d39a278e80e39f5ef886fd49e799
diff --git a/tests/integration/project/elements/stack/another-hi.bst b/tests/integration/project/elements/stack/another-hi.bst
index eb98dea36..f83fdee82 100644
--- a/tests/integration/project/elements/stack/another-hi.bst
+++ b/tests/integration/project/elements/stack/another-hi.bst
@@ -7,5 +7,5 @@ depends:
config:
commands:
- - "mkdir -p /buildstream/install"
- - "echo 'Another hi' > /buildstream/install/another-hi"
+ - "mkdir -p %{install-root}"
+ - "echo 'Another hi' > %{install-root}/another-hi"
diff --git a/tests/integration/project/elements/stack/hi.bst b/tests/integration/project/elements/stack/hi.bst
index adbf81537..0aa2d32f2 100644
--- a/tests/integration/project/elements/stack/hi.bst
+++ b/tests/integration/project/elements/stack/hi.bst
@@ -4,5 +4,5 @@ depends:
type: build
config:
commands:
- - "mkdir -p /buildstream/install"
- - "echo 'Hi' > /buildstream/install/hi"
+ - "mkdir -p %{install-root}"
+ - "echo 'Hi' > %{install-root}/hi"
diff --git a/tests/integration/script.py b/tests/integration/script.py
index 5ecc51973..88226c0b7 100644
--- a/tests/integration/script.py
+++ b/tests/integration/script.py
@@ -39,8 +39,8 @@ def test_script(cli, tmpdir, datafiles):
create_script_element(element_name, element_path,
config={
'commands': [
- "mkdir -p /buildstream/install",
- "echo 'Hi' > /buildstream/install/test"
+ "mkdir -p %{install-root}",
+ "echo 'Hi' > %{install-root}/test"
],
})
@@ -69,9 +69,9 @@ def test_script_root(cli, tmpdir, datafiles):
# want to check the default here
# 'root-read-only': False,
'commands': [
- "mkdir -p /buildstream/install",
+ "mkdir -p %{install-root}",
"echo 'I can write to root' > /test",
- "cp /test /buildstream/install"
+ "cp /test %{install-root}"
],
})
@@ -97,9 +97,9 @@ def test_script_no_root(cli, tmpdir, datafiles):
config={
'root-read-only': True,
'commands': [
- "mkdir -p /buildstream/install",
+ "mkdir -p %{install-root}",
"echo 'I can not write to root' > /test",
- "cp /test /buildstream/install"
+ "cp /test %{install-root}"
],
})
diff --git a/tests/variables/variables.py b/tests/variables/variables.py
index b16511ad6..944d19818 100644
--- a/tests/variables/variables.py
+++ b/tests/variables/variables.py
@@ -43,16 +43,16 @@ def assert_command(datafiles, tmpdir, target, command, expected):
# Test proper loading of some default commands from plugins #
###############################################################
@pytest.mark.parametrize("target,command,expected", [
- ('autotools.bst', 'install-commands', "make -j1 DESTDIR=\"/buildstream/install\" install"),
+ ('autotools.bst', 'install-commands', "make -j1 DESTDIR=\"/buildstream-install\" install"),
('cmake.bst', 'configure-commands',
"cmake -B_builddir -H. -DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
"-DCMAKE_INSTALL_LIBDIR=lib"),
('distutils.bst', 'install-commands',
"python3 setup.py install --prefix \"/usr\" \\\n" +
- "--root \"/buildstream/install\""),
- ('makemaker.bst', 'configure-commands', "perl Makefile.PL PREFIX=/buildstream/install/usr"),
- ('modulebuild.bst', 'configure-commands', "perl Build.PL --prefix \"/buildstream/install/usr\""),
- ('qmake.bst', 'install-commands', "make -j1 INSTALL_ROOT=\"/buildstream/install\" install"),
+ "--root \"/buildstream-install\""),
+ ('makemaker.bst', 'configure-commands', "perl Makefile.PL PREFIX=/buildstream-install/usr"),
+ ('modulebuild.bst', 'configure-commands', "perl Build.PL --prefix \"/buildstream-install/usr\""),
+ ('qmake.bst', 'install-commands', "make -j1 INSTALL_ROOT=\"/buildstream-install\" install"),
])
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'defaults'))
def test_defaults(datafiles, tmpdir, target, command, expected):