-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
I need to gobind multiple packages for an app.
I considered running gomobile for each package and import multiple .so files, but that will fail due to various reasons:
- gobind framework for java assumes a single 'gojni.so' file
- duplicate code for go runtime in multiple .so files; conflicting symbols, storage, ...
Option 1:
gomobile bind -target=android -o=myapp.aar pkg1 pkg2 pkg3
The command will generate separate java classes for those packages, and gather all asset files under one asset directory. Conflicting package names and asset file names are error.
- Problem of proposal 1
I was about to implement fix for x/mobile/cmd/gobind: Allow custom java package prefix #9660 and I don't know how it works with multiple packages.
Option 1.a
gomobile bind -target=android -o=myapp.aar -pkg=com.example.foo,org.example.bar,net.example.baz pkg pkg2 pkg3
Option 1.b
gomobile bind -target=android -o=myapp.aar pkg1:com.example.foo pkg2:org.example.bar pkg3 ...
Option 2:
gomobile bind -target=android -o=myapp.aar -list=something.json
Make gomobile take an input file of a certain format that lists all packages for gobind.
/* something.json */ { Name: "pkg1", Android: "com.example.foo", IOS: "MyFoo" }
Option 3:
Fake main package file - so when gomobile bind sees the 'main' package, it runs gobind on all the imported packages, and process the command that specifies the custom package name for java and prefix for obj-c.
gomobile bind -target=android -o myapp.aar myapp.go
/* myapp.go */ package main import ( _ "pkg1" // android:com.example.foo ios:MyFoo ... ) func main() { }