README.md: rewrite to describe Dockerfile builds

Change-Id: Ibfdd36f306d9a52f226904aa99653dc1b932410b
Reviewed-on: https://go-review.googlesource.com/1289
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
David Crawshaw 2014-12-10 13:24:12 -05:00
parent 32030f7750
commit ce2d014f4a
2 changed files with 48 additions and 69 deletions

69
README
View File

@ -1,69 +0,0 @@
The go.mobile repository holds libraries and build tools for Go on Android.
This is early stage work. The build system integration is not ready.
For now,
1. Install the Android SDK, either standalone or via Android Studio.
2. Install the Android NDK.
3. Pick a home for the standalone NDK toolchain and set an environment variable:
NDK_ROOT=$HOME/android/ndk-toolchain
4. Confiure the NDK toolchain:
ndk/build/tools/make-standalone-toolchain.sh \
--platform=android-9 --install-dir=$NDK_ROOT
5. Install a Go cross-compiler from the unstable development branch:
hg clone https://code.google.com/p/go
cd go/src
CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash
More details about installing from source are available at
https://golang.org/doc/install/source.
6. Use the Go tool installed in the go/bin created above.
For simplicity, put it on your path.
From here, there are two kinds of Android projects you can build,
Android apps written in Java with Go libraries, and Android apps
built entirely in Go. The first lets you use standard Android UI
libraries from Java, the second gives you only OpenGL, but an
entirely Go development environment.
Go library in an Android app - via ant/build.xml
-------------
Apps are written in Java, developed using the standard Android
tools, that include a Go library for added functionality. There is an
example of such a library in go.mobile/example/libhello.
Use the all.bash script in the libhello directory to build and run it.
More details on the build process are in libhello/README.
Go library in an Android app - via gradle
-------------
Coming soon.
For now, create an app in Android Studio, build the .so file in the
same way it is in the ant/build.xml examples and copy it into
YourApp/src/main/jniLibs/armeabi/libgojni.so.
Go Android apps (games)
-------------
Go Android apps are built on top of the NDK's NativeActivity. These apps
are written entirely in Go. An example of such an app, with touch events
and OpenGL, is in go.mobile/example/basic.
To build and deploy the app to the device currently attached to adb,
use the all.bash script in the example's directory. It requires
ndk-build, ant, and adb on your PATH.
APIs are currently very limited, but under active development.
To submit changes to this repository, see http://golang.org/doc/contribute.html.

48
README.md Normal file
View File

@ -0,0 +1,48 @@
# Go support for Mobile devices
The Go mobile repository holds packages and build tools for using Go on Android.
This is early work and the build system is a bumpy ride. Building a binary for
Android requires using a Go cross compiler and an external linker from the NDK.
For now, the easiest way to setup a build environment is using the provided
Dockerfile:
go get -d golang.org/x/mobile/...
docker build -t mobile $GOPATH/src/golang.org/x/mobile
In your app directory under your `$GOPATH`, copy the following files from either
the [golang.org/x/mobile/basic](https://github.com/golang/mobile/tree/master/example/basic)
or [golang.org/x/mobile/libhello](https://github.com/golang/mobile/tree/master/example/libhello)
apps:
AndroidManifest.xml
all.bash
build.xml
jni/Android.mk
make.bash
Start with `basic` if you are writing an all-Go application (that is, an OpenGL game)
or libhello if you are building a `.so` file for use from Java via
[gobind](https://godoc.org/golang.org/x/mobile/cmd/gobind). Edit the files to change
the name of your app.
To build, run:
docker run -v $GOPATH/src:/src mobile /bin/bash -c 'cd /src/your/project && ./make.bash'
When working with an all-Go application, this will produce a binary at
`$GOPATH/src/your/project/bin/name-debug.apk`. You can use the adb tool to install
and run this app. See all.bash for an example.
--
APIs are currently very limited, but under active development. Package
documentation serves as a starting point:
- [mobile/app](http://godoc.org/golang.org/x/mobile/app)
- [mobile/gl](http://godoc.org/golang.org/x/mobile/gl)
- [mobile/sprite](http://godoc.org/golang.org/x/mobile/sprite)
- [mobile/cmd/gobind](http://godoc.org/golang.org/x/mobile/cmd/gobind)
Contributions to Go are appreciated. See https://golang.org/doc/contribute.html.