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>
From r16, the legacy headers no longer ship with the NDK. Update
the gomobile build system to use the unified headers instead.
They're available from r14.
Based on a patch by Steeve Morin.
Fixesgolang/go#21802
Change-Id: I098330962c737edb833e968fe82558e15837f23f
Reviewed-on: https://go-review.googlesource.com/69950
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Xcode 9 now enables CLANG_WARN_STRICT_PROTOTYPES by default.
This update ObjC function prototypes with no params from
FOUNDATION_EXPORT Something* DoSomething();
to
FOUNDATION_EXPORT Something* DoSomething(void);
Change-Id: I23b1d3e70a2ede2d2d77951ffe8a1a9598a1b7a0
Reviewed-on: https://go-review.googlesource.com/68970
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Convert Go documentation to JavaDoc tags (/** ... */).
Since the .aar file format doesn't support source files, gomobile
will create a package-sources.jar along with the main package.aar.
For Objective-C, JavaDoc-style comments seems to work as well,
judging by manual inspection of Xcode quick help.
Change-Id: I47fe5b6804681d459a873be37a44610d392166ef
Reviewed-on: https://go-review.googlesource.com/52330
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Declare all implemented interfaces in the protocol list of a bound
struct. This is the ObjC equivalent of similar functionality for
Java.
Change-Id: Ibaea881f57fecf8a0716d25ec925de43974fe0fe
Reviewed-on: https://go-review.googlesource.com/52010
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For functions on the form
New<T>... (...) *T
or
New<T>... (...) (*T, error)
generate corresponding initializers. The name of an initializer is
the function name where "New<T>" is replaced by "init".
If no functions match for a type *T, generate a default (empty)
initializer that returns new(T). The default initializer mirrors
the default constructor in Java.
Fixesgolang/go#20254.
Change-Id: I3c317418fa517d3f2de3f67f400867285b11ea4f
Reviewed-on: https://go-review.googlesource.com/52012
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
in gldebug.go, Enum value TIMEOUT_IGNORED requires uint64 length
to handle it. On the other hand, Enum is declared as uint32, it causes
build error because of overflow.
Since GL_TIMEOUT_IGNORED is not a kind of GLenum, it should not be
listed in that switch statement. Introduce white list for available
Enum value to exclude such variables they cannot be classified as Enum
because of its variable length.
Fixesgolang/go#17075
Change-Id: Ic1a4ee72b313861e48fe3e1cfaec91c91da6ddb3
Reviewed-on: https://go-review.googlesource.com/53531
Reviewed-by: Elias Naur <elias.naur@gmail.com>
The name replacement is done in asMethod.
Change-Id: I9aedf1231c0563f53e3a34f29197e106c090ee6e
Reviewed-on: https://go-review.googlesource.com/51871
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
In commit https://git.io/vQ1gV, the classpath was delayed evaluated to
the task executions. But at Library mode, there will be exception
because the javaCompile involved is not intialized. Add check to fix it.
Change-Id: I23ab2374a704de9fd7bf74ccfaed255045032b3d
Reviewed-on: https://go-review.googlesource.com/48050
Reviewed-by: Elias Naur <elias.naur@gmail.com>
In two places gobind launches go commands but does not pass along
the system's GOROOT causing the subprocess go's to look in
/usr/local/go and fail if GOROOT is not there.
Fixesgolang/go#18209
Change-Id: Ica9455c0b15ba57afc5699b7757d67aa4231c508
Reviewed-on: https://go-review.googlesource.com/46671
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Currently the generated bindings assume that any object
passed to Go as a method argument is actually a valid one
originating from Go. The `null` object is however a corner
case to this assumption, which should be accepted for Go
pointer types, since they can cleanly convert into `nil`.
This CL modifies the generated wrapper code so any `nil`
reference is permitted for Go pointer types, which until
now produced a nil pointer dereference error.
Fixesgolang/go#20330
Change-Id: If1ab9cf9df7ac3808486d23ccf2db8d32fb89426
Reviewed-on: https://go-review.googlesource.com/43253
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Before this CL, unexported fields were ignored for the purposes of
determining which classes a Go struct should extend or implement.
However, the field types were also ignored, resulting in the types
not being generated at all. This CL adds the types of unexported
fields to the set of types to be generated.
Fixesgolang/go#17945
Change-Id: I5c6c44b7cdfe0c3d4c4dc44863ae201dca7ae9a4
Reviewed-on: https://go-review.googlesource.com/38635
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
CL 35953 bumped the minimum required version to Go 1.7. Update the
gomobile documentation to reflect that.
Change-Id: I7cd7937471eb16456a51e8f41bae331344860888
Reviewed-on: https://go-review.googlesource.com/40919
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
CL 30093 removed the go install step from gobind to avoid errors from
circular dependencies with Java reverse wrapper. However, if a
dependency is either never installed or outdated, gobind will fail.
Reinstate the go install step, but ignore errors from the go install
tool.
Tested manually by wiping the $GOPATH/pkg directory and running the
cmd/gobind tests.
Updates golang/go#19046
Change-Id: I31832eccab09b2a7cf29e5d5bc1cc76963b7c2ef
Reviewed-on: https://go-review.googlesource.com/37326
Reviewed-by: David Crawshaw <crawshaw@golang.org>
The test broke a long time ago when the underlying API changed.
It seems too useful to remove outright, so disable it until someone
cares enough to update it.
Updates golang/go#19046.
Change-Id: Iec49be30fbc2e3ffd6fa73e584b15a481751049f
Reviewed-on: https://go-review.googlesource.com/37321
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>