[PATCH 3/3] aiaiai-make-project: Support non-kernel project builds

Jacob Keller jacob.e.keller at intel.com
Tue May 27 10:56:36 PDT 2014


It is often useful to run tests against non-kernel projects, such as
ethtool. This patch renames aiaiai-make-kernel to aiaiai-make-project,
and adds support for detecting kernel, ./configure, and ./autogen.sh
style projects.

It will be a slow process for actually converting all tools to work with
non-kernel builds, and various options and documentation are only
relevant for kernel builds, but this is a small step in the more generic
direction.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
 aiaiai-test-patchset                               |  4 +-
 doc/README                                         | 10 +--
 .../{aiaiai-make-kernel => aiaiai-make-project}    | 82 +++++++++++++++++++---
 helpers/aiaiai-test-bisectability                  |  4 +-
 4 files changed, 80 insertions(+), 20 deletions(-)
 rename helpers/{aiaiai-make-kernel => aiaiai-make-project} (77%)

diff --git a/aiaiai-test-patchset b/aiaiai-test-patchset
index efaa07596ae8..00e3c4a9b555 100755
--- a/aiaiai-test-patchset
+++ b/aiaiai-test-patchset
@@ -187,7 +187,7 @@ test_configuration()
 	# Note, we use the --keep-going option assuming that the base commit
 	# build may fail, which is OK for continuing as long as the patches
 	# under test fix it.
-	aiaiai-make-kernel $verbose $sparse $smatch $cppcheck $coccinelle -o "$obj1" \
+	aiaiai-make-project $verbose $sparse $smatch $cppcheck $coccinelle -o "$obj1" \
 		--check-only "$mod_files" -j "$jobs" $arch_opt -D "$defconfig" \
 		-O "$log1.stdout.log" -E "$log1.stderr.log" --keep-going \
 		${kmake_opts:+-M "$kmake_opts"} -- "$cloned_kernel1" "$targets"
@@ -209,7 +209,7 @@ test_configuration()
 	local log2="$logdir2/$config"
 	local obj2="$tmpdir2/obj.$config"
 
-	aiaiai-make-kernel $verbose $sparse $smatch $cppcheck $coccinelle -o "$obj2" \
+	aiaiai-make-project $verbose $sparse $smatch $cppcheck $coccinelle -o "$obj2" \
 		--check-only "$mod_files" -j "$jobs" $arch_opt -D "$defconfig" \
 		-O "$log2.stdout.log" -E "$log2.stderr.log" \
 		${kmake_opts:+-M "$kmake_opts"} -- "$cloned_kernel2" "$targets"
diff --git a/doc/README b/doc/README
index 28e0bca3b820..e34651f9c21b 100644
--- a/doc/README
+++ b/doc/README
@@ -121,12 +121,12 @@ doc/email/example-aiaiai.cfg
     path to the kernel to test against, the commit id to test against, which
     tests to run, etc.
 
-* aiaiai-make-kernel
-    Low-level scripts which builds the kernel. It has several switches which
+* aiaiai-make-project
+    Low-level scripts which builds the project. It has several switches which
     change its behavior, e.g., you can select whether you want to run
     sparse/smatch/cppcheck/coccinelle tools or not.
 
-    'aiaiai-make-kernel' utilizes the 'aiaiai-locker' utility to make
+    'aiaiai-make-project;' utilizes the 'aiaiai-locker' utility to make
     sure the build logs of parallel builds are not scrambled and stay readable.
 
 * aiaiai-locker
@@ -144,7 +144,7 @@ doc/email/example-aiaiai.cfg
     another command.
 
 * aiaiai-checker
-    A helper script for 'aiaiai-make-kernel' which runs
+    A helper script for 'aiaiai-make-project' which runs
     sparse/smatch/cppcheck/coccinelle tools. The reason we need it is because
     the kernel build system allows only one checking program at a time, but we
     want to run multiple of them.
@@ -210,7 +210,7 @@ To summarize:
    * it runs 'checkpatch.pl'
    * it runs 'aiaiai-test-bisectability'
    * for every configuration specified by the user, it builds the kernel
-     before and after the patch using the 'aiaiai-make-kernel' script, then
+     before and after the patch using the 'aiaiai-make-project' script, then
      compares the build log using the 'aiaiai-diff-log' script.
    * Things are done in parallel.
    * The results of all tests are collected and printed to stdout
