Commit Graph

399 Commits

Author SHA1 Message Date
David Crawshaw f02d32beeb event: add String method to LifecycleStage enum
Change-Id: Iaa723e8db258540d60170216430295ac9dee1901
Reviewed-on: https://go-review.googlesource.com/11813
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-01 05:20:26 +00:00
David Crawshaw e19b161d0d cmd/gomobile: report errors from go install std
While here, make the output of -v easier to read.

Fixes golang/go#11295, golang/go#11296.

Change-Id: I51974a3443bb60a5c0bb77ac784e48987eee8391
Reviewed-on: https://go-review.googlesource.com/11814
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-01 05:19:37 +00:00
Nigel Tao c2c03d3a71 asset: add missing copyright header, fix typo.
Change-Id: I86feab77d053d384af74219df371b31a7f5d82f0
Reviewed-on: https://go-review.googlesource.com/11823
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-01 00:10:52 +00:00
David Crawshaw e7a7f32e55 asset: wrong package name
Not part of, but mentioned on golang/go#11424.

Change-Id: I9d9289a67592aa43bcd55e073d8f3b29daa93056
Reviewed-on: https://go-review.googlesource.com/11735
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-06-30 23:51:02 +00:00
Nigel Tao c7c93d6952 app/debug: move to exp/app/debug.
Change-Id: I97f3585ff155e8c5b95c5bb32cfa793980c81a9a
Reviewed-on: https://go-review.googlesource.com/11821
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-30 23:41:11 +00:00
Nigel Tao a5abc28279 app: consolidate multiple cgo directives into one.
Change-Id: Ie65251fe24063096cd95645089a222b597f3bd8b
Reviewed-on: https://go-review.googlesource.com/11666
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-30 23:04:34 +00:00
Nigel Tao 8de8fcfbf7 app/debug, exp/font: remove the freetype dependency.
Change-Id: Id71acfeb605995d8caf947d996a1375335410e08
Reviewed-on: https://go-review.googlesource.com/11668
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-30 23:03:35 +00:00
Burcu Dogan 3522bcc2e0 asset: add missing license header
Change-Id: Ife81591606a2fadcc216eae0ea17d772b3757cf7
Reviewed-on: https://go-review.googlesource.com/11736
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-30 17:31:44 +00:00
Burcu Dogan 52ece69162 gitignore: add apk and app to the ignore list
Change-Id: Ie9150aded0ebefd0d6f63e0acdb7b8c06773125f
Reviewed-on: https://go-review.googlesource.com/11586
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-30 15:15:53 +00:00
Burcu Dogan 86a5c4ee9b cmd/gomobile: remove obsolete TODOs
Change-Id: Iad4da95329c6f0d446f82a815bf84ae9bb54312c
Reviewed-on: https://go-review.googlesource.com/11732
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-30 15:15:46 +00:00
Burcu Dogan 383ad68fc0 exp/audio: APIs should not use Context pointer type
This CL is a followup of CL/11315 where it is suggested to remove
Context pointer types from the signatures.

Change-Id: Ice68bfabad0e345f7d93102257a99402be8760b5
Reviewed-on: https://go-review.googlesource.com/11560
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-30 06:09:10 +00:00
Nigel Tao d06bbc53e4 exp/audio/al: use the standard log library, if al_init fails.
This means that there's only one adb log prefix that Go app developers
need to watch: GoLog.

Change-Id: I562566b92a7bba19f7c7a9cc71315bea02844db1
Reviewed-on: https://go-review.googlesource.com/11609
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-06-30 06:08:38 +00:00
Nigel Tao 4f45fb5d7f app: remove some unnecessary logging.
Change-Id: Idf0e03e90a9cc2a497c4ac6ebde7a842d5f0a81b
Reviewed-on: https://go-review.googlesource.com/11606
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-30 03:36:16 +00:00
David Crawshaw 8bb4ca139b asset: move app.Open to its own package
This does not break the dependency on the app package's AndroidContext
for loading assets on android. A potential answer for gobind-based
apps: add a SetAndroidContext method to app.Context. But I'll explore
that separately after the long weekend.

