1 #!/bin/bash 2 3 # Copyright 2017 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 if [ -z "${ANDROID_SDK_HOME}" ]; 18 then echo "Please set ANDROID_SDK_HOME, exiting"; exit 1; 19 else echo "ANDROID_SDK_HOME is ${ANDROID_SDK_HOME}"; 20 fi 21 22 if [ -z "${ANDROID_NDK_HOME}" ]; 23 then echo "Please set ANDROID_NDK_HOME, exiting"; exit 1; 24 else echo "ANDROID_NDK_HOME is ${ANDROID_NDK_HOME}"; 25 fi 26 27 if [[ $(uname) == "Linux" ]]; then 28 cores=$(nproc) || echo 4 29 elif [[ $(uname) == "Darwin" ]]; then 30 cores=$(sysctl -n hw.ncpu) || echo 4 31 fi 32 33 function findtool() { 34 if [[ ! $(type -t $1) ]]; then 35 echo Command $1 not found, see ../BUILD.md; 36 exit 1; 37 fi 38 } 39 40 # Check for dependencies 41 findtool aapt 42 findtool zipalign 43 findtool jarsigner 44 45 set -ev 46 47 LAYER_BUILD_DIR=$PWD 48 DEMO_BUILD_DIR=$PWD/../demos/android 49 echo LAYER_BUILD_DIR="${LAYER_BUILD_DIR}" 50 echo DEMO_BUILD_DIR="${DEMO_BUILD_DIR}" 51 52 function create_APK() { 53 aapt package -f -M AndroidManifest.xml -I "$ANDROID_SDK_HOME/platforms/android-26/android.jar" -S res -F bin/$1-unaligned.apk bin/libs 54 # update this logic to detect if key is already there. If so, use it, otherwise create it. 55 jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android bin/$1-unaligned.apk androiddebugkey 56 zipalign -f 4 bin/$1-unaligned.apk bin/$1.apk 57 } 58 59 # 60 # build layers 61 # 62 ./update_external_sources_android.sh --no-build 63 ./android-generate.sh 64 ndk-build -j $cores 65 66 # 67 # build VulkanLayerValidationTests APK 68 # 69 mkdir -p bin/libs/lib 70 cp -r $LAYER_BUILD_DIR/libs/* $LAYER_BUILD_DIR/bin/libs/lib/ 71 create_APK VulkanLayerValidationTests 72 73 echo Builds succeeded 74 exit 0 75