diff options
author | Phil Dawson <phil.dawson@codethink.co.uk> | 2018-12-12 11:40:57 +0000 |
---|---|---|
committer | Phil Dawson <phil.dawson@codethink.co.uk> | 2018-12-12 14:43:40 +0000 |
commit | c2efeba064f30c9bdbb4e370b1911dc50a78ff9b (patch) | |
tree | 1a7e4db7a120debc764c79546682917d2f413a40 /buildstream/_stream.py | |
parent | 733aab53ce07c0b36a460eb55b5eb629197b4faa (diff) | |
download | buildstream-c2efeba064f30c9bdbb4e370b1911dc50a78ff9b.tar.gz |
Add option to source-checkout command to generate build scripts
Diffstat (limited to 'buildstream/_stream.py')
-rw-r--r-- | buildstream/_stream.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/buildstream/_stream.py b/buildstream/_stream.py index 03e189714..059b7f653 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -453,7 +453,8 @@ class Stream(): deps='none', fetch=False, except_targets=(), - tar=False): + tar=False, + include_build_scripts=False): self._check_location_writable(location, force=force, tar=tar) @@ -469,7 +470,8 @@ class Stream(): # Stage all sources determined by scope try: - self._source_checkout(elements, location, force, deps, fetch, tar) + self._source_checkout(elements, location, force, deps, + fetch, tar, include_build_scripts) except BstError as e: raise StreamError("Error while writing sources" ": '{}'".format(e), detail=e.detail, reason=e.reason) from e @@ -807,7 +809,7 @@ class Stream(): ] self._write_element_sources(os.path.join(tempdir, "source"), elements) - self._write_build_script(tempdir, elements) + self._write_master_build_script(tempdir, elements) self._collect_sources(tempdir, tar_location, target.normal_name, compression) @@ -1197,7 +1199,8 @@ class Stream(): force=False, deps='none', fetch=False, - tar=False): + tar=False, + include_build_scripts=False): location = os.path.abspath(location) location_parent = os.path.abspath(os.path.join(location, "..")) @@ -1207,6 +1210,8 @@ class Stream(): temp_source_dir = tempfile.TemporaryDirectory(dir=location_parent) try: self._write_element_sources(temp_source_dir.name, elements) + if include_build_scripts: + self._write_build_scripts(temp_source_dir.name, elements) if tar: self._create_tarball(temp_source_dir.name, location) else: @@ -1266,8 +1271,14 @@ class Stream(): except OSError as e: raise StreamError("Failed to create tar archive: {}".format(e)) from e + # Write all the build_scripts for elements in the directory location + def _write_build_scripts(self, location, elements): + for element in elements: + self._write_element_script(location, element) + self._write_master_build_script(location, elements) + # Write a master build script to the sandbox - def _write_build_script(self, directory, elements): + def _write_master_build_script(self, directory, elements): module_string = "" for element in elements: |