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

383 Коммитов

Автор SHA1 Сообщение Дата
Hajime Hoshi 7ff83004ec cmd/gomobile: use Output instead of CombinedOutput at envClang
It dosen't make sense to parse stdout and stderr to get a necessary
information like clang command. Actually envClang sometimes didn't work
correctly due to this.

Fixes golang/go#53316

Change-Id: Ia2c518c44c0003b4f9b50dba85fb971c2ef4340d
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/620315
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-10-16 13:47:51 +00:00
Sander Bruens 755f4ef71b cmd/gomobile: fix error message to reflect current build target
Change-Id: I94b7d1c7029102c252a77f75929066281040b9f2
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/564856
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-04-01 22:45:55 +00:00
scosman 365c353387 cmd/gomobile: add CFBundleShortVersionString and CFBundleVersion, fixing Apple validation/distribution
An app containing a framework can't be validated and distributed without these two entries in the framework bundle's `Info.plist`.

Using `0.0.epoch` format per discussion here: https://go.dev/issue/66500#issuecomment-2025767017

Tested Xcode 15.3 with:
 - without keys, fails to validate
 - with keys: passing validation, distribution upload, and Apple's server validation ("Ready to test" server check).

Fixes golang/go#66500

Change-Id: I2e0718247301ec7db36f8d85aea81b203ca7848b
GitHub-Last-Rev: 1455c5e816
GitHub-Pull-Request: golang/mobile#100
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/575115
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2024-03-29 16:42:31 +00:00
scosman 268e6c3a80 cmd/gomobile: produce frameworks which follow Apple's specs per platform, fixing Xcode 15.3 compatibility issues
This patch updates the framework generation code to follow the Apple spec for placing content:
https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle

Previously, we setup the framework in MacOS format, and used symlinks to make it compatible with iOS format. This approach no longer works (it works locally in simulator, but causes signing issues when attempting to upload apps for distribution, or running on real hardware). We now setup the expected bundle format for each platform.

Other benefits:

 - Thirds the size of the xcframework and resulting app binary when distributing the xcframework by zip (common for SPM and other formats). The symlinks resulted in duplicate files after zipping, which made it into the final app.
 - Set MinimumOSVersion, fixing SPM compatibility issue
 - Eliminates the blank Info.plist
 - Initial testing shows this also fixes golang/go#66406 (code signing issues) as a side effect of using the proper format

Testing:

 - Tested all 4 platforms (iOS, simulator, macOS, Catalyst) on Xcode 15.3

Fixes golang/go#66406
Fixes golang/go#66500

Change-Id: I8538989efe67cb0d2d0496087dcbeca923c3dffe
GitHub-Last-Rev: 28dca85888
GitHub-Pull-Request: golang/mobile#98
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/574055
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-03-26 19:53:18 +00:00
scosman 19e4cdff46 cmd/gomobile: fix a compatibility issue with Xcode 15.3
This change adds compatibility for Xcode 15.3 to "gomobile bind" for building xcframeworks.

 - New blank Info.plist in the *.framework target root
 - Add CFBundleExecutable and CFBundleIdentifier to the resource level Info.plist

