1 #!/bin/bash 2 # Copyright 2015 The Gemmlowp Authors. All Rights Reserved. 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 16 if [ -z "$CXX" ] 17 then 18 echo "please set the CXX environment variable to point to your native Android toolchain C++ compiler" 19 exit 1 20 fi 21 22 default_cflags="-O3" 23 24 if [ "$#" -eq 0 ] 25 then 26 echo "Usage: $0 files... [cflags...]" 27 echo "All command-line parameters are passed along to the C++ compiler, so they can \ 28 be either source files, or compiler flags." 29 echo "Default cflags: $default_cflags" 30 echo "Relies on the CXX environment variable to point to an Android C++ toolchain compiler." 31 exit 1 32 fi 33 34 EXE=gemmlowp-android-binary 35 36 if [[ $CXX =~ .*aarch64.* ]] 37 then 38 NEON_FLAGS= 39 else 40 NEON_FLAGS="-mfpu=neon -mfloat-abi=softfp" 41 fi 42 43 $CXX \ 44 --std=c++11 \ 45 -Wall -Wextra -pedantic \ 46 -fPIE -pie $NEON_FLAGS \ 47 -lstdc++ -latomic \ 48 -I . -I .. \ 49 -o $EXE \ 50 -Wno-unused-variable -Wno-unused-parameter \ 51 $default_cflags \ 52 $* 53 54 if [ $? != 0 ]; then 55 echo "build failed" 56 exit 1 57 fi 58 59 adb root 60 61 if [ $? != 0 ]; then 62 echo "$0: adb root failed" 63 exit 1 64 fi 65 66 adb shell mkdir -p /data/local/tmp 67 68 if [ $? != 0 ]; then 69 echo "$0: adb shell failed to mkdir /data/local/tmp" 70 exit 1 71 fi 72 73 adb push $EXE /data/local/tmp 74 75 if [ $? != 0 ]; then 76 echo "$0: adb push failed to write to /data/local/tmp" 77 exit 1 78 fi 79 80 echo adb shell "/data/local/tmp/$EXE $TESTARGS" 81 82 adb shell "/data/local/tmp/$EXE $TESTARGS" | tee "log-$EXE" 83 84 if [ $? != 0 ]; then 85 echo "$0: adb shell failed to run binary on device" 86 exit 1 87 fi 88