mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 04:24:26 +01:00
cli_function: extra argument for per-script configs
This commit is contained in:
@@ -130,10 +130,11 @@ class CliFunction:
|
|||||||
def _do_main(self, kwargs):
|
def _do_main(self, kwargs):
|
||||||
return self.main(**self._get_args(kwargs))
|
return self.main(**self._get_args(kwargs))
|
||||||
|
|
||||||
def __init__(self, config_file=None, description=None):
|
def __init__(self, config_file=None, description=None, extra_config_params=None):
|
||||||
self._arguments = collections.OrderedDict()
|
self._arguments = collections.OrderedDict()
|
||||||
self._config_file = config_file
|
self._config_file = config_file
|
||||||
self._description = description
|
self._description = description
|
||||||
|
self.extra_config_params = extra_config_params
|
||||||
if self._config_file is not None:
|
if self._config_file is not None:
|
||||||
self.add_argument(
|
self.add_argument(
|
||||||
'--config-file',
|
'--config-file',
|
||||||
@@ -155,7 +156,10 @@ class CliFunction:
|
|||||||
if config_file is not None and os.path.exists(config_file):
|
if config_file is not None and os.path.exists(config_file):
|
||||||
config_configs = {}
|
config_configs = {}
|
||||||
config = imp.load_source('config', config_file)
|
config = imp.load_source('config', config_file)
|
||||||
config.set_args(config_configs)
|
if self.extra_config_params is None:
|
||||||
|
config.set_args(config_configs)
|
||||||
|
else:
|
||||||
|
config.set_args(config_configs, self.extra_config_params)
|
||||||
for key in config_configs:
|
for key in config_configs:
|
||||||
if key not in self._arguments:
|
if key not in self._arguments:
|
||||||
raise Exception('Unknown key in config file: ' + key)
|
raise Exception('Unknown key in config file: ' + key)
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class LkmcCliFunction(cli_function.CliFunction):
|
|||||||
:param defaults: override the default value of an argument
|
:param defaults: override the default value of an argument
|
||||||
'''
|
'''
|
||||||
kwargs['config_file'] = consts['config_file']
|
kwargs['config_file'] = consts['config_file']
|
||||||
|
kwargs['extra_config_params'] = os.path.basename(inspect.getfile(self.__class__))
|
||||||
if defaults is None:
|
if defaults is None:
|
||||||
defaults = {}
|
defaults = {}
|
||||||
self._defaults = defaults
|
self._defaults = defaults
|
||||||
@@ -294,7 +295,7 @@ Use gem5 instead of QEMU. Shortcut for `--emulator gem5`.
|
|||||||
'''
|
'''
|
||||||
For Python code calls, print the CLI equivalent of the call.
|
For Python code calls, print the CLI equivalent of the call.
|
||||||
'''
|
'''
|
||||||
print_cmd = ['./' + inspect.getfile(self.__class__), LF]
|
print_cmd = ['./' + self.extra_config_params, LF]
|
||||||
for line in self.get_cli(**kwargs):
|
for line in self.get_cli(**kwargs):
|
||||||
print_cmd.extend(line)
|
print_cmd.extend(line)
|
||||||
print_cmd.append(LF)
|
print_cmd.append(LF)
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
def set_args(args):
|
def set_args(args, script_name):
|
||||||
args['arch'] = 'aarch64'
|
args['arch'] = 'aarch64'
|
||||||
args['gem5'] = True
|
args['gem5'] = True
|
||||||
|
if script_name == 'build-gem5':
|
||||||
|
# This argument is defined only for ./build-gem5.
|
||||||
|
args['extra_scons_args'] = ['ADSF=qwer']
|
||||||
|
|||||||
Reference in New Issue
Block a user