Move Config creation out of Context constructor
This helps to avoid circular dependencies. It also allows the Config constructor to make use of the global context. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
594fa97692
commit
f5cea27269
@ -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()
|
||||
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user