Skip to content

Commit 7e8be21

Browse files
Android: build scripts for the collector and the async runtime (#507)
* Android: build scripts for the collector and the async runtime scripts/build_gc_release_android.bat and scripts/build_tslang_runtime_release_android.bat build Boehm and TypeScriptAsyncRuntime for Android API 29 (arm64-v8a and x86_64) with the NDK's CMake toolchain, from ANDROID_NDK_HOME. The runtime goes through the standalone tslang/runtime project, which needs no LLVM or MLIR libraries. tslang/runtime had drifted from lib/TypeScriptAsyncRuntime: it lacked AsyncGCThreads.cpp (GC_enable_threads, needed by every gc program that is linked against it) and ProcessHeap.cpp (__tslang_heap_*, which ProcessHeapPass makes Windows programs call). Both are back, for the x86 Windows build too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Android build: name the NDK version it was tested with Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8b653fb commit 7e8be21

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@rem Android Boehm, static, for programs compiled with -mtriple=<arch>-linux-android29.
2+
@rem
3+
@rem scripts\build_gc_release_android.bat [arm64-v8a|x86_64] (no argument: both)
4+
@rem
5+
@rem Needs the Android NDK (tested with r30) in ANDROID_NDK_HOME, and Ninja. Installs into
6+
@rem 3rdParty\gc\android\<abi>\release. API level 29 is the floor the default library needs
7+
@rem (timespec_get).
8+
@echo off
9+
setlocal
10+
11+
if "%ANDROID_NDK_HOME%"=="" (
12+
echo ANDROID_NDK_HOME is not set: point it at the Android NDK, e.g. C:\Android\android-ndk-r30
13+
exit /b 1
14+
)
15+
if not exist "%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake" (
16+
echo "%ANDROID_NDK_HOME%" is not an Android NDK: build\cmake\android.toolchain.cmake is missing
17+
exit /b 1
18+
)
19+
20+
if "%~1"=="" (
21+
call "%~f0" arm64-v8a || exit /b 1
22+
call "%~f0" x86_64 || exit /b 1
23+
exit /b 0
24+
)
25+
26+
set ABI=%~1
27+
set ROOT=%~dp0..
28+
set BUILD_DIR=%ROOT%\__build\gc\android\%ABI%\release
29+
30+
cmake -S "%ROOT%\3rdParty\gc-8.2.12" -B "%BUILD_DIR%" -G Ninja -Wno-dev ^
31+
-DCMAKE_TOOLCHAIN_FILE="%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake" ^
32+
-DANDROID_ABI=%ABI% -DANDROID_PLATFORM=android-29 ^
33+
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON ^
34+
-DCMAKE_INSTALL_PREFIX="%ROOT%\3rdParty\gc\android\%ABI%\release" ^
35+
-Denable_threads=ON -Denable_cplusplus=OFF -Denable_docs=OFF -Dbuild_tests=OFF -Dbuild_cord=OFF || exit /b 1
36+
cmake --build "%BUILD_DIR%" -j 8 || exit /b 1
37+
cmake --install "%BUILD_DIR%" || exit /b 1
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@rem TypeScriptAsyncRuntime for Android, linked into programs compiled with
2+
@rem -mtriple=<arch>-linux-android29.
3+
@rem
4+
@rem scripts\build_tslang_runtime_release_android.bat [arm64-v8a|x86_64] (no argument: both)
5+
@rem
6+
@rem Needs the Android NDK in ANDROID_NDK_HOME, Ninja, the Android gc
7+
@rem (scripts\build_gc_release_android.bat) for gc.h, and 3rdParty\llvm\x64\release\include for
8+
@rem the one header-only MLIR file (see tslang\runtime\CMakeLists.txt). Installs
9+
@rem libTypeScriptAsyncRuntime.a into __build\tslang-runtime\release\android\<abi>.
10+
@echo off
11+
setlocal
12+
13+
if "%ANDROID_NDK_HOME%"=="" (
14+
echo ANDROID_NDK_HOME is not set: point it at the Android NDK, e.g. C:\Android\android-ndk-r30
15+
exit /b 1
16+
)
17+
18+
if "%~1"=="" (
19+
call "%~f0" arm64-v8a || exit /b 1
20+
call "%~f0" x86_64 || exit /b 1
21+
exit /b 0
22+
)
23+
24+
set ABI=%~1
25+
set ROOT=%~dp0..
26+
set BUILD_DIR=%ROOT%\__build\tslang-runtime\ninja\android\%ABI%\release
27+
28+
cmake -S "%ROOT%\tslang\runtime" -B "%BUILD_DIR%" -G Ninja -Wno-dev ^
29+
-DCMAKE_TOOLCHAIN_FILE="%ANDROID_NDK_HOME%\build\cmake\android.toolchain.cmake" ^
30+
-DANDROID_ABI=%ABI% -DANDROID_PLATFORM=android-29 ^
31+
-DCMAKE_BUILD_TYPE=Release ^
32+
-DTSLANG_GC_INCLUDE="%ROOT%\3rdParty\gc\android\%ABI%\release\include" ^
33+
-DTSLANG_MLIR_INCLUDE="%ROOT%\3rdParty\llvm\x64\release\include" ^
34+
-DCMAKE_INSTALL_PREFIX="%ROOT%\__build\tslang-runtime\release\android\%ABI%" || exit /b 1
35+
cmake --build "%BUILD_DIR%" -j 8 || exit /b 1
36+
cmake --install "%BUILD_DIR%" || exit /b 1

‎tslang/runtime/CMakeLists.txt‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ if (NOT EXISTS "${TSLANG_MLIR_INCLUDE}/mlir/ExecutionEngine/AsyncRuntime.h")
2222
endif()
2323

2424
set(SRC "${CMAKE_CURRENT_SOURCE_DIR}/../lib/TypeScriptAsyncRuntime")
25-
add_library(TypeScriptAsyncRuntime STATIC "${SRC}/AsyncRuntime.cpp" "${SRC}/DynamicRuntime.cpp")
25+
# The same sources as lib/TypeScriptAsyncRuntime/CMakeLists.txt: without AsyncGCThreads.cpp a `gc`
26+
# program using async does not link (GC_enable_threads); ProcessHeap.cpp is empty off Windows.
27+
add_library(TypeScriptAsyncRuntime STATIC
28+
"${SRC}/AsyncRuntime.cpp"
29+
"${SRC}/AsyncGCThreads.cpp"
30+
"${SRC}/ProcessHeap.cpp"
31+
"${SRC}/DynamicRuntime.cpp")
2632
target_include_directories(TypeScriptAsyncRuntime PRIVATE
2733
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
2834
"${CMAKE_CURRENT_SOURCE_DIR}/../lib"

0 commit comments

Comments
 (0)