summaryrefslogtreecommitdiff
path: root/src/androidtest.bash
diff options
context:
space:
mode:
authorDavid Crawshaw <david.crawshaw@zentus.com>2014-07-09 06:56:49 -0400
committerDavid Crawshaw <david.crawshaw@zentus.com>2014-07-09 06:56:49 -0400
commit4a3f61bf4a7ea11cb66bae75c981d552bb741cf4 (patch)
tree089d11370d9c41d7618b423f6363b1190c3dc2de /src/androidtest.bash
parentcd0dc4cecc7cc0dadbf112d8dd229ffba05b21a0 (diff)
downloadgo-4a3f61bf4a7ea11cb66bae75c981d552bb741cf4.tar.gz
androidtest.bash, misc/android: build scripts for android
LGTM=minux R=minux CC=golang-codereviews https://codereview.appspot.com/107640044
Diffstat (limited to 'src/androidtest.bash')
-rwxr-xr-xsrc/androidtest.bash54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/androidtest.bash b/src/androidtest.bash
new file mode 100755
index 000000000..ede085ef8
--- /dev/null
+++ b/src/androidtest.bash
@@ -0,0 +1,54 @@
+#/usr/bin/env bash
+# Copyright 2014 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# For testing Android.
+# The compiler runs locally, then a copy of the GOROOT is pushed to a
+# target device using adb, and the tests are run there.
+
+set -e
+ulimit -c 0 # no core files
+
+if [ ! -f make.bash ]; then
+ echo 'nacl.bash must be run from $GOROOT/src' 1>&2
+ exit 1
+fi
+
+if [ -z $GOOS ]; then
+ export GOOS=android
+fi
+if [ "$GOOS" != "android" ]; then
+ echo "androidtest.bash requires GOOS=android, got GOOS=$GOOS" 1>&2
+ exit 1
+fi
+
+export CGO_ENABLED=1
+
+# Run the build for the host bootstrap, so we can build go_android_exec.
+# Also lets us fail early before the (slow) adb push if the build is broken.
+./make.bash
+export GOROOT=$(dirname $(pwd))
+export PATH=$GOROOT/bin:$PATH
+GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build \
+ -o ../bin/go_android_${GOARCH}_exec \
+ ../misc/android/go_android_exec.go
+
+# Push GOROOT to target device.
+#
+# The adb sync command will sync either the /system or /data
+# directories of an android device from a similar directory
+# on the host. So we fake one with symlinks to push the GOROOT
+# into a subdirectory of /data.
+export ANDROID_PRODUCT_OUT=/tmp/androidtest-$$
+FAKE_GOROOT=$ANDROID_PRODUCT_OUT/data/local/tmp/goroot
+mkdir -p $FAKE_GOROOT/src
+ln -s $GOROOT/src/cmd $FAKE_GOROOT/src/cmd
+ln -s $GOROOT/src/pkg $FAKE_GOROOT/src/pkg
+ln -s $GOROOT/test $FAKE_GOROOT/test
+ln -s $GOROOT/lib $FAKE_GOROOT/lib
+adb sync data
+rm -rf "$ANDROID_PRODUCT_OUT"
+
+# Run standard build and tests.
+./all.bash --no-clean