aboutsummaryrefslogtreecommitdiff
path: root/go/android
diff options
context:
space:
mode:
Diffstat (limited to 'go/android')
-rwxr-xr-xgo/android/adb_shamu8
-rwxr-xr-xgo/android/adb_volantis8
-rwxr-xr-xgo/android/build_go26
-rwxr-xr-xgo/android/go_shamu11
-rwxr-xr-xgo/android/go_shamu_exec8
-rwxr-xr-xgo/android/go_volantis11
-rwxr-xr-xgo/android/go_volantis_exec8
-rwxr-xr-xgo/android/target_cp28
-rwxr-xr-xgo/android/target_sh13
-rwxr-xr-xgo/android/target_tmpdir5
10 files changed, 126 insertions, 0 deletions
diff --git a/go/android/adb_shamu b/go/android/adb_shamu
new file mode 100755
index 00000000..1c53ecc1
--- /dev/null
+++ b/go/android/adb_shamu
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# This wrapper runs adb with the serial number of the shamu device.
+# Replace XXXXXXXX with the actual serial number of the device.
+# This is just an example. Create one such wrapper for each Android
+# device used for running Go tests.
+
+exec adb -s XXXXXXXX "$@"
diff --git a/go/android/adb_volantis b/go/android/adb_volantis
new file mode 100755
index 00000000..4712eec2
--- /dev/null
+++ b/go/android/adb_volantis
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# This wrapper runs adb with the serial number of the volantis device.
+# Replace YYYYYYYY with the actual serial number of the device.
+# This is just an example. Create one such wrapper for each Android
+# device used for running Go tests.
+
+exec adb -s YYYYYYYY "$@"
diff --git a/go/android/build_go b/go/android/build_go
new file mode 100755
index 00000000..65b7ec2b
--- /dev/null
+++ b/go/android/build_go
@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e -o pipefail
+
+# This script builds the go cross compilers for Android targets.
+#
+# Usage: build_go
+#
+# It assumes that the "arm-linux-androideabi" toolchain is already installed.
+# It assumes that the "aarch64-linux-android" toolchain is already installed.
+
+if [[ ! -e "make.bash" && -e "src/make.bash" ]]
+then
+ cd src
+fi
+
+# Build the Go toolchain for arm devices.
+GOOS="android" GOARCH="arm" CGO_ENABLED="1" \
+ CC_FOR_TARGET="arm-linux-androideabi-gcc" \
+ CXX_FOR_TARGET="arm-linux-androideabi-g++" \
+ ./make.bash --no-clean
+
+# Build the Go toolchain for arm64 devices.
+GOOS="android" GOARCH="arm64" CGO_ENABLED="1" \
+ CC_FOR_TARGET="aarch64-linux-android-gcc" \
+ CXX_FOR_TARGET="aarch64-linux-android-g++" \
+ ./make.bash --no-clean
diff --git a/go/android/go_shamu b/go/android/go_shamu
new file mode 100755
index 00000000..7e1ffbea
--- /dev/null
+++ b/go/android/go_shamu
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Invoke the Go cross compiler for shamu.
+# Uses ../go_target to add PIE flags.
+#
+# This is just an example for an arm device.
+
+GOOS="android" GOARCH="arm" CGO_ENABLED="1" \
+ CC="arm-linux-androideabi-gcc" \
+ CXX="arm-linux-androideabi-g++" \
+ exec go_target "$@"
diff --git a/go/android/go_shamu_exec b/go/android/go_shamu_exec
new file mode 100755
index 00000000..2c169026
--- /dev/null
+++ b/go/android/go_shamu_exec
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Copy and remotely execute a binary on the shamu device.
+#
+# For this to work, the corresponding adb_shamu wrapper
+# must exist to tell adb the serial number of the device.
+
+GOOS="android" GOARCH="arm" exec go_target_exec shamu "$@"
diff --git a/go/android/go_volantis b/go/android/go_volantis
new file mode 100755
index 00000000..bfeab196
--- /dev/null
+++ b/go/android/go_volantis
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Invoke the Go cross compiler for volantis.
+# Uses ../go_target to add PIE flags.
+#
+# This is just an example for an arm64 device.
+
+GOOS="android" GOARCH="arm64" CGO_ENABLED="1" \
+ CC="aarch64-linux-android-gcc" \
+ CXX="aarch64-linux-android-g++" \
+ exec go_target "$@"
diff --git a/go/android/go_volantis_exec b/go/android/go_volantis_exec
new file mode 100755
index 00000000..86cb2cfb
--- /dev/null
+++ b/go/android/go_volantis_exec
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Copy and remotely execute a binary on the volantis device.
+#
+# For this to work, the corresponding adb_volantis wrapper
+# must exist to tell adb the serial number of the device.
+
+GOOS="android" GOARCH="arm64" exec go_target_exec volantis "$@"
diff --git a/go/android/target_cp b/go/android/target_cp
new file mode 100755
index 00000000..8a311534
--- /dev/null
+++ b/go/android/target_cp
@@ -0,0 +1,28 @@
+#!/bin/bash
+set -e -o pipefail
+
+# Copy a file or directory to the target Android device.
+#
+# Usage: target_cp <src> <target>:<dest>
+
+src="$1"
+shift
+
+targetdest="$1"
+shift
+
+target="${targetdest%:*}"
+dest="${targetdest#*:}"
+
+if [[ -z "${src}" || -z "${target}" || -z "${dest}" || "${targetdest}" != "${target}:${dest}" || -n "$*" ]]
+then
+ echo "Usage: target_cp <src> <target>:<dest>"
+ exit 1
+fi
+
+if [[ -d ${src} ]]
+then
+ adb_${target} push ${src} ${dest}/${src##*/} 2>/dev/null
+else
+ adb_${target} push ${src} ${dest} 2>/dev/null
+fi
diff --git a/go/android/target_sh b/go/android/target_sh
new file mode 100755
index 00000000..241843e8
--- /dev/null
+++ b/go/android/target_sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e -o pipefail
+
+# Run a command on the target Android device.
+#
+# Usage: target_sh <cmd> <args>...
+
+target="$1"
+shift
+
+exitcode="$(target_tmpdir)/exitcode"
+adb_${target} shell "$*; echo -n \$? > ${exitcode}" | sed -e 's:\r$::' -u
+exit $(adb_${target} shell "cat ${exitcode}")
diff --git a/go/android/target_tmpdir b/go/android/target_tmpdir
new file mode 100755
index 00000000..b5953696
--- /dev/null
+++ b/go/android/target_tmpdir
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# Temporary directory to be used on Android devices.
+
+echo "/data/local/tmp"