mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Runtimes: add overlay for Android platform
This introduces the Android and Math modules for Android in the platform specific overlay.
This commit is contained in:
25
Runtimes/Overlay/Android/Android/CMakeLists.txt
Normal file
25
Runtimes/Overlay/Android/Android/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
gyb_expand(tgmath.swift.gyb tgmath.swift)
|
||||
|
||||
add_library(swiftAndroid
|
||||
tgmath.swift
|
||||
Android.swift
|
||||
Platform.swift
|
||||
POSIXError.swift
|
||||
TiocConstants.swift)
|
||||
set_target_properties(swiftAndroid PROPERTIES
|
||||
Swift_MODULE_NAME Android)
|
||||
target_compile_definitions(swiftAndroid PRIVATE
|
||||
$<$<BOOL:${SwiftOverlay_ENABLE_REFLECTION}>:SWIFT_ENABLE_REFLECTION>)
|
||||
target_link_libraries(swiftAndroid PRIVATE
|
||||
SwiftAndroid
|
||||
swiftCore)
|
||||
|
||||
install(TARGETS swiftAndroid
|
||||
ARCHIVE DESTINATION "${SwiftOverlay_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${SwiftOverlay_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
emit_swift_interface(swiftAndroid)
|
||||
install_swift_interface(swiftAndroid)
|
||||
|
||||
embed_manifest(swiftAndroid)
|
||||
4
Runtimes/Overlay/Android/CMakeLists.txt
Normal file
4
Runtimes/Overlay/Android/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
add_subdirectory(clang)
|
||||
add_subdirectory(Android)
|
||||
add_subdirectory(Math)
|
||||
17
Runtimes/Overlay/Android/Math/CMakeLists.txt
Normal file
17
Runtimes/Overlay/Android/Math/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
add_library(swift_math
|
||||
Math.swift)
|
||||
set_target_properties(swift_math PROPERTIES
|
||||
Swift_MODULE_NAME math)
|
||||
target_link_libraries(swift_math PRIVATE
|
||||
SwiftAndroid
|
||||
swiftCore)
|
||||
|
||||
install(TARGETS swift_math
|
||||
ARCHIVE DESTINATION "${SwiftOverlay_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${SwiftOverlay_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
emit_swift_interface(swift_math)
|
||||
install_swift_interface(swift_math)
|
||||
|
||||
embed_manifest(swift_math)
|
||||
40
Runtimes/Overlay/Android/clang/CMakeLists.txt
Normal file
40
Runtimes/Overlay/Android/clang/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
# FIXME: how do we determine the sysroot? `CMAKE_SYSROOT` does not contain the sysroot.
|
||||
file(CONFIGURE
|
||||
OUTPUT android-ndk-overlay.yaml
|
||||
CONTENT [[
|
||||
---
|
||||
version: 0
|
||||
case-sensitive: false
|
||||
use-external-names: false
|
||||
roots:
|
||||
- name: "@CMAKE_ANDROID_NDK@/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include"
|
||||
type: directory
|
||||
contents:
|
||||
- name: module.modulemap
|
||||
type: file
|
||||
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/android.modulemap"
|
||||
- name: SwiftAndroidNDK.h
|
||||
type: file
|
||||
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/SwiftAndroidNDK.h"
|
||||
- name: SwiftBionic.h
|
||||
type: file
|
||||
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/SwiftBionic.h"
|
||||
]]
|
||||
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
|
||||
|
||||
add_library(SwiftAndroid INTERFACE)
|
||||
target_compile_options(SwiftAndroid INTERFACE
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc --sysroot=\"${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/sysroot\">"
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-vfsoverlay ${CMAKE_CURRENT_BINARY_DIR}/android-ndk-overlay.yaml>")
|
||||
|
||||
install(FILES
|
||||
android.modulemap
|
||||
SwiftAndroidNDK.h
|
||||
SwiftBionic.h
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SwiftOverlay_PLATFORM_SUBDIR}/${SwiftOverlay_ARCH_SUBDIR})
|
||||
|
||||
install(FILES
|
||||
posix_filesystem.apinotes
|
||||
spawn.apinotes
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/apinotes)
|
||||
@@ -50,6 +50,9 @@ add_compile_options(
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-string-processing-module-import>")
|
||||
|
||||
add_subdirectory(clang)
|
||||
if(ANDROID)
|
||||
add_subdirectory(Android)
|
||||
endif()
|
||||
if(WIN32)
|
||||
add_subdirectory(Windows)
|
||||
endif()
|
||||
|
||||
@@ -104,11 +104,35 @@ copy_library_sources("linker-support" "" "Overlay")
|
||||
message(STATUS "Clang[${StdlibSources}/public/ClangOverlays] -> ${CMAKE_CURRENT_LIST_DIR}/Overlay/clang")
|
||||
copy_files(public/ClangOverlays Overlay/clang FILES float.swift.gyb)
|
||||
|
||||
# Android Overlay
|
||||
message(STATUS "Android modulemaps[${StdlibSources}/Platform] -> ${CMAKE_CURRENT_LIST_DIR}/Overlay/Android/clang")
|
||||
copy_files(public/Platform Overlay/Android/clang
|
||||
FILES
|
||||
android.modulemap
|
||||
posix_filesystem.apinotes
|
||||
spawn.apinotes
|
||||
SwiftAndroidNDK.h
|
||||
SwiftBionic.h)
|
||||
|
||||
message(STATUS "Android Android[${StdlibSources}/Platform] -> ${CMAKE_CURRENT_LIST_DIR}/Overlay/Android/Android")
|
||||
copy_files(public/Platform Overlay/Android/Android
|
||||
FILES
|
||||
Android.swift
|
||||
Platform.swift
|
||||
POSIXError.swift
|
||||
TiocConstants.swift
|
||||
tgmath.swift.gyb)
|
||||
|
||||
message(STATUS "Android Math[${StdlibSources}/Platform] -> ${CMAKE_CURRENT_LIST_DIR}/Overlay/Android/Math")
|
||||
copy_files(public/Platform Overlay/Android/Math
|
||||
FILES
|
||||
Math.swift)
|
||||
|
||||
# Windows Overlay
|
||||
message(STATUS "WinSDK[${StdlibSources}/public/Windows] -> ${CMAKE_CURRENT_LIST_DIR}/Overlay/Windows/WinSDK")
|
||||
copy_files(public/Windows Overlay/Windows/WinSDK FILES WinSDK.swift)
|
||||
|
||||
message(STATUS "Windows Modulemaps[${StdlibSources}/Platform] -> ${CMAKE_CURRENT_LIST_DIR}/Overlay/Windows/clang")
|
||||
message(STATUS "Windows modulemaps[${StdlibSources}/Platform] -> ${CMAKE_CURRENT_LIST_DIR}/Overlay/Windows/clang")
|
||||
copy_files(public/Platform Overlay/Windows/clang
|
||||
FILES
|
||||
ucrt.modulemap
|
||||
|
||||
Reference in New Issue
Block a user