diff --git a/scripts/build_gc_release_android.bat b/scripts/build_gc_release_android.bat new file mode 100644 index 000000000..db9ce3621 --- /dev/null +++ b/scripts/build_gc_release_android.bat @@ -0,0 +1,37 @@ +@rem Android Boehm, static, for programs compiled with -mtriple=-linux-android29. +@rem +@rem scripts\build_gc_release_android.bat [arm64-v8a|x86_64] (no argument: both) +@rem +@rem Needs the Android NDK (tested with r30) in ANDROID_NDK_HOME, and Ninja. Installs into +@rem 3rdParty\gc\android\\release. API level 29 is the floor the default library needs +@rem (timespec_get). +@echo off +setlocal + +if "%ANDROID_NDK_HOME%"=="" ( + echo ANDROID_NDK_HOME is not set: point it at the Android NDK, e.g. C:\Android\android-ndk-r30 + exit /b 1 +) +if not exist "%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake" ( + echo "%ANDROID_NDK_HOME%" is not an Android NDK: build\cmake\android.toolchain.cmake is missing + exit /b 1 +) + +if "%~1"=="" ( + call "%~f0" arm64-v8a || exit /b 1 + call "%~f0" x86_64 || exit /b 1 + exit /b 0 +) + +set ABI=%~1 +set ROOT=%~dp0.. +set BUILD_DIR=%ROOT%\__build\gc\android\%ABI%\release + +cmake -S "%ROOT%\3rdParty\gc-8.2.12" -B "%BUILD_DIR%" -G Ninja -Wno-dev ^ + -DCMAKE_TOOLCHAIN_FILE="%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake" ^ + -DANDROID_ABI=%ABI% -DANDROID_PLATFORM=android-29 ^ + -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON ^ + -DCMAKE_INSTALL_PREFIX="%ROOT%\3rdParty\gc\android\%ABI%\release" ^ + -Denable_threads=ON -Denable_cplusplus=OFF -Denable_docs=OFF -Dbuild_tests=OFF -Dbuild_cord=OFF || exit /b 1 +cmake --build "%BUILD_DIR%" -j 8 || exit /b 1 +cmake --install "%BUILD_DIR%" || exit /b 1 diff --git a/scripts/build_tslang_runtime_release_android.bat b/scripts/build_tslang_runtime_release_android.bat new file mode 100644 index 000000000..e1e0e952f --- /dev/null +++ b/scripts/build_tslang_runtime_release_android.bat @@ -0,0 +1,36 @@ +@rem TypeScriptAsyncRuntime for Android, linked into programs compiled with +@rem -mtriple=-linux-android29. +@rem +@rem scripts\build_tslang_runtime_release_android.bat [arm64-v8a|x86_64] (no argument: both) +@rem +@rem Needs the Android NDK in ANDROID_NDK_HOME, Ninja, the Android gc +@rem (scripts\build_gc_release_android.bat) for gc.h, and 3rdParty\llvm\x64\release\include for +@rem the one header-only MLIR file (see tslang\runtime\CMakeLists.txt). Installs +@rem libTypeScriptAsyncRuntime.a into __build\tslang-runtime\release\android\. +@echo off +setlocal + +if "%ANDROID_NDK_HOME%"=="" ( + echo ANDROID_NDK_HOME is not set: point it at the Android NDK, e.g. C:\Android\android-ndk-r30 + exit /b 1 +) + +if "%~1"=="" ( + call "%~f0" arm64-v8a || exit /b 1 + call "%~f0" x86_64 || exit /b 1 + exit /b 0 +) + +set ABI=%~1 +set ROOT=%~dp0.. +set BUILD_DIR=%ROOT%\__build\tslang-runtime\ninja\android\%ABI%\release + +cmake -S "%ROOT%\tslang\runtime" -B "%BUILD_DIR%" -G Ninja -Wno-dev ^ + -DCMAKE_TOOLCHAIN_FILE="%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake" ^ + -DANDROID_ABI=%ABI% -DANDROID_PLATFORM=android-29 ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DTSLANG_GC_INCLUDE="%ROOT%\3rdParty\gc\android\%ABI%\release\include" ^ + -DTSLANG_MLIR_INCLUDE="%ROOT%\3rdParty\llvm\x64\release\include" ^ + -DCMAKE_INSTALL_PREFIX="%ROOT%\__build\tslang-runtime\release\android\%ABI%" || exit /b 1 +cmake --build "%BUILD_DIR%" -j 8 || exit /b 1 +cmake --install "%BUILD_DIR%" || exit /b 1 diff --git a/tslang/runtime/CMakeLists.txt b/tslang/runtime/CMakeLists.txt index e4ef008aa..664c98be4 100644 --- a/tslang/runtime/CMakeLists.txt +++ b/tslang/runtime/CMakeLists.txt @@ -22,7 +22,13 @@ if (NOT EXISTS "${TSLANG_MLIR_INCLUDE}/mlir/ExecutionEngine/AsyncRuntime.h") endif() set(SRC "${CMAKE_CURRENT_SOURCE_DIR}/../lib/TypeScriptAsyncRuntime") -add_library(TypeScriptAsyncRuntime STATIC "${SRC}/AsyncRuntime.cpp" "${SRC}/DynamicRuntime.cpp") +# The same sources as lib/TypeScriptAsyncRuntime/CMakeLists.txt: without AsyncGCThreads.cpp a `gc` +# program using async does not link (GC_enable_threads); ProcessHeap.cpp is empty off Windows. +add_library(TypeScriptAsyncRuntime STATIC + "${SRC}/AsyncRuntime.cpp" + "${SRC}/AsyncGCThreads.cpp" + "${SRC}/ProcessHeap.cpp" + "${SRC}/DynamicRuntime.cpp") target_include_directories(TypeScriptAsyncRuntime PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../include" "${CMAKE_CURRENT_SOURCE_DIR}/../lib"