Cody Northrop | 7199b12 | 2017-03-27 13:08:30 -0600 | [diff] [blame] | 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-23/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 | # |
Cody Northrop | 8efcadc | 2017-11-09 14:26:51 -0700 | [diff] [blame] | 62 | ./update_external_sources_android.sh --no-build |
Cody Northrop | 7199b12 | 2017-03-27 13:08:30 -0600 | [diff] [blame] | 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 | # |
| 74 | # build cube APKs (with and without layers) |
| 75 | # |
| 76 | ( |
| 77 | pushd $DEMO_BUILD_DIR |
| 78 | ndk-build -j $cores |
| 79 | # Package one APK without validation layers |
| 80 | mkdir -p $DEMO_BUILD_DIR/cube/bin/libs/lib |
| 81 | cp -r $DEMO_BUILD_DIR/libs/* $DEMO_BUILD_DIR/cube/bin/libs/lib/ |
| 82 | cd $DEMO_BUILD_DIR/cube |
| 83 | create_APK cube |
| 84 | # And one with validation layers |
| 85 | mkdir -p $DEMO_BUILD_DIR/cube-with-layers/bin/libs/lib |
| 86 | cp -r $DEMO_BUILD_DIR/libs/* $DEMO_BUILD_DIR/cube-with-layers/bin/libs/lib/ |
| 87 | cp -r $LAYER_BUILD_DIR/libs/* $DEMO_BUILD_DIR/cube-with-layers/bin/libs/lib/ |
| 88 | cd $DEMO_BUILD_DIR/cube-with-layers |
| 89 | create_APK cube-with-layers |
| 90 | popd |
| 91 | ) |
| 92 | |
| 93 | # |
| 94 | # build Smoke with layers |
| 95 | # |
| 96 | # TODO |
| 97 | |
| 98 | echo Builds succeeded |
| 99 | exit 0 |