• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17if [ -z "$CXX" ]
18then
19  echo "please set the CXX environment variable to point to your native Android toolchain C++ compiler"
20  exit 1
21fi
22
23default_cflags="-O3"
24
25if [ "$#" -eq 0 ]
26then
27  echo "Usage: $0 files... [cflags...]"
28  echo "All command-line parameters are passed along to the C++ compiler, so they can \
29be 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
33fi
34
35EXE=gemmlowp-android-binary
36
37if [[ $CXX =~ .*aarch64.* ]]
38then
39  NEON_FLAGS=
40else
41  NEON_FLAGS="-mfpu=neon -mfloat-abi=softfp"
42fi
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
55if [ $? != 0 ]; then
56  echo "build failed"
57  exit 1
58fi
59
60adb root
61
62if [ $? != 0 ]; then
63  echo "$0: adb root failed"
64  exit 1
65fi
66
67adb shell mkdir -p /data/local/tmp
68
69if [ $? != 0 ]; then
70  echo "$0: adb shell failed to mkdir /data/local/tmp"
71  exit 1
72fi
73
74adb push $EXE /data/local/tmp
75
76if [ $? != 0 ]; then
77  echo "$0: adb push failed to write to /data/local/tmp"
78  exit 1
79fi
80
81echo adb shell "/data/local/tmp/$EXE $TESTARGS"
82
83adb shell "/data/local/tmp/$EXE $TESTARGS" | tee "log-$EXE"
84
85if [ $? != 0 ]; then
86  echo "$0: adb shell failed to run binary on device"
87  exit 1
88fi
89