aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-03-25 18:43:43 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-03-28 20:50:32 +0200
commit6279f0514ab0193e074b465e317ba4e4b3d14e59 (patch)
tree7b8e786c200801dffa54f6898f61defa66017486
parentf8ab9197d8e167f38486b8230dd73f47f8e19c1f (diff)
downloadhardware_replicant_libsamsung-ipc-6279f0514ab0193e074b465e317ba4e4b3d14e59.tar.gz
hardware_replicant_libsamsung-ipc-6279f0514ab0193e074b465e317ba4e4b3d14e59.tar.bz2
hardware_replicant_libsamsung-ipc-6279f0514ab0193e074b465e317ba4e4b3d14e59.zip
Add tools to build all the last commits
This makes it easier to build-test all the latest commits before sending patches or pushing patches. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-xscripts/rebase-build-check-android.sh102
-rwxr-xr-xscripts/rebase-build-check-gnu-linux.sh81
2 files changed, 183 insertions, 0 deletions
diff --git a/scripts/rebase-build-check-android.sh b/scripts/rebase-build-check-android.sh
new file mode 100755
index 0000000..e43e3c6
--- /dev/null
+++ b/scripts/rebase-build-check-android.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+# -*- coding: utf-8 -*-
+# Copyright (C) 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+set -e
+
+usage()
+{
+ printf "Usage:\n"
+ printf "%s build-from <base-commit-ref> " "$0"
+ printf "# Build all commits since <base-commit-ref>\n" "%0"
+ printf "%s continue " "$0"
+ printf "# Continue rebasing and building commits\n" "%0"
+ exit 64; # EX_USAGE from sysexits.h
+}
+
+print_header()
+{
+ set +e
+ message="$1"
+
+ len=$(expr $(echo -n ${message} | wc -c) + 2)
+
+ nr_chars=$(expr $(expr 80 - ${len}) / 2)
+
+ i="${nr_chars}"
+
+ while [ ${i} -gt 0 ] ; do
+ echo -n "#"
+ i="$(expr ${i} - 1)"
+ done
+
+ echo -n " ${message} "
+
+ i="${nr_chars}"
+
+ while [ ${i} -gt 0 ] ; do
+ echo -n "#"
+ i="$(expr ${i} - 1)"
+ done
+ echo
+ set -e
+}
+
+build_and_git_rebase_continue()
+{
+ total_commits="$1"
+
+ total_targets="$(./vendor/replicant/build.sh targets | wc -l)"
+ parallel_tasks=$(echo "$(grep 'processor' /proc/cpuinfo | wc -l ) + 1" | bc)
+
+ local_modules="$(grep \
+ "^LOCAL_MODULE := " \
+ hardware/replicant/libsamsung-ipc/Android.mk | \
+ awk '{print $3}' | sort -u)"
+
+ source build/envsetup.sh
+
+ # Currently all the Replicant versions supported by libsamsung-ipc
+ # have an aosp_arm-eng target. Using aosp_arm-eng also ensures
+ # that TARGET_DEVICE isn't set by the device repository. This also
+ # leaves us more freedom in libsamsung-ipc as we could for
+ # instance decide to not build unused code based on TARGET_DEVICE.
+ lunch aosp_arm-eng
+
+ commit_nr=1
+ while true ; do
+ print_header "[ commit ${commit_nr} of ${total_commits} ]"
+ make "-j${parallel_tasks}" ${local_modules}
+ git -C hardware/replicant/libsamsung-ipc rebase --continue || break
+ commit_nr="$(expr ${commit_nr} + 1)"
+ done
+}
+
+if [ $# -eq 2 ] && [ "$1" == "build-from" ] ; then
+ base_commit="$2"
+ nr_commits="$(git -C hardware/replicant/libsamsung-ipc log --oneline \
+ ${base_commit}~1..HEAD --oneline | wc -l)"
+ GIT_EDITOR="sed 's#^pick #edit #g' -i " \
+ git -C hardware/replicant/libsamsung-ipc \
+ rebase -i "${base_commit}"
+
+ build_and_git_rebase_continue "${nr_commits}"
+elif [ $# -eq 1 ] && [ "$1" == "continue" ] ; then
+ nr_commits="$(git -C hardware/replicant/libsamsung-ipc \
+ log --oneline REBASE_HEAD~1..ORIG_HEAD --oneline | wc -l)"
+ build_and_git_rebase_continue "${nr_commits}"
+else
+ usage
+fi
diff --git a/scripts/rebase-build-check-gnu-linux.sh b/scripts/rebase-build-check-gnu-linux.sh
new file mode 100755
index 0000000..a909290
--- /dev/null
+++ b/scripts/rebase-build-check-gnu-linux.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+# -*- coding: utf-8 -*-
+# Copyright (C) 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+die()
+{
+ echo "$@"
+ exit 1;
+}
+
+usage()
+{
+ printf "Usage:\n"
+ printf "%s build-from <base-commit-ref> " "$0"
+ printf "# Build all commits since <base-commit-ref>\n" "%0"
+ printf "%s continue " "$0"
+ printf "# Continue rebasing and building commits\n" "%0"
+ exit 64; # EX_USAGE from sysexits.h
+}
+
+print_header()
+{
+ message="$1"
+
+ len=$(expr $(echo -n ${message} | wc -c) + 2)
+
+ nr_chars=$(expr $(expr 80 - ${len}) / 2)
+
+ i="${nr_chars}"
+ while [ ${i} -gt 0 ] ; do
+ echo -n "#"
+ i="$(expr ${i} - 1)"
+ done
+
+ echo -n " ${message} "
+
+ i="${nr_chars}"
+ while [ ${i} -gt 0 ] ; do
+ echo -n "#"
+ i="$(expr ${i} - 1)"
+ done
+ echo
+}
+
+build_and_git_rebase_continue()
+{
+ commits="$1"
+ commit=1
+
+ while true ; do
+ print_header "[ ${commit} of ${commits} ]"
+ guix build --file=scripts/guix.scm || die "guix build failed"
+ commit="$(expr ${commit} + 1)"
+ git rebase --continue || break
+ done
+}
+
+if [ $# -eq 2 ] && [ "$1" == "build-from" ] ; then
+ base_commit="$2"
+ nr_commits="$(git log --oneline ${base_commit}~1..HEAD --oneline | wc -l)"
+ GIT_EDITOR="sed 's#^pick #edit #g' -i " git rebase -i "${base_commit}"
+ build_and_git_rebase_continue "${nr_commits}"
+elif [ $# -eq 1 ] && [ "$1" == "continue" ] ; then
+ nr_commits="$(git log --oneline REBASE_HEAD~1..ORIG_HEAD --oneline | wc -l)"
+ build_and_git_rebase_continue "${nr_commits}"
+else
+ usage
+fi