1#!/bin/bash 2# Copyright (c) Facebook, Inc. and its affiliates. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -exo pipefail 17 18BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.." 19CMAKE=$ANDROID_HOME/cmake/3.18.1/bin/cmake 20export CXX=clang++ 21 22mkdir -p "$BASE_DIR/host-build-cmake" 23cd "$BASE_DIR/host-build-cmake" 24 25# Configure CMake project 26$CMAKE -DJAVA_HOME="$JAVA_HOME" .. 27# Build binaries and libraries 28make 29# Run C++ tests 30make test 31# LD_LIBRARY_PATH is needed for native library dependencies to load cleanly 32TEST_LD_LIBRARY_PATH="$BASE_DIR/host-build-cmake:$BASE_DIR/host-build-cmake/test/jni" 33# Build and run JNI tests 34cd "$BASE_DIR" 35env LD_LIBRARY_PATH="$TEST_LD_LIBRARY_PATH" ./gradlew -b host.gradle -PbuildDir=host-build-gradle test 36