Loading buildstream/_exceptions.py +3 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,9 @@ class LoadErrorReason(Enum): # A recursive variable has been encountered RECURSIVE_VARIABLE = 22 # An attempt so set the value of a protected variable PROTECTED_VARIABLE_REDEFINED = 23 # LoadError # Loading buildstream/data/projectconfig.yaml +0 −15 Original line number Diff line number Diff line Loading @@ -20,21 +20,7 @@ fail-on-overlap: False # Variable Configuration # variables: # Maximum number of parallel build processes within a given # build, support for this is conditional on the element type # and the build system used (any element using 'make' can # implement this). # # 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" exec_prefix: "%{prefix}" bindir: "%{exec_prefix}/bin" Loading Loading @@ -93,7 +79,6 @@ variables: find "%{install-root}" -name '*.pyc' -exec \ dd if=/dev/zero of={} bs=1 count=4 seek=4 conv=notrunc ';' # Base sandbox environment, can be overridden by plugins environment: PATH: /usr/bin:/bin:/usr/sbin:/sbin Loading buildstream/element.py +9 −1 Original line number Diff line number Diff line Loading @@ -2166,7 +2166,8 @@ class Element(Plugin): # substituting command strings to be run in the sandbox # def __extract_variables(self, meta): default_vars = _yaml.node_get(self.__defaults, Mapping, 'variables', default_value={}) default_vars = _yaml.node_get(self.__defaults, Mapping, 'variables', default_value={}) project = self._get_project() if self.__is_junction: Loading @@ -2179,6 +2180,13 @@ class Element(Plugin): _yaml.composite(variables, meta.variables) _yaml.node_final_assertions(variables) for var in ('project-name', 'element-name', 'max-jobs'): provenance = _yaml.node_get_provenance(variables, var) if provenance and provenance.filename != '': raise LoadError(LoadErrorReason.PROTECTED_VARIABLE_REDEFINED, "{}: invalid redefinition of protected variable '{}'" .format(provenance, var)) return variables # This will resolve the final configuration to be handed Loading doc/source/format_declaring.rst +22 −0 Original line number Diff line number Diff line Loading @@ -420,3 +420,25 @@ dependency and that all referenced variables are declared, the following is fine install-commands: - | %{make-install} RELEASE_TEXT="%{release-text}" Variables declared by BuildStream ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BuildStream declares a set of :ref:`builtin <project_builtin_defaults>` variables that may be overridden. In addition, the following read-only variables are also dynamically declared by BuildStream: * ``element-name`` The name of the element being processed (e.g base/alpine.bst). * ``project-name`` The name of project where BuildStream is being used. * ``max-jobs`` Maximum number of parallel build processes within a given build, support for this is conditional on the element type and the build system used (any element using 'make' can implement this). tests/integration/manual.py +5 −11 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ strip @pytest.mark.datafiles(DATA_DIR) def test_manual_element_noparallel(cli, tmpdir, datafiles): def test_manual_element_environment(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) checkout = os.path.join(cli.directory, 'checkout') element_path = os.path.join(project, 'elements') Loading @@ -72,15 +72,11 @@ def test_manual_element_noparallel(cli, tmpdir, datafiles): create_manual_element(element_name, element_path, { 'install-commands': [ "echo $MAKEFLAGS >> test", "echo $V >> test", "cp test %{install-root}" ] }, { 'max-jobs': 2, 'notparallel': True }, { 'MAKEFLAGS': '-j%{max-jobs} -Wall', 'V': 2 }) Loading @@ -93,13 +89,11 @@ def test_manual_element_noparallel(cli, tmpdir, datafiles): with open(os.path.join(checkout, 'test')) as f: text = f.read() assert text == """-j1 -Wall 2 """ assert text == "2\n" @pytest.mark.datafiles(DATA_DIR) def test_manual_element_environment(cli, tmpdir, datafiles): def test_manual_element_noparallel(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) checkout = os.path.join(cli.directory, 'checkout') element_path = os.path.join(project, 'elements') Loading @@ -112,7 +106,7 @@ def test_manual_element_environment(cli, tmpdir, datafiles): "cp test %{install-root}" ] }, { 'max-jobs': 2 'notparallel': True }, { 'MAKEFLAGS': '-j%{max-jobs} -Wall', 'V': 2 Loading @@ -127,6 +121,6 @@ def test_manual_element_environment(cli, tmpdir, datafiles): with open(os.path.join(checkout, 'test')) as f: text = f.read() assert text == """-j2 -Wall assert text == """-j1 -Wall 2 """ Loading
buildstream/_exceptions.py +3 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,9 @@ class LoadErrorReason(Enum): # A recursive variable has been encountered RECURSIVE_VARIABLE = 22 # An attempt so set the value of a protected variable PROTECTED_VARIABLE_REDEFINED = 23 # LoadError # Loading
buildstream/data/projectconfig.yaml +0 −15 Original line number Diff line number Diff line Loading @@ -20,21 +20,7 @@ fail-on-overlap: False # Variable Configuration # variables: # Maximum number of parallel build processes within a given # build, support for this is conditional on the element type # and the build system used (any element using 'make' can # implement this). # # 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" exec_prefix: "%{prefix}" bindir: "%{exec_prefix}/bin" Loading Loading @@ -93,7 +79,6 @@ variables: find "%{install-root}" -name '*.pyc' -exec \ dd if=/dev/zero of={} bs=1 count=4 seek=4 conv=notrunc ';' # Base sandbox environment, can be overridden by plugins environment: PATH: /usr/bin:/bin:/usr/sbin:/sbin Loading
buildstream/element.py +9 −1 Original line number Diff line number Diff line Loading @@ -2166,7 +2166,8 @@ class Element(Plugin): # substituting command strings to be run in the sandbox # def __extract_variables(self, meta): default_vars = _yaml.node_get(self.__defaults, Mapping, 'variables', default_value={}) default_vars = _yaml.node_get(self.__defaults, Mapping, 'variables', default_value={}) project = self._get_project() if self.__is_junction: Loading @@ -2179,6 +2180,13 @@ class Element(Plugin): _yaml.composite(variables, meta.variables) _yaml.node_final_assertions(variables) for var in ('project-name', 'element-name', 'max-jobs'): provenance = _yaml.node_get_provenance(variables, var) if provenance and provenance.filename != '': raise LoadError(LoadErrorReason.PROTECTED_VARIABLE_REDEFINED, "{}: invalid redefinition of protected variable '{}'" .format(provenance, var)) return variables # This will resolve the final configuration to be handed Loading
doc/source/format_declaring.rst +22 −0 Original line number Diff line number Diff line Loading @@ -420,3 +420,25 @@ dependency and that all referenced variables are declared, the following is fine install-commands: - | %{make-install} RELEASE_TEXT="%{release-text}" Variables declared by BuildStream ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BuildStream declares a set of :ref:`builtin <project_builtin_defaults>` variables that may be overridden. In addition, the following read-only variables are also dynamically declared by BuildStream: * ``element-name`` The name of the element being processed (e.g base/alpine.bst). * ``project-name`` The name of project where BuildStream is being used. * ``max-jobs`` Maximum number of parallel build processes within a given build, support for this is conditional on the element type and the build system used (any element using 'make' can implement this).
tests/integration/manual.py +5 −11 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ strip @pytest.mark.datafiles(DATA_DIR) def test_manual_element_noparallel(cli, tmpdir, datafiles): def test_manual_element_environment(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) checkout = os.path.join(cli.directory, 'checkout') element_path = os.path.join(project, 'elements') Loading @@ -72,15 +72,11 @@ def test_manual_element_noparallel(cli, tmpdir, datafiles): create_manual_element(element_name, element_path, { 'install-commands': [ "echo $MAKEFLAGS >> test", "echo $V >> test", "cp test %{install-root}" ] }, { 'max-jobs': 2, 'notparallel': True }, { 'MAKEFLAGS': '-j%{max-jobs} -Wall', 'V': 2 }) Loading @@ -93,13 +89,11 @@ def test_manual_element_noparallel(cli, tmpdir, datafiles): with open(os.path.join(checkout, 'test')) as f: text = f.read() assert text == """-j1 -Wall 2 """ assert text == "2\n" @pytest.mark.datafiles(DATA_DIR) def test_manual_element_environment(cli, tmpdir, datafiles): def test_manual_element_noparallel(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) checkout = os.path.join(cli.directory, 'checkout') element_path = os.path.join(project, 'elements') Loading @@ -112,7 +106,7 @@ def test_manual_element_environment(cli, tmpdir, datafiles): "cp test %{install-root}" ] }, { 'max-jobs': 2 'notparallel': True }, { 'MAKEFLAGS': '-j%{max-jobs} -Wall', 'V': 2 Loading @@ -127,6 +121,6 @@ def test_manual_element_environment(cli, tmpdir, datafiles): with open(os.path.join(checkout, 'test')) as f: text = f.read() assert text == """-j2 -Wall assert text == """-j1 -Wall 2 """