Граф коммитов

383 Коммитов

Автор SHA1 Сообщение Дата
Hajime Hoshi 82c397c4c5 cmd/gomobile: always use abolute paths to replace in go.mod
A replative path in go.mod works only in the directory of the
go.mod. When creating go.mod for gobind, copying relative paths
did not work since go.mod is in a different temporary directory.

This CL fixes the issue to use Dir, which is an absolute path to
the module, instead of Path.

Updates golang/go#27234

Change-Id: Ib009ec508aa3ce3d092af14f921a57192feaac61
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/215421
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-01-23 02:49:42 +00:00
Hajime Hoshi 23a0503ab4 cmd/gomobile: enable Cgo
This CL gives CGO_ENABLED=1 explicitly when executing gobind since
Cgo is disabled by default when GOOS is given.

This CL also adds importing C to the tests to confirm that Cgo
works correctly.

This CL also updates go.mod since this change requries the change
in go/packages: golang.org/cl/214943

Updates golang/go#27234
Updates golang/go#36547

Change-Id: I66f9697f992f15b52fca7871e4e0ed64ca2b4965
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214498
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-01-23 02:49:29 +00:00
Hajime Hoshi 1d4ecbb920 cmd/gomobile: output an error message at gomobile-init
Updates golang/go#36668

Change-Id: Ic93ea6334dae3fef953bbb928c5246b03279a22f
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/215419
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-21 16:05:05 +00:00
Hajime Hoshi 875e90d6f7 cmd/gomobile: disable bitcode on Go 1.13 or older
iOS's bitcode conflicts with headerpad on Go 1.13 or older. This
problem is fixed on Go 1.14.

This CL disables bitcode only on Go 1.13 or older.

Fixes golang/go#32963

Change-Id: Iac9edd56aaf7819288e8f46b9e29d310305acd9d
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214899
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-01-15 17:48:49 +00:00
Hajime Hoshi af4a92906a cmd/gomobile: enable Go modules at gomobile-build
This CL enables Go modules at gomobile-build command. This CL is
a counterpart for the change gomobile-bind: https://golang.org/cl/210380

This CL also reformats the tests in bind_test.go

Updates golang/go#27234

Change-Id: I9fb9612be6b08f5f61259879f563c8586fb1efef
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214897
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-15 16:36:13 +00:00
Hajime Hoshi 56347cccba cmd: replace goBin() with a plain string "go"
This was introduced at https://go-review.googlesource.com/c/mobile/+/191518
originally, but this change was against the decision at
golang/go#26845.

"go" always works even when Go command that name is not "go", like
"go1.14beta1" is used. See also the discussion at golang/go#28043

Change-Id: Ifebe969edaeda0373b2840d25a4f4030509176fa
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214898
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-15 09:57:20 +00:00
Hajime Hoshi b9f03b3fa3 cmd/gomobile: remove the logic to clean the given path
This CL fixes an issue that a relative path didn't work with
gomobile. path.Clean removed the prefix './' and this was too
aggressive. path.Clean was needed for go/build.Context.Import
(see golang/go#18876), but they have already been replaced with
packages.Load, so clearning paths is no longer needed.

Updates golang/go#27234

Change-Id: Ife28da6d845baaf94e627a7a44a5e962b8a1d013
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214497
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-01-13 19:03:25 +00:00
Hajime Hoshi 1d13e329d2 cmd/gomobile: enable Go modules in gomobile-bind
This CL enables Go modules in gomobile-bind command. This CL
generates go.mod at $WORK/src based on the modules state of the
working directory, and use it when executing go-build.

Updates golang/go#27234

Change-Id: I6958f29a317c0d2fb9ffa373f6e3c4cabdc4e898
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/210380
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-01-13 15:31:55 +00:00
Hajime Hoshi 1a1fef8273 cmd/gomobile: make gomobile-init support Go modules
Before this change, all the gomobile commands forced Go modules
to be off internally, regardless of the current Go modules state.

After this change, gomobile-init command follows the current Go
modules state. The other gomobile commands are not changed.

This is also a preparation to support Go modules in gomobile-bind
and gomobile-build.

Updates golang/go#27234

Change-Id: I3d9eedd667cba4d30de3ac0543f037be36cd3e51
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/210477
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-12-10 15:19:39 +00:00
Hajime Hoshi 5c0e7e404a cmd/gomobile: change the working directory to $WORK/src/gobind when go-building
This is a preparation to enable Go modules for gomobile commands.

When Go modules is used, $GOPATH is not available. To build a
local package with Go modules, changing the working directory and
specifying the package by a relative path begining with `./` is
required. Changing the working directory is necessary because
building outside of modules is forbidden.

Specifying $GOPATH is still needed for reverse bindings (i.e.
special packages begining with `Java/` or `ObjC/`). Note that
gomobile with Go modules cannot support reverse bindings so far.

Updates golang/go#27234

Change-Id: Ib19300e1b8a973e76e06d24472c63a98605d65f7
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/209137
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-11-30 19:14:48 +00:00
Hajime Hoshi d9e324ca8c cmd/gomobile: remove go/build usages from build.go
This CL is a pure refactoring. This removes a global variable ctx,
which is a build.Default.

Before this change, ctx was used to keep build tags and its state
affected go command executions. As the variable is mutable, the
code was not readable.

This changes introduces another global variable buildTags instead,
but this is more consistent with other build flags, and this is
immutable.

Updates golang/go#27234

Change-Id: Id8d0c779de21b249e96febd2f40833cd0c84534f
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/208060
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-11-23 05:49:42 +00:00
Hajime Hoshi 08e574b148 cmd/gomobile: replace go/build with go/packages in gomobile-build
This is a preparation to use Go modules at gomobile command.

Updates golang/go#27234

Change-Id: I8ee47cb53f5b748592a0c8c9f383abab27a7fdad
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/208059
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-23 05:48:59 +00:00
Hajime Hoshi 8715129287 cmd/gomobile: remove an unsed function
Change-Id: I2d5fcebd96de1d81d01c2b0765a292897b404a5a
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/208058
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-11-20 16:19:35 +00:00
Hajime Hoshi 26e634b6c9 cmd/gomobile: remove a global variable
This CL is a pure refactoring to remove a global variable.

Change-Id: I996c6a15354163e90148bc2540bda6b56296271c
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/208057
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-11-20 16:19:11 +00:00
Hajime Hoshi f0c40035f2 cmd/gomobile: replace go/build with go/packages in bind
This is a preparation to use Go modules at gomobile-bind.

Updates golang/go#27234

Change-Id: I33684888b4181cc1ebd4d3c8872a6b2e62950855
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/206777
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-11-15 02:22:31 +00:00
Hajime Hoshi 6a1b097663 cmd/gobind: enable TestDocs tested with Go modules
This CL fixes TestDocs to test with Go modules by packagestest.

Updates golang/go#27234

Change-Id: I9055f52d26e494cd3b71b59d3db0755d415df356
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/206737
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-11-15 01:59:51 +00:00
Hajime Hoshi c2e8f9e9c7 cmd/gobind: add tests enabling Go modules
This CL adds tests with Go modules enabled.

Updates golang/go#27234.

Change-Id: I8a583c929ed9151e3b3220b4e669ff572361bb0e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/195937
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-11-12 16:56:57 +00:00
Hajime Hoshi 0945064e01 cmd/gobind: remove go/build and go/import usages from main.go
This change removes the usages of go/build and go/import, that don't
work with Go module.

Before this change:

  1) Package information is retrieved by go/packages
  2) Files for reverse bindings are generated
  3) Package information is retrieved by go/imports

