diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index c87f84c..36130d4 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b8fc8e9..8c9b7c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/hyperbole.py b/hyperbole.py index 5846127..97367ba 100755 --- a/hyperbole.py +++ b/hyperbole.py @@ -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") diff --git a/platforms.txt b/platforms.txt index af4b781..9b6f677 100644 --- a/platforms.txt +++ b/platforms.txt @@ -28,3 +28,9 @@ freebsd/amd64-avx freebsd/386 freebsd/arm freebsd/arm64 + +# Android +android/386 +android/amd64 +android/armv7 +android/arm64 \ No newline at end of file