summaryrefslogtreecommitdiff
path: root/buildstream/_platform
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2017-10-31 11:25:16 +0000
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2017-11-01 10:01:40 +0000
commitd64ea749379100f61ed2c3342bcda4d8e5a46d71 (patch)
tree3e12bf841da3b2056aece86b03fa8611a1f79dde /buildstream/_platform
parentde35793125af66650568316c21b4a878b00ecb23 (diff)
downloadbuildstream-d64ea749379100f61ed2c3342bcda4d8e5a46d71.tar.gz
Make the platform object a singleton
Diffstat (limited to 'buildstream/_platform')
-rw-r--r--buildstream/_platform/platform.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py
index 920fddbde..d4b5f89a3 100644
--- a/buildstream/_platform/platform.py
+++ b/buildstream/_platform/platform.py
@@ -27,6 +27,7 @@ from .. import PlatformError, ProgramNotFoundError, ImplError
class Platform():
+ _instance = None
# Platform()
#
@@ -42,8 +43,7 @@ class Platform():
self.project = project
@classmethod
- def get_platform(cls, *args, **kwargs):
-
+ def _create_instance(cls, *args, **kwargs):
if sys.platform.startswith('linux'):
backend = 'linux'
else:
@@ -62,7 +62,13 @@ class Platform():
else:
raise PlatformError("No such platform: '{}'".format(backend))
- return PlatformImpl(*args, **kwargs)
+ cls._instance = PlatformImpl(*args, **kwargs)
+
+ @classmethod
+ def get_platform(cls, *args, **kwargs):
+ if not cls._instance:
+ raise PlatformError("Platform needs to be initialized first")
+ return cls._instance
##################################################################
# Platform properties #