summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-06-18 17:52:52 +0100
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-06-26 09:34:16 +0100
commit516bfb3c24e675b553c1dc8128ef9df89c5bc5e7 (patch)
treebfd3f40b970089a47b79f0392b9597cffdfc10da
parentadc03c65025a701cf5a84200996fccdb1c63af23 (diff)
downloadbuildstream-516bfb3c24e675b553c1dc8128ef9df89c5bc5e7.tar.gz
_sandboxbwrap: Create Command object, put it into local CAS and push it
-rw-r--r--buildstream/sandbox/_sandboxbwrap.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index 79d62b49c..137d024be 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -34,6 +34,7 @@ from ._mount import MountMap
from . import Sandbox, SandboxFlags
from ..storage._filebaseddirectory import FileBasedDirectory
from ..storage._casbaseddirectory import CasBasedDirectory
+from google.devtools.remoteexecution.v1test import remote_execution_pb2, remote_execution_pb2_grpc
from .._artifactcache.cascache import CASCache
# SandboxBwrap()
@@ -89,6 +90,22 @@ class SandboxBwrap(Sandbox):
if isinstance(command, str):
command = [command]
+ # Now transmit the command to execute
+ remote_command = remote_execution_pb2.Command(arguments=command)
+ # (Ignore environment for now)
+ # Serialise this into the cascache...
+ digest = cascache.add_object(buffer=remote_command.SerializeToString())
+
+ command_ref = 'worker-command/{}'.format(digest.hash)
+ cascache.set_ref(command_ref, digest)
+ print("Pushing key from local to remote: {}".format(command_ref))
+
+ # TODO: push_key_only isn't really meant to work with refs to Command
+ # objects - it will try and find the dependencies of it; there are none,
+ # but it expects to find a directory. We may need to pass a flag to tell
+ # it not to look for any.
+ cascache.push_key_only(command_ref, self._get_project())
+
# Create the mount map, this will tell us where
# each mount point needs to be mounted from and to
mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)