From c8efbe23d049578fd17e6e08f8b96bdfbe98189d Mon Sep 17 00:00:00 2001 From: Jim MacArthur Date: Fri, 17 Aug 2018 10:11:14 +0100 Subject: element.py: Switch to SandboxRemote if config option is set --- buildstream/element.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/buildstream/element.py b/buildstream/element.py index cd56eff07..9dee245f3 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2123,7 +2123,24 @@ class Element(Plugin): project = self._get_project() platform = Platform.get_platform() - if directory is not None and os.path.exists(directory): + if self.__remote_execution_url and self.BST_VIRTUAL_DIRECTORY: + if not self.__artifacts.has_push_remotes(element=self): + # Give an early warning if remote execution will not work + raise ElementError("Artifact {} is configured to use remote execution but has no push remotes. " + .format(self.name) + + "The remote artifact server(s) may not be correctly configured or contactable.") + + self.info("Using a remote 'sandbox' for artifact {}".format(self.name)) + sandbox = SandboxRemote(context, project, + directory, + stdout=stdout, + stderr=stderr, + config=config, + server_url=self.__remote_execution_url, + allow_real_directory=False) + yield sandbox + elif directory is not None and os.path.exists(directory): + self.info("Using a local sandbox for artifact {}".format(self.name)) sandbox = platform.create_sandbox(context, project, directory, stdout=stdout, -- cgit v1.2.1