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