cmd/gobind: simplify filepath.Join uses.
filepath.Join returns a Cleaned path that went through FromSlash. Change-Id: I23afeea32453c3eb271d4e4bf47147940061c20f Reviewed-on: https://go-review.googlesource.com/7161 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
b316a2d0ce
commit
f1ef55e1be
@ -125,11 +125,7 @@ func runBind(cmd *command) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pathJoin := func(a, b string) string {
|
mainFile := filepath.Join(tmpdir, "androidlib/main.go")
|
||||||
return filepath.Join(a, filepath.FromSlash(b))
|
|
||||||
}
|
|
||||||
|
|
||||||
mainFile := pathJoin(tmpdir, "androidlib/main.go")
|
|
||||||
err = writeFile(mainFile, func(w io.Writer) error {
|
err = writeFile(mainFile, func(w io.Writer) error {
|
||||||
return androidMainTmpl.Execute(w, "../go_"+binder.pkg.Name())
|
return androidMainTmpl.Execute(w, "../go_"+binder.pkg.Name())
|
||||||
})
|
})
|
||||||
@ -137,9 +133,9 @@ func runBind(cmd *command) error {
|
|||||||
return fmt.Errorf("failed to create the main package for android: %v", err)
|
return fmt.Errorf("failed to create the main package for android: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
androidOutdir := pathJoin(*bindOutdir, "android")
|
androidOutdir := filepath.Join(*bindOutdir, "android")
|
||||||
|
|
||||||
err = gobuild(mainFile, pathJoin(androidOutdir, "libs/armeabi-v7a/libgojni.so"))
|
err = gobuild(mainFile, filepath.Join(androidOutdir, "libs/armeabi-v7a/libgojni.so"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -150,19 +146,19 @@ func runBind(cmd *command) error {
|
|||||||
repo := filepath.Clean(filepath.Join(p.Dir, "..")) // golang.org/x/mobile directory.
|
repo := filepath.Clean(filepath.Join(p.Dir, "..")) // golang.org/x/mobile directory.
|
||||||
|
|
||||||
// TODO(crawshaw): use a better package path derived from the go package.
|
// TODO(crawshaw): use a better package path derived from the go package.
|
||||||
if err := binder.GenJava(pathJoin(androidOutdir, "src/main/java/go/"+binder.pkg.Name())); err != nil {
|
if err := binder.GenJava(filepath.Join(androidOutdir, "src/main/java/go/"+binder.pkg.Name())); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
src := pathJoin(repo, "app/Go.java")
|
src := filepath.Join(repo, "app/Go.java")
|
||||||
dst := pathJoin(androidOutdir, "src/main/java/go/Go.java")
|
dst := filepath.Join(androidOutdir, "src/main/java/go/Go.java")
|
||||||
rm(dst)
|
rm(dst)
|
||||||
if err := symlink(src, dst); err != nil {
|
if err := symlink(src, dst); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
src = pathJoin(repo, "bind/java/Seq.java")
|
src = filepath.Join(repo, "bind/java/Seq.java")
|
||||||
dst = pathJoin(androidOutdir, "src/main/java/go/Seq.java")
|
dst = filepath.Join(androidOutdir, "src/main/java/go/Seq.java")
|
||||||
rm(dst)
|
rm(dst)
|
||||||
if err := symlink(src, dst); err != nil {
|
if err := symlink(src, dst); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -78,9 +78,9 @@ func runInit(cmd *command) error {
|
|||||||
if len(gopaths) == 0 {
|
if len(gopaths) == 0 {
|
||||||
return fmt.Errorf("GOPATH is not set")
|
return fmt.Errorf("GOPATH is not set")
|
||||||
}
|
}
|
||||||
ndkccpath = filepath.Join(gopaths[0], "pkg", "gomobile", "android-"+ndkVersion)
|
ndkccpath = filepath.Join(gopaths[0], "pkg/gomobile/android-"+ndkVersion)
|
||||||
ndkccdl := filepath.Join(ndkccpath, "downloaded")
|
ndkccdl := filepath.Join(ndkccpath, "downloaded")
|
||||||
verpath := filepath.Join(gopaths[0], "pkg", "gomobile", "version")
|
verpath := filepath.Join(gopaths[0], "pkg/gomobile/version")
|
||||||
if buildX {
|
if buildX {
|
||||||
fmt.Fprintln(xout, "NDKCCPATH="+ndkccpath)
|
fmt.Fprintln(xout, "NDKCCPATH="+ndkccpath)
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ func runInit(cmd *command) error {
|
|||||||
if buildN {
|
if buildN {
|
||||||
envpath = "$PATH"
|
envpath = "$PATH"
|
||||||
}
|
}
|
||||||
makeScript := filepath.Join(tmpGoroot, "src", "make")
|
makeScript := filepath.Join(tmpGoroot, "src/make")
|
||||||
if goos == "windows" {
|
if goos == "windows" {
|
||||||
makeScript += ".bat"
|
makeScript += ".bat"
|
||||||
} else {
|
} else {
|
||||||
@ -196,7 +196,7 @@ func runInit(cmd *command) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move the Go cross compiler toolchain into GOPATH.
|
// Move the Go cross compiler toolchain into GOPATH.
|
||||||
gotoolsrc := filepath.Join(tmpGoroot, "pkg", "tool", goos+"_"+goarch)
|
gotoolsrc := filepath.Join(tmpGoroot, "pkg/tool", goos+"_"+goarch)
|
||||||
tools := []string{"5l", "5g", "asm", "cgo", "nm", "pack", "link"}
|
tools := []string{"5l", "5g", "asm", "cgo", "nm", "pack", "link"}
|
||||||
for i, name := range tools {
|
for i, name := range tools {
|
||||||
tools[i] = bin(name)
|
tools[i] = bin(name)
|
||||||
@ -230,7 +230,7 @@ func runInit(cmd *command) error {
|
|||||||
// Move pre-compiled stdlib for android into GOROOT. This is
|
// Move pre-compiled stdlib for android into GOROOT. This is
|
||||||
// the only time we modify the user's GOROOT.
|
// the only time we modify the user's GOROOT.
|
||||||
cannotRemove := false
|
cannotRemove := false
|
||||||
if err := removeAll(filepath.Join(goroot, "pkg", "android_arm")); err != nil {
|
if err := removeAll(filepath.Join(goroot, "pkg/android_arm")); err != nil {
|
||||||
cannotRemove = true
|
cannotRemove = true
|
||||||
}
|
}
|
||||||
if err := move(filepath.Join(goroot, "pkg"), filepath.Join(tmpGoroot, "pkg"), "android_arm"); err != nil {
|
if err := move(filepath.Join(goroot, "pkg"), filepath.Join(tmpGoroot, "pkg"), "android_arm"); err != nil {
|
||||||
@ -452,17 +452,17 @@ func fetchNDK() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dst := filepath.Join(ndkccpath, "arm")
|
dst := filepath.Join(ndkccpath, "arm")
|
||||||
dstSysroot := filepath.Join(dst, "sysroot", "usr")
|
dstSysroot := filepath.Join(dst, "sysroot/usr")
|
||||||
if err := mkdir(dstSysroot); err != nil {
|
if err := mkdir(dstSysroot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
srcSysroot := filepath.Join(tmpdir, "android-ndk-r10d", "platforms", "android-15", "arch-arm", "usr")
|
srcSysroot := filepath.Join(tmpdir, "android-ndk-r10d/platforms/android-15/arch-arm/usr")
|
||||||
if err := move(dstSysroot, srcSysroot, "include", "lib"); err != nil {
|
if err := move(dstSysroot, srcSysroot, "include", "lib"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ndkpath := filepath.Join(tmpdir, "android-ndk-r10d", "toolchains", "arm-linux-androideabi-4.8", "prebuilt")
|
ndkpath := filepath.Join(tmpdir, "android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt")
|
||||||
if goos == "windows" && ndkarch == "x86" {
|
if goos == "windows" && ndkarch == "x86" {
|
||||||
ndkpath = filepath.Join(ndkpath, "windows")
|
ndkpath = filepath.Join(ndkpath, "windows")
|
||||||
} else {
|
} else {
|
||||||
@ -472,7 +472,7 @@ func fetchNDK() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
linkpath := filepath.Join(dst, "arm-linux-androideabi", "bin")
|
linkpath := filepath.Join(dst, "arm-linux-androideabi/bin")
|
||||||
if err := mkdir(linkpath); err != nil {
|
if err := mkdir(linkpath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user