linux: add --linux-source-dir to have custom linux source dir

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-12-04 00:00:00 +00:00
parent 38ba2b85fc
commit f03e6ea2eb
3 changed files with 31 additions and 22 deletions

View File

@@ -561,7 +561,7 @@ To modify the Linux kernel, build and use it as usual:
For gem5, do: For gem5, do:
.... ....
git submodule update --init --depth 1 "$(./getvar linux_src_dir)" git submodule update --init --depth 1 "$(./getvar linux_source_dir)"
sudo apt-get install qemu-utils sudo apt-get install qemu-utils
./build-gem5 ./build-gem5
./run --gem5 --prebuilt ./run --gem5 --prebuilt
@@ -3491,14 +3491,14 @@ Overview: https://stackoverflow.com/questions/50364863/how-to-get-graphical-gui-
More concretely: More concretely:
.... ....
git -C "$(./getvar linux_src_dir)" fetch https://gem5.googlesource.com/arm/linux gem5/v4.15:gem5/v4.15 git -C "$(./getvar linux_source_dir)" fetch https://gem5.googlesource.com/arm/linux gem5/v4.15:gem5/v4.15
git -C "$(./getvar linux_src_dir)" checkout gem5/v4.15 git -C "$(./getvar linux_source_dir)" checkout gem5/v4.15
./build-linux \ ./build-linux \
--arch arm \ --arch arm \
--custom-config-file "$(./getvar linux_src_dir)/arch/arm/configs/gem5_defconfig" \ --custom-config-file "$(./getvar linux_source_dir)/arch/arm/configs/gem5_defconfig" \
--linux-build-id gem5-v4.15 \ --linux-build-id gem5-v4.15 \
; ;
git -C "$(./getvar linux_src_dir)" checkout - git -C "$(./getvar linux_source_dir)" checkout -
./run --arch arm --gem5 --linux-build-id gem5-v4.15 ./run --arch arm --gem5 --linux-build-id gem5-v4.15
.... ....
@@ -3566,15 +3566,15 @@ Tested on: link:http://github.com/cirosantilli/linux-kernel-module-cheat/commit/
For `aarch64` we also need to configure the kernel with link:linux_config/display[]: For `aarch64` we also need to configure the kernel with link:linux_config/display[]:
.... ....
git -C "$(./getvar linux_src_dir)" fetch https://gem5.googlesource.com/arm/linux gem5/v4.15:gem5/v4.15 git -C "$(./getvar linux_source_dir)" fetch https://gem5.googlesource.com/arm/linux gem5/v4.15:gem5/v4.15
git -C "$(./getvar linux_src_dir)" checkout gem5/v4.15 git -C "$(./getvar linux_source_dir)" checkout gem5/v4.15
./build-linux \ ./build-linux \
--arch aarch64 \ --arch aarch64 \
--config-fragment linux_config/display \ --config-fragment linux_config/display \
--custom-config-file "$(./getvar linux_src_dir)/arch/arm64/configs/gem5_defconfig" \ --custom-config-file "$(./getvar linux_source_dir)/arch/arm64/configs/gem5_defconfig" \
--linux-build-id gem5-v4.15 \ --linux-build-id gem5-v4.15 \
; ;
git -C "$(./getvar linux_src_dir)" checkout - git -C "$(./getvar linux_source_dir)" checkout -
./run --arch aarch64 --gem5 --linux-build-id gem5-v4.15 ./run --arch aarch64 --gem5 --linux-build-id gem5-v4.15
.... ....
@@ -3590,15 +3590,15 @@ The key option to enable support in Linux is `DRM_MALI_DISPLAY=y` which we enabl
.... ....
./build-linux ./build-linux
git -C "$(./getvar linux_src_dir)" fetch https://gem5.googlesource.com/arm/linux gem5/v4.15:gem5/v4.15 git -C "$(./getvar linux_source_dir)" fetch https://gem5.googlesource.com/arm/linux gem5/v4.15:gem5/v4.15
git -C "$(./getvar linux_src_dir)" checkout gem5/v4.15 git -C "$(./getvar linux_source_dir)" checkout gem5/v4.15
./build-linux \ ./build-linux \
--arch aarch64 \ --arch aarch64 \
--config-fragment linux_config/display \ --config-fragment linux_config/display \
--custom-config-file "$(./getvar linux_src_dir)/arch/arm64/configs/gem5_defconfig" \ --custom-config-file "$(./getvar linux_source_dir)/arch/arm64/configs/gem5_defconfig" \
--linux-build-id gem5-v4.15 \ --linux-build-id gem5-v4.15 \
; ;
git -C "$(./getvar linux_src_dir)" checkout - git -C "$(./getvar linux_source_dir)" checkout -
./run --arch aarch64 --dp650 --gem5 --linux-build-id gem5-v4.15 ./run --arch aarch64 --dp650 --gem5 --linux-build-id gem5-v4.15
.... ....
@@ -4139,7 +4139,7 @@ cat /proc/version
or in the source: or in the source:
.... ....
cd "$(./getvar linux_src_dir)" cd "$(./getvar linux_source_dir)"
git log | grep -E ' Linux [0-9]+\.' | head git log | grep -E ' Linux [0-9]+\.' | head
.... ....
@@ -11415,12 +11415,12 @@ If you want to keep two builds around, one for the latest Linux version, and the
./build-linux ./build-linux
# Build another branch. # Build another branch.
git -C "$(./getvar linux_src_dir)" fetch --tags --unshallow git -C "$(./getvar linux_source_dir)" fetch --tags --unshallow
git -C "$(./getvar linux_src_dir)" checkout v4.16 git -C "$(./getvar linux_source_dir)" checkout v4.16
./build-linux --linux-build-id v4.16 ./build-linux --linux-build-id v4.16
# Restore master. # Restore master.
git -C "$(./getvar linux_src_dir)" checkout - git -C "$(./getvar linux_source_dir)" checkout -
# Run master. # Run master.
./run ./run
@@ -11921,7 +11921,7 @@ This example is based on the Linux kernel, for which we used to have patches, bu
# Last point before out patches. # Last point before out patches.
last_mainline_revision=v4.15 last_mainline_revision=v4.15
next_mainline_revision=v4.16 next_mainline_revision=v4.16
cd "$(./getvar linux_src_dir)" cd "$(./getvar linux_source_dir)"
# Create a branch before the rebase in case things go wrong. # Create a branch before the rebase in case things go wrong.
git checkout -b "lkmc-${last_mainline_revision}" git checkout -b "lkmc-${last_mainline_revision}"

