Move build-buildroot linux configs to build-linux.

Needs a lot of testing, and need to cleanup readme, but seems to work.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-10-24 00:00:01 +00:00
parent a410100f3f
commit 21627ff9d8
11 changed files with 164 additions and 229 deletions

View File

@@ -7,6 +7,42 @@ import common
class LinuxComponent(common.Component):
def add_parser_arguments(self, parser):
parser.add_argument(
'--config', default=[], action='append',
help='''\
Add a single kernel config configs to the current build.
The `CONFIG_` prefix is added automatically. Sample values:
'FORTIFY_SOURCE=y', `KGDB=n`. Can be used multiple times to add multiple
configs. Takes precedence over any config files.
'''
)
parser.add_argument(
'--config-fragment', default=[], action='append',
help='''\
Also use the given kernel configuration fragment file.
Pass multiple times to use multiple fragment files.
'''
)
parser.add_argument(
'--custom-config-file',
help='''\
Ignore all default kernel configurations and use this file instead.
Still uses options explicitly passed with `--config` and
`--config-fragment` on top of it.
'''
)
parser.add_argument(
'--config-only', default=False, action='store_true',
help='''\
Configure the kernel, but don't build it.
'''
)
parser.add_argument(
'--initramfs', default=False, action='store_true',
)
parser.add_argument(
'--initrd', default=False, action='store_true',
)
parser.add_argument(
'extra_make_args',
default=[],
@@ -16,11 +52,9 @@ class LinuxComponent(common.Component):
def do_build(self, args):
build_dir = self.get_build_dir(args)
if args.initrd or args.initramfs:
raise Exception('just trolling, --initrd and --initramfs are broken for now')
os.makedirs(build_dir, exist_ok=True)
common.cp(
os.path.join(common.linux_config_dir, 'buildroot-{}'.format(args.arch)),
os.path.join(build_dir, '.config'),
)
tool = 'gcc'
gcc = common.get_toolchain_tool(tool)
prefix = gcc[:-len(tool)]
@@ -33,6 +67,8 @@ class LinuxComponent(common.Component):
else:
cc = gcc
common_make_args = [
'make',
'-j', str(args.nproc),
'ARCH={}'.format(common.linux_arch),
'CROSS_COMPILE={}'.format(prefix),
'CC={}'.format(cc),
@@ -42,41 +78,51 @@ class LinuxComponent(common.Component):
verbose = ['V=1']
else:
verbose = []
if args.custom_config_file is not None:
if not os.path.exists(args.custom_config_file):
raise Exception('config fragment file does not exist: {}'.format(args.custom_config_file))
base_config_file = args.custom_config_file
config_fragments = []
else:
base_config_file = os.path.join(common.linux_config_dir, 'buildroot-{}'.format(args.arch))
config_fragments = ['min', 'default']
for i, config_fragment in enumerate(config_fragments):
config_fragments[i] = os.path.join(common.linux_config_dir, config_fragment)
config_fragments.extend(args.config_fragment)
if args.config != []:
cli_config_fragment_path = os.path.join(build_dir, 'lkmc_cli_config_fragment')
cli_config_str = '\n'.join(map(lambda x: 'CONFIG_' + x, args.config))
with open(cli_config_fragment_path, 'w') as cli_config_fragment_cli:
cli_config_fragment_cli.write(cli_config_str)
config_fragments.append(cli_config_fragment_path)
common.cp(
base_config_file,
os.path.join(build_dir, '.config'),
)
common.run_cmd(
[
os.path.join(common.linux_src_dir, 'scripts', 'kconfig', 'merge_config.sh'),
'-m',
'-O', build_dir,
os.path.join(build_dir, '.config'),
os.path.join(common.linux_config_dir, 'min'),
os.path.join(common.linux_config_dir, 'default'),
],
] +
config_fragments
)
common.run_cmd(
(
[
'make',
'-j', str(args.nproc),
] +
common_make_args +
[
'olddefconfig',
]
['olddefconfig']
),
**common_args,
)
common.run_cmd(
(
[
'make',
'-j', str(args.nproc),
] +
common_make_args +
verbose +
args.extra_make_args
),
**common_args,
**common_args
)
if not args.config_only:
common.run_cmd(
(
common_make_args +
args.extra_make_args
),
**common_args
)
def get_argparse_args(self):
return {