summaryrefslogtreecommitdiff
path: root/src/buildstream/sandbox/_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildstream/sandbox/_config.py')
-rw-r--r--src/buildstream/sandbox/_config.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/buildstream/sandbox/_config.py b/src/buildstream/sandbox/_config.py
new file mode 100644
index 000000000..457f92b3c
--- /dev/null
+++ b/src/buildstream/sandbox/_config.py
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2018 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+# Authors:
+# Jim MacArthur <jim.macarthur@codethink.co.uk>
+
+
+# SandboxConfig
+#
+# A container for sandbox configuration data. We want the internals
+# of this to be opaque, hence putting it in its own private file.
+class SandboxConfig():
+ def __init__(self, build_uid, build_gid, build_os=None, build_arch=None):
+ self.build_uid = build_uid
+ self.build_gid = build_gid
+ self.build_os = build_os
+ self.build_arch = build_arch
+
+ # get_unique_key():
+ #
+ # This returns the SandboxConfig's contribution
+ # to an element's cache key.
+ #
+ # Returns:
+ # (dict): A dictionary to add to an element's cache key
+ #
+ def get_unique_key(self):
+
+ # Currently operating system and machine architecture
+ # are not configurable and we have no sandbox implementation
+ # which can conform to such configurations.
+ #
+ # However this should be the right place to support
+ # such configurations in the future.
+ #
+ unique_key = {
+ 'os': self.build_os,
+ 'arch': self.build_arch
+ }
+
+ # Avoid breaking cache key calculation with
+ # the addition of configurabuild build uid/gid
+ if self.build_uid != 0:
+ unique_key['build-uid'] = self.build_uid
+
+ if self.build_gid != 0:
+ unique_key['build-gid'] = self.build_gid
+
+ return unique_key