This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/digest-environment in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 1d1fafe49aa78120726916d6969a76862b540523 Author: Jürg Billeter <j...@bitron.ch> AuthorDate: Fri Jul 25 15:33:05 2025 +0200 element.py: Improve logging of build environment Elements can configure additional environment variables in `configure_sandbox()`, which is used by `BuildElement` to support `digest-environment`. Change the build environment logging to log the complete environment configured in the sandbox. --- src/buildstream/element.py | 10 +++++----- src/buildstream/sandbox/sandbox.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/buildstream/element.py b/src/buildstream/element.py index df469c139..ee05ce423 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -1672,11 +1672,6 @@ class Element(Plugin): # Assert call ordering assert not self._cached_success() - # Print the environment at the beginning of the log file. - env_dump = _yaml.roundtrip_dump_string(self.get_environment()) - - self.log("Build environment for element {}".format(self.name), detail=env_dump) - context = self._get_context() with self._output_file() as output_file: @@ -1702,6 +1697,11 @@ class Element(Plugin): # Step 1 - Configure self.__configure_sandbox(sandbox) + + # Print the environment at the beginning of the log file. + env_dump = _yaml.roundtrip_dump_string(sandbox._get_environment()) + self.log("Build environment for element {}".format(self.name), detail=env_dump) + # Step 2 - Stage self.__stage(sandbox) try: diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py index 29a3e31bf..821f14254 100644 --- a/src/buildstream/sandbox/sandbox.py +++ b/src/buildstream/sandbox/sandbox.py @@ -432,7 +432,7 @@ class Sandbox: def _get_environment(self, *, cwd=None, env=None): cwd = self._get_work_directory(cwd=cwd) if env is None: - env = self.__env + env = self.__env or {} # Naive getcwd implementations can break when bind-mounts to different # paths on the same filesystem are present. Letting the command know