mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
cmd/gomobile: call System.loadLibrary for .aar
Change-Id: I3fd099910cfb1fe112ded4386905d370acfea002 Reviewed-on: https://go-review.googlesource.com/11816 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
@@ -15,6 +15,14 @@ import java.util.concurrent.Executors;
|
||||
// Used by automatically generated language bindings to talk to Go.
|
||||
public class Seq {
|
||||
static {
|
||||
// Look for the shim class auto-generated by gomobile bind.
|
||||
// Its only purpose is to call System.loadLibrary.
|
||||
try {
|
||||
Class.forName("go.LoadJNI");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Ignore, assume the user will load JNI for it.
|
||||
}
|
||||
|
||||
initSeq();
|
||||
new Thread("GoSeq") {
|
||||
public void run() { Seq.receive(); }
|
||||
|
||||
@@ -15,7 +15,6 @@ import go.testpkg.Testpkg;
|
||||
|
||||
public class SeqTest extends AndroidTestCase {
|
||||
public SeqTest() {
|
||||
System.loadLibrary("gojni");
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
|
||||
+15
-1
@@ -150,8 +150,13 @@ func runBind(cmd *command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
dst := filepath.Join(androidDir, "src/main/java/go/LoadJNI.java")
|
||||
if err := ioutil.WriteFile(dst, []byte(loadSrc), 0664); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
src := filepath.Join(repo, "bind/java/Seq.java")
|
||||
dst := filepath.Join(androidDir, "src/main/java/go/Seq.java")
|
||||
dst = filepath.Join(androidDir, "src/main/java/go/Seq.java")
|
||||
rm(dst)
|
||||
if err := symlink(src, dst); err != nil {
|
||||
return err
|
||||
@@ -160,6 +165,15 @@ func runBind(cmd *command) error {
|
||||
return buildAAR(androidDir, bindPkg)
|
||||
}
|
||||
|
||||
var loadSrc = `package go;
|
||||
|
||||
public class LoadJNI {
|
||||
static {
|
||||
System.loadLibrary("gojni");
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
type binder struct {
|
||||
files []*ast.File
|
||||
fset *token.FileSet
|
||||
|
||||
Reference in New Issue
Block a user