After this change, only 3) will be changed:

  3) Package information is retrieved by go/packages again only when
     reverse binding is used.

This is preparation to support Go modules.

Updates golang/go#27234

Change-Id: I1997f71f23455fdd3b3c6b2643d35ec33ad147a3
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/203399
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-10-31 02:03:45 +00:00
Hajime Hoshi 73ccc5ba04 cmd/gobind: replace go/build with go/packages in gen.go
This is preparation to support Go module.

Updates golang/go#27234

Change-Id: I8dcaed231e877e81d2072c7c85321c0acb6a8b1b
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/203397
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-25 11:06:07 +00:00
Robin Zhong d3ece3b6da add -trimpath build flag.
Add the "-trimpath" flag from Go 1.13.

Change-Id: I10938fb5f7efd701f4025e451ddf438dc3e011ee
GitHub-Last-Rev: 4e82381342
GitHub-Pull-Request: golang/mobile#39
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/196877
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-23 20:44:09 +00:00
Hajime Hoshi cafc553e1a cmd/gobind: fix build-tag, CGO and load trybot failures
* Correctly format build tags to pass into go/packages
* Removes CGO_ENABLED=0 from a packages.Load configuration
* Calls go/packages.Load twice to work around a build cache
* staleness issue

These bugs were introduced by CL 189597.

Updates golang/go#27234.
Updates golang/go#33687.

Change-Id: I3ae6737bf53bbecda0c7e25885b9c6aea5779332
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/190479
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
2019-08-26 17:01:11 +00:00
Hajime Hoshi 30c70e3810 all: use GOROOT/bin/go instead of go everywhere
This is a non-test code version of CL 191517.

Using 'go' command in tests is confusing when using a different version
of Go (e.g., go1.13rc1). Use GOROOT/bin/go so that the same Go is used.

Change-Id: Id5937cfa6dd6d3164d5f774e3fc0fd15b7f613b5
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/191518
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-08-23 17:37:32 +00:00
Hajime Hoshi fe31116dde all: use GOROOT/bin/go instead of go for tests
Using 'go' command in tests is confusing when using a different version
of Go (e.g., go1.13rc1). Use GOROOT/bin/go so that the same Go is used.

Change-Id: I0ca297207acc5e7fd8b291f544302f6c7b0d38e1
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/191517
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-08-23 15:22:30 +00:00
Hajime Hoshi e8b3e6111d internal/importers: replace go/build usages with go/packages
This CL is a pure refactoring to replace go/build usage with
golang.org/x/tools/go/packages. This is a preparation for Go
modules.

Updates golang/go#27234

Change-Id: I3e6a30b962da1a64bc43a89a7f02c03d559f86d3
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/189597
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-08-14 14:30:26 +00:00
Tim Cooijmans e47acb2ca7 bind/java: Do not get ApplicationContext via reflection, ask for it when needed.
Previously any library created using gobind used reflection to get the ApplicationContext. The methods used are disallowed in Android 9 causing any library to crash.  However the ApplictionContext is not required and only needed when using RunOnJvm. This change adds an method to set the ApplicationContext when needed, but will not get it by default by using reflection.

Fixes #31364

Change-Id: I83ce69f3b4b59d2cc4a275928f0439e5e4651ba8
GitHub-Last-Rev: b563af1d7f
GitHub-Pull-Request: golang/mobile#31
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/175103
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-07-11 16:50:09 +00:00
Chotepud Teo ab05907dce cmd/gomobile: add arg to set android api level
Fixes golang/go#31905

Change-Id: Icee0ece2e78028fa4afd8b273b86e4eed404d99a
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/176077
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-05-09 16:47:12 +00:00
Hana Kim 12c8d8ccab cmd/gomobile: update doc
Ran `gomobile help documentation doc.go`

Change-Id: Ie7f89349520393e63a8d72495d69c299e3218876
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/176157
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-09 15:01:47 +00:00
Daniel Lublin 3e0bab5405 cmd/gomobile: fall back to $ANDROID_NDK_HOME for the NDK path
After trying $ANDROID_HOME/ndk-bundle, we also try $ANDROID_NDK_HOME.

