Path: blob/main/kokoro/ndk-build/build-docker.sh
1560 views
#!/bin/bash1# Copyright (c) 2018 Google LLC.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14#15# Linux Build Script.1617# Fail on any error.18set -e19# Display commands being run.20set -x2122# This is required to run any git command in the docker since owner will23# have changed between the clone environment, and the docker container.24# Marking the root of the repo as safe for ownership changes.25git config --global --add safe.directory $ROOT_DIR2627. /bin/using.sh # Declare the bash `using` function for configuring toolchains.2829cd $ROOT_DIR3031function clean_dir() {32dir=$133if [[ -d "$dir" ]]; then34rm -fr "$dir"35fi36mkdir "$dir"37}3839# Get source for dependencies, as specified in the DEPS file40/usr/bin/python3 utils/git-sync-deps --treeless4142using ndk-r25c4344clean_dir "$ROOT_DIR/build"45cd "$ROOT_DIR/build"4647function do_ndk_build () {48echo $(date): Starting ndk-build $@...49$ANDROID_NDK_HOME/ndk-build \50-C $ROOT_DIR/android_test \51NDK_PROJECT_PATH=. \52NDK_LIBS_OUT=./libs \53NDK_APP_OUT=./app \54V=1 \55SPVTOOLS_LOCAL_PATH=$ROOT_DIR/third_party/spirv-tools \56SPVHEADERS_LOCAL_PATH=$ROOT_DIR/third_party/spirv-headers \57-j8 $@58}5960# Builds all the ABIs (see APP_ABI in jni/Application.mk)61do_ndk_build6263# Check that libshaderc_combined builds64# Explicitly set each ABI, otherwise it will only pick x86.65# It seems to be the behaviour when specifying an explicit target.66for abi in x86 x86_64 armeabi-v7a arm64-v8a; do67do_ndk_build APP_ABI=$abi libshaderc_combined68done6970echo $(date): ndk-build completed.717273