aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-12-15 04:32:00 +0800
committerFelix Lange <fjl@twurst.com>2015-12-15 04:32:00 +0800
commit9c636d2490c4f88598752834cc3226902d198ced (patch)
tree81fa2ef7931fd9ed80a5bff0ecc064626a04b590 /cmd/geth
parentfa187a366dda1894179635eeec2a929bfacc4ad3 (diff)
parent03f090b30bdee27bfd8e45b0532b6674d808c8ae (diff)
downloaddexon-9c636d2490c4f88598752834cc3226902d198ced.tar
dexon-9c636d2490c4f88598752834cc3226902d198ced.tar.gz
dexon-9c636d2490c4f88598752834cc3226902d198ced.tar.bz2
dexon-9c636d2490c4f88598752834cc3226902d198ced.tar.lz
dexon-9c636d2490c4f88598752834cc3226902d198ced.tar.xz
dexon-9c636d2490c4f88598752834cc3226902d198ced.tar.zst
dexon-9c636d2490c4f88598752834cc3226902d198ced.zip
Merge pull request #2070 from karalabe/android-archives
Makefile, cmd/geth: support building Android archives
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/library_android.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/cmd/geth/library_android.go b/cmd/geth/library_android.go
new file mode 100644
index 000000000..fb021bfe0
--- /dev/null
+++ b/cmd/geth/library_android.go
@@ -0,0 +1,56 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
+// Contains specialized code for running Geth on Android.
+
+package main
+
+// #include <android/log.h>
+// #cgo LDFLAGS: -llog
+import "C"
+import (
+ "bufio"
+ "os"
+)
+
+func init() {
+ // Redirect the standard output and error to logcat
+ oldStdout, oldStderr := os.Stdout, os.Stderr
+
+ outRead, outWrite, _ := os.Pipe()
+ errRead, errWrite, _ := os.Pipe()
+
+ os.Stdout = outWrite
+ os.Stderr = errWrite
+
+ go func() {
+ scanner := bufio.NewScanner(outRead)
+ for scanner.Scan() {
+ line := scanner.Text()
+ C.__android_log_write(C.ANDROID_LOG_INFO, C.CString("Stdout"), C.CString(line))
+ oldStdout.WriteString(line + "\n")
+ }
+ }()
+
+ go func() {
+ scanner := bufio.NewScanner(errRead)
+ for scanner.Scan() {
+ line := scanner.Text()
+ C.__android_log_write(C.ANDROID_LOG_INFO, C.CString("Stderr"), C.CString(line))
+ oldStderr.WriteString(line + "\n")
+ }
+ }()
+}