diff --git a/helpers/aiaiai-make-kernel b/helpers/aiaiai-make-project
similarity index 77%
rename from helpers/aiaiai-make-kernel
rename to helpers/aiaiai-make-project
index 4338a2764a09..bf8270921f84 100755
--- a/helpers/aiaiai-make-kernel
+++ b/helpers/aiaiai-make-project
@@ -26,19 +26,21 @@ fi
 show_usage()
 {
 	cat <<-EOF
-Usage: $PROG [options] <kernel-tree> <targets...>
+Usage: $PROG [options] <project-tree> <targets...>
 
-<kernel-tree>          - directory with kernel sources
+<project-tree>          - directory with project sources
 <targets...>           - list of targets to make.
 
 Options:
   -o, --objdir=OBJDIR    locate all output files in OBJDIR, including .config
                          (O=OBJDIR Kbuild feature); if undefined - use the
-                         source directory (<kernel-tree>);
+                         source directory (<project-tree>);
   -D, --defconfig=CONF   name of the defconfig to use for each target; if the
                          name contains a "/" character, it is interpreted as a
                          stand-alone defconfig file, otherwise it is assumed
-                         that CONF is part of the <kernel-tree>;
+                         that CONF is part of the <project-tree>; Note this
+                         only affects kernel projects, as other project styles
+                         do not use the Kconfig system
   -j, --jobs=N           allow to run N jobs simultaneously (default is 1);
   -O, --stdout=FILE      redirect stdout of the build to FILE;
   -E, --stderr=FILE      redirect stderr of the build to FILE (note, if neither
@@ -56,6 +58,9 @@ Options:
                          scripts from PATH; the scripts have to have ".cocci"
                          extention and may reside anywhere under PATH
       --check-only=FILE  check only files listed in FILE;
+      --build-style=TYPE force build style to a specific type. Recognized
+                         styles are "kernel", "configure", "autogen". Default
+                         is to determine style by contents of repository.
   -M, --kmake-opts       additional options to append to the final kernel
                          compilation 'make' command
                          (e.g., W=12 KALLSYMS_EXTRA_PASS=1)
@@ -90,7 +95,7 @@ strip_log()
 		   /^'make CONFIG_DEBUG_SECTION_MISMATCH=y'$/d
 
 		   # Make all source paths relative to the kernel tree root
-		   s/$(quote_sed_regexp "$kernel_tree/")//g" "$logfile"
+		   s/$(quote_sed_regexp "$project_tree/")//g" "$logfile"
 
 	# Strip objdir paths as well
 	[ -z "$objdir" ] || sed -i -e "s/$(quote_sed_regexp "$objdir/")//g" "$logfile"
@@ -100,30 +105,80 @@ make_target()
 {
 	local target="$1"
 
+	# Attempt to determine style automatically
+	if [ -z "$build_style" ]; then
+		if [ -f "$project_tree/autogen.sh" ]; then
+			build_style="autogen"
+		elif [ -f "$project_tree/configure" ]; then
+			build_style="configure"
+		elif [ -f "$project_tree/Kbuild" ] && [ -f "$project_tree/Kconfig" ]; then
+			build_style="kernel"
+		fi
+	fi
+
+	if [ "$build_style" = "kernel" ]; then
+		make_kernel_target "$target"
+	elif [ "$build_style" = "configure" ]; then
+		make_configure_target "$target"
+	elif [ "$build_style" = "autogen" ]; then
+		make_autogen_target "$target"
+	else
+		die "unknown project build style"
+	fi
+}
+
+make_kernel_target()
+{
+	local target="$1"
+
 	if [ -n "$defconfig" ]; then
 		if printf "%s" "$defconfig" | grep -q '/'; then
 			# The defconfig is a path to a stand-alone defconfig file
 			# FIXME: ugly hack!
-			make -C $kernel_tree ${arch:+ARCH="$arch"} \
+			make -C $project_tree ${arch:+ARCH="$arch"} \
 				${cross:+CROSS_COMPILE="$cross"} \
 				${objdir:+O="$objdir"} \
 				KCONFIG_ALLCONFIG="$defconfig" -- alldefconfig
 		else
 			# The defconfig is part of the git tree
-			make -C $kernel_tree ${arch:+ARCH="$arch"} \
+			make -C $project_tree ${arch:+ARCH="$arch"} \
 				${cross:+CROSS_COMPILE="$cross"} \
 				${objdir:+O="$objdir"} -- "$defconfig"
 		fi
 	fi
 
 	aiaiai-locker $split -l "$lockfile" -c \
-		"make $keep_going -j $jobs -C $kernel_tree ${arch:+ARCH="$arch"} \
+		"make $keep_going -j $jobs -C $project_tree ${arch:+ARCH="$arch"} \
 		${cross:+CROSS_COMPILE="$cross"} ${objdir:+O="$objdir"} \
 		CHECK=\"aiaiai-checker $sparse $smatch $cppcheck $coccinelle $check_only --\" \
 		C=$check ${check:+CF="-D__CHECK_ENDIAN__"} SHELL=\"aiaiai-locker $split -l $lockfile\" \
 		$kmake_opts $target"
 }
 
+make_configure_target()
+{
+	local target="$1"
+
+	cd "$project_tree"
+	./configure
+
+	aiaiai-locker $split -l "$lockfile" -c \
+		"make $keep_going -j $jobs -C $project_tree ${arch:+ARCH="$arch"} \
+		${cross:+CROSS_COMPILE="$cross"} ${objdir:+O="$objdir"} \
+		SHELL=\"aiaiai-locker $split -l $lockfile\" \
+		$kmake_opts $target"
+}
+
+make_autogen_target()
+{
+	local target="$1"
+
+	cd "$project_tree"
+	./autogen.sh
+
+	make_configure_target "$target"
+}
+
 lockfile=
 build_stdout=
 build_stdout_given=
@@ -139,7 +194,7 @@ cleanup_handler()
 }
 set_cleanup_handler cleanup_handler
 
-TEMP=`getopt -n $PROG -o o:,D:,j:,O:,E:,k:,a:,M:,v,h --long objdir:,defconfig:,jobs:,stdout:,stderr:,keep-going,arch:,sparse,smatch,cppcheck,coccinelle:,check-only:,kmake-opts:,verbose,help -- "$@"` ||
+TEMP=`getopt -n $PROG -o o:,D:,j:,O:,E:,k:,a:,M:,v,h --long objdir:,defconfig:,jobs:,stdout:,stderr:,keep-going,arch:,sparse,smatch,cppcheck,coccinelle:,check-only:,build-style:,kmake-opts:,verbose,help -- "$@"` ||
 	fail_usage ""
 eval set -- "$TEMP"
 
@@ -155,6 +210,7 @@ cppcheck=
 coccinelle=
 cocci_path=
 check_only=
+build_style=
 check=0
 kmake_opts="KCFLAGS='-Wno-missing-field-initializers -Wno-sign-compare' W=1"
 verbose=
@@ -216,6 +272,10 @@ while true; do
 		check_only="--check-only $(opt_check_read "$1" "$2")"
 		shift
 		;;
+	--build-style)
+		build_style="$2"
+		shift
+		;;
 	-M|--kmake-opts)
 		kmake_opts="$2"
 		shift
