diff --git a/kas/build.py b/kas/build.py index d0b5155..bb9f430 100644 --- a/kas/build.py +++ b/kas/build.py @@ -25,6 +25,7 @@ import os from .context import create_global_context +from .config import Config from .libkas import find_program, run_cmd, kasplugin from .libcmds import (Macro, Command, SetupDir, CleanupSSHAgent, SetupSSHAgent, SetupEnviron, SetupRepos, @@ -71,7 +72,9 @@ class Build: if args.cmd != 'build': return False - ctx = create_global_context(args.config, args.target, args.task) + ctx = create_global_context() + ctx.config = Config(args.config, args.target, args.task) + ctx.config.set_context(ctx) macro = Macro() diff --git a/kas/context.py b/kas/context.py index 418e756..89fa3ed 100644 --- a/kas/context.py +++ b/kas/context.py @@ -25,7 +25,6 @@ import os import logging -from .config import Config try: import distro @@ -48,16 +47,17 @@ except ImportError: # pylint: disable=deprecated-method return platform.dist()[0] + __context__ = None -def create_global_context(config_filename, bitbake_target, bitbake_task): +def create_global_context(): """ Create global context as singleton. """ # pylint: disable=global-statement global __context__ - __context__ = Context(config_filename, bitbake_target, bitbake_task) + __context__ = Context() return __context__ @@ -73,15 +73,12 @@ class Context: """ Implements the kas build context. """ - def __init__(self, config_filename, bitbake_target, bitbake_task): + def __init__(self): self.__kas_work_dir = os.environ.get('KAS_WORK_DIR', os.getcwd()) self.__kas_repo_ref_dir = os.environ.get('KAS_REPO_REF_DIR', None) - self.setup_initial_environ() self.keep_config = False - - self.config = Config(config_filename, bitbake_target, bitbake_task) - self.config.set_context(self) + self.config = None def setup_initial_environ(self): """ diff --git a/kas/shell.py b/kas/shell.py index 84261f8..b204871 100644 --- a/kas/shell.py +++ b/kas/shell.py @@ -28,6 +28,7 @@ import subprocess import os from .libkas import kasplugin from .context import create_global_context +from .config import Config from .libcmds import (Macro, Command, SetupDir, SetupEnviron, WriteBBConfig, SetupHome, ReposApplyPatches, CleanupSSHAgent, SetupSSHAgent, SetupRepos) @@ -75,7 +76,9 @@ class Shell: if args.cmd != 'shell': return False - ctx = create_global_context(args.config, args.target, None) + ctx = create_global_context() + ctx.config = Config(args.config, args.target, None) + ctx.config.set_context(ctx) macro = Macro()