blob: e1cada878261dcf53d7f8dedab09605a71146a3b [file] [log] [blame]
Cody Northrop7199b122017-03-27 13:08:30 -06001#!/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-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#
62./update_external_sources_android.sh
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
73#
74# build cube APKs (with and without layers)
75#
76(
77pushd $DEMO_BUILD_DIR
78ndk-build -j $cores
79# Package one APK without validation layers
80mkdir -p $DEMO_BUILD_DIR/cube/bin/libs/lib
81cp -r $DEMO_BUILD_DIR/libs/* $DEMO_BUILD_DIR/cube/bin/libs/lib/
82cd $DEMO_BUILD_DIR/cube
83create_APK cube
84# And one with validation layers
85mkdir -p $DEMO_BUILD_DIR/cube-with-layers/bin/libs/lib
86cp -r $DEMO_BUILD_DIR/libs/* $DEMO_BUILD_DIR/cube-with-layers/bin/libs/lib/
87cp -r $LAYER_BUILD_DIR/libs/* $DEMO_BUILD_DIR/cube-with-layers/bin/libs/lib/
88cd $DEMO_BUILD_DIR/cube-with-layers
89create_APK cube-with-layers
90popd
91)
92
93#
94# build Smoke with layers
95#
96# TODO
97
98echo Builds succeeded
99exit 0