@@ -242,8 +302,8 @@ program_required "aiaiai-locker" ""
 program_required "${cross}gcc" ""
 program_required "make" ""
 
-kernel_tree="$(opt_check_dir "kernel-tree" "$1")"; shift
-build_info="$kernel_tree${objdir:+ (O="$objdir")}"
+project_tree="$(opt_check_dir "project-tree" "$1")"; shift
+build_info="$project_tree${objdir:+ (O="$objdir")}"
 
 if [ -n "$build_stdout_given" ] || [ -n "$build_stderr_given" ]; then
 	split="-s"
diff --git a/helpers/aiaiai-test-bisectability b/helpers/aiaiai-test-bisectability
index 66d5cc57918e..f8900528faed 100755
--- a/helpers/aiaiai-test-bisectability
+++ b/helpers/aiaiai-test-bisectability
@@ -105,7 +105,7 @@ compile_patch()
 	# Apply the patch
 	apply_patch < "$file" || exit 0
 
-	aiaiai-make-kernel $verbose -j "$jobs" -o "$objdir" $arch_opt -D "$dconf" \
+	aiaiai-make-project $verbose -j "$jobs" -o "$objdir" $arch_opt -D "$dconf" \
 		-O "$stdout_log" -E "$stderr_log" ${kmake_opts:+-M "$kmake_opts"} \
 		-- "$cloned_kernel" all
 }
@@ -241,7 +241,7 @@ stderr_log="$tmpdir/$defconfig.stderr.log"
 
 verbose "Building the base tree"
 base_commit_failed=
-aiaiai-make-kernel $verbose -j "$jobs" -o "$objdir" $arch_opt -D "$dconf" \
+aiaiai-make-project $verbose -j "$jobs" -o "$objdir" $arch_opt -D "$dconf" \
 	-O "$base_stdout_log" -E "$base_stderr_log" \
 	${kmake_opts:+-M "$kmake_opts"} -- "$cloned_kernel" all
 if build_failed "$base_stderr_log"; then
-- 
1.9.0




More information about the aiaiai mailing list