Change-Id: I812f899740e288c379eee7900f42d9d53926d4ce
Reviewed-on: https://go-review.googlesource.com/11675
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 21:49:28 +00:00
David Crawshaw 743b9bfd9a cmd/gomobile: simplify init
The Go toolchain used to require that we rebuild the compiler and
friends (the cgo command) when building a cgo-enabled cross compiler.
This meant that gomobile init used to invoke make.bash in a temporary
copy of the GOROOT. This works, but brings with it several
complications, including needing to use -toolexec when invoking the
go tool, finding a boostrap copy of Go 1.4, long initialization
times, and a variety of unusual failure modes.

Fortunately we don't need our own compiler any more. All that's
necessary is building the standard library for the cross-compilation
targets and making sure the right C compiler is used when calling
go build (as it always was). This means most of the initialization
process can be replaced with a carefully invoked 'go install std'.

While here, remove the source install instructions (most of it is
documented already, and the final step, choosing the right git
revision should be within the skills of anyone using pre-release
software.) Some other documentation is changing because it's been a
while since go generate was run.

Change-Id: I88c10fef87867536e83c7df063ae7241b2e9eea4
Reviewed-on: https://go-review.googlesource.com/11711
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 20:40:46 +00:00
Burcu Dogan d1e52bb351 cmd/gomobile: enable target=ios builds
This CL adds iOS build support to gomobile command.

  $ gomobile build golang.org/x/mobile/example/basic

gomobile builds an .app file that is signed with the development
provisioning entities.

You may deploy .app files to your test device or convert them to IPA
to publish on App Store or share them as an AdHoc distribution.

target=ios flag requires a Darwin host machine.

Fixes golang/go#11043.

Change-Id: Ibc23b6d355f10b09940b20c813eb73d0f4313851
Reviewed-on: https://go-review.googlesource.com/11587
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-29 20:16:57 +00:00
Burcu Dogan ef2d0c9811 cmd/gomobile: ios builds should be achievable without an assets dir
Fixes golang/go#11445.

Change-Id: Ie1eb6df1501aeb651439711d08f2a7505b386614
Reviewed-on: https://go-review.googlesource.com/11585
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 18:34:58 +00:00
Burcu Dogan 8cac158036 cmd/gomobile: rewrite to output .app even it already exists
Fixes golang/go#11446.

Change-Id: I578bb0c6f09ea35abe56ddb8310fac85bfa20c97
Reviewed-on: https://go-review.googlesource.com/11583
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-29 17:35:19 +00:00
Burcu Dogan b9ad843048 cmd/gomobile: rename pkgImportsAudio to pkgImportsAL
We are determining whether to add libopenal.so dependending on the
al package imports. The names must suggest we are looking for the
al package rather than the audio.

Change-Id: Ib6896302238ff1ebe135f004b134911a0c340821
Reviewed-on: https://go-review.googlesource.com/11680
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-29 17:26:34 +00:00
Burcu Dogan beece5b2b6 cmd/gomobile: fix CC, CXX compliers for ios builds
Fixes #golang/go#11339.

