go 1.4支持Android的说明(译文)


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,它包括:

  • 绑定OPENGL OpenSL 和OpenMax

  • java->GO绑定器。给定一个Go包,这会使得让Java代码调用它,这样游戏菜单UI可以用标准sdk来编译。(因为go定义了绑定,这也使得使用同样的代码来绑定像Objective C语言成为可能)

  • Android studio编译系统集成

二进制包会在工程稳定后发布。


附原文:

Go support for Android
David Crawshaw
June 2014
Abstract
We propose to introduce Go support for the Android platform. The focus will be on supporting
games written in Go. The APIs will be those defined in the Android NDK.
Background
Android is an operating system designed for running apps. An app relies on far more platform
libraries and services than are provided by a traditional Unix operating system, which means a
direct 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 Java
and has a huge API surface. Any attempt to wrap these APIs in Go would give an undesirable
result: manually built wrappers would lag in features, automatically generated wrappers would
lead 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 API
surface provided in the Android NDK: Games. It is feasible to build Go support for Android
providing the equivalent features found in the NDK.
Proposal
During the Go 1.4 cycle, GOOS=android will be introduced to the Go repository, along with cgo
support on Android (contributed by Elias Naur). Dalvik/ART-loadable .so files will be produced
using 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 a
linux 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 code
call it, so game menu UIs can be built in the standard SDK. (As Go defines the binding, it
also 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.


转载于:https://my.oschina.net/itfanr/blog/355177

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值