Commit Graph

1088 Commits

Author SHA1 Message Date
Hana (Hyang-Ah) Kim eb3c0abee2 example/ivy: make ivy as a separate module, and update to use AndroidX
golang.org/x/mobile/example/ivy module specifies dependency on
golang.org/x/mobile and robpike.io/ivy versions.

- Updated to use AndroidX and target API level 30 to meet
the current Google Play policies
https://support.google.com/googleplay/android-developer/answer/9859152?visit_id=637402646062706504-1797308153&rd=1#targetsdk&zippy=%2Ctarget-api-level-requirements-for-play-console
- Updated demo.ivy script (copied from 66c48de6eb/demo/demo.ivy)
- Added example/ivy/android/README.md

Change-Id: Ie613ecdba4c3d77b5c45ef8a792fba6ee8a2c5cf
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/356729
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-27 13:47:44 +00:00
Hana (Hyang-Ah) Kim 122ae57121 go.mod: update golang.org/x/tools@316ba0b
We plan to move example/ivy to a separate module by adding go.mod
in the directory. That change will break gobind tests that depend
on golang.org/x/tools/packages/packagestest which didn't handle
nested module directories. Update the dependency to pick up the fix
(https://go-review.googlesource.com/c/tools/+/358037)

Change-Id: Ie333093a7f48e50623738ff7c18748161ce62175
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/357617
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
2021-10-27 13:47:05 +00:00
wmdngngng 1c027f395e cmd/gomobile: fix header padding computation in apk generation
fix file data align to 4

Change-Id: Ie88c46521e216b3f83a8dc3495591cd19bce83c6
GitHub-Last-Rev: aebf3cd7ff0d77050659e9269f7eddaeff364eff
GitHub-Pull-Request: golang/mobile#73
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/351789
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-24 03:28:53 +00:00
Randy Reddig b5eb1abba0 example: updates for XCFramework and Mac Catalyst
This updates examples for the changes in golang.org/cl/334689 for
.xcframework files and Mac Catalyst.

Depends on golang.org/cl/334689

https://go-review.googlesource.com/c/mobile/+/334689/28/example/bind/ios/README#1

Change-Id: Ice89e7e675c8f190c7040407908f619a7631fd2b
GitHub-Last-Rev: 64da8e6cad76f3e0530e36895bbfeacab7439b35
GitHub-Pull-Request: golang/mobile#72
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/350489
Reviewed-by: Changkun Ou <euryugasaki@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-22 14:22:29 +00:00
Changkun Ou b17b856605 cmd/gomobile: embed teamID into Xcode project settings
The default Xcode project settings do not specify any team ID.
If we open the Xcode project in Xcode, it won't compile and deploy
the app directly via Xcode unless a user manually selects the team
account. This is an extra effort. Since we can detect team ID
automatically embeds the teamID directly into the project settings
so it better helps the user to compile and deploy apps without getting
into the project settings.

Change-Id: I268653f66280bb6cf013f0a28891e4382e4de576
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/351409
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-09-22 14:04:04 +00:00
Randy Reddig 6d8ad35e46 cmd/gomobile: improve support for macOS and Catalyst
This is is a follow-up from my previous PR (#65). It makes gomobile
aware of GOOS=ios and adds support for specifying specific Apple
platforms, instead of overloading the "ios" platform.

Supported platforms: ios, iossimulator, macos, and maccatalyst

These can now be specified the -target argument to gomobile, e.g.:
gomobile build -target=ios,iossimulator,macos,maccatalyst

It preserves the current behavior of -target=ios, which will build for
ios and iossimulator on supported architectures (arm64 and amd64).

It adds platform-specific build tags so Go code can discriminate between
different Apple platforms like maccatalyst (UIKit on macOS).

This PR also fixes a number of broken tests.

TODO: cgo has a bug where c-archive builds targeting Catalyst will fail
unless -tags=ios is supplied. See https://golang.org/issues/47228

Fixes https://golang.org/issues/47212
Updates https://golang.org/issues/47228

Change-Id: Ib1a2f5302c5edd0704c13ffbe8f4061211f50d4e
GitHub-Last-Rev: 01ab28e63fe6890a9f9783e3fc41b1c895b0274d
GitHub-Pull-Request: golang/mobile#70
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/334689
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
2021-09-17 18:55:23 +00:00
Changkun Ou 5d9a33257a example/ivy: make ivy work again
This CL allows a (super) outdated Xcode project - the Pob Pike's Ivy
work again and can compile and run on the latest iOS (tested on iOS 15
beta 8).

There are some changes to the project that might be worth mentioning:

- The UIWebView is deprecated in iOS 10, this CL migrates the code to
use the latest recommended WKWebView.
- The old project does not compatible with iOS 9 and later, the CL upgrades
the development target to iOS 14, and makes it compatible with all
all orientation (Portrait, landscape, upside down).
- The old Launch.storyboard is deprecated, the Main.storyboard cannot
be opened (will cause Xcode crash), this change slightly reworked on
the UI management, and merges the purpose of Launch.storyboard as well
as Main.storyboard into the single Main.storyboard.
- Injects a meta tag into the HTML header so that the fonts are properly
scaled on (very) high-resolution display.
- The app is not only tested on a simulator but also physically tested
on an iPhone 12 Pro.

See screenshots:

- iOS Home: https://changkun.de/midgard/img/ivy-ios-home.png
- iOS Help: https://changkun.de/midgard/img/ivy-ios-help.png
- Mac Home: https://changkun.de/midgard/img/ivy-mac-home.png
- Mac Help: https://changkun.de/midgard/img/ivy-mac-help.png

Change-Id: I1b8dec6b17d5722fddb1011453b3c8f86e4900e4
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346949
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-09-02 10:41:08 +00:00
Changkun Ou ddd6497b06 cmd/gomobile: enable bitcode unconditionally
As discussed in CL 346150, conditional bitcode build flag was introduced
in CL 214899, for Go >= 1.14 but not Go 1.13.

Since we have dropped the support for 1.13, all bitcode conditions
can be removed.

Hence this CL removes it.

Updates golang/go#47952

Change-Id: I0436cad8d5ab5675b647e25e7dfa85af85996a7e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346390
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-09-01 16:06:15 +00:00
Changkun Ou 80cb72e7af cmd/gomobile: use GOOS=ios for iOS builds
This change permits gomobile to build iOS applications by properly
set GOOS=ios in the build process. The change is locally tested on
darwin/arm64, and golang.org/x/mobile/example/basic can be build
using the following commands:

gomobile build -target=android -o=basic.apk \
golang.org/x/mobile/example/basic

gomobile build -target=ios -bundleid=org.golang.gomobiletest \
-o=basic.app golang.org/x/mobile/example/basic

The built binaries are also tested on iOS 15 beta7 and Android 12 API31.

Updates golang/go#47952
Fixes golang/go#47238

Change-Id: Ibf40a77933ac957640c78d0dbc1af043477e4b3a
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346150
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-01 15:58:30 +00:00
Changkun Ou a0f9ae51e3 cmd/gomobile: allow tests to pass on ios builder
There are several tests are skipped for Android but they may still be
tested on iOS. This will leads to trybot failure.

This CL skips those tests and allow them to pass on iOS.

Furthermore, deprecated C function warning are promoted to errors on
builders, this CL also fixes a deprecated asl_log for iOS in mobileinit.

Change-Id: Ie9da57a20dd75ef3d29b393e30aef01051bab454
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346391
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-09-01 15:13:16 +00:00
Changkun Ou 1fde1d6c3c cmd/gomobile: remove unused binary xml
The removed binary XML was introduced in CL 2653 for the TestBinaryXML.
But in CL 16150, the test was reworked and the binary XML was never
used since then.

Delete it.

Change-Id: I80fd90264142bdcd4a6d88a377e36cba64088a5a
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346389
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-09-01 02:52:45 +00:00
Changkun Ou f7a629369e cmd/gomobile: extract import packages more robust
In darwin/arm64, with Xcode13 toolchain, the nm shows a prefix `_` in
the import path, which was previously not handled.

Such as:

000000010009cd70 t _golang.org/x/mobile/app.(*app).Events
000000010009ce70 t _golang.org/x/mobile/app.(*app).Filter
000000010009cdf0 t _golang.org/x/mobile/app.(*app).Publish
000000010009cd80 t _golang.org/x/mobile/app.(*app).Send
000000010009d870 t _golang.org/x/mobile/app.(*app).loop
000000010009d7f0 t _golang.org/x/mobile/app.(*app).loop.func1

This change fixes the regexp for import package extraction and permits
TestRegexImportGolangXPackage to pass.

Change-Id: I5f8b02177c8b022283276f2ddffaa8bb277aa255
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346154
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-31 18:40:57 +00:00
Changkun Ou 9cba7bc03c cmd/gomobile: handle NDK path for darwin/arm64
This change allows TestBindAndroid to pass.

Fixes golang/go#46464

Change-Id: I8cc3edb21fe9ae9efdc0c8c243a4098553b06e5e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346153
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-31 15:17:48 +00:00
Changkun Ou d82874c7e6 cmd/gomobile: fix flaky TestNdkRoot test
The current TestNdkRoot may fail if ANDROID_HOME and ANDROID_NDK_HOME
are both set from the environment. This is because ndkRoot will first
check ANDROID_HOME, if fails, then check ANDROID_NDK_HOME.

The test was intended to reset the ANDROID_HOME and expecting an error
for fetching ANDROID_NDK_HOME. However, if ANDROID_NDK_HOME is set,
the ndkRoot will not return an error, which may fail the test.

This change moves the environment settings around to permit TestNdkRoot
to pass.

Change-Id: I17ce6dbeec186d35f7a4ba2d8275a43a862c306d
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346152
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-08-31 15:17:20 +00:00
Changkun Ou 18b1a0c48f cmd/gomobile: use Apple Development over iPhone Developer
Apple Development Program was introduced in WWDC2015. It is 2021 today,
and there should have no possibility to use iPhone Developer certificate
for code signing.

This CL replaces "iPhone Developer" by "Apple Development" so that
cmd/gomobile can use the correct certificate to sign the building
application. Otherwise, gomobile throws an error gomobile: failed to
pull the signing certificate to determine your team ID: exit status 44

Updates golang/go#47238

Change-Id: Ia48c03ff7cda39a95159e0f77e7ba7042776f9ef
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346151
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-08-31 15:17:05 +00:00
Hajime Hoshi 34ab1303b5 Revert "cmd/gomobile: support macOS and Catalyst"
This reverts commit 76c259c465.

Reason for revert: Regression. Specifying architectures doesn't work. See golang/go#47212

Change-Id: I3200316cf28535cfb48e37636bc3b9d14d13e91e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/334590
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-07-16 00:47:57 +00:00
Randy Reddig 76c259c465 cmd/gomobile: support macOS and Catalyst
Add support for macOS (non-Catalyst) and Catalyst targets.

The compiled library is packaged into a "fat" XCFramework file (as
opposed to a Framework), which includes binaries for iOS, macOS,
MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and
arm64 architectures.

The generated XCFramework file is suitable for distribution as a binary
Swift Package Manager package:
https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages

This change is based on earlier work:
https://github.com/golang/mobile/pull/45
https://github.com/golang/mobile/pull/63

Fixes golang/go#36856

Change-Id: Iabe535183c7215c68838d6c8f31618d8bceefdcf
GitHub-Last-Rev: 623f8f38653c856d2cd07e721f0932e515b50d02
GitHub-Pull-Request: golang/mobile#65
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/310949
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-07-10 06:49:35 +00:00
Hajime Hoshi 93619952ba cmd/gomobile: enable the test for gomobile-build on iOS
As golang/go#32963 has been fixed, gomobile-build test on iOS now
works.

Updates golang/go#32963

Change-Id: I96add914d1f97de6506f26e4ae0c07e8c884cb6a
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/214957
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-07-01 03:20:07 +00:00
Joseph Morag 7c8f154d10 cmd/gomobile: remove unnecessary IsDir check
The check when looking for android platform is unnecessarily stringent
in that the error would be caught by the call to os.Stat, and
it fails when the android platform folder is a symlink,
which is the case when developing on NixOs.

Change-Id: I07a96c969ffa29dea8bf8e353264e8597dcdc550
GitHub-Last-Rev: c684b80402ad30ad52eb854951aab69657ad7a5d
GitHub-Pull-Request: golang/mobile#55
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/267081
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-06-14 20:29:36 +00:00
Jay Conrod 7e972142eb all: update golang.org/x/tools to v0.1.2
This should fix an incompatibility between
golang.org/x/tools/go/packages/packagestest and Go 1.17.

Fixes golang/go#46418

Change-Id: If1416f53685632d705e7814354f792eb30de88a2
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/323149
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-05-27 17:15:05 +00:00
Russ Cox bdb1ca9a1e all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I30822eb504168b037ed3ec0f7759da1f41251f52
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/294374
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-20 03:30:13 +00:00
Than McIntosh f462b3930c app: support C compiler that defaults to -fno-common
For the Android NDK, between r21 and r22 the NDK compiler switched the
default from "-fcommon" to "-fno-common", which causes duplicate
definitions when building the examples given the current C code. To
fix things, rework the C code to insure that we have a single
definition and an "extern" reference to the objects in question.

Updates golang/go#44121.

Change-Id: If198d5cfd977a7cfd1a37652d3a1916d8c8dbcb7
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/290031
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Than McIntosh <thanm@google.com>
2021-02-08 17:11:26 +00:00
Hajime Hoshi e4a08af010 cmd/gomobile: create go.sum at the temporary directory
As of Go1.16, `go build` fails if go.sum does not exist. This change
fixes this issue by forcing to create go.sum by calling `go mod tidy`.

Closes golang/go#44162

Change-Id: Ibba738503d1a58c6533b2427dd4efa6954b8eaa3
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/290409
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Than McIntosh <thanm@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-02-08 16:36:35 +00:00
Dmitri Shuralyov e6ae53a27f gl: add darwin/arm64 (macOS) support
Update the build constraints so that OpenGL is used both on
macOS AMD64 and ARM64, while OpenGL ES is used on iOS.
This fixes the build on M1 Macs.

For golang/go#43237.

Change-Id: Iad2d406eaf0ddbe72f221f497dd074ad0b22015e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/278779
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
2020-12-17 15:07:44 +00:00
Julie Qiu da85bec010 README.md: add badge to pkg.go.dev
Change-Id: I2324b1db9d9fcf35c52c6c109de277bc1c053644
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/275891
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
2020-12-08 15:29:44 +00:00
Hajime Hoshi 973feb4309 cmd/gomobile: skip TestWriter
TestWriter is flaky and often fails on the trybots. Skip this as a
tentative solution.

Updates golang/go#40290

Change-Id: I3a8aa74fb6cb727a216da4046edaa159f9aa2dc3
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/243839
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-08-01 11:21:45 +00:00
Hajime Hoshi bcce011712 cmd/gomobile: remove darwin/386 support
Go 1.15 no longer supports darwin/386 and supports only arm64 and amd64
for darwin.

Updates golang/go#39575

Change-Id: I89e43f195f87baf5ea647da40614c579fbe45f88
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/243838
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-07-21 16:15:23 +00:00
Hajime Hoshi 68de546597 cmd/gomobile: fix the test for Go 1.15
This is a remaining task for golang/go#39575.

Updates golang/go#39575

Change-Id: I10c021a9349461a7a773d4e93e80601b906741b2
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/243837
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-07-21 16:14:50 +00:00
Hajime Hoshi 1a48f808d8 cmd/gomobile: use arm64 at packagesConfig
Go 1.15 no longer supports darwin/arm. arm64 is still supported by
Android and iOS.

Updates golang/go#39575

Change-Id: I91f09477ae68de148e4d63eef38d7d28f553d16c
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/241717
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-07-20 14:09:40 +00:00
Hajime Hoshi 588b2b2fb0 cmd/gomobile: fix the error when specifying -target=ios with Go 1.15
Go 1.15 no longer supports darwin/arm. This CL fixes by replacing
'allArchs' variable with a function taking a target OS, and excludes
'arm' when the target OS is iOS.

Updates golang/go#39575

Change-Id: I0623ed4cda2c679d2762fd80a7919f24dd5ce016
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/243477
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-07-20 14:09:13 +00:00
Hajime Hoshi 33b8054058 cmd/gomobile: use the specified output name for the module name on iOS
When the module name in *.modulemap and the framework name don't match,
Xcode fails to find the framework.

This CL fixes this issue by using the specified .framework name for the
module name.

Fixes golang/go#35641

Change-Id: I0df5335f2d64f0529e7357c2d04af5eaf760a879
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/239237
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-06-29 15:35:29 +00:00
Hajime Hoshi 4c31acba00 cmd/gomobile: keep the module version information as much as possible
Before this change, the main module specifies the module version of the
package to bind, the version might not be adopted by gomobile because
gomobile trims some dependencies information. If a dependency is not
a main module nor a replaced module, the dependency information is
omitted.

For example, if you have this go.mod in a workspace:

    module example.com/m

    requier (
        github.com/foo/bar v0.1.0-123456
    )

and then run `gomobile bind github.com/foo/bar` there, the specified
version might not be used because github.com/foo/bar is not a main nor
a replaced module.

This change keeps the dependency information as much as possible
to avoid this confusion.

Updates golang/go#37048

Change-Id: I875a1b9485438bdee336f3fc2d131775353004f5
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/226279
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-03-29 12:56:38 +00:00
Hajime Hoshi 3c8601c510 app: fix comparison of keys' direction
KeyEvent's getAction returns ACTION_DOWN (0), ACTION_UP (1) or
other values, and not AKEY_STATE_DOWN (1) or AKEY_STATE_UP (0).
This change fixes the wrong comparison.

Fixes golang/go#37374

Change-Id: Ia65ac881e57cc29d4bdde2365e177c2b4499a2d9
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/220538
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-02-22 14:29:34 +00:00
Hana Kim 2b26a4705d cmd/gomobile: handle modules replaced by other versioned modules
Previously, gomobile bind's go.mod generation logic assumed
replacing module was always located in the disk, but is not
always true. It's valid to replace a module(version) with
another module&version.

For example,

replace golang.org/x/tools => ../

causes:

{
        "Path": "golang.org/x/tools",
        "Version": "v0.0.0-20191017151554-a3bc800455d5",
        "Replace": {
                "Path": "../",
                "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools",
                "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod",
                "GoVersion": "1.11"
        },
        "Dir": "/usr/local/google/home/hakim/go/src/golang.org/x/tools",
        "GoMod": "/usr/local/google/home/hakim/go/src/golang.org/x/tools/go.mod",
        "GoVersion": "1.11"
}

replace github.com/anacrolix/torrent v1.13.0 => gitlab.com/axet/torrent v0.0.0-20200205141541-92b4b9e7387e

causes:

{
        "Path": "github.com/anacrolix/torrent",
        "Version": "v1.13.0",
        "Replace": {
                "Path": "gitlab.com/axet/torrent",
                "Version": "v0.0.0-20200205141541-92b4b9e7387e",
                "Time": "2020-02-05T14:15:41Z",
                "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e",
                "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod"
        },
        "Dir": "/usr/local/google/home/hakim/go/pkg/mod/gitlab.com/axet/torrent@v0.0.0-20200205141541-92b4b9e7387e",
        "GoMod": "/usr/local/google/home/hakim/go/pkg/mod/cache/download/gitlab.com/axet/torrent/@v/v0.0.0-20200205141541-92b4b9e7387e.mod"
}

Also, while we are here, trim down the entries added to the generated
go.mod. We need the main module, and the replaced module info.
We may want to pin golang.org/x/mobile version if possible, but I don't
know a reliable way to achieve that yet.

Fixes golang/go#37048

Change-Id: Ibd7332338c0a3c4165a642c3e86852061f6ab13b
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/218057
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
2020-02-12 15:27:14 +00:00
Hajime Hoshi 0df4eb2385 cmd/mobile: add an arbitrary package to go-list at gomobile-init
go-list without a given module/package tries to analyze the module
at the current directory. If the current directory's module doesn't
have any Go files and is empty, go-list fails. This is the cause
of the problem that gomobile-init fails if the current directory
is such module.

This CL fixes this issue by giving an arbitrary standard library
when executing go-list.

Fixes golang/go#36668

Change-Id: If72d88081c94c2b9ef19d2870b41956a07102122
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/217700
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-02-05 17:02:28 +00:00
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 0c13fd3166 gl: enable use of buffer objects for TexSubImage2D by nil
This CL enables use of a bound buffer at TexSubImage2D by allowing
nil (0) data, which indicates the head of the bound buffer.

In the long run, we need to be able to pass non-0 integer to not
only TexSubImage2D but also other functions like TexImage2D. As we
might change the API, let's revisit this issue later.

Fixes golang/go#36355

Change-Id: I66f6650b10fca9a346cfa6eba246ea9286ed3a85
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/213077
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-01-19 07:00:23 +00:00
fujimoto kyosuke d70acc1097 internal/binres: update wrong URL in comment
The URL in the comment was invalid due to a change in the repository directory structure.
That commit is this:
f6113af2d6

Change-Id: I7dcb9c505de0c5ce4f4a2115d48ccb0c6eadbd52
GitHub-Last-Rev: 85c5e3af7ef53611ca8d9ad83f6929e35d114cc6
GitHub-Pull-Request: golang/mobile#42
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/215357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-01-18 06:27:24 +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