misc: new script to try to make some targets
authorJean Privat <jean@pryen.org>
Tue, 28 Feb 2017 14:44:17 +0000 (09:44 -0500)
committerJean Privat <jean@pryen.org>
Wed, 1 Mar 2017 18:34:31 +0000 (13:34 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

misc/jenkins/trymake.sh [new file with mode: 0755]

diff --git a/misc/jenkins/trymake.sh b/misc/jenkins/trymake.sh
new file mode 100755 (executable)
index 0000000..9bd7c0e
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Try to make targets (like pre-build). If the rule does on exists this does nothing instead of failing.
+# This also generate xml JUnit files
+#
+# Usage
+#
+#     trymake.sh name directory [targets]..
+#
+# Example
+#
+#     trymake.sh foo contrib/foo check android
+
+shdir="`dirname "$BASH_SOURCE"`"
+
+name="$1"
+dir="$2"
+shift
+shift
+failed=
+# Check each rules, if they exists
+for rule in "$@"; do
+       make -C "$dir" $rule -n >/dev/null 2>/dev/null || {
+               # Special case for `all` that falls back as the default target
+               if [ "$rule" = "all" ]; then
+                       echo "*** make -C $dir ***"
+                       $shdir/unitrun.sh "cmd-$name-make" make -C "$dir" ||
+                               failed="$failed $name"
+               fi
+               continue
+       }
+       echo "*** make $rule -C $dir ***"
+       $shdir/unitrun.sh "cmd-$name-make$rule" make -C "$dir" $rule ||
+       failed="$failed $name-$rule"
+done
+if test -n "$failed"; then
+       echo "FAILED: $failed"
+       exit 1
+fi
+exit 0