From 3296ca83f11339e90d6e774fdd98480b4373b7fb Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 22 Dec 2014 09:25:27 +0100 Subject: [PATCH] Improve check_tools script --- check_tools.sh | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/check_tools.sh b/check_tools.sh index 9946c1fff..4c46e7aad 100755 --- a/check_tools.sh +++ b/check_tools.sh @@ -1,37 +1,37 @@ -#!/bin/bash +#!/bin/sh rm -f check_tools.mk touch check_tools.mk -# Check java -JAVA=\"$(which java)\" -if [ -z ${JAVA} ]; then - echo "Could not find java. Please install java"; - exit -1; +error_on_quit=0 + +check_installed() { + if [ -z "$(which $1)" ]; then + echo "Could not find $1. Please install $2." + error_on_quit=1 + return 1 + fi + return 0 +} + + +check_installed "java" "it" +check_installed "ant" "it" +check_installed "yasm" "it" +check_installed "nasm" "it" +check_installed "ndk-build" "android NDK" +if check_installed "android" "android SDK"; then + check_installed "adb" "android SDK platform tools" + # check that at least one target is installed + if [ -z "$(android list target -c)" ]; then + echo "Install at least one android target in android SDK" + error_on_quit=1 + fi fi -# Check antlr -ANTLR="${JAVA} -jar \"submodules/externals/antlr3/antlr-3.2.jar\""; - -# Check NDK -NDK=$(which ndk-build) -if [ -z ${NDK} ]; then - echo "Could not find ndk-build. Please install android ndk"; - exit -1; +if [ $error_on_quit = 0 ]; then + echo "JAVA=\"$(which java)\"" >> check_tools.mk + echo "ANTLR=\"$(which java)\" -jar \"submodules/externals/antlr3/antlr-3.2.jar\"" >> check_tools.mk fi -# Check SDK -SDK=$(which android) -if [ -z ${SDK} ]; then - echo "Could not find android. Please install android sdk"; - exit -1; -fi - -SDK_PLATFORM_TOOLS=$(which adb) -if [ -z ${SDK_PLATFORM_TOOLS} ]; then - echo "Could not find adb. Please install android sdk platform tools"; - exit -1; -fi - -echo JAVA=${JAVA} >> check_tools.mk -echo ANTLR=${ANTLR} >> check_tools.mk +exit $error_on_quit