Skip to content

Commit

Permalink
removed bootclasspath
Browse files Browse the repository at this point in the history
  • Loading branch information
TimaSlipko committed Mar 4, 2024
1 parent 2e68c85 commit 7b255cd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
37 changes: 18 additions & 19 deletions cmd/gomobile/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ import (
"strings"
"sync"

"github.com/TimaSlipko/gomobile/internal/sdkpath"
"golang.org/x/mod/modfile"
"golang.org/x/tools/go/packages"
)

var cmdBind = &command{
run: runBind,
Name: "bind",
Usage: "[-target android|" + strings.Join(applePlatforms, "|") + "] [-bootclasspath <path>] [-classpath <path>] [-o output] [build flags] [package]",
Usage: "[-target android|" + strings.Join(applePlatforms, "|") + "] [-classpath <path>] [-o output] [build flags] [package]",
Short: "build a library for Android and iOS",
Long: `
Bind generates language bindings for the package named by the import
Expand Down Expand Up @@ -59,8 +58,8 @@ For Apple -target platforms, gomobile must be run on an OS X machine with
Xcode installed. The generated Objective-C types can be prefixed with the
-prefix flag.
For -target android, the -bootclasspath and -classpath flags are used to
control the bootstrap classpath and the classpath for Go wrappers to Java
For -target android, the -classpath flag is used to
control the classpath for Go wrappers to Java
classes.
The -v flag provides verbose output, including the list of packages built.
Expand Down Expand Up @@ -139,10 +138,10 @@ func runBind(cmd *command) error {
}

var (
bindPrefix string // -prefix
bindJavaPkg string // -javapkg
bindClasspath string // -classpath
bindBootClasspath string // -bootclasspath
bindPrefix string // -prefix
bindJavaPkg string // -javapkg
bindClasspath string // -classpath
//bindBootClasspath string // -bootclasspath
)

func init() {
Expand All @@ -152,19 +151,19 @@ func init() {
cmdBind.flag.StringVar(&bindPrefix, "prefix", "",
"custom Objective-C name prefix. Valid only with -target=ios.")
cmdBind.flag.StringVar(&bindClasspath, "classpath", "", "The classpath for imported Java classes. Valid only with -target=android.")
cmdBind.flag.StringVar(&bindBootClasspath, "bootclasspath", "", "The bootstrap classpath for imported Java classes. Valid only with -target=android.")
//cmdBind.flag.StringVar(&bindBootClasspath, "bootclasspath", "", "The bootstrap classpath for imported Java classes. Valid only with -target=android.")
}

func bootClasspath() (string, error) {
if bindBootClasspath != "" {
return bindBootClasspath, nil
}
apiPath, err := sdkpath.AndroidAPIPath(buildAndroidAPI)
if err != nil {
return "", err
}
return filepath.Join(apiPath, "android.jar"), nil
}
//func bootClasspath() (string, error) {
// if bindBootClasspath != "" {
// return bindBootClasspath, nil
// }
// apiPath, err := sdkpath.AndroidAPIPath(buildAndroidAPI)
// if err != nil {
// return "", err
// }
// return filepath.Join(apiPath, "android.jar"), nil
//}

func copyFile(dst, src string) error {
if buildX {
Expand Down
16 changes: 8 additions & 8 deletions cmd/gomobile/bind_androidapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func goAndroidBind(gobind string, pkgs []*packages.Package, targets []targetInfo
if bindClasspath != "" {
cmd.Args = append(cmd.Args, "-classpath="+bindClasspath)
}
if bindBootClasspath != "" {
cmd.Args = append(cmd.Args, "-bootclasspath="+bindBootClasspath)
}
//if bindBootClasspath != "" {
// cmd.Args = append(cmd.Args, "-bootclasspath="+bindBootClasspath)
//}
for _, p := range pkgs {
cmd.Args = append(cmd.Args, p.PkgPath)
}
Expand Down Expand Up @@ -275,17 +275,17 @@ func buildJar(w io.Writer, srcDir string) error {
}
}

bClspath, err := bootClasspath()
//bClspath, err := bootClasspath()

if err != nil {
return err
}
//if err != nil {
// return err
//}

args := []string{
"-d", dst,
"-source", javacTargetVer,
"-target", javacTargetVer,
"-bootclasspath", bClspath,
//"-bootclasspath", bClspath,
}
if bindClasspath != "" {
args = append(args, "-classpath", bindClasspath)
Expand Down
2 changes: 1 addition & 1 deletion cmd/gomobile/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ GOOS=android CGO_ENABLED=1 gobind -lang=go,java -outdir=$WORK{{if .JavaPkg}} -ja
mkdir -p $WORK/src-android-arm
PWD=$WORK/src-android-arm GOMODCACHE=$GOPATH/pkg/mod GOOS=android GOARCH=arm CC=$NDK_PATH/toolchains/llvm/prebuilt/{{.NDKARCH}}/bin/armv7a-linux-androideabi16-clang CXX=$NDK_PATH/toolchains/llvm/prebuilt/{{.NDKARCH}}/bin/armv7a-linux-androideabi16-clang++ CGO_ENABLED=1 GOARM=7 GOPATH=$WORK:$GOPATH go mod tidy
PWD=$WORK/src-android-arm GOMODCACHE=$GOPATH/pkg/mod GOOS=android GOARCH=arm CC=$NDK_PATH/toolchains/llvm/prebuilt/{{.NDKARCH}}/bin/armv7a-linux-androideabi16-clang CXX=$NDK_PATH/toolchains/llvm/prebuilt/{{.NDKARCH}}/bin/armv7a-linux-androideabi16-clang++ CGO_ENABLED=1 GOARM=7 GOPATH=$WORK:$GOPATH go build -x -buildmode=c-shared -o=$WORK/android/src/main/jniLibs/armeabi-v7a/libgojni.so ./gobind
PWD=$WORK/java javac -d $WORK/javac-output -source 17 -target 17 -bootclasspath {{.AndroidPlatform}}/android.jar *.java
PWD=$WORK/java javac -d $WORK/javac-output -source 17 -target 17 {{.AndroidPlatform}}/android.jar *.java
jar c -C $WORK/javac-output .
`))

Expand Down
2 changes: 1 addition & 1 deletion cmd/gomobile/gendex.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func gendex() error {
"javac",
"-source", "17",
"-target", "17",
"-bootclasspath", platform+"/android.jar",
//"-bootclasspath", platform+"/android.jar",
"-d", tmpdir+"/work",
)
cmd.Args = append(cmd.Args, javaFiles...)
Expand Down

0 comments on commit 7b255cd

Please sign in to comment.