OLD | NEW |
1 Sample Go application that can be loaded into a mojo shell running on Android. | 1 Sample Go application that can be loaded into a mojo shell running on Android. |
2 The application exports a MojoMain entry point for the shell and then makes | 2 The application exports a MojoMain entry point for the shell and then makes |
3 a GetTimeTicksNow system call. | 3 a GetTimeTicksNow system call. |
4 | 4 |
5 Setup instructions | 5 Setup instructions |
6 | 6 |
7 1) Generate the NDK toolchain for the android platform you plan to use. | 7 1) Generate the NDK toolchain for the android platform you plan to use. |
8 | 8 |
9 $ cd mojo/src/third_party/android_tools/ndk | 9 $ cd mojo/src/third_party/android_tools/ndk |
10 $ NDK_ROOT=$HOME/android/ndk-toolchain | 10 $ NDK_ROOT=$HOME/android/ndk-toolchain |
11 $ ./build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir
=$NDK_ROOT | 11 $ ./build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir
=$NDK_ROOT |
12 $ NDK_CC=$NDK_ROOT/bin/arm-linux-androideabi-gcc | 12 $ NDK_CC=$NDK_ROOT/bin/arm-linux-androideabi-gcc |
13 | 13 |
14 2) Download/Install the Go compiler. | 14 2) Download/Install the Go compiler. |
15 | 15 |
16 $ unset GOBIN GOPATH GOROOT | 16 $ unset GOBIN GOPATH GOROOT |
17 $ hg clone https://code.google.com/p/go | 17 $ hg clone https://code.google.com/p/go |
18 $ export GOROOT=`pwd`/go | 18 $ export GOROOT=`pwd`/go |
19 $ cd go/src | 19 $ cd go/src |
20 $ CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash | 20 $ CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash |
21 $ ls $GOROOT/bin/go | 21 $ ls $GOROOT/bin/go |
22 | 22 |
23 3) Now, we switch to the Mojo workspace and build the sample application. | 23 3) Now, we switch to the Mojo workspace and build the sample application. |
24 | 24 |
25 $ cd mojo/src | 25 $ cd mojo/src |
26 $ gn args <output_directory> | 26 $ build/install-build-deps-android.sh |
27 | 27 $ mojo/tools/mojob.py gn --android |
28 Set the following arguments | 28 This should show an error 'assert(go_build_tool != "")', now run |
| 29 $ gn args out/android_Debug |
| 30 And append two lines: |
29 mojo_use_go=true | 31 mojo_use_go=true |
30 go_build_tool="<path_to_go_binary>" | 32 go_build_tool="<path_to_go_binary>" |
31 os="android" | |
32 | 33 |
33 $ gn gen <output_directory> | 34 $ ninja -C out/android_Debug go_sample_app |
34 $ ninja -C <output_directory> go_sample_app | 35 |
| 36 To run the app: |
| 37 1) configure port forwarding 4444 -> localhost:4444 on android device or |
| 38 use 10.0.2.2 instead of 127.0.0.1 if you are running an android emulator |
| 39 2) open new terminal and run |
| 40 $ cd out/android_Debug |
| 41 $ python -m SimpleHTTPServer 4444 |
| 42 3) in the previous terminal run |
| 43 $ mojo/tools/android_mojo_shell.py --url-mappings="mojo:go_sample_app"="http://1
27.0.0.1:4444/obj/mojo/go/go_sample_app" "mojo:go_sample_app" |
| 44 |
| 45 More inforamtion about building mojo: https://github.com/domokit/mojo/blob/maste
r/README.md |
OLD | NEW |