diff --git a/build-buildroot b/build-buildroot index c84cb2b..d12daa0 100755 --- a/build-buildroot +++ b/build-buildroot @@ -61,16 +61,10 @@ Don't add our overlay which contains all files we build without going through Bu This prevents us from overwriting certain Buildroot files. Remember however that you must still rebuild the Buildroot package that provides those files to actually put the Buildroot files on the root filesystem. -''' - ) - self.add_argument( - 'extra-make-args', default=[], nargs='*', - help='''\ -Extra arguments to be passed to the Buildroot make, -usually extra Buildroot targets. ''' ) self._add_argument('--force-rebuild') + self._add_argument('extra_make_args') def build(self): build_dir = self.get_build_dir() diff --git a/build-gem5 b/build-gem5 index 6326fce..c3dc001 100755 --- a/build-gem5 +++ b/build-gem5 @@ -33,11 +33,7 @@ Build and run all the gem5 unit tests instead of the gem5 executable. https://github.com/cirosantilli/linux-kernel-module-cheat-regression#gem5-unit-tests ''' ) - self.add_argument( - 'extra_scons_args', - metavar='extra-scons-args', - nargs='*', - ) + self._add_argument('extra_make_args') def build(self): build_dir = self.get_build_dir() @@ -141,7 +137,7 @@ https://github.com/cirosantilli/linux-kernel-module-cheat-regression#gem5-unit-t #'SLICC_HTML=True', LF, ] + self.sh.add_newlines(targets) + - self.sh.add_newlines(self.env['extra_scons_args']) + self.sh.add_newlines(self.env['extra_make_args']) ), cwd=self.env['gem5_source_dir'], extra_env=extra_env, diff --git a/build-linux b/build-linux index 8aa5d6a..a851097 100755 --- a/build-linux +++ b/build-linux @@ -75,13 +75,8 @@ so you might want to --clean the build first. Run `make modules_install` after `make`. ''' ) - self.add_argument( - 'extra_make_args', - default=[], - metavar='extra-make-args', - nargs='*' - ) self._add_argument('--force-rebuild') + self._add_argument('extra_make_args') def build(self): build_dir = self.get_build_dir() diff --git a/build-qemu b/build-qemu index 8b814ba..054a052 100755 --- a/build-qemu +++ b/build-qemu @@ -9,12 +9,8 @@ class Main(common.BuildCliFunction): def __init__(self): super().__init__() self._add_argument('--configure') - self.add_argument( - 'extra_config_args', - default=[], - metavar='extra-config-args', - nargs='*' - ) + self.add_argument('--extra-config-args') + self._add_argument('extra_make_args') def build(self): build_dir = self.get_build_dir() @@ -41,7 +37,7 @@ class Main(common.BuildCliFunction): '--enable-sdl', LF, ] + build_type_cmd + - self.sh.add_newlines(self.env['extra_config_args']), + self.sh.shlex_split(self.env['extra_config_args']), extra_paths=[self.env['ccache_dir']], cwd=build_dir ) @@ -52,7 +48,8 @@ class Main(common.BuildCliFunction): '-j', str(self.env['nproc']), LF, ] + - verbose + verbose + + self.sh.add_newlines(self.env['extra_make_args']) ), cwd=build_dir, extra_paths=[self.env['ccache_dir']], diff --git a/common.py b/common.py index 0d2c56a..0d92586 100644 --- a/common.py +++ b/common.py @@ -1613,33 +1613,46 @@ class BuildCliFunction(LkmcCliFunction): 'default': '', 'help': '''\ Pass the given compiler flags to all languages (C, C++, Fortran, etc.) +''', + }, + '--configure': { + 'default': True, + 'help': '''\ +Also run the configuration step during build. ''', }, '--force-rebuild': { 'default': False, "help": '''\ Force rebuild even if sources didn't change. -''', - }, - '--configure': { - 'default': True, - "help": '''\ -Also run the configuration step during build. ''', }, '--optimization-level': { 'default': '0', - 'help': ''' + 'help': '''\ Use the given GCC -O optimization level. For some scripts, there are hard technical challenges why it cannot be implemented, e.g.: https://cirosantilli.com/linux-kernel-module-cheat#kernel-o0 and for others such as gem5 have their custom mechanism: https://cirosantilli.com/linux-kernel-module-cheat#gem5-debug-build ''', - } + }, + 'extra_make_args': { + 'default': [], + 'help': '''\ +Extra arguments to pass to the Make command or analogous final build command, +after configure, e.g. SCons. Usually contains specific targets or other build flags. +''', + 'metavar': 'extra-make-args', + 'nargs': '*', + }, } def _add_argument(self, argument_name): + ''' + Enable build argument with a fixed name to provide an uniform CLI API + across different builds. + ''' self.add_argument( argument_name, **self._build_arguments[argument_name]