feat: add android build

This commit is contained in:
xishang0128 2023-09-14 18:29:09 +08:00
parent 7ae977866a
commit a28234a21a
4 changed files with 37 additions and 2 deletions

View file

@ -26,7 +26,16 @@ jobs:
with:
python-version: "3.11"
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25b
add-to-path: false
local-cache: true
- name: Run build script
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
export HY_APP_PLATFORMS=$(sed 's/\r$//' platforms.txt | awk '!/^#/ && !/^$/' | paste -sd ",")
python hyperbole.py build -r

View file

@ -26,7 +26,16 @@ jobs:
with:
python-version: "3.11"
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25b
add-to-path: false
local-cache: true
- name: Run build script
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
export HY_APP_PLATFORMS=$(sed 's/\r$//' platforms.txt | awk '!/^#/ && !/^$/' | paste -sd ",")
python hyperbole.py build -r

View file

@ -168,7 +168,6 @@ def get_app_platforms():
result.append((parts[0], parts[1]))
return result
def cmd_build(pprof=False, release=False):
if not check_build_env():
return
@ -204,13 +203,25 @@ def cmd_build(pprof=False, release=False):
out_name += ".exe"
env = os.environ.copy()
env["CGO_ENABLED"] = "0"
env["GOOS"] = os_name
if arch in ARCH_ALIASES:
for k, v in ARCH_ALIASES[arch].items():
env[k] = v
else:
env["GOARCH"] = arch
if os_name == "android":
env["CGO_ENABLED"] = "1"
ANDROID_NDK_HOME = os.environ.get("ANDROID_NDK_HOME") + "/toolchains/llvm/prebuilt/linux-x86_64/bin"
if arch == "arm64" :
env["CC"] = ANDROID_NDK_HOME + "/aarch64-linux-android33-clang"
if arch == "armv7" :
env["CC"] = ANDROID_NDK_HOME + "/armv7a-linux-androideabi33-clang"
if arch == "386" :
env["CC"] = ANDROID_NDK_HOME + "/i686-linux-android33-clang"
if arch == "amd64" :
env["CC"] = ANDROID_NDK_HOME + "/x86_64-linux-android33-clang"
else:
env["CGO_ENABLED"] = "0"
plat_ldflags = ldflags.copy()
plat_ldflags.append("-X")

View file

@ -28,3 +28,9 @@ freebsd/amd64-avx
freebsd/386
freebsd/arm
freebsd/arm64
# Android
android/386
android/amd64
android/armv7
android/arm64