1#!/bin/bash 2# Update source for glslang, spirv-tools, shaderc 3 4# Copyright 2016 The Android Open Source Project 5# Copyright (C) 2015 Valve Corporation 6# 7# Licensed under the Apache License, Version 2.0 (the "License"); 8# you may not use this file except in compliance with the License. 9# You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, software 14# distributed under the License is distributed on an "AS IS" BASIS, 15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16# See the License for the specific language governing permissions and 17# limitations under the License. 18 19set -e 20 21ANDROIDBUILDDIR=$PWD 22BUILDDIR=$ANDROIDBUILDDIR 23BASEDIR=$BUILDDIR/third_party 24 25if [[ $(uname) == "Linux" ]]; then 26 cores="$(nproc || echo 4)" 27elif [[ $(uname) == "Darwin" ]]; then 28 cores=$(sysctl -n hw.ncpu) 29fi 30 31# 32# Parse parameters 33# 34 35function printUsage { 36 echo "Supported parameters are:" 37 echo " --abi <abi> (optional)" 38 echo " --no-build (optional)" 39 echo 40 echo "i.e. ${0##*/} --abi arm64-v8a \\" 41 exit 1 42} 43 44while [[ $# -gt 0 ]] 45do 46 case $1 in 47 --abi) 48 abi="$2" 49 shift 2 50 ;; 51 --no-build) 52 nobuild=1 53 shift 1 54 ;; 55 *) 56 # unknown option 57 echo Unknown option: $1 58 echo 59 printUsage 60 exit 1 61 ;; 62 esac 63done 64 65echo abi=$abi 66if [[ -z $abi ]] 67then 68 echo No abi provided, so building for all supported abis. 69fi 70 71 72 73 74echo no-build=$nobuild 75if [[ $nobuild ]] 76then 77 echo Skipping build. 78fi 79 80function build_shaderc () { 81 echo "Building $BASEDIR/shaderc" 82 cd $BASEDIR/shaderc/android_test 83 if [[ $abi ]]; then 84 ndk-build NDK_APPLICATION_MK=../../../jni/shaderc/Application.mk THIRD_PARTY_PATH=../third_party APP_ABI=$abi -j $cores; 85 else 86 ndk-build NDK_APPLICATION_MK=../../../jni/shaderc/Application.mk THIRD_PARTY_PATH=../third_party -j $cores; 87 fi 88} 89 90# Pull down or update external dependencies 91echo "Update external dependencies based on the $ANDROIDBUILDDIR/known_good.json file" 92python3 ../scripts/update_deps.py --no-build --dir $BASEDIR --known_good_dir $BUILDDIR 93 94if [[ -z $nobuild ]] 95then 96build_shaderc 97fi 98 99echo "" 100echo "${0##*/} finished." 101 102