Tested locally on my framework on Xcode 15.3 (fixes issue) and 15.2 (doesn't create new issues).

Would love to get some more folks to try this fix, to make sure it works broadly.

Note: I'm using the framework name as the bundleID. Some chance of collision here, but didn't want to add a required top level cmd parameter. I don't *think* a collision is a serious concern, but I'm not an apple build system expert.

To test:
 - sync my branch
 - build go mobile: `go build` in the `cmd/gomobile` dir
 - Build your xcframework with this version of go mobile: `gomobile bind ... `
 - Launch a project using the xcframework in Xcode 15.3, and run in simulator

Fixes golang/go#66018

Change-Id: I3e8ee99adb09071aa89a541dc97271a44b552ea3
GitHub-Last-Rev: 6277c7d66a
GitHub-Pull-Request: golang/mobile#96
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/572175
TryBot-Result: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-03-18 14:18:34 +00:00
Hajime Hoshi e2f452493d cmd/gomobile: resolve symbolic links as a workaround for an Xcode bug
On macOS, a temporary directory starts with /var, which is a symbolic
link to /private/var. And in gomobile, a temporary directory is usually
used as a working directly. Unfortunately, xcodebuild in Xcode 15 seems
to have a bug and might not be able to understand fullpaths with
symbolic links. As a workaround, resolve the path with symbolic links by
filepath.EvalSymlinks.

Fixes golang/go#63141

Change-Id: Ieb684223192fc3e354b79dededaecdb0b25937e6
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/530135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Hajime Hoshi <hajimehoshi@gmail.com>
2023-09-22 14:23:53 +00:00
Hajime Hoshi dc64209e86 cmd/gomobile: add go statements to autogenerated go.mod files
go.mod files are automatically generated in a temporary working
directory in order to resolve dependencies. The go.mod files didn't
include go statements, which means a Go compiler tried to resolve
dependencies in the most conservative way. In this way, some paths could
not be resolved as ambiguous paths (e.g. golang.org/x/exp vs
golang.org/x/exp/shiny).

This CL fixes this issue by giving a go statement to the go.mod files.

Fixes golang/go#62458

Change-Id: Ibabd1974f8cd7a3e01eb89994080e32a7115693a
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/525695
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-06 02:19:30 +00:00
Hajime Hoshi fbe1c053b6 all: update Go version to 1.18
Fixes golang/go#62415

Change-Id: Ica46a62f60b8ebcf6244da98fe4e0643206cb24f
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/525095
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-09-05 14:05:55 +00:00
Suzukihonoka 3c911d8e3e cmd/gomobile: upgrade minimal javac version to 1.8
Fixes golang/go#59803

Change-Id: I248ab312eedf091bbfd6ebf35c8990fbdf611fbc
GitHub-Last-Rev: c61def7df0
GitHub-Pull-Request: golang/mobile#91
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/488555
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2023-05-31 17:31:38 +00:00
cui fliter e8d11dd0ba cmd/gobind: remove repeated definite articles
Change-Id: Ib2d256f59ec759100f8c25e52acf24547a6528fb
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/489735
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-04-27 22:14:53 +00:00
Hajime Hoshi e0f57694e1 cmd/gomobile: update the doc about the minimum Android SDK version
Change-Id: Ia17aadf683b8e3e918e0490b9b3bf4f6ae48d813
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/472236
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
2023-03-01 16:31:55 +00:00
Hajime Hoshi b36e624617 cmd/gomobile: concurrent build for iOS archive files
This change makes building archive files for iOS concurrent for each
architecture and each platform. The strategy is basically the same as
my previous CL for Android: https://go.dev/cl/426274.

This change also specifies GOMODCACHE explicitly when executing Go
commands so that the existing cache is always used. The default
GOMODCACHE is $GOPATH/pkg/mod, and this path varies when a temporary
GOPATH is specified, which results in cold cache.

Before this change (on my MacBook Pro 2020):

$ time go run ./cmd/gomobile/ bind -target ios ./example/bind/hello/

real    0m23.274s
user    0m15.751s
sys     0m10.469s

After this change:

$ time go run ./cmd/gomobile/ bind -target ios ./example/bind/hello/

real    0m8.059s
user    0m13.763s
sys     0m9.004s

Updates golang/go#37902
Updates golang/go#54770

Change-Id: Iaeb077b58c22ab63d28f78972a0af76660883a05
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/442195
Reviewed-by: Changkun Ou <mail@changkun.de>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-10-20 08:52:26 +00:00
Hana (Hyang-Ah) Kim 406ed3a7b8 cmd/gobind: do not compile package just to find package dir
Gobind utilizes golang.org/x/tools/go/packages.Load to find
the directory of a package. Configure the load configuration
to just find the list of files. Zero load mode is equivalent
to combining NeedName+NeedFiles+NeedCompiledGoFiles bits.
That is unnecessary, and can increase the chance of load
failures. For example, load with the zero load mode may fail
if all the necessary cgo dependencies aren't available in the
system, but that shouldn't be critical for gobind's use case.

Updates golang/go#56292

Change-Id: Ifaf4f43e9053cf4a43fd657a9a394fc13f611576
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/443935
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-10-19 14:23:27 +00:00
Bryan C. Mills 3eb82726e4 cmd/gobind: exec the test binary as gobind and log only stderr by default
Using the test binary as the "gobind" command not only avoids the
overhead of recompiling the command, but also allows commands like "go
test -race" to actually test the requested configuration of the
command.

Logging stderr and stdout separately — and logging only stderr by
default — makes the failure messages much easier to spot. (Logging the
combined output as before produced a massive wall of text that tends
to bury the actual errors.)

For golang/go#56292.

Change-Id: Ia11fad19418d9b9004608c76fe512ceab4f247bc
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/443655
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-10-18 19:01:30 +00:00
Hajime Hoshi 58284a7bfc cmd/gomobile: clean-up the code using gobind for iOS
This CL cleans up the code using gobind by these fixes:

- Run the gobind command for each platform, instead of each target (=
  platform + arch).
- Run the gobind command in parallel with errgroup.Group.

This CL doesn't improve performance significantly, but should improve
readability by splitting the long for-range loop.

Updates golang/go#54770

Change-Id: I881810b95db0fa6a6d17982154591af467f1ebfe
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/437035
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Changkun Ou <mail@changkun.de>
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
2022-10-10 19:42:47 +00:00
Hajime Hoshi fa6bcb0768 cmd/gomobile: concurrent gomobile-bind building for Android
This speeds up gomobile-bind for Android by concurrent building for
each architecture.

Before this change (on my MacBook Pro 2020):

```
$ time go run ./cmd/gomobile/ bind -target android ./example/bind/hello/

real    0m22.555s
user    0m14.859s
sys     0m10.232s
```

After this change:

```
$ time go run ./cmd/gomobile/ bind -target android ./example/bind/hello/

real    0m9.404s
user    0m15.846s
sys     0m11.044s
```

For #54770

Change-Id: I5a709dd4422a569e9244e924bd43ad2da1ede164
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/426274
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Changkun Ou <mail@changkun.de>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
2022-09-28 05:21:26 +00:00
Ben Schwartz 8578da9835 all: modernize handling of Android SDK and NDK paths
This change removes Gomobile's dependency on ANDROID_HOME and
ANDROID_NDK_HOME.  Setting ANDROID_HOME is generally optional,
and ANDROID_NDK_HOME is deprecated.

This change also increases the minimum API version to 16, as
all SDKs that supported API 15 are now deprecated.

Fixes golang/go#52470

Change-Id: I546365774a089e5d7ae1be0a538efd72741d92ac
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/401574
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Skinner <daniel@dasa.cc>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-05-18 20:53:45 +00:00
Changkun Ou 50dca8fc07 cmd/gomobile: tidy a few unused code and variables
Change-Id: I979589adf74ec0cd097ef7acc6c120f6557c8f25
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/369201
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-05-04 14:47:22 +00:00
Russ Cox ce6a79cf6a all: gofmt
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: I9b4c287e2d25aa108adfa9fe2f972c8fd3d68fe1
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/399597
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-04-14 15:34:00 +00:00
Zaiyang Li 032b21455f cmd/gomobile: add missing latest tag to gobind
Go install requires a version to be provided after the package name.
gomobile init command is updated to reflect this new requirement

Fixes golang/go#50994

Change-Id: I014bd6815d9620415ceb43dd7e0aea3afac60556
GitHub-Last-Rev: 3a07fa6691
GitHub-Pull-Request: golang/mobile#75
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/384414
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-23 14:21:00 +00:00
Hana 858099ff78 cmd,bind: add implicit dependencies
cmd/gomobile depends on cmd/gobind. Code generated by cmd/gobind
depends on packages under golang.org/x/mobile/bind. Explicitly
list those (with build tags) so the go command can take into account
these implicit dependencies (e.g. go mod tidy or go mod vendor).

We use tag `mobile_implicit`.

Updates golang/go#43736

Change-Id: I09c519556ffe8e8c4db0754571c5173b1613c210
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/377754
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-01-12 01:59:53 +00:00
Changkun Ou 4e6c2922fd cmd/gomobile: remove binary XML
It is a full of unused code. Remove it.

Change-Id: I086f244adde57c8c9f1fc73b46e25550f15562f7
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/369197
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-07 04:14:40 +00:00
Changkun Ou 29d5ad490c cmd/gomobile: remove outdated TODO of bundle ID
The TODO message was introduced in CL 13041, but later resolved
in CL 77070 because it allows bundle id customization.

Remove the oudated TODO message.

Change-Id: Ib32793ace937f67b5c95d6efadd6d4eef48a8986
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/369200
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Alex Rakoczy <alex@golang.org>
Run-TryBot: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-07 04:13:54 +00:00
Changkun Ou fea317f4e1 cmd/gomobile: use LLVM binutils if GNU binutils are missing
Starting from NDK 23, GNU binutils are fully migrated to LLVM binutils.
Use LLVM if GNU binutils are missing.

Fixes golang/go#49808

Change-Id: Iccb40780390a66081fc811d717c7357194b92acf
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/369195
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-12-06 11:09:38 +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: aebf3cd7ff
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
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: 01ab28e63f
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 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: 623f8f3865
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: c684b80402
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
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
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
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
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