Before this change, binding unsupported basic types such as
uint failed with an error. Instead, add them to the list of
ignored types so that no error is generated and a comment is
generated explaining why the offending function, constant or
variable was skipped.
Unsigned integers are probably easy to support in ObjC, but
leave them unsupported for now.
While here, improve the printing of the ignored types in the
explaining comments.
Fixesgolang/go#24762
Change-Id: I0d9ab471b2245728270f6ee588f554d4a105d500
Reviewed-on: https://go-review.googlesource.com/105377
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
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>
Delay loading of the getRune method ID to the first GoNativeActivity
is created. That way, importing golang.org/x/mobile/app will not
crash, even for gomobile bind programs that don't include (or use)
GoNativeActivity.
Fixesgolang/go#24490
Change-Id: I4bf90e067700451f7c026e53165b6614366d7a94
Reviewed-on: https://go-review.googlesource.com/104395
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For some reason, the changes to the build tags that was supposed to
go in with CL 102915 didn't make it.
Fixesgolang/go#24644
Change-Id: I106b3c71fef1088dd1eea193323c13d81e5985fa
Reviewed-on: https://go-review.googlesource.com/104355
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
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>
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>
Instead of using os.Getenv("GOPATH"), use go env GOPATH to determine
the effective GOPATH.
Fixesgolang/go#21658
Change-Id: I03f897969e30fc3256d171aa7b32c101a9342a1a
Reviewed-on: https://go-review.googlesource.com/101117
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
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.
Fixesgolang/go#24058
Change-Id: I4692fcaa927e7076a6387d080ebc1726905afd72
Reviewed-on: https://go-review.googlesource.com/99875
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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.
Fixesgolang/go#22152
Change-Id: Ie0e05c3e0340b3608de5c68bb3f852d4ef7cdeb1
Reviewed-on: https://go-review.googlesource.com/102095
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Move the benchmark support package to the testdata directory, just
like the other test packages.
Change-Id: Idc35ca973a7da78e8c8bb640ba60cfb947fbed5b
Reviewed-on: https://go-review.googlesource.com/101896
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
If ever the gobind tool switches to a source importer (see CL
99777), make sure import paths are without trailing slashes are
handled correctly.
Change-Id: Ib3ce15f8dcd53dce09a5bb183e4013a5deba39b4
Reviewed-on: https://go-review.googlesource.com/99776
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
The reverse bindings allow access to Java and ObjC APIs by importing
Java/... and Objc/... package from Go. The gobind tool automatically
create the bindings for the API referenced from the packages.
The reverse example takes that ability too far, however. It creates
a circular dependency from the Android databinding layout files to
exported Go types while those same Go types access the Java classes
generated by databinding. It works almost by accident, but not for
newer Gradle versions.
The circular dependencies are bad, but the underlying circular references
created by using the reverse bindings this way are worse. I haven't found
a satisfactory was to avoid retaining references to Go objects from Java
and back without carefully and manually breaking cycles at appropriate
times. One might succeed in ObjC where breaking reference cycles are
already necessary, but not in Java.
The reverse example is a nice technical feat, but promises more than
it can deliver. Delete it.
Fixesgolang/go#19862Fixesgolang/go#18210
Change-Id: Ie6abd2a0ebd4c4ce36339d1294898e15f22f83bd
Reviewed-on: https://go-review.googlesource.com/101155
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Gobind now outputs Java sources to the java/ subdirectory. Update the
gradle plugin to match. Only projects using reverse bindings are
affected.
Change-Id: Id7f893d3c67a9ab63336c4e031c9196a0b6dad2c
Reviewed-on: https://go-review.googlesource.com/99775
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
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>
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>
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>
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>
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>
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>
Remove the android support library dependency.
The Android build system assumes at least one resource, so
add a dummy string.
Change-Id: I7223b75709f1aa5907e6d04bc656eea5503bb640
Reviewed-on: https://go-review.googlesource.com/94195
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
When there is no prior gradle cache (i.e .gradle/ directory isn't created yet) in your Android project and a gradle build command is executed (e.g ./gradlew build), the *.so files generated by the gobind android plugin is not packaged into the apk.
Successive builds work fine though.
This issue doesn't happen when using Android plugin version 2.x, but does using version 3.x.
The gomobile bind task, libTask, is only finalizing the java compile task which allows it to run in parallel with javaCompile. That is probably too late, so instead, make libTask a dependency of the compile task to make sure the output of gomobile bind (in particular, the *so libraries) are included in the final build product.
Fixesgolang/go#23766
Change-Id: I62727bfa0ffd54d8158c3a2aa3d7303867fcbabc
Reviewed-on: https://go-review.googlesource.com/94835
Reviewed-by: Elias Naur <elias.naur@gmail.com>
The test in CL 87656 exposed the problem that an ObjC class C in
header C.h can't implement an interface I in I.h if I.h itself includes
C.h, resulting in an include cycle. Avoid the problem for now by
restricting the set of declared interfaces to the current package and
its imports. This is too strict, but simple and avoids any include
cycles.
Fixes the bind/objc SeqTest on iOS.
Change-Id: I2ff964593cb9e56994c42b68cc49eebe2f549217
Reviewed-on: https://go-review.googlesource.com/88818
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
Windows bindings had few invalid bindings.
Debug type had a typo, making gldebug non-compilable.
Use consistently .c() for types.
Fixesgolang/go#23451
Change-Id: Ic9e68b1aafcd732dd5e4d8f883324723a35d24c3
Reviewed-on: https://go-review.googlesource.com/87855
Reviewed-by: Elias Naur <elias.naur@gmail.com>
If a Go struct or interface has the same name as its package class,
append an underscore to the generated Java class name.
Fixesgolang/go#23327.
Change-Id: Ib680af35c956801073a0effb510a3ed9bbb8b9d1
Reviewed-on: https://go-review.googlesource.com/87656
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
0.2.9 was broken - for unknown reasons, the plugin was built on
top of stale sources.
Updates golang/go#21594
Plugin 0.2.10 was built with rev 50b7067 and this change.
% docker run --rm -u root -v "$PWD":/home/gradle/project \
-w /home/gradle/project gradle:latest \
gradle publishPlugins
Gradle version is 4.0.1.
Change-Id: I146dc67cbad3c9945a2acdf4ac7993283725090a
Reviewed-on: https://go-review.googlesource.com/86775
Reviewed-by: Elias Naur <elias.naur@gmail.com>
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>
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".
Fixesgolang/go#17407
Change-Id: Ib0b878424a95a0cd49f3655ed4de56b2b91ff7a0
Reviewed-on: https://go-review.googlesource.com/77070
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Go compiles to machine code, not bitcode and Xcode will complain if
the bitcode setting is left enabled (the default).
Change-Id: If2caca0b70419c2901b5bfc159669307be39f964
Reviewed-on: https://go-review.googlesource.com/72670
Reviewed-by: David Crawshaw <crawshaw@golang.org>
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>