mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Fix https://github.com/cirosantilli/linux-kernel-module-cheat/issues/68 Copy source tree into build dir since ./ctng started failing out of tree. I give up.
81 lines
2.7 KiB
Python
Executable File
81 lines
2.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import common
|
|
from shell_helpers import LF
|
|
|
|
class Main(common.BuildCliFunction):
|
|
def __init__(self):
|
|
super().__init__(
|
|
description='''\
|
|
Build crosstool-NG with Newlib for bare metal compilation
|
|
''',
|
|
supported_archs=common.consts['crosstool_ng_supported_archs']
|
|
)
|
|
|
|
def build(self):
|
|
build_dir = self.get_build_dir()
|
|
defconfig_dest = os.path.join(self.env['crosstool_ng_source_copy_dir'], 'defconfig')
|
|
os.makedirs(self.env['crosstool_ng_download_dir'], exist_ok=True)
|
|
|
|
# Bootstrap out-ot-tree WONTFIX. I've tried.
|
|
# https://github.com/crosstool-ng/crosstool-ng/issues/1021
|
|
#
|
|
# Then out-of-tree ./ctng usage also started to fail in 1.24.0.
|
|
#
|
|
# So instead of fighting upstream, I'll just take the Buildroot approach
|
|
# to life and rsync the entire source tree into the build tree. Fun times.
|
|
self.sh.copy_dir_if_update(
|
|
self.env['crosstool_ng_source_dir'],
|
|
self.env['crosstool_ng_source_copy_dir'],
|
|
)
|
|
os.chdir(self.env['crosstool_ng_source_copy_dir'])
|
|
self.sh.run_cmd(
|
|
[os.path.join(self.env['crosstool_ng_source_copy_dir'], 'bootstrap'), LF],
|
|
)
|
|
self.sh.run_cmd(
|
|
[
|
|
os.path.join(self.env['crosstool_ng_source_copy_dir'], 'configure'), LF,
|
|
'--enable-local', LF,
|
|
],
|
|
)
|
|
self.sh.run_cmd(['make', '-j', str(self.env['nproc']), LF])
|
|
|
|
# Build the toolchain.
|
|
self.sh.cp(
|
|
os.path.join(self.env['root_dir'], 'crosstool_ng_config', self.env['arch']),
|
|
defconfig_dest
|
|
)
|
|
self.sh.write_configs(
|
|
self.env['crosstool_ng_defconfig'],
|
|
[
|
|
'CT_PREFIX_DIR="{}"'.format(self.env['crosstool_ng_install_dir']),
|
|
'CT_WORK_DIR="{}"'.format(build_dir),
|
|
'CT_LOCAL_TARBALLS_DIR="{}"'.format(self.env['crosstool_ng_download_dir']),
|
|
]
|
|
)
|
|
self.sh.run_cmd(
|
|
[
|
|
self.env['crosstool_ng_executable'], LF,
|
|
'defconfig', LF,
|
|
],
|
|
)
|
|
self.sh.rmrf(defconfig_dest)
|
|
self.sh.run_cmd(
|
|
[
|
|
self.env['crosstool_ng_executable'], LF,
|
|
'build', LF,
|
|
'CT_JOBS={}'.format(str(self.env['nproc'])), LF,
|
|
],
|
|
out_file=os.path.join(build_dir, self.env['repo_short_id'] + '.log'),
|
|
delete_env=['LD_LIBRARY_PATH'],
|
|
extra_paths=[self.env['ccache_dir']],
|
|
)
|
|
|
|
def get_build_dir(self):
|
|
return self.env['crosstool_ng_build_dir']
|
|
|
|
if __name__ == '__main__':
|
|
Main().cli()
|