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:
		@@ -75,7 +75,7 @@ class Build:
 | 
				
			|||||||
        if args.cmd != 'build':
 | 
					        if args.cmd != 'build':
 | 
				
			||||||
            return False
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ctx = create_global_context()
 | 
					        ctx = create_global_context(args)
 | 
				
			||||||
        ctx.config = Config(args.config, args.target, args.task)
 | 
					        ctx.config = Config(args.config, args.target, args.task)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        macro = Macro()
 | 
					        macro = Macro()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,12 +50,12 @@ except ImportError:
 | 
				
			|||||||
__context__ = None
 | 
					__context__ = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def create_global_context():
 | 
					def create_global_context(args):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
        Creates global context as singleton.
 | 
					        Creates global context as singleton.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    global __context__
 | 
					    global __context__
 | 
				
			||||||
    __context__ = Context()
 | 
					    __context__ = Context(args)
 | 
				
			||||||
    return __context__
 | 
					    return __context__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,12 +70,13 @@ class Context:
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
        Implements the kas build 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_work_dir = os.environ.get('KAS_WORK_DIR', os.getcwd())
 | 
				
			||||||
        self.__kas_repo_ref_dir = os.environ.get('KAS_REPO_REF_DIR', None)
 | 
					        self.__kas_repo_ref_dir = os.environ.get('KAS_REPO_REF_DIR', None)
 | 
				
			||||||
        self.setup_initial_environ()
 | 
					        self.setup_initial_environ()
 | 
				
			||||||
        self.keep_config = False
 | 
					        self.keep_config = False
 | 
				
			||||||
        self.config = None
 | 
					        self.config = None
 | 
				
			||||||
 | 
					        self.args = args
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup_initial_environ(self):
 | 
					    def setup_initial_environ(self):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,7 +71,7 @@ class Shell:
 | 
				
			|||||||
        if args.cmd != 'shell':
 | 
					        if args.cmd != 'shell':
 | 
				
			||||||
            return False
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ctx = create_global_context()
 | 
					        ctx = create_global_context(args)
 | 
				
			||||||
        ctx.config = Config(args.config, None, None)
 | 
					        ctx.config = Config(args.config, None, None)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        macro = Macro()
 | 
					        macro = Macro()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user