android: use set -e in scripts

This commit is contained in:
Robert Swiecki
2022-01-02 17:05:04 +01:00
parent e49e303bd2
commit 28310f6847
3 changed files with 13 additions and 49 deletions
+6 -18
View File
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -xu
set -xeu
abort() {
cd - &>/dev/null
@@ -34,10 +34,7 @@ fi
readonly CAPSTONE_DIR="$1"
if [ ! -d "$CAPSTONE_DIR/.git" ]; then
git submodule update --init third_party/android/capstone || {
echo "[-] git submodules init failed"
exit 1
}
git submodule update --init third_party/android/capstone
fi
# Change workspace
@@ -50,7 +47,7 @@ else
abort 1
fi
ARCH="$2"
readonly ARCH="$2"
case "$ARCH" in
arm)
@@ -71,12 +68,7 @@ case "$ARCH" in
;;
esac
if [[ $(which ndk-build) != "" ]]; then
$NDK=$(dirname $(which ndk-build))
else
echo "[-] Could not detect Android NDK dir"
abort 1
fi
NDK=$(dirname $(which ndk-build))
if ! echo "$ANDROID_API" | grep -qoE 'android-[0-9]{1,2}'; then
echo "[-] Invalid ANDROID_API '$ANDROID_API'"
@@ -97,11 +89,7 @@ make clean
NDK=$NDK CAPSTONE_BUILD_CORE_ONLY=yes CAPSTONE_ARCHS=$CS_ARCH \
CAPSTONE_SHARED=no CAPSTONE_STATIC=yes \
eval $CS_BUILD_BIN
if [ $? -ne 0 ]; then
echo "[-] Compilation failed"
abort 1
else
echo "[*] '$ARCH' libcapstone available at '$CAPSTONE_DIR/$ARCH'"
fi
echo "[*] '$ARCH' libcapstone available at '$CAPSTONE_DIR/$ARCH'"
abort 0
+5 -11
View File
@@ -15,14 +15,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -xu
set -xeu
# Search in $PATH
if [[ $(which ndk-build) != "" ]]; then
NDK=$(dirname $(which ndk-build))
else
echo "[-] Could not detect Android NDK dir"
exit 1
abort 1
fi
if ! echo "$ANDROID_API" | grep -qoE 'android-[0-9]{1,2}'; then
@@ -50,8 +50,6 @@ case "$2" in
;;
esac
ARCH="$2"
case "$ARCH" in
arm)
BRT_ARCH="armeabi-v7a"
@@ -80,15 +78,11 @@ $NDK/ndk-build NDK_PROJECT_PATH=$BRT_DIR APP_BUILD_SCRIPT=$BRT_DIR/Android.mk \
$NDK/ndk-build NDK_PROJECT_PATH=$BRT_DIR APP_BUILD_SCRIPT=$BRT_DIR/Android.mk \
APP_PLATFORM=$ANDROID_API APP_ABI=$BRT_ARCH \
NDK_TOOLCHAIN=$BRT_TOOLCHAIN
if [ $? -ne 0 ]; then
echo "[-] Compilation failed"
exit 1
else
echo "[*] '$ARCH' libBlocksRuntime available at '$BRT_DIR/$ARCH'"
fi
echo "[*] '$ARCH' libBlocksRuntime available at '$BRT_DIR/$ARCH'"
# Change workdir to simplify args
cd $BRT_DIR
cd "$BRT_DIR"
# Revert workdir to caller
cd - &>/dev/null
+2 -20
View File
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -xu
set -xeu
abort() {
cd - &>/dev/null
@@ -34,16 +34,12 @@ fi
readonly LIBUNWIND_DIR="$1"
if [ ! -d "$LIBUNWIND_DIR/.git" ]; then
git submodule update --init third_party/android/libunwind || {
echo "[-] git submodules init failed"
exit 1
}
git submodule update --init third_party/android/libunwind
fi
# Change workspace
cd "$LIBUNWIND_DIR" &>/dev/null
# Search in $PATH
if [[ $(which ndk-build) != "" ]]; then
NDK=$(dirname $(which ndk-build))
else
@@ -94,26 +90,12 @@ fi
if [ ! -f configure ]; then
autoreconf -i
if [ $? -ne 0 ]; then
echo "[-] autoreconf failed"
abort 1
fi
else
make clean
fi
./configure "--host=$TOOLCHAIN" --disable-coredump --enable-static --disable-shared --disable-tests --enable-ptrace
if [ $? -ne 0 ]; then
echo "[-] configure failed"
abort 1
fi
make -j LDFLAGS="$LC_LDFLAGS"
if [ $? -ne 0 ]; then
echo "[-] Compilation failed"
cd - &>/dev/null
abort 1
fi
# Naming conventions for arm64
if [[ "$ARCH" == "arm64" ]]; then