ANDROID_NDK_HOME is advised in this NDK sample code wiki:
https://github.com/googlesamples/android-ndk/wiki
Mentioned in the Bazel buildsystem Android app tutorial:
https://docs.bazel.build/versions/master/tutorial/android-app.html

On Ubuntu, the google-android-ndk-installer leaves the NDK in
/usr/lib/android-ndk, and it seems to be up to the user to set
ANDROID_NDK_HOME.

On Arch Linux, the android-ndk package installs the NDK into /opt/android-ndk
and sets ANDROID_NDK_HOME to there using an /etc/profile.d/file

Fixes golang/go#31461

Change-Id: I9f7f7e24b19e0047419f9725b67bd6daf2b1d328
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/171938
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Elias Naur <mail@eliasnaur.com>
2019-04-15 19:13:53 +00:00
Elias Naur 167ebed0ec cmd/gomobile: require NDK r19c and delete workaround for NDK r19b
The prebuilt toolchains introduced in NDK r19b didn't work on Windows.
NDK r19c contains a fix, so remove our workaround and check for r19c
on Windows.

Change-Id: I3bcfedbc156f10c3cab8e74dcbd7de68575669e7
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/168067
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-27 16:31:28 +00:00
Elias Naur 9487ef54b9 cmd/gomobile: enable bitcode
Add -fembed-bitcode to the host compiler and linker to instruct it
to add bitcode to object files.

Updates golang/go#22395

Change-Id: Ie0297079f27c9b5b8ea55e0a36067dc768342986
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/168062
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-19 15:52:45 +00:00
Elias Naur cde3d952bc cmd/gomobile: explicitly disable modules
Gomobile doesn't support modules.

Updates golang/go#27234

Change-Id: I426db1600eafd4a9ddc7eb239f5f264756f1ba35
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167659
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-16 15:04:07 +00:00
Bryan C. Mills f0d57f48df all: set GO111MODULE=off explicitly in bind tests
Updates golang/go#27234
Updates golang/go#30228

Change-Id: Ibe281480398ff9d8c27657f399159885a75f646e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167179
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-13 03:07:56 +00:00
Elias Naur d3739f865f cmd/gobind: fix tests on the linux-amd64-longtest builder
The builder doesn't have javap nor the Android fonts installed.

Change-Id: Ia3965be967482aa76b0c8c83b951deb30ebe5645
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167057
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-03-12 15:16:09 +00:00
Elias Naur d2e1c1c4a6 cmd/gomobile: improve NDK version detection
Look for the compiler directly, not just the existence of the
directory containing.

Fixes golang/go#30637

Change-Id: Iae4429406da8622e7085bf3701c0f84d5c95d2fd
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/165937
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-03-07 20:28:46 +00:00
Elias Naur 56dec8b502 cmd/gomobile: fix tests on builders
The naïve string matching of GOROOT fails on the builders where
GOROOT is a string prefix og GOPATH.

We're not manipulating GOROOT in the tools anymore so do the easiest
thing and delete GOROOT matching.

Change-Id: I194883b9c25f38e2bfdd3eb0ccc9fade76f45549
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/165579
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-06 14:38:14 +00:00
Elias Naur 9ce7b04580 cmd/gomobile: fix tests
Change-Id: Ifb7f27faa274b5935896395e74ecbb29156b2253
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/165577
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-06 00:21:39 +00:00
Elias Naur b8c6dab863 all: skip or fix tests for GOOS=android
Some x/mobile tests are designed to run from a host with a device
or emulator attached. Some fail if they run directly from a device,
which is the case when GOOS=android.

Fix the tests by skipping them or adjusting them to work on GOOS=android.

Remove gomobile environment naïve variable expansion for $HOME; on
Android devices HOME=/ so every path separator is replaced with
$HOME.

Fixes golang/go#30482

Change-Id: I553e708226922f6284163f0b7d7b1011a9502e34
Reviewed-on: https://go-review.googlesource.com/c/164799
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-02 06:36:18 +00:00
Elias Naur 3ac37b7f94 cmd/gomobile: bump default iOS minimum version to 7.0
Recent Xcode versions are unable to build C++ files if the minimum
iOS version is below 7.0. Bump the default version to 7.0; it is
ancient and users can override it with -iosversion.

Fixes golang/go#29969

Change-Id: I4e35e021e0fa10c1681df1073efa73700c3aae69
Reviewed-on: https://go-review.googlesource.com/c/164800
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-03-01 22:35:04 +00:00
Elias Naur 246a99880f cmd/gomobile: work around broken Windows NDK compiler scripts
Fixes golang/go#30415

Change-Id: I6cda312f465e05d28601432845c3c3d0f7a85605
Reviewed-on: https://go-review.googlesource.com/c/164177
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-01 19:41:37 +00:00
Elias Naur e6099be231 cmd/gomobile: add generated package names to proguard.txt
No test as I couldn't figure out how to persuade gradle test to
strip classes.

Fixes golang/go#30251

Change-Id: I7dca9169a4a8eb31b981ad49047a6bdfa6f6efd7
Reviewed-on: https://go-review.googlesource.com/c/164798
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-01 16:18:23 +00:00
Elias Naur 2c6ea15e35 cmd/gobind,cmd/gomobile: don't go install binaries
Use a temporary location for the gobind and gomobile binaries
during tests.

This avoids depending on the go install path being in PATH and avoids
overwriting any existing gobind or gomobile binary the user have installed.

For the android x/mobile builder.

Change-Id: I98a6767fcff642a7143efc3eeb2cb3aa1f1719cc
Reviewed-on: https://go-review.googlesource.com/c/164797
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-01 16:17:44 +00:00
Elias Naur ca80213619 cmd/gomobile: use the NDK r19b prebuilt toolchains
To use the NDK before version r19b standalone toolchains had to be
generated. Version r19b added prebuilt standalone toolchains.

Use the prebuilt for gomobile build and gomobile bind and
stop generating toolchains during gomobile init.

gomobile init is now only necessary for building OpenAL for
gomobile build programs.

