diff options
author | Jürg Billeter <j@bitron.ch> | 2018-09-26 10:08:25 +0100 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-04-14 16:25:19 +0900 |
commit | 1e9f7e45d8c5ef4a8c5db131e69e701c8cb6eb82 (patch) | |
tree | 0273bc43a090448faa30275552fc09803f8ffdca | |
parent | 19f0c1ff4c4a8f53a4c07f48745381d223969d31 (diff) | |
download | buildstream-1e9f7e45d8c5ef4a8c5db131e69e701c8cb6eb82.tar.gz |
Use lazy platform instantiation
Now that the platform is independent of the context, explicit
instantiation is no longer required. This avoids issues with platform
instances used across test cases with mismatching context.
-rw-r--r-- | buildstream/_frontend/app.py | 2 | ||||
-rw-r--r-- | buildstream/_platform/platform.py | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index a07fe9860..5d6dfedc9 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -199,7 +199,7 @@ class App(): if option_value is not None: setattr(self.context, context_attr, option_value) try: - Platform.create_instance() + Platform.get_platform() except BstError as e: self._error_exit(e, "Error instantiating platform") diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py index bbd2e65ab..b37964986 100644 --- a/buildstream/_platform/platform.py +++ b/buildstream/_platform/platform.py @@ -35,7 +35,7 @@ class Platform(): pass @classmethod - def create_instance(cls, *args, **kwargs): + def _create_instance(cls): if sys.platform.startswith('linux'): backend = 'linux' else: @@ -54,12 +54,12 @@ class Platform(): else: raise PlatformError("No such platform: '{}'".format(backend)) - cls._instance = PlatformImpl(*args, **kwargs) + cls._instance = PlatformImpl() @classmethod def get_platform(cls): if not cls._instance: - raise PlatformError("Platform needs to be initialized first") + cls._create_instance() return cls._instance ################################################################## |