代码拉取完成,页面将自动刷新
同步操作将从 ttpc2008/BaiduPCS-Go 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// AndroidNDKBuild
// go build -ldflags "-X main.APILevel=15 -X main.Arch=x86_64"
// env ANDROID_API_LEVEL NDK ANDROID_NDK_ROOT GOARCH
package main
import (
"os"
"os/exec"
"path/filepath"
"runtime"
"syscall"
)
var (
// NDKPath path to Android NDK
NDKPath string
// APILevel Android api level
APILevel string
// Arch arch
Arch string
)
func getNDKPath() string {
ndkPath, ok := os.LookupEnv("NDK")
if ok {
return ndkPath
}
ndkPath, ok = os.LookupEnv("ANDROID_NDK_ROOT")
if ok {
return ndkPath
}
ndkPath, ok = os.LookupEnv("ANDROID_NDK_DIR")
if ok {
return ndkPath
}
return ""
}
func getAPILevel() string {
apiLevelStr, ok := os.LookupEnv("ANDROID_API_LEVEL")
if ok {
return apiLevelStr
}
return "21"
}
func getGoarch() string {
arch, ok := os.LookupEnv("GOARCH")
if ok {
return arch
}
return runtime.GOARCH
}
func getArch() string {
if Arch != "" {
return Arch
}
goarch := getGoarch()
switch goarch {
case "386":
return "x86"
case "amd64":
return "x86_64"
case "arm64":
return "aarch64"
}
return goarch
}
func getPlatformsArch() string {
arch := getArch()
switch arch {
case "aarch64":
return "arm64"
}
return arch
}
func main() {
if NDKPath == "" {
NDKPath = getNDKPath()
}
if APILevel == "" {
APILevel = getAPILevel()
}
if Arch == "" {
Arch = getArch()
}
lastPattern := "*-gcc"
if runtime.GOOS == "windows" {
lastPattern += ".exe"
}
gccPaths, err := filepath.Glob(filepath.Join(NDKPath, "toolchains", getArch()+"-*", "prebuilt", runtime.GOOS+"-*", "bin", lastPattern))
checkErr(err)
if len(gccPaths) == 0 {
panic("no match gcc")
}
args := make([]string, len(os.Args))
copy(args[1:], os.Args[1:])
args[0] = "--sysroot=" + filepath.Join(NDKPath, "platforms", "android-"+APILevel, "arch-"+getPlatformsArch())
gccExec := exec.Command(gccPaths[0], args...)
gccExec.Stdout = os.Stdout
gccExec.Stderr = os.Stderr
err = gccExec.Run()
exitError, ok := err.(*exec.ExitError)
if ok {
status := exitError.ProcessState.Sys().(syscall.WaitStatus)
os.Exit(status.ExitStatus())
}
if err != nil {
println(err.Error())
}
return
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。