• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17if [ -z "${ANDROID_SDK_HOME}" ];
18then echo "Please set ANDROID_SDK_HOME, exiting"; exit 1;
19else echo "ANDROID_SDK_HOME is ${ANDROID_SDK_HOME}";
20fi
21
22if [ -z "${ANDROID_NDK_HOME}" ];
23then echo "Please set ANDROID_NDK_HOME, exiting"; exit 1;
24else echo "ANDROID_NDK_HOME is ${ANDROID_NDK_HOME}";
25fi
26
27if [[ $(uname) == "Linux" ]]; then
28    cores=$(nproc) || echo 4
29elif [[ $(uname) == "Darwin" ]]; then
30    cores=$(sysctl -n hw.ncpu) || echo 4
31fi
32
33function 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
41findtool aapt
42findtool zipalign
43findtool jarsigner
44
45set -ev
46
47LAYER_BUILD_DIR=$PWD
48DEMO_BUILD_DIR=$PWD/../demos/android
49echo LAYER_BUILD_DIR="${LAYER_BUILD_DIR}"
50echo DEMO_BUILD_DIR="${DEMO_BUILD_DIR}"
51
52function 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
64ndk-build -j $cores
65
66#
67# build VulkanLayerValidationTests APK
68#
69mkdir -p bin/libs/lib
70cp -r $LAYER_BUILD_DIR/libs/* $LAYER_BUILD_DIR/bin/libs/lib/
71create_APK VulkanLayerValidationTests
72
73echo Builds succeeded
74exit 0
75