aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2016-08-01 07:03:41 +0200
committerThierry Reding <treding@nvidia.com>2016-08-01 07:03:41 +0200
commit1bb3c857e19ec1ec8544c62392f7969c1d09cbfa (patch)
tree777eb0f09bde609fe1668bbd38c0d6138acf8f9f
parent26bf60dcfedb1c592c130164bbf50975ec49009f (diff)
downloadmaint-scripts-1bb3c857e19ec1ec8544c62392f7969c1d09cbfa.tar.gz
Add build-linux-tegra.sh script
This script can be used to run sanity builds of the Tegra tree. It will build all branches separately, either in separate directories or within the same directory, incrementally. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rwxr-xr-xbuild-linux-tegra.sh91
-rw-r--r--configs3
-rw-r--r--lib.sh56
3 files changed, 150 insertions, 0 deletions
diff --git a/build-linux-tegra.sh b/build-linux-tegra.sh
new file mode 100755
index 0000000..53980fc
--- /dev/null
+++ b/build-linux-tegra.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+set -e
+#set -x
+
+. "${0%/*}/tegra-branches.sh.dot"
+. "${0%/*}/lib.sh"
+
+function usage()
+{
+ echo "usage: $1 [options]"
+ echo ""
+ echo "options:"
+ echo " -i, --incremental build all branches incrementally"
+}
+
+outputdir=build/tegra
+dry_run=no
+incremental=no
+num_jobs=1
+
+while test $# -gt 0; do
+ if test -n "$prev"; then
+ eval "$prev=$1"
+ shift; prev=
+ continue
+ fi
+
+ case $1 in
+ -i | --incremental)
+ incremental=yes
+ shift
+ ;;
+
+ -j | --jobs)
+ prev=num_jobs
+ shift
+ ;;
+
+ -n | --dry-run)
+ dry_run=yes
+ shift
+ ;;
+
+ -o | --output)
+ prev=outputdir
+ shift
+ ;;
+
+ *)
+ usage $0
+ exit 1
+ ;;
+ esac
+done
+
+for branch in ${branches} for-next; do
+ if test "x$dry_run" = "xyes"; then
+ echo "dry-run: building $branch"
+ else
+ git checkout ${branch}
+ fi
+
+ while read arch config; do
+ if test "x$incremental" = "xno"; then
+ KBUILD_OUTPUT="${outputdir}/${branch}/${arch}/${config}"
+ logdir="${KBUILD_OUTPUT}"
+
+ if test -d "$KBUILD_OUTPUT"; then
+ rm -rf "$KBUILD_OUTPUT"
+ fi
+ else
+ KBUILD_OUTPUT="${outputdir}/${arch}/${config}"
+ logdir="${KBUILD_OUTPUT}/logs/${branch}"
+ fi
+
+ export KBUILD_OUTPUT
+ mkdir -p "${logdir}"
+
+ cross_compile_prepare $arch
+ echo -n " ${arch}:${config} in $KBUILD_OUTPUT... "
+
+ exec 3> "${logdir}/build.log"
+ make ${config} >&3 2>&1
+ make -j ${num_jobs} >&3 2>&1
+ exec 3>&-
+
+ cross_compile_cleanup
+ echo "done"
+ done < "${0%/*}/configs"
+done
diff --git a/configs b/configs
new file mode 100644
index 0000000..34584d5
--- /dev/null
+++ b/configs
@@ -0,0 +1,3 @@
+arm tegra_defconfig
+arm multi_v7_defconfig
+arm64 defconfig
diff --git a/lib.sh b/lib.sh
index 0163927..fe83ff4 100644
--- a/lib.sh
+++ b/lib.sh
@@ -17,3 +17,59 @@ get_remote()
esac
done
}
+
+function cross_compile_prepare()
+{
+ local arch key value path
+
+ case $1 in
+ aarch64)
+ arch=arm64
+ ;;
+
+ *)
+ arch=$1
+ ;;
+ esac
+
+ if test -f "$HOME/.cross-compile"; then
+ while read key value; do
+ key="${key%:}"
+
+ if test "$key" = "path"; then
+ eval "value=$value"
+
+ if test -n "$path"; then
+ path="$path:$value"
+ else
+ path="$value"
+ fi
+ elif test "$key" = "$arch"; then
+ if test -n "$CROSS_COMPILE"; then
+ saved_CROSS_COMPILE="$CROSS_COMPILE"
+ fi
+
+ ARCH=$arch; CROSS_COMPILE="$value"
+ export ARCH CROSS_COMPILE
+ fi
+ done < "$HOME/.cross-compile"
+ fi
+
+ if test -n "$path"; then
+ saved_PATH="$PATH"
+ PATH="$path:$PATH"
+ fi
+}
+
+function cross_compile_cleanup()
+{
+ if test -n "$saved_CROSS_COMPILE"; then
+ CROSS_COMPILE="$saved_CROSS_COMPILE"
+ else
+ unset CROSS_COMPILE
+ fi
+
+ if test -n "$saved_PATH"; then
+ PATH="$saved_PATH"
+ fi
+}