mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
build: rewritten the Android build system
Completely rewritten the Android build system using Python Co-Authored-By: 东灯 <43312495+Lampese@users.noreply.github.com> Co-Authored-By: Feng Yu <F3n67u@outlook.com> PR-URL: https://github.com/nodejs/node/pull/44207 Refs: https://github.com/nodejs/node/issues/36287 Reviewed-By: Feng Yu <F3n67u@outlook.com> Reviewed-By: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
7dd2f41c73
commit
ee9aac1f1c
3 changed files with 134 additions and 80 deletions
76
android_configure.py
Normal file
76
android_configure.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
import platform
|
||||
import sys
|
||||
import os
|
||||
|
||||
# TODO: In next version, it will be a JSON file listing all the patches, and then it will iterate through to apply them.
|
||||
def patch_android():
|
||||
print("- Patches List -")
|
||||
print("[1] [deps/v8/src/trap-handler/trap-handler.h] related to https://github.com/nodejs/node/issues/36287")
|
||||
if platform.system() == "Linux":
|
||||
os.system('patch -f ./deps/v8/src/trap-handler/trap-handler.h < ./android-patches/trap-handler.h.patch')
|
||||
print("\033[92mInfo: \033[0m" + "Tried to patch.")
|
||||
|
||||
if platform.system() == "Windows":
|
||||
print("android-configure is not supported on Windows yet.")
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "patch":
|
||||
patch_android()
|
||||
sys.exit(0)
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print("Usage: ./android-configure [patch] <path to the Android NDK> <Android SDK version> <target architecture>")
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.exists(sys.argv[1]) or not os.listdir(sys.argv[1]):
|
||||
print("\033[91mError: \033[0m" + "Invalid path to the Android NDK")
|
||||
sys.exit(1)
|
||||
|
||||
if int(sys.argv[2]) < 24:
|
||||
print("\033[91mError: \033[0m" + "Android SDK version must be at least 24 (Android 7.0)")
|
||||
sys.exit(1)
|
||||
|
||||
android_ndk_path = sys.argv[1]
|
||||
android_sdk_version = sys.argv[2]
|
||||
arch = sys.argv[3]
|
||||
|
||||
if arch == "arm":
|
||||
DEST_CPU = "arm"
|
||||
TOOLCHAIN_PREFIX = "armv7a-linux-androideabi"
|
||||
elif arch in ("aarch64", "arm64"):
|
||||
DEST_CPU = "arm64"
|
||||
TOOLCHAIN_PREFIX = "aarch64-linux-android"
|
||||
arch = "arm64"
|
||||
elif arch == "x86":
|
||||
DEST_CPU = "ia32"
|
||||
TOOLCHAIN_PREFIX = "i686-linux-android"
|
||||
elif arch == "x86_64":
|
||||
DEST_CPU = "x64"
|
||||
TOOLCHAIN_PREFIX = "x86_64-linux-android"
|
||||
arch = "x64"
|
||||
else:
|
||||
print("\033[91mError: \033[0m" + "Invalid target architecture, must be one of: arm, arm64, aarch64, x86, x86_64")
|
||||
sys.exit(1)
|
||||
|
||||
print("\033[92mInfo: \033[0m" + "Configuring for " + DEST_CPU + "...")
|
||||
|
||||
if platform.system() == "Darwin":
|
||||
host_os = "darwin"
|
||||
toolchain_path = android_ndk_path + "/toolchains/llvm/prebuilt/darwin-x86_64"
|
||||
|
||||
elif platform.system() == "Linux":
|
||||
host_os = "linux"
|
||||
toolchain_path = android_ndk_path + "/toolchains/llvm/prebuilt/linux-x86_64"
|
||||
|
||||
os.environ['PATH'] += os.pathsep + toolchain_path + "/bin"
|
||||
os.environ['CC'] = toolchain_path + "/bin/" + TOOLCHAIN_PREFIX + android_sdk_version + "-" + "clang"
|
||||
os.environ['CXX'] = toolchain_path + "/bin/" + TOOLCHAIN_PREFIX + android_sdk_version + "-" + "clang++"
|
||||
|
||||
GYP_DEFINES = "target_arch=" + arch
|
||||
GYP_DEFINES += " v8_target_arch=" + arch
|
||||
GYP_DEFINES += " android_target_arch=" + arch
|
||||
GYP_DEFINES += " host_os=" + host_os + " OS=android"
|
||||
os.environ['GYP_DEFINES'] = GYP_DEFINES
|
||||
|
||||
if os.path.exists("./configure"):
|
||||
os.system("./configure --dest-cpu=" + DEST_CPU + " --dest-os=android --openssl-no-asm --cross-compiling")
|
Loading…
Add table
Add a link
Reference in a new issue