This change is not compatible with NDK versions < r19b, but the
user is instructed how to upgrade when running gomobile build or
gomobile bind.

Change-Id: I96953298ecce42402459a9dd15169c09fe6b6f8b
Reviewed-on: https://go-review.googlesource.com/c/163378
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-02-22 14:21:12 +00:00
Elias Naur dc07713565 cmd/gomobile: require -bundleid set for -target=ios
The default, org.golang.todo, is not available outside Google
and the resulting error is confusing.

Fixes golang/go#26615

Change-Id: I417a2f83bc3755628f1f3541a061c9272eb318c0
Reviewed-on: https://go-review.googlesource.com/c/156498
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 16:22:57 +00:00
Elias Naur 9a2b4796a4 cmd/gomobile: bump required Go version to 1.10
Go 1.9 is probably enough, but I'm not willing to support it.

Fixes golang/go#29486

Change-Id: I6dac22dbbd527d6668c5951d9060617efb758b96
Reviewed-on: https://go-review.googlesource.com/c/156137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-03 14:45:51 +00:00
Tadas V a27dd33d35 cmd/gomobile: use the correct case for the generated Universe.objc.h file
Fixes golang/go#28335

Change-Id: Ia6ef4a5e9c426d810770459632ab276eea9cab8f
GitHub-Last-Rev: 47d9c16539
GitHub-Pull-Request: golang/mobile#24
Reviewed-on: https://go-review.googlesource.com/c/144117
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-10-26 06:21:14 +00:00
Elias Naur 920b52be60 cmd/gomobile: bump minimum sdk version and update gradle for NDK 18
NDK 18 drops support for API levels below 16. Bump it to 16.

NDK 18 also needs a newer version of the Android gradle plugin.
Update the bind example and test build.gradle files.

Change-Id: I71499c88b48c43b2d4da50e415cb0b0dcbbbed75
Reviewed-on: https://go-review.googlesource.com/136775
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-09-22 16:38:55 +00:00
Tadas 18ac050e90 cmd/gomobile: make the minimum iOS sdk version configurable
Fixes #27680

Change-Id: I8af5c120aaa2ddbf03fc8832b60c293aca77b1e6
GitHub-Last-Rev: 22f5d033fc
GitHub-Pull-Request: golang/mobile#21
Reviewed-on: https://go-review.googlesource.com/135415
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-09-15 07:57:13 +00:00
Elias Naur 9bd09ef1cf cmd/gomobile: remove note about incomplete support on iOS
While the gomobile project itself is experimental, the iOS support
is just as "complete" as the Android ditto. Remove the special note
for iOS.

Change-Id: I624a29340ee453f3a54e6f8dc75203a03681df66
Reviewed-on: https://go-review.googlesource.com/135435
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-09-14 15:40:29 +00:00
Elias Naur 6d4b718bf3 app: make GoNativeActivity.getKey static
The input queue runs concurrent with the native activity lifecycle,
and so the getKey helper Java method might be called after the
app has been destroyed. This is particularly likely for "back"
key presses that destroys activities.

Change the getKey method to be static so that it can be called
outside the app lifecycle.

Run `go generate ./cmd/gomobile` to update the compiled dex file that
contains GoNativeActivity.

Fixes golang/go#27652

Change-Id: Id2c863ee07e5447f033e67d6948fbfe746916ffa
Reviewed-on: https://go-review.googlesource.com/135215
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-09-13 17:01:46 +00:00
Tadas 6c7f9eaa5c cmd/gomobile: specify clang++ compiler for C++ compilation, setup CGO_CXXFLAGS
Fixes #27508, #17343

Change-Id: I3e50ae781012a093254f7f8d6d719d89426f04a9
GitHub-Last-Rev: 7c3232d8ee
GitHub-Pull-Request: golang/mobile#20
Reviewed-on: https://go-review.googlesource.com/134975
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-09-13 07:56:01 +00:00
Elias Naur 6621de06e1 cmd/gomobile: fix gomobile build of non-main packages for iOS
Non-main packages are built in an earlier code path than main
packages. Add the ios build tag before that early code path to
ensure packages that expect that tag successfully compiles.

Fixes golang/go#25944

Change-Id: Ida15475109373127dde024037e9787c76b32ee0b
Reviewed-on: https://go-review.googlesource.com/119555
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-06-18 22:25:54 +00:00
Elias Naur 002e3c5c61 cmd/gobind: copy documentation to generated source
CL 99316 moved generation of bindings from the the gomobile command
to the gobind command. In the process, the ability to copy over
documentation from the Go source to the derived Java and ObjC was
lost. The relevant test didn't fail because it tests the generator
itself, not gobind.

Re-add support and add a gobind test for it.

Fixes golang/go#25473

Change-Id: I6eee3e79173f37d3e3e65eabc0bad59e4252da64
Reviewed-on: https://go-review.googlesource.com/114056
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-05-22 19:36:14 +00:00
Elias Naur c909788f99 cmd/gobind: fix build of ObjC bindings with a custom prefix
Also add a test. The corresponding Java custom package option
already have one.

Fixes golang/go#24986

Change-Id: I095d97022beb0a57df784fe0a12bc42a66bb8a07
Reviewed-on: https://go-review.googlesource.com/110058
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-05-01 17:35:30 +00:00
Elias Naur bf2d30a68a cmd/gomobile: disable DWARF in gomobile builds
DWARF doesn't work for buildmode exe binaries; see
golang.org/issues/25148.

Fixes golang/go#25148.

Change-Id: I511599f3d1963ff0b3e48ac5c8cce50ee6aa54de
Reviewed-on: https://go-review.googlesource.com/110059
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-29 17:04:17 +00:00
Elias Naur e6f3196453 cmd/gomobile: use go list -f {{.Stale}} to determine staleness
With CL 107957, the appropriate way to check that the gomobile
binary is up to date is by using go list -f {{.Stale}}. Use that
instead of go install -x -n.

Fixes golang/go#24389

