Skip to content

Commit 3b15278

Browse files
committed
kernel_patch_verify: Add support for separate build output directory
Add -O option to specify a build output directory for out-of-tree kernel builds. This allows using O= make parameter for builds in a separate directory from the kernel source tree. Update all .config and make operations to respect BUILD_OUTPUT_DIR when specified. Signed-off-by: Dhruva Gole <d-gole@ti.com>
1 parent 06b931d commit 3b15278

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

kernel_patch_verify

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ fi
7373
kmake_single() {
7474
# XXX: kmake operations depend on variable expansion- do not quote variables here.
7575
# Except for compiler option since ccache will be involved
76-
make $KM_A $KP_PARAMS "$KM_C" $KM_L -j1 $@
76+
make $KM_A $KP_PARAMS "$KM_C" $KM_L $KM_O -j1 $@
7777
}
7878

7979
kmake() {
8080
# XXX: kmake operations depend on variable expansion- do not quote variables here.
8181
# Except for compiler option since ccache will be involved
82-
make $KM_A $KP_PARAMS "$KM_C" $KM_L -j$KM_CPUS $@
82+
make $KM_A $KP_PARAMS "$KM_C" $KM_L $KM_O -j$KM_CPUS $@
8383
}
8484

8585
to_time() {
@@ -380,7 +380,11 @@ defconfig() {
380380
if [ -n "$DEFCONFIG" ]; then
381381
kmake "$DEFCONFIG" >/dev/null
382382
else
383-
cp "$TEST_DIR"/.config .config
383+
if [ -n "$BUILD_OUTPUT_DIR" ]; then
384+
cp "$TEST_DIR"/.config "$BUILD_OUTPUT_DIR"/.config
385+
else
386+
cp "$TEST_DIR"/.config .config
387+
fi
384388
kmake olddefconfig >/dev/null
385389
fi
386390
}
@@ -597,7 +601,11 @@ on_exit() {
597601
fi
598602
if [ -f "$TEST_DIR/.config" ]; then
599603
echo "restoring .config"
600-
cp "$TEST_DIR"/.config .config
604+
if [ -n "$BUILD_OUTPUT_DIR" ]; then
605+
cp "$TEST_DIR"/.config "$BUILD_OUTPUT_DIR"/.config
606+
else
607+
cp "$TEST_DIR"/.config .config
608+
fi
601609
fi
602610
if [ -n "$TEST_DIR" ] && [ -d "$TEST_DIR" ]; then
603611
echo "Removing temp dir"
@@ -810,14 +818,15 @@ usage() {
810818

811819
printf '%s\n' \
812820
'' \
813-
"Usage: $APP_NAME [-d | -V] [-j CPUs] [-B build_target] [-T tmp_dir_base] [-l logfile] [-C] [-P] [-c defconfig_name] [-n N][-1..9]|[-p patch_dir]|[-b base_branch [-t head_branch]] [-S smatch_script] -U -Z" \
821+
"Usage: $APP_NAME [-d | -V] [-j CPUs] [-B build_target] [-O build_output_dir] [-T tmp_dir_base] [-l logfile] [-C] [-P] [-c defconfig_name] [-n N][-1..9]|[-p patch_dir]|[-b base_branch [-t head_branch]] [-S smatch_script] -U -Z" \
814822
''
815823

816824
printf '\t%s\n' \
817825
"-d: if not already defined, use CROSS_COMPILE=$DEF_CROSS_COMPILE, ARCH=$DEF_ARCH, and builds for '$KP_TARGETS $DEF_BUILDTARGETS' build targets" \
818826
"-V: (default armV8 targets) if not already defined, use CROSS_COMPILE=$DEF_V8_CROSS_COMPILE, ARCH=$DEF_V8_ARCH, and builds for '$KP_TARGETS $DEF_V8_BUILDTARGETS' build targets" \
819827
"-j CPUs: override default CPUs count with build (default is $KM_CPUS)" \
820828
"-B build_target: override default build target and use provided build_target" \
829+
"-O build_output_dir: kernel build output directory (for separate build directory with O=)" \
821830
"-T temp_dir_base: temporary directory base (default is $TEST_B_DIR)" \
822831
"-l logfile: report file (defaults to $LOG_FILE)" \
823832
"-L Use llvm to build 'LLVM=1 CC='$ccache clang''" \
@@ -869,7 +878,8 @@ usage() {
869878

870879
ORIDE=0
871880
DTB_NOSKIP=0
872-
while getopts "S:n:j:c:T:B:l:p:b:t:m:123456789CdDUVZLP" opt; do
881+
BUILD_OUTPUT_DIR=""
882+
while getopts "S:n:j:c:T:B:l:p:b:t:m:O:123456789CdDUVZLP" opt; do
873883
case $opt in
874884
j)
875885
KM_CPUS=$OPTARG
@@ -942,6 +952,13 @@ while getopts "S:n:j:c:T:B:l:p:b:t:m:123456789CdDUVZLP" opt; do
942952
exit 1
943953
fi
944954
;;
955+
O)
956+
BUILD_OUTPUT_DIR=$OPTARG
957+
if [ ! -d "$BUILD_OUTPUT_DIR" ]; then
958+
usage "Build output directory $BUILD_OUTPUT_DIR does not exist"
959+
exit 1
960+
fi
961+
;;
945962
C)
946963
COMPLETE_TESTS=1
947964
KP_PARAMS="$KP_PARAMS W=12 EXTRA_CFLAGS=-W"
@@ -1080,6 +1097,10 @@ if [ -n "$ARCH" ]; then
10801097
KM_A="ARCH=$ARCH"
10811098
fi
10821099

1100+
if [ -n "$BUILD_OUTPUT_DIR" ]; then
1101+
KM_O="O=$BUILD_OUTPUT_DIR"
1102+
fi
1103+
10831104
KDIR=$(pwd)
10841105

10851106
CURRENT_BRANCH=$(git branch | grep '^\*' | cut -d " " -f 2)
@@ -1096,7 +1117,12 @@ if [ -n "$TEST_BRANCH" ] && [ "$TEST_BRANCH" = "$BASE_BRANCH" ]; then
10961117
exit 3
10971118
fi
10981119

1099-
if [ ! -e ".config" ] && [ -z "$DEFCONFIG" ]; then
1120+
CONFIG_FILE=".config"
1121+
if [ -n "$BUILD_OUTPUT_DIR" ]; then
1122+
CONFIG_FILE="$BUILD_OUTPUT_DIR/.config"
1123+
fi
1124+
1125+
if [ ! -e "$CONFIG_FILE" ] && [ -z "$DEFCONFIG" ]; then
11001126
usage "No default .config exists nor is a defconfig specified with -c"
11011127
exit 3
11021128
fi
@@ -1120,7 +1146,7 @@ if [ -e "$GIT_RM_DIR" ] || [ -e "$GIT_RA_DIR" ]; then
11201146
exit 3
11211147
fi
11221148

1123-
cp .config "$TEST_DIR"/.config 2>/dev/null
1149+
cp "$CONFIG_FILE" "$TEST_DIR"/.config 2>/dev/null
11241150
if [ -z "$SMATCH" ]; then
11251151
SMATCH=$TEST_DIR/smatch
11261152
echo -e '#!/bin/bash\nsmatch -p=kernel $@'> "$SMATCH"

0 commit comments

Comments
 (0)