Some checks failed
Build / Calculate version (push) Failing after 11s
Build / Build binary (386, i386, sse2, true, i386_pentium4, linux, i386, musl) (push) Has been skipped
Build / Build binary (386, i686-linux-android23, android) (push) Has been skipped
Build / Build binary (386, softfloat, i386_pentium-mmx, linux) (push) Has been skipped
Build / Build binary (386, sse2, linux) (push) Has been skipped
Build / Build binary (386, sse2, true, linux, glibc) (push) Has been skipped
Build / Build binary (amd64, amd64, true, x86_64, linux, x86_64, x86_64, musl) (push) Has been skipped
Build / Build binary (amd64, true, linux, glibc) (push) Has been skipped
Build / Build binary (386, windows-7, true, windows) (push) Has been skipped
Build / Build binary (amd64, true, linux, purego) (push) Has been skipped
Build / Build binary (arm, 5, arm_arm926ej-s arm_cortex-a7 arm_cortex-a9 arm_fa526 arm_xscale, linux) (push) Has been skipped
Build / Build binary (amd64, windows-7, true, windows) (push) Has been skipped
Build / Build binary (amd64, x86_64-linux-android23, android) (push) Has been skipped
Build / Build binary (arm, 7, true, linux, glibc) (push) Has been skipped
Build / Build binary (arm, 7, linux) (push) Has been skipped
Build / Build binary (arm, armel, 6, arm_arm1176jzf-s_vfp, linux, armv6hl) (push) Has been skipped
Build / Build binary (arm, armhf, 7, true, arm_cortex-a5_vfpv4 arm_cortex-a7_neon-vfpv4 arm_cortex-a7_vfpv4 arm_cortex-a8_vfpv3 arm_cortex-a9_neon arm_cortex-a9_vfpv3-d16 arm_cortex-a15_neon-vfpv4, linux, armv7hl, armv7hl, musl) (push) Has been skipped
Build / Build binary (arm64, aarch64-linux-android23, android) (push) Has been skipped
Build / Build binary (arm, armv7a-linux-androideabi23, android) (push) Has been skipped
Build / Build binary (arm64, arm64, true, aarch64_cortex-a53 aarch64_cortex-a72 aarch64_cortex-a76 aarch64_generic, linux, aarch64, aarch64, musl) (push) Has been skipped
Build / Build binary (arm64, true, linux, glibc) (push) Has been skipped
Build / Build binary (arm64, true, linux, purego) (push) Has been skipped
Build / Build binary (loong64, linux) (push) Has been skipped
Build / Build binary (loong64, loongarch64, true, loongarch64_generic, linux, loongarch64, musl) (push) Has been skipped
Build / Build binary (loong64, true, linux, glibc) (push) Has been skipped
Build / Build binary (mips, softfloat, mips_24kc mips_4kec mips_mips32, linux) (push) Has been skipped
Build / Build binary (mips64, softfloat, mips64_mips64r2 mips64_octeonplus, linux) (push) Has been skipped
Build / Build binary (mips64le, hardfloat, linux) (push) Has been skipped
Build / Build binary (mips64le, mips64el, hardfloat, true, linux, mips64el, glibc) (push) Has been skipped
Build / Build binary (mips64le, softfloat, mips64el_mips64r2, linux) (push) Has been skipped
Build / Build binary (mipsle, hardfloat, mipsel_24kc_24kf, linux) (push) Has been skipped
Build / Build binary (mipsle, hardfloat, true, linux, glibc) (push) Has been skipped
Build / Build binary (mipsle, mipsel, softfloat, true, mipsel_24kc mipsel_74kc mipsel_mips32, linux, mipsel, musl) (push) Has been skipped
Build / Build binary (mipsle, softfloat, linux) (push) Has been skipped
Build / Build binary (ppc64le, ppc64el, linux, ppc64le) (push) Has been skipped
Build / Build binary (riscv64, linux) (push) Has been skipped
Build / Build binary (riscv64, riscv64, true, riscv64_generic, linux, riscv64, musl) (push) Has been skipped
Build / Build binary (riscv64, true, linux, glibc) (push) Has been skipped
Build / Build binary (s390x, s390x, linux, s390x) (push) Has been skipped
Build / Build Android (push) Has been skipped
Build / Publish Android (push) Has been skipped
Build / Build Darwin binaries (amd64) (push) Has been cancelled
Build / Build Darwin binaries (amd64, true, macos-11) (push) Has been cancelled
Build / Build Darwin binaries (arm64) (push) Has been cancelled
Build / Build Windows binaries (386) (push) Has been cancelled
Build / Build Windows binaries (amd64, true) (push) Has been cancelled
Build / Build Windows binaries (arm64, true) (push) Has been cancelled
Build / Build Apple clients (build/SFI.xcarchive, generic/platform=iOS, ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'app-store'|| inputs.build == 'iOS' }}, iOS, ios, SFI, SFI/Upload.plist) (push) Has been cancelled
Build / Build Apple clients (build/SFM.System.xcarchive, generic/platform=macOS, SFM.System/Export.plist, build/SFM.System, ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'macOS-standalone' }… (push) Has been cancelled
Build / Build Apple clients (build/SFM.xcarchive, generic/platform=macOS, ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'app-store'|| inputs.build == 'macOS' }}, macOS, macos, SFM, SFI/Uploa… (push) Has been cancelled
Build / Build Apple clients (build/SFT.xcarchive, generic/platform=tvOS, ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'app-store'|| inputs.build == 'tvOS' }}, tvOS, tvos, SFT, SFI/Upload.pl… (push) Has been cancelled
Build / Upload builds (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Successful in 10s
109 lines
2.8 KiB
Go
109 lines
2.8 KiB
Go
package build_shared
|
|
|
|
import (
|
|
"go/build"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"sort"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/sagernet/sing-box/log"
|
|
"github.com/sagernet/sing/common"
|
|
"github.com/sagernet/sing/common/rw"
|
|
)
|
|
|
|
var (
|
|
androidSDKPath string
|
|
androidNDKPath string
|
|
)
|
|
|
|
func FindSDK() {
|
|
searchPath := []string{
|
|
"$ANDROID_HOME",
|
|
"$ANDROID_NDK_HOME",
|
|
"$ANDROID_NDK_HOME/..",
|
|
"$HOME/Android/Sdk",
|
|
"$HOME/.local/lib/android/sdk",
|
|
"$HOME/Library/Android/sdk",
|
|
}
|
|
for _, path := range searchPath {
|
|
path = os.ExpandEnv(path)
|
|
if rw.IsFile(filepath.Join(path, "licenses", "android-sdk-license")) {
|
|
androidSDKPath = path
|
|
break
|
|
}
|
|
}
|
|
if androidSDKPath == "" {
|
|
log.Fatal("android SDK not found")
|
|
}
|
|
if !findNDK() {
|
|
log.Fatal("android NDK not found")
|
|
}
|
|
|
|
os.Setenv("ANDROID_HOME", androidSDKPath)
|
|
os.Setenv("ANDROID_SDK_HOME", androidSDKPath)
|
|
os.Setenv("ANDROID_NDK_HOME", androidNDKPath)
|
|
os.Setenv("NDK", androidNDKPath)
|
|
os.Setenv("PATH", os.Getenv("PATH")+":"+filepath.Join(androidNDKPath, "toolchains", "llvm", "prebuilt", runtime.GOOS+"-x86_64", "bin"))
|
|
}
|
|
|
|
func findNDK() bool {
|
|
const fixedVersion = "28.0.13004108"
|
|
const versionFile = "source.properties"
|
|
if fixedPath := filepath.Join(androidSDKPath, "ndk", fixedVersion); rw.IsFile(filepath.Join(fixedPath, versionFile)) {
|
|
androidNDKPath = fixedPath
|
|
return true
|
|
}
|
|
if ndkHomeEnv := os.Getenv("ANDROID_NDK_HOME"); rw.IsFile(filepath.Join(ndkHomeEnv, versionFile)) {
|
|
androidNDKPath = ndkHomeEnv
|
|
return true
|
|
}
|
|
ndkVersions, err := os.ReadDir(filepath.Join(androidSDKPath, "ndk"))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
versionNames := common.Map(ndkVersions, os.DirEntry.Name)
|
|
if len(versionNames) == 0 {
|
|
return false
|
|
}
|
|
sort.Slice(versionNames, func(i, j int) bool {
|
|
iVersions := strings.Split(versionNames[i], ".")
|
|
jVersions := strings.Split(versionNames[j], ".")
|
|
for k := 0; k < len(iVersions) && k < len(jVersions); k++ {
|
|
iVersion, _ := strconv.Atoi(iVersions[k])
|
|
jVersion, _ := strconv.Atoi(jVersions[k])
|
|
if iVersion != jVersion {
|
|
return iVersion > jVersion
|
|
}
|
|
}
|
|
return true
|
|
})
|
|
for _, versionName := range versionNames {
|
|
currentNDKPath := filepath.Join(androidSDKPath, "ndk", versionName)
|
|
if rw.IsFile(filepath.Join(currentNDKPath, versionFile)) {
|
|
androidNDKPath = currentNDKPath
|
|
log.Warn("reproducibility warning: using NDK version " + versionName + " instead of " + fixedVersion)
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
var GoBinPath string
|
|
|
|
func FindMobile() {
|
|
goBin := filepath.Join(build.Default.GOPATH, "bin")
|
|
if runtime.GOOS == "windows" {
|
|
if !rw.IsFile(filepath.Join(goBin, "gobind.exe")) {
|
|
log.Fatal("missing gomobile installation")
|
|
}
|
|
} else {
|
|
if !rw.IsFile(filepath.Join(goBin, "gobind")) {
|
|
log.Fatal("missing gomobile installation")
|
|
}
|
|
}
|
|
GoBinPath = goBin
|
|
}
|