Change-Id: Ib6069d8471332a80251bea6e8740fc7a96a16404
Reviewed-on: https://go-review.googlesource.com/11614
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-29 15:07:58 +00:00
David Crawshaw 8144405762 app, bind: separate the app package from gobind
Historically, the app package implemented Go runtime initialization.
This was convoluted, so the package was used both by all-Go apps
(currently based on Android's NativeActivity) and bind-based apps.

With Go 1.5 we have -buildmode=c-shared, which does a lot of the work
of the old app package. That code was removed a while back, but both
all-Go and gobind-based apps still used package app. The intermingled
initialization processes led to some strange states.

This CL separates gobind-based apps completely from the app package.
As part of that users are now expected to use System.loadLibrary
themselves. (A future CL may want to make the loadLibrary call part
of the .aar generated by gomobile bind.)

Delete the libhello example, which has been replaced by gomobile bind,
which could do with its own example at some point. Also delete the
libhellojni example, which now has nothing to do with the x/mobile
repository.

Change-Id: I444397f246dbafe81e5c53532eb482c197d26f70
Reviewed-on: https://go-review.googlesource.com/11654
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 11:40:40 +00:00
David Crawshaw 20f0df5da5 app: darwin/arm{,64} event model implementation
Change-Id: Ie04a58ac090d8916463586b5fadb14c5539a21dd
Reviewed-on: https://go-review.googlesource.com/11640
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-29 11:38:56 +00:00
David Crawshaw 9ed16d2774 app: leave GL buffer clearing to clients
It is already done in our examples and is missing from the linux/x11
implementation. If memory serves this is just long-standing
debugging cruft.

Change-Id: I1919a8704b11502fe8f402e3840bc5a1cd8b16e3
Reviewed-on: https://go-review.googlesource.com/11655
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-29 11:10:40 +00:00
Nigel Tao 4dd66723b0 cmd/gomobile: have pkgImportsAudio look for exp/audio/al, not exp/audio.
An app could conceivably import the former without importing the latter.

Change-Id: I7b0e13fe7d9e6d9e586fa2edf00811330be2a9b7
Reviewed-on: https://go-review.googlesource.com/11607
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 04:41:45 +00:00
Nigel Tao d1d3d8a5a0 exp/audio/al: delete a debugging log message.
This was accidentally introduced in
https://go-review.googlesource.com/#/c/11351/

Change-Id: Icc9bc9ccb97e48d376e0da440b72631e605a0a15
Reviewed-on: https://go-review.googlesource.com/11608
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-29 04:33:40 +00:00
Nigel Tao b6ec031d27 exp/audio/al: call log.Fatalf for a dlsym failure.
Change-Id: I197e101f2b93c2aa9dc69cb697afa68a69142783
Reviewed-on: https://go-review.googlesource.com/11537
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-06-29 01:50:48 +00:00
David Crawshaw d1958fa5cf app: remove error return from Main
Move runtime.LockOSThread from the portable Main to the
platform-specific android main. For darwin, calling LockOSThread in
Main is too late, there has been enough time for the goroutine
calling it to jump off the initial OS thread. For darwin we call
LockOSThread from an init function, which the runtime keeps on the
first thread. For Android we call LockOSThread only to maintain the
thread-local storage for the GL context that is created later, so
it is safe to call it from func main.

Also remove TODOs about starting a gobind app on Android, which
will be simplified in a followup CL.

Tested on darwin/amd64 and android. Not tested on X11.

Change-Id: I34c56abf8b1292959d4d508bfade287d196c0380
Reviewed-on: https://go-review.googlesource.com/11653
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-28 03:06:59 +00:00
David Crawshaw 9cc656ecd6 app: darwin/amd64 event model implementation
Change-Id: I16d706131508bd27415f26c6bbb64210e0af2819
Reviewed-on: https://go-review.googlesource.com/11620
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-27 19:19:22 +00:00
Nigel Tao 42f0d17876 app: use one thread for both GL and other UI C code.
This change will break Darwin. I have only built and tested this on
desktop linux and Android linux. A follow-up CL will fix Darwin.

Currently, OpenGL gets its own thread, and UI C code (e.g. the Android
event loop, or the X11 event loop) gets its own thread. This relies on
multiple system-provided UI-related C libraries working nicely together,
even when running on different threads. Keeping all the C code on the
one thread seems more sound.

As side-effects:
  - In package app/debug, DrawFPS now takes an explicit Config.
  - In package app, some callbacks now take an explicit Config.
  - In package exp/sprite, Render now takes an explicit Config.
  - In package event, there are new events (Config, Draw, Lifecycle),
    and an event filter mechanism to replace multiple app Callbacks.
  - In package geom, the deprecated Width, Height and PixelsPerPt global
    variables were removed in favor of an event.Config that is
    explicitly passed around (and does not require mutex-locking).
    Converting a geom.Pt to pixels now requires passing a pixelsPerPt.
  - In package gl, the Do, Start and Stop functions are removed, as well
    as the need to call Start in its own goroutine. There is no longer a
    separate GL thread. Instead, package app explicitly performs any GL
    work (gl.DoWork) when some is available (gl.WorkAvailable).
  - In package gl/glutil, Image.Draw now takes an explicit Config.

Callbacks are no longer executed on 'the UI thread'.

Changing the app programming model from callbacks to events (since a
channel of events works with select) will be a follow-up change.

Change-Id: Id9865cd9ee1c45a98c613e9021a63c17226a64b1
Reviewed-on: https://go-review.googlesource.com/11351
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-26 07:43:17 +00:00
Burcu Dogan 0a8a8b8cb6 exp/audio/al,cmd/gomobile: fix the broken build
Change-Id: Ia2da7d987f253c11a62843f54051c9d18c1612b5
Reviewed-on: https://go-review.googlesource.com/11521
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-26 07:40:05 +00:00
Burcu Dogan 25dc511cde exp/audio: allow multiple instances of al.Context
Fixes golang/go#11299.

Change-Id: Ie59981a0515abcf015c7b22d05d2cdbb8be35f56
Reviewed-on: https://go-review.googlesource.com/11315
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-26 06:57:01 +00:00
Burcu Dogan 95c05c6dfd cmd/gomobile: parse -target and -o
Fixes golang/go#11337.

Change-Id: I324f0c4482476b6f2b084828625fd53b8f802a23
Reviewed-on: https://go-review.googlesource.com/11480
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-26 04:37:57 +00:00
Nigel Tao e47fb7683e app: delete the unused Config.ClassFinder method.
Change-Id: I8eea69f3ac6406fd58a9338f3aa358fead1afc0e
Reviewed-on: https://go-review.googlesource.com/11473
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-26 01:34:58 +00:00
Nigel Tao 0dbccd26eb gl: delete an unused global variable.
Change-Id: I0591a27da24a5d7eca9055db5960164eae42dfcd
Reviewed-on: https://go-review.googlesource.com/11476
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-26 01:22:12 +00:00
Burcu Dogan e9833322dc Revert "cmd/gomobile: build *.app files if target=ios"
This reverts commit 597df59d36.

Reverting the change since, runtime/cgo is still not buildable and CCFLAGS is not a valid env variable. See golang/go#11339 for more information.

Change-Id: I2f168508d1ca72f5c75ff641938fd3b304939617
Reviewed-on: https://go-review.googlesource.com/11453
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-25 17:14:22 +00:00
Hyang-Ah (Hana) Kim 3ebbe2de54 cmd/gomobile: fix the path of the audio package.
The audio package has been moved.
The path used to determine whether to include openal in apk needs to
be updated.

Change-Id: Ic368617763e1991b0e82172c199e8f4318f115dc
Reviewed-on: https://go-review.googlesource.com/11500
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 13:10:31 +00:00
Nigel Tao 96bcad7e98 example/audio: delete obsolete TODO.
Change-Id: I6245a48a45fd1631550bb4102734a41e06fafcba
Reviewed-on: https://go-review.googlesource.com/11471
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-06-25 00:36:49 +00:00
Nigel Tao 229b9af752 exp/sprite/portable: unbreak test.
The test was broken with the foo -> exp/foo move.

Change-Id: Ie2bdf54f6da0365d2e0332bcacdd2b7a000c950c
Reviewed-on: https://go-review.googlesource.com/11392
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-24 23:49:55 +00:00
Burcu Dogan 597df59d36 cmd/gomobile: build *.app files if target=ios
This CL will be followed by another change to remove the
misc/ios/clangwrapper.sh dependency.

Updates golang/go#11043.

Fixes golang/go#11339.

Change-Id: I82466f8d845945935ab82d3d0b75f5af9e1ef3ec
Reviewed-on: https://go-review.googlesource.com/11345
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-24 20:21:15 +00:00
James Schofield 5878957524 mobile/bind: Fix objc bindings for multiple return vals.
The existing implementation generates uncompilable objc code for
functions returning two results.

Change-Id: I13f7329596d8fa6103c4b7827c26c5461e16a925
Reviewed-on: https://go-review.googlesource.com/11364
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-24 18:25:43 +00:00
Hyang-Ah (Hana) Kim f770de8d07 cmd/gomobile: change the generated go file name
This prevents filenames like go_test.go (when the package name is test)
or go_windows.go (wen the package name is windows).

Change-Id: Iae8f549d4d73baac8f8ba2ea33be7fec83f0023a
Reviewed-on: https://go-review.googlesource.com/11305
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-23 13:25:24 +00:00
Hyang-Ah (Hana) Kim 3a9b5b50ac bind: correct methods' return arg type mapping in obj-c binding.
Change-Id: Ieda05982c7f894c5603103b8890658e682e97423
Reviewed-on: https://go-review.googlesource.com/11307
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-23 13:13:31 +00:00
Nigel Tao 4d3dd47e87 app/debug: use the *image.RGBA drawing fast path.
On my 2013 Nexus 7, a simple

start := time.Now()
draw.Draw(etc)
log.Printf("draw.Draw took %v", time.Since(start))

around the draw.Draw call dropped from 12ms to 30µs.

Change-Id: I12aea4a4ade07eedb8ee86f7c8d4a4ed49f39f36
Reviewed-on: https://go-review.googlesource.com/11299
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-23 04:51:34 +00:00
Burcu Dogan 4d8c316cd9 cmd/gomobile: fix the aar suffix check
Change-Id: Iecfa5326b4b2e234fbbd9e4d1815cf782035efbf
Reviewed-on: https://go-review.googlesource.com/11310
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-22 12:42:51 +00:00
Burcu Dogan d1e00c1c1c doc: fix whitespace between stable and exp packages
Markdown acts weirdly at puts more whitespace around the audio
package if there is no other content seperating the lists.

Change-Id: Ia60c0ea05ab2d86b9b0cbcbabccdeebda8c13cbf
Reviewed-on: https://go-review.googlesource.com/11314
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-22 00:54:25 +00:00
Burcu Dogan 55faa67276 doc: list sensor and audio package as experimental
Change-Id: Ib0834fd74d412e8ddc01f30eca72557799d33aeb
Reviewed-on: https://go-review.googlesource.com/11313
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-21 18:25:00 +00:00
Burcu Dogan 1d641b5393 audio: move to exp/audio
Change-Id: I8640b1a38a292972db6dd00506e38c89470b2c15
Reviewed-on: https://go-review.googlesource.com/11311
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-21 18:18:56 +00:00
Burcu Dogan e9faa8965b sensor: move to exp/sensor
Change-Id: I707a1555952355ccdd5e851062c4749dc94544eb
Reviewed-on: https://go-review.googlesource.com/11312
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-21 07:47:51 +00:00
Nigel Tao c0c696a96d sprite: move to exp/sprite.
Change-Id: Idfdc0c192d7e6d50e1063b2eb582bbe05294643a
Reviewed-on: https://go-review.googlesource.com/11230
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-21 03:08:52 +00:00
Burcu Dogan df4a6521ad cmd/gomobile: improve error message if gomobile hasn't inited
gomobile init builds and install the toolchain for iOS builds now.
The error message shouldn't exclude the darwin/arm and darwin/arm64
related initialization.

Change-Id: Iebd5d7fb1466d9be694d8848c0fd8fa782850c79
Reviewed-on: https://go-review.googlesource.com/11239
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-06-20 22:31:06 +00:00