View File

@@ -58,7 +58,7 @@ Configure the kernel, but don't build it.
gcc = common.get_toolchain_tool(tool) gcc = common.get_toolchain_tool(tool)
prefix = gcc[:-len(tool)] prefix = gcc[:-len(tool)]
common_args = { common_args = {
'cwd': common.linux_src_dir, 'cwd': common.linux_source_dir,
} }
ccache = shutil.which('ccache') ccache = shutil.which('ccache')
if ccache is not None: if ccache is not None:
@@ -99,7 +99,7 @@ Configure the kernel, but don't build it.
) )
common.run_cmd( common.run_cmd(
[ [
os.path.join(common.linux_src_dir, 'scripts', 'kconfig', 'merge_config.sh'), common.Newline, os.path.join(common.linux_source_dir, 'scripts', 'kconfig', 'merge_config.sh'), common.Newline,
'-m', common.Newline, '-m', common.Newline,
'-O', build_dir, common.Newline, '-O', build_dir, common.Newline,
os.path.join(build_dir, '.config'), common.Newline, os.path.join(build_dir, '.config'), common.Newline,

View File

@@ -48,10 +48,8 @@ submodules_dir = os.path.join(root_dir, 'submodules')
buildroot_src_dir = os.path.join(submodules_dir, 'buildroot') buildroot_src_dir = os.path.join(submodules_dir, 'buildroot')
crosstool_ng_src_dir = os.path.join(submodules_dir, 'crosstool-ng') crosstool_ng_src_dir = os.path.join(submodules_dir, 'crosstool-ng')
crosstool_ng_supported_archs = set(['arm', 'aarch64']) crosstool_ng_supported_archs = set(['arm', 'aarch64'])
linux_src_dir = os.path.join(submodules_dir, 'linux')
linux_config_dir = os.path.join(common.root_dir, 'linux_config') linux_config_dir = os.path.join(common.root_dir, 'linux_config')
rootfs_overlay_dir = os.path.join(common.root_dir, 'rootfs_overlay') rootfs_overlay_dir = os.path.join(common.root_dir, 'rootfs_overlay')
extract_vmlinux = os.path.join(linux_src_dir, 'scripts', 'extract-vmlinux')
qemu_src_dir = os.path.join(submodules_dir, 'qemu') qemu_src_dir = os.path.join(submodules_dir, 'qemu')
parsec_benchmark_src_dir = os.path.join(submodules_dir, 'parsec-benchmark') parsec_benchmark_src_dir = os.path.join(submodules_dir, 'parsec-benchmark')
ccache_dir = os.path.join('/usr', 'lib', 'ccache') ccache_dir = os.path.join('/usr', 'lib', 'ccache')
@@ -316,6 +314,12 @@ Use the docker download Ubuntu root filesystem instead of the default Buildroot
'--linux-build-dir', '--linux-build-dir',
help='Select the directory that contains the Linux kernel build. Overrides linux-build-id.' help='Select the directory that contains the Linux kernel build. Overrides linux-build-id.'
) )
parser.add_argument(
'--linux-source-dir',
help='''\
Use the given directory as the Linux source tree.
'''
)
parser.add_argument( parser.add_argument(
'--machine', '--machine',
help='''Machine type. help='''Machine type.
@@ -859,6 +863,11 @@ def setup(parser):
common.run_cmd_file = os.path.join(common.run_dir, 'run.sh') common.run_cmd_file = os.path.join(common.run_dir, 'run.sh')
# Linux # Linux
if args.linux_source_dir is None:
common.linux_source_dir = os.path.join(submodules_dir, 'linux')
else:
common.linux_source_dir = args.linux_source_dir
common.extract_vmlinux = os.path.join(linux_source_dir, 'scripts', 'extract-vmlinux')
common.linux_buildroot_build_dir = os.path.join(common.buildroot_build_build_dir, 'linux-custom') common.linux_buildroot_build_dir = os.path.join(common.buildroot_build_build_dir, 'linux-custom')
if args.linux_build_dir is None: if args.linux_build_dir is None:
common.linux_build_dir = os.path.join(common.out_dir, 'linux', args.linux_build_id, args.arch) common.linux_build_dir = os.path.join(common.out_dir, 'linux', args.linux_build_id, args.arch)