Files
linux-kernel-module-cheat/build-crosstool-ng
Ciro Santilli 六四事件 法轮功 4b99e522dd common.run_cmd: assert result == 0 by default
2018-10-23 09:58:30 +01:00

80 lines
2.3 KiB
Python
Executable File

#!/usr/bin/env python3
import multiprocessing
import os
import common
class CrosstoolNgComponent(common.Component):
def do_build(self, args):
common.raise_no_x86(args.arch)
build_dir = self.get_build_dir(args)
nproc = multiprocessing.cpu_count()
defconfig_dest = os.path.join(common.crosstool_ng_util_dir, 'defconfig')
os.makedirs(common.crosstool_ng_util_dir, exist_ok=True)
os.makedirs(common.crosstool_ng_download_dir, exist_ok=True)
# Bootstrap out-ot-tree WONTFIX. I've tried.
# https://github.com/crosstool-ng/crosstool-ng/issues/1021
os.chdir(common.crosstool_ng_src_dir)
common.run_cmd(
[os.path.join(common.crosstool_ng_src_dir, 'bootstrap')],
)
os.chdir(common.crosstool_ng_util_dir)
common.run_cmd(
[
os.path.join(common.crosstool_ng_src_dir, 'configure'),
'--enable-local',
],
)
common.run_cmd(
[
'make',
'-j', str(nproc),
],
)
# Build the toolchain.
common.cp(
os.path.join(common.root_dir, 'crosstool_ng_config', args.arch),
defconfig_dest
)
common.write_configs(
common.crosstool_ng_defconfig,
[
'CT_PREFIX_DIR="{}"'.format(common.crosstool_ng_install_dir),
'CT_WORK_DIR="{}"'.format(build_dir),
'CT_LOCAL_TARBALLS_DIR="{}"'.format(common.crosstool_ng_download_dir),
]
)
common.run_cmd(
[
common.crosstool_ng_executable,
'defconfig',
],
)
os.unlink(defconfig_dest)
common.run_cmd(
[
common.crosstool_ng_executable,
'build',
'CT_JOBS={}'.format(str(nproc)),
],
out_file=os.path.join(build_dir, 'lkmc.log'),
delete_env=['LD_LIBRARY_PATH'],
extra_paths=[common.ccache_dir],
)
def get_argparse_args(self):
return {
'description': '''\
Build crosstool-NG with Newlib for bare metal compilation'
'''
}
def get_build_dir(self, args):
return common.crosstool_ng_build_dir
if __name__ == '__main__':
CrosstoolNgComponent().build()