Change-Id: I93a4428b048f0be9463c61928673886445dce3ed
Reviewed-on: https://go-review.googlesource.com/108055
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Sun Shine <mizommz89@gmail.com>
2018-04-25 21:19:26 +00:00
Elias Naur 5d5d88d1b1 cmd/gomobile: add CGO_ENABLED=1 to gobind runs
A previous CL switched gobind to use the "source" importer so go
files using cgo can be type checked. However, CGO_ENABLED=1 also
have to be passed in for such files not be ignored.

Also add -tags ios to the gomobile test output missing from CL
99777.

Fixes golang/go#24941

Change-Id: I868469af3061b82ab592899e365a8a90a0333e58
Reviewed-on: https://go-review.googlesource.com/108336
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-04-20 08:11:07 +00:00
Elias Naur 7d79e14f04 cmd/gobind: make sure to set exit code on type checking errors
Change-Id: Iea30db321c53b37b41a2b18689c5f724938a1593
Reviewed-on: https://go-review.googlesource.com/108135
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-04-19 19:22:22 +00:00
Elias Naur 5bfa0d14b7 cmd/gomobile,cmd/gobind: allow per-platform bindings again
CL 99316 changed gobind to be platform independent, so
standalone bindings could be generated without having the
Android and Xcode SDKs installed. However, bindings that does
depend on GOOS for its exported API, in particular go source
files that use Cgo now only works if the exported API is
extracted to platform independent files.

By switching to use the source importer, importer.For("source", nil),
gobind can type check the bound packages even in the presence of
Cgo.

The source importer in Go 1.9 and 1.10 has problems with relative
imports and imports from testdata directories (issues 23092 and 24392),
but works from Go 1.10.1 on.

Fixes golang/go#24856

Change-Id: Icb18dce15325b7d4e58cabc1181051bc6269fc1f
Reviewed-on: https://go-review.googlesource.com/99777
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-04-17 15:00:54 +00:00
Elias Naur 90139f6bae cmd/gomobile: don't run gobind with the ios tag
Bindings are independent of any particular GOOS/GOARCH pair and
as such the gomobile bind command doesn't set GOOS nor GOARCH when
running gobind. However, the ios tag was still added to the list
of tags to pass to gobind for -target=ios.

Move the ios tag to when actually building the bound packages,
mirroring gomobile build.

Add TestBindIOS and update TestBindAndroid.

Updates golang/go#24644

Change-Id: I007829c26036427a3376bba11a1ccb86e7338848
Reviewed-on: https://go-review.googlesource.com/104458
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-04-05 18:31:59 +00:00
Elias Naur 19987bc3dc cmd/gomobile: fix tests
Forgot to update tests on macOS after CL 102915.

Change-Id: I902fd1046434d133129a0cd82bc28c3f7ee47816
Reviewed-on: https://go-review.googlesource.com/104455
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-04-03 15:02:56 +00:00
Elias Naur 54bca60619 app,cmd/gomobile,exp/gl/glutil: support target architectures for iOS build and bind
While we're here, add 386 to the list of supported architectures
on iOS.

To support gomobile build for amd64 and 386, use the "ios" tag to
distinguish between iOS and macOS builds.

Change-Id: Ie09a432794bd8d9853950115349f8d3b57cf43f5
Reviewed-on: https://go-review.googlesource.com/102915
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-28 15:26:55 +00:00
Elias Naur 4e3d9b7944 cmd/gomobile: add missing checks for the NDK and Xcode
Fixes golang/go#24571

Change-Id: I8d08548b4a4d6f9490a8bfd80c80a6408fde089b
Reviewed-on: https://go-review.googlesource.com/102896
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-28 14:47:19 +00:00
Hajime Hoshi ae1772d3eb x/mobile/cmd/gomobile: allow digits-only basename for Android package name
Now package names for Android is generated based on the given package
path's base name, And the package name generation fails when the base
name consists of only digits (e.g. github.com/hajimehoshi/ebiten/examples/2048).

This CL fixes this problem by allowing only-number base name.

Fixes #24511

Change-Id: I6108c46823d0b2ee08869b306922f62351fb1510
Reviewed-on: https://go-review.googlesource.com/102576
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-27 03:16:25 +00:00
Elias Naur 2a86fdcad0 cmd/gomobile: don't ignore -openal if no NDK was found
Updates golang/go#20902

Change-Id: I523c0b7a205e620c143f2ba9c7cdbe30865a9c59
Reviewed-on: https://go-review.googlesource.com/101136
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-26 17:12:34 +00:00
Elias Naur 5d852261b1 cmd/gobind,cmd/gomobile: support the default GOPATH
Instead of using os.Getenv("GOPATH"), use go env GOPATH to determine
the effective GOPATH.

Fixes golang/go#21658

Change-Id: I03f897969e30fc3256d171aa7b32c101a9342a1a
Reviewed-on: https://go-review.googlesource.com/101117
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-26 17:12:27 +00:00
Elias Naur b07e525bd7 cmd/gomobile: make sure gobind is installed and updated
When running gomobile bind, make sure gobind exists. If not, instruct
the user to run gomobile init which will go install gobind.

Change-Id: I2d064ba58874fd5581c17417124561f3d1fb6b83
Reviewed-on: https://go-review.googlesource.com/101055
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-26 17:12:18 +00:00
Elias Naur 6b7c05d452 cmd/gomobile: use standalone NDK toolchains
Issue golang/go#24058 demonstrates a Go package that fails to build with
gomobile but builds successfully with a manually using the standalone NDK
toolchain. I haven't been able to figure out a set of CPPFLAGS/LDFLAGS
that fixes the build for 24058 so instead rework gomobile to use
standalone NDK toolchains.

Standalone toolchains fixes the 24058 build and is the official way
to build Android programs. So gomobile should be less affected by
future changes in the NDK toolchain internals.

Create the standalone toolchains with gomobile init.

