[PATCH 06/11] Compile helper tools if necessary
Artem Bityutskiy
dedekind1 at gmail.com
Fri Feb 7 07:28:19 PST 2014
From: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
Some of our tools like 'remap-log' have to be compiled. This is not a problem
when using Aiaiai from a package, because it has the compiled version of the
tool, but this is a problem when using Aiaiai from sources.
Introduce a function which tries to compile the internal tools. This is
supposed to improve user experience with Aiaiai.
Remove the top-level Makefile since it is not really needed after this change.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
---
Makefile | 5 -----
aiaiai-test-patchset | 3 ---
doc/TODO.txt | 2 --
helpers/Makefile | 6 +++++-
helpers/aiaiai-checker | 4 ++--
helpers/aiaiai-diff-log | 5 +++--
helpers/aiaiai-make-kernel | 5 +++--
helpers/aiaiai-sh-functions | 24 ++++++++++++++++++++++++
8 files changed, 37 insertions(+), 17 deletions(-)
delete mode 100644 Makefile
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 00039af..0000000
--- a/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all:
- make -C helpers
-
-clean:
- make -C helpers clean
diff --git a/aiaiai-test-patchset b/aiaiai-test-patchset
index 0707019..bda85b3 100755
--- a/aiaiai-test-patchset
+++ b/aiaiai-test-patchset
@@ -341,9 +341,6 @@ kernel_tree="$(readlink -ev -- "$1")"; shift
defconfigs="$@"
# Make sure external programs we depend on are installed
-msg="You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
-program_required "remap-log" "$msg"
-program_required "aiaiai-locker" "$msg"
program_required "git" ""
program_required "make" ""
program_required "patch" ""
diff --git a/doc/TODO.txt b/doc/TODO.txt
index c5eed38..e64901c 100644
--- a/doc/TODO.txt
+++ b/doc/TODO.txt
@@ -35,8 +35,6 @@ implementing them.
order to make it easier for people to start hacking Aiaiai.
* Describe how the e-mail front-end distinguish patches and collects
patch-sets.
- * Teach the scripts to compile 'remap-log' if it is not compiled,
- instead of just failing. This is probably more user-friendly.
* Describe some review policy, e.g., how many days I promise to wait
for review/reply before applying patches.
diff --git a/helpers/Makefile b/helpers/Makefile
index 4a06f73..7fd7567 100644
--- a/helpers/Makefile
+++ b/helpers/Makefile
@@ -1,5 +1,9 @@
-all:
+all: remap-log aiaiai-locker
+
+remap-log:
$(CC) $(CFLAGS) -o remap-log remap-log.c
+
+aiaiai-locker:
$(CC) $(CFLAGS) -o aiaiai-locker aiaiai-locker.c
clean:
diff --git a/helpers/aiaiai-checker b/helpers/aiaiai-checker
index 0487670..21d52ef 100755
--- a/helpers/aiaiai-checker
+++ b/helpers/aiaiai-checker
@@ -143,8 +143,8 @@ while true; do
shift
done
-program_required "aiaiai-locker" \
- "You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
+compile_helpers "$srcdir"
+program_required "aiaiai-locker" ""
tmpdir="$(mktemp -dt "$PROG.XXXX")"
file_to_check="$(get_file_to_check "$@")"
diff --git a/helpers/aiaiai-diff-log b/helpers/aiaiai-diff-log
index e053edc..c7a572a 100755
--- a/helpers/aiaiai-diff-log
+++ b/helpers/aiaiai-diff-log
@@ -167,8 +167,9 @@ done
[ "$#" = 3 ] || die "Insufficient or too many arguments"
-program_required "remap-log" \
- "You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
+
+compile_helpers "$srcdir"
+program_required "remap-log" ""
patch="$(readlink -ev -- "$1")"; shift
input_log1="$(readlink -ev -- "$1")"; shift
diff --git a/helpers/aiaiai-make-kernel b/helpers/aiaiai-make-kernel
index 7153629..4db126b 100755
--- a/helpers/aiaiai-make-kernel
+++ b/helpers/aiaiai-make-kernel
@@ -230,8 +230,9 @@ done
[ "$#" -ge 2 ] || die "Insufficient arguments"
-program_required "aiaiai-locker" \
- "You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
+compile_helpers "$srcdir"
+
+program_required "aiaiai-locker" ""
program_required "${cross}gcc" ""
program_required "make" ""
diff --git a/helpers/aiaiai-sh-functions b/helpers/aiaiai-sh-functions
index abbd0f4..b32e457 100644
--- a/helpers/aiaiai-sh-functions
+++ b/helpers/aiaiai-sh-functions
@@ -57,6 +57,30 @@ program_required()
fi
}
+# Some tools in the "helpers" subdirectory have to be compiled before they can
+# be sued. When Aiaiai is used from the source tree (as opposed to being
+# installed from an RPM package), the user may froget to compile the tools.
+# This function tries to compile them.
+#
+# Usage: compile_helpers <srcdir>
+#
+# where <srcdir> is the directory where the helper tools are supposed to live.
+compile_helpers()
+{
+ local srcdir="$1"
+ local tools="remap-log aiaiai-locker"
+
+ for tool in $tools; do
+ if command -v "$tool" >/dev/null 2>&1; then
+ continue
+ fi
+
+ if [ -f "$srcdir/${tool}.c" ]; then
+ make -C "$srcdir" "$tool" >/dev/null 2>&1 ||:
+ fi
+ done
+}
+
# Fetch the first occurrence of an mbox header from a file
# Usage: fetch_header <header_name> < <mbox_file>
fetch_header()
--
1.8.5.2
More information about the aiaiai
mailing list