這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
https://docs.google.com/document/d/1N3XyVkAP8nmWjASz8L_OjjnjVKxgeVBjIsTr5qIUcA4/edit?pli=1
摘要
我們計劃為Android平台引入GO支援。我們會關注於對用GO來開發遊戲提供支援。
背景
Android是為了運行APP而設計的作業系統。一個app依賴於更多的平台庫和服務(比傳統Unix作業系統),這意味著如果沒有新的API,Android上的GO運行時的一個連接埠,那將不會有多大用處。
提供一個Android平台的等價的GO是難以避免的。平台是用java寫的,有很多的api介面。任何用GO來封裝封裝這些API的嘗試都會得到一個不好的結果:手動編譯封裝會跟不上特色,自動產生封裝會導致醜陋的GO。無論哪種方法,都會很慢。
然而,在Android NDK中提供了用非常少的基於C的API寫的Android app子集:遊戲。編譯GO for Android來提供NDK的等效的特色是可行的。
建議
在GO 1.4周期裡,GOOS=android會引入到GO 倉庫,和Android支援cgo一起。Dalvik/ART-loadable .so檔案會用外部的Android NDK連結器來產生。
編譯面板方面,我們會維護一個交叉編譯器來在Linux主機上運行GO 工具,同時使用adb工具來在Android模擬器上運行測試二進位包。
我們會引入子倉庫,go.mobile,它包括:
二進位包會在工程穩定後發布。
附原文:
Go support for AndroidDavid CrawshawJune 2014AbstractWe propose to introduce Go support for the Android platform. The focus will be on supportinggames written in Go. The APIs will be those defined in the Android NDK.BackgroundAndroid is an operating system designed for running apps. An app relies on far more platformlibraries and services than are provided by a traditional Unix operating system, which means adirect port of the Go runtime to Android without new APIs would not be particularly useful.Providing a Go equivalent to the Android platform is intractable. The platform is written in Javaand has a huge API surface. Any attempt to wrap these APIs in Go would give an undesirableresult: manually built wrappers would lag in features, automatically generated wrappers wouldlead to ugly Go. And either way, it would be slow.There is however, a subset of Android apps written against a much smaller C-based APIsurface provided in the Android NDK: Games. It is feasible to build Go support for Androidproviding the equivalent features found in the NDK.ProposalDuring the Go 1.4 cycle, GOOS=android will be introduced to the Go repository, along with cgosupport on Android (contributed by Elias Naur). Dalvik/ART-loadable .so files will be producedusing the external linker provided in the Android NDK.For the build dashboard, we will maintain a cross-compiling builder that runs the Go tool on alinux host and uses the adb tool to run test binaries on a stock Android device.We will introduce a subrepository, go.mobile. It will house:● Bindings for OpenGL, OpenSL, and OpenMAX as exported through the Android NDK.● A Java -> Go language binding generator. Given a Go package, this will let Java codecall it, so game menu UIs can be built in the standard SDK. (As Go defines the binding, italso makes it possible to use the same code to bind to languages like Objective C.)● Android Studio build system integration.Binary releases will be provided after the project has stabilized.