With the new Go 1.10 build cache, the prebuild work by the gomobile
init command is useless. Use the opportunity to simplify init to
only creating NDK toolchains and, optionally, building OpenAL for
Android. With that, it is no longer necessary to use gomobile init
to build iOS apps and frameworks.

Fixes golang/go#24058

Change-Id: I4692fcaa927e7076a6387d080ebc1726905afd72
Reviewed-on: https://go-review.googlesource.com/99875
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-26 17:11:49 +00:00
pankona 598bfe4b20 cmd/gomobile: support vendored "golang.org/x/mobile/..." packages
gomobile checks "golang.org/x/mobile/..." packages are included in
the build product using nm.
If "golang/x/mobile/..." package is placed under vendor directory,
this check fails and it is treated as a build failure.

Fixes golang/go#22152

Change-Id: Ie0e05c3e0340b3608de5c68bb3f852d4ef7cdeb1
Reviewed-on: https://go-review.googlesource.com/102095
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-03-23 11:57:23 +00:00
Elias Naur 4600df55ca bind, cmd: generate complete standalone bindings from gobind
The gobind and gomobile bind tools have historically overlapped:
gobind outputs generated bindings, and gomobile bind will generate
bindings before building them. However, the gobind bindings were
never used for building and thus allowed to not be complete.

To simplify version control, debugging, instrumentation and build
system flexibility, this CL upgrades the gobind tool to be the
canonical binding generator and change gomobile bind to use gobind
instead of its own generator code.

This greatly simplifies gomobile bind, but also paves the way to skip
gomobile bind entirely. For example:

$ gobind -outdir=$GOPATH golang.org/x/mobile/example/bind/hello
$ GOOS=android GOARCH=arm64 CC=<ndk-toolchain>/bin/clang go build -buildmode=c-shared -o libgobind.so gobind
$ ls libgobind.*
libgobind.h  libgobind.so

The same applies to iOS, although the go build command line is more
involved.

By skipping gomobile it is possible to freely customize the Android
or iOS SDK level or any other flags not supported by gomobile bind.
By checking in the generated source code, the cost of supporting
gomobile in a custom build system is also decreased.

Change-Id: I59c14a77d625ac1377c23b3213672e0d83a48c85
Reviewed-on: https://go-review.googlesource.com/99316
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-16 06:47:34 +00:00
Elias Naur f16143114e bind, cmd/gobind/test: remove GOOS build tags from test packages
The gobind command is about to get more powerful and able to generate
complete and standalone bindings. Platform specific build tags based
on GOOS or GOARCH are now meaningless to generate bindings from, so
remove them from the test packages.

The tags mattered to the reverse bound packages, since the go tool can't
build them without the Go wrappers for the imported Java packages.
Before this CL, the `android` tag was used to fool the go tool since
the host GOOS is unlikely to be android.

A fix is to check in the generated Go wrappers, but since the
packages are for testing we don't want that. Instead, move the test
packages to the testdata directory so the go tool ignores them.

Change-Id: I57178e930a400f690ebd7a65758bed894eeb10b0
Reviewed-on: https://go-review.googlesource.com/99315
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-14 22:25:02 +00:00
Elias Naur b7e3346cb3 cmd/gomobile: update gomobile bind -help text
The default ObjC prefix and Java package have been the empty string
for a while, but the gomobile bind -help text wasn't updated.

Change-Id: I8acb265ae7385121fae4c2cc314220d97575d20c
Reviewed-on: https://go-review.googlesource.com/99317
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-14 14:08:55 +00:00
Elias Naur bcd28df570 all: fix non-standard "DO NOT EDIT" comments for generated files
In the spirit of CL 99955, fix all non-standard generated code
headers and re-run the generators. Some generated files needed
git gofmt afterwards, but that problem is left for now.

Change-Id: I6b3131fb1753dc427d05af03107031120755cab0
Reviewed-on: https://go-review.googlesource.com/99975
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-14 14:08:28 +00:00
Elias Naur eac33190a3 cmd/gomobile: don't dump certificate to test log
The output takes up many lines and obscures other test output from
go test -v.

Change-Id: I0896717db3ce287f9e4b4263451475c19758b0e3
Reviewed-on: https://go-review.googlesource.com/99778
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-14 14:07:50 +00:00
Elias Naur 70bad68322 cmd/gomobile: remove redundant build
The extra build can't be required, because it is not run for the
build of the first GOARCH later in the loop. Tests run fine
without it.

Change-Id: Ida27e31ace2417192cce06c2efc93fa0d357012e
Reviewed-on: https://go-review.googlesource.com/98975
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-03-07 14:01:21 +00:00
Elias Naur 8a8a989f48 cmd/gomobile: run go install in c-shared mode only if NDK is set
A check for the NDK was missing from the pre-install of the standard
library for each Android GOARCH. If the NDK wasn't set, the go install
invocation would silently use the host GOARCH and GOOS and only fail if
no host gcc was found for runtime/cgo.

Discovered while setting up gomobile on a clean Windows machine.

With the go 1.10 cache go installing the standard library might be
pointless, but let's wait a little before removing it.

Change-Id: I880eed32aad23fda10ae92bd35be2ce9b03ddb86
Reviewed-on: https://go-review.googlesource.com/96636
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-02-23 15:52:32 +00:00
Elias Naur 4bfed40def all: fix vet errors from Go 1.10
Change-Id: I624bbbb5aeda923aa48c37af9447bc4903b0de3f
Reviewed-on: https://go-review.googlesource.com/93996
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-02-14 22:03:29 +00:00
Ryuji Iwata 125c5259d9 cmd/gomobile: improve Xcode check
Since the xcrun binary exists in macOS from the beginning, it can not be used to check that Xcode is available.

The xcodebuild command does not return an error if Xcode is available.

Reference https://go-review.googlesource.com/c/mobile/+/35852

