context: Store arguments in global context

This makes it much simpler to implement new command line arguments.

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Paul Barker 2020-06-15 22:03:29 +02:00 committed by Jan Kiszka
parent f0094af79f
commit 90598db3c8
3 changed files with 6 additions and 5 deletions

View File

@ -75,7 +75,7 @@ class Build:
if args.cmd != 'build':
return False
ctx = create_global_context()
ctx = create_global_context(args)
ctx.config = Config(args.config, args.target, args.task)
macro = Macro()

View File

@ -50,12 +50,12 @@ except ImportError:
__context__ = None
def create_global_context():
def create_global_context(args):
"""
Creates global context as singleton.
"""
global __context__
__context__ = Context()
__context__ = Context(args)
return __context__
@ -70,12 +70,13 @@ class Context:
"""
Implements the kas build context.
"""
def __init__(self):
def __init__(self, args):
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 = None
self.args = args
def setup_initial_environ(self):
"""

View File

@ -71,7 +71,7 @@ class Shell:
if args.cmd != 'shell':
return False
ctx = create_global_context()
ctx = create_global_context(args)
ctx.config = Config(args.config, None, None)
macro = Macro()