Change-Id: Ibb6324a2d801eab47b3544c50ee1cdbc36b608bc
Reviewed-on: https://go-review.googlesource.com/88755
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-01-20 19:27:59 +00:00
Thomas Meson 02851653b1 cmd/gobind: make it generate everything like gomobile bind
the promise of the doc is to be able, once run twice with objc/java and go, to
import the generated code into a package and build a c-archive for iOS and
a c-shared for Android. As of today, this promise is not kept. Imports were not
properly made, files were missing. Also, make it generates the output `gomobile
bind` does.

Change-Id: Ic28087fe1b1661d54f41c446233580856e3a1211
Reviewed-on: https://go-review.googlesource.com/87715
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-01-15 13:32:49 +00:00
Thomas Meson ace2f0b992 cmd/gobind: fix missing parameter for formatting
Change-Id: I89256a18a9aeb2f32808f391258c8f66690e5247
Reviewed-on: https://go-review.googlesource.com/87716
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2018-01-15 13:14:41 +00:00
Kevin Ruffin 37cf9e7ab8 cmd/gomobile: rename bundleId to bundleID
Renames the argument to the -bundleid command line flag to be
consistent with other parameter naming.

Change-Id: Icde0be0fbacb08712c415abce462070a84aa46d9
Reviewed-on: https://go-review.googlesource.com/79115
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-21 18:45:43 +00:00
Kevin Ruffin c0beac360c cmd/gomobile: add the -bundleid flag
The current gomobile build command fails when attempting to sign the application
indicating that a development team should be selected. These changes fix that
by auto-detecting the developer team ID and setting the
"allowProvisioningUpdates" flag on the xcodebuild command. The bundle ID of
the application is also allowed to be changed via another command line
parameter "bundleid".

Fixes golang/go#17407

Change-Id: Ib0b878424a95a0cd49f3655ed4de56b2b91ff7a0
Reviewed-on: https://go-review.googlesource.com/77070
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2017-11-18 10:20:10 +00:00
Kyohei Kadota 2a5bbaa217 cmd/gobind: fix a typo that is missing quote at end
Change-Id: I91ffbda9c8f562bc66b75ca8a6360196d41c1b28
Reviewed-on: https://go-review.googlesource.com/74610
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2017-10-31 14:28:16 +00:00
Daniel Skinner eed0461ac2 cmd/gomobile: icon support for android
Provides support for resources.arsc generation enabling
the setting of an application icon.

If an asset/icon.png is encountered during build, then
the resources.arsc is generated to identify a single
xxxhdpi resource and the manifest will be updated to
reference resource as app icon.

References golang/go#9985

Change-Id: I9ef59fff45dcd612a41c479b2c679d22c094ab36
Reviewed-on: https://go-review.googlesource.com/30019
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-10-17 01:04:57 +00:00
Elias Naur 3ef91fec25 cmd/gomobile, internal/mobileinit: update to the NDK unified headers
From r16, the legacy headers no longer ship with the NDK. Update
the gomobile build system to use the unified headers instead.
They're available from r14.

Based on a patch by Steeve Morin.

Fixes golang/go#21802

Change-Id: I098330962c737edb833e968fe82558e15837f23f
Reviewed-on: https://go-review.googlesource.com/69950
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-11 16:08:37 +00:00
James Treanor 72d8d1135a bind: fix CLANG_WARN_STRICT_PROTOTYPES errors for generated ObjC code
Xcode 9 now enables CLANG_WARN_STRICT_PROTOTYPES by default.

This update ObjC function prototypes with no params from

FOUNDATION_EXPORT Something* DoSomething();

to

FOUNDATION_EXPORT Something* DoSomething(void);

Change-Id: I23b1d3e70a2ede2d2d77951ffe8a1a9598a1b7a0
Reviewed-on: https://go-review.googlesource.com/68970
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2017-10-09 16:20:38 +00:00
Elias Naur 9bd992d065 bind,cmd/gomobile: fix follow ups to doc generator CL (52330)
Also, add tests for blank, anonymous and multiple struct fields.

Change-Id: I15e6fff8d1684f2a31e99e1adf023b92f1f3cb48
Reviewed-on: https://go-review.googlesource.com/59550
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-09-05 18:43:28 +00:00
Elias Naur 05f1abc543 bind,cmd: generate ObjC and Java documentation
Convert Go documentation to JavaDoc tags (/** ... */).

Since the .aar file format doesn't support source files, gomobile
will create a package-sources.jar along with the main package.aar.

For Objective-C, JavaDoc-style comments seems to work as well,
judging by manual inspection of Xcode quick help.

Change-Id: I47fe5b6804681d459a873be37a44610d392166ef
Reviewed-on: https://go-review.googlesource.com/52330
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-08-25 16:30:26 +00:00
Dan Ballard e1125eeafd cmd/gobind: add GOROOT to cmd.Env from ctx.GOROOT
In two places gobind launches go commands but does not pass along
the system's GOROOT causing the subprocess go's to look in
/usr/local/go and fail if GOROOT is not there.

Fixes golang/go#18209

Change-Id: Ica9455c0b15ba57afc5699b7757d67aa4231c508
Reviewed-on: https://go-review.googlesource.com/46671
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2017-06-27 08:56:46 +00:00
Elias Naur dedec14c61 cmd/gomobile: update documentation to reflect Go 1.7 requirement
CL 35953 bumped the minimum required version to Go 1.7. Update the
gomobile documentation to reflect that.

Change-Id: I7cd7937471eb16456a51e8f41bae331344860888
Reviewed-on: https://go-review.googlesource.com/40919
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-04-18 12:40:40 +00:00
Elias Naur eb9032959f cmd/gobind: update export data for imported packages
CL 30093 removed the go install step from gobind to avoid errors from
circular dependencies with Java reverse wrapper. However, if a
dependency is either never installed or outdated, gobind will fail.

Reinstate the go install step, but ignore errors from the go install
tool.

Tested manually by wiping the $GOPATH/pkg directory and running the
cmd/gobind tests.

Updates golang/go#19046

Change-Id: I31832eccab09b2a7cf29e5d5bc1cc76963b7c2ef
Reviewed-on: https://go-review.googlesource.com/37326
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-07 11:58:33 +00:00
Elias Naur 57e7952fd5 cmd/gomobile: fix openal init test
Updates golang/go#19046

Change-Id: I0fc8fedc179d24ec9691528cab98857f3f9a4291
Reviewed-on: https://go-review.googlesource.com/37327
Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
2017-03-03 23:32:52 +00:00
Elias Naur f3e28d5ad0 cmd/gomobile: clean package paths
Clean the package paths so gomobile use the same directory for the
export data (*.a) files as the go tool.

Fixes golang/go#18876.

Change-Id: I40285f9203f04dbb80b21bd74d9b24212b677533
Reviewed-on: https://go-review.googlesource.com/37323
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-02-21 20:01:09 +00:00
Elias Naur 44ced21510 bind,cmd/gomobile: require Go 1.7
Bump the minimum required version of Go to 1.7.

This removes version specific code and makes sure users have the
latest mobile related fixes to Go applied. Also, this change is
necessary when runtime.KeepAlive is introduced in a later CL.

Change-Id: I8441a28aef7f645379fbd8f00edabe3c3fb219de
Reviewed-on: https://go-review.googlesource.com/35953
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-30 19:32:33 +00:00
Elias Naur e7109766ab cmd/gomobile: test for XCode in gomobile init
Previously, gomobile init assumed that the XCode developer tools
were available when running on darwin. That is not always the case,
in particular for Android developers on macOS.

Replace the GOOS check with an explicit check for the xcrun binary.

Change-Id: Ie5ae917288932cc641a17f904ed9822a105367cc
Reviewed-on: https://go-review.googlesource.com/35852
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2017-01-28 13:36:49 +00:00
Elias Naur c243211167 bind,internal/importers: add Unwrap methods to unwrap Java wrappers
For Java classes implemented in Go, it is useful to take a Java instance
and extract its wrapped Go instance. For example, consider the
java.lang.Runnable implementation wrapping a Go function:

package somepkg

type GoRunnable struct {
    lang.Runnable
    f func()
}

Java methods that take a java.lang.Runnable cannot directly take a
*GoRunnable, so this CL adds a Unwrap method:

import gorun "Java/somepkg/GoRunnable"

...

r := gorun.New()
r.Unwrap().(*GoRunnable).f = func() { ... }
javapkg.Run(r)

The extra interface conversion is unfortunately needed to avoid
import cycles.

Change-Id: Ib775a5712cd25aa75a19d364a55d76b1e11dce77
Reviewed-on: https://go-review.googlesource.com/35295
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-18 20:31:42 +00:00
Elias Naur 226c1c8284 cmd/gomobile: avoid header guard clash in iOS headers
Fix manually verified; none of our tests or the hello example fails
without this fix.

While we're here, update the hello iOS example to actually include the
Hello.framework and to use module @import syntax.

Fixes golang/go#18693

Change-Id: Id2edf80e2ed9ed8060ec825369a64f276a3b3c1d
Reviewed-on: https://go-review.googlesource.com/35330
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-18 01:06:16 +00:00
Elias Naur 3212b34dba cmd/gomobile: replace stripped NDK with external NDK
Gomobile has up until now used stripped NDKs hosted by Google. This
arrangement adds maintenance overhead and blocks the use of custom
NDKs or custom API levels. Also, as noted in issue 16211, the stripped
NDK is no longer tiny because Gomobile supports more platforms.

This CL removed the code for generating and packaging stripped NDKs and
adds support for using external NDKs to the gomobile tool.

gomobile init will now use the NDK installed by the Android SDK manager,
if present, or a user specified NDK if the -ndk flag is given. If no
NDK was found or specified, Android initialization is skipped. gomobile
will instruct the user to run init with a valid NDK if bind or build is
invoked without Android initialization.

gomobile init will also attempt to build OpenAL for Android if the -openal
flag specifies a source directory. It needs cmake and, on Windows, nmake
installed. If gomobile build is run on an app that requires
golang.org/x/mobile/exp/audio/al and OpenAL wasn't built by init, the user
is instructed to do so.

Tested on Linux, macOS, Windows.

Fixes golang/go#16211
Fixes golang/go#18522

Change-Id: Ia38f6e43e671a207dad562678c65225b426e7e3e
Reviewed-on: https://go-review.googlesource.com/35173
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-17 21:04:41 +00:00
Elias Naur d8b1e1aab8 bind,misc: guard reverse generated import with mobile os tags
Running go get golang.org/x/mobile/... results in errors because the
go tool fails to find the reverse generated Java ("Java/...") and
Objective-C ("ObjC/...") packages. Work around the errors by adding
the android and ios tags, respectively, to files importing those
packages.

The gobind gradle plugin is updated to pass along GOOS=android to
ensure the gobind tool continues to build Android reverse packages.

Fixes golang/go#17750

Change-Id: Id66a3c6cdfe249c6ed494192eb12195d6509332f
Reviewed-on: https://go-review.googlesource.com/34956
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-17 14:22:42 +00:00
Elias Naur 9ec2d17db2 cmd: fix handling of (multiple) tags
The gomobile tool mishandled build tags in two ways, first by
ignoring tags for iOS, second by passing multiple tags along to
the go tool incorrectly. This CL fixes both.

Fixes golang/go#18523
Fixes golang/go#18515

Change-Id: I28a49c1e23670adb085617d9f5fb5cd5e22a4b65
Reviewed-on: https://go-review.googlesource.com/34955
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-12 22:00:16 +00:00
Elias Naur 82c03f1188 cmd/gomobile: document the GOMOBILEFLAGS, GOARCH, GOBIND plugin settings
Change-Id: I681ac02869e137f67880416743352951960f7d8a
Reviewed-on: https://go-review.googlesource.com/33950
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-12 21:57:09 +00:00