Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Runtimes/Overlay/Android/clang/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

# FIXME: how do we determine the sysroot? `CMAKE_SYSROOT` does not contain the sysroot.
file(CONFIGURE
OUTPUT android-ndk-overlay.yaml
CONTENT [[
Expand All @@ -8,7 +6,7 @@ version: 0
case-sensitive: false
use-external-names: true
roots:
- name: "@CMAKE_ANDROID_NDK@/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include"
- name: "@CMAKE_SYSROOT@/usr/include"
type: directory
contents:
- name: module.modulemap
Expand All @@ -25,7 +23,7 @@ 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:-Xcc --sysroot=\"${CMAKE_SYSROOT}\">"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-vfsoverlay ${CMAKE_CURRENT_BINARY_DIR}/android-ndk-overlay.yaml>")

install(TARGETS SwiftAndroid
Expand Down
7 changes: 5 additions & 2 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1747,14 +1747,15 @@ function Build-CMakeProject {
Add-KeyValueIfNew $Defines CMAKE_ANDROID_API "$AndroidAPILevel"
Add-KeyValueIfNew $Defines CMAKE_ANDROID_ARCH_ABI $Platform.Architecture.ABI
Add-KeyValueIfNew $Defines CMAKE_ANDROID_NDK "$AndroidNDKPath"
Add-KeyValueIfNew $Defines CMAKE_SYSROOT "$AndroidSysroot"

if ($UseASM) {
}

if ($UseC) {
Add-KeyValueIfNew $Defines CMAKE_C_COMPILER_TARGET $Platform.Triple

$CFLAGS = @("--sysroot=${AndroidSysroot}", "-ffunction-sections", "-fdata-sections")
$CFLAGS = @("-ffunction-sections", "-fdata-sections")
if ($DebugInfo) {
$CFLAGS += @("-gdwarf")
}
Expand All @@ -1764,7 +1765,7 @@ function Build-CMakeProject {
if ($UseCXX) {
Add-KeyValueIfNew $Defines CMAKE_CXX_COMPILER_TARGET $Platform.Triple

$CXXFLAGS = @("--sysroot=${AndroidSysroot}", "-ffunction-sections", "-fdata-sections")
$CXXFLAGS = @("-ffunction-sections", "-fdata-sections")
if ($DebugInfo) {
$CXXFLAGS += @("-gdwarf")
}
Expand All @@ -1790,6 +1791,8 @@ function Build-CMakeProject {
[string[]] $SwiftFlags = @()

$SwiftFlags += if ($SwiftSDK) {
# TODO: CMake does not yet have support for passing `CMAKE_SYSROOT` to the Swift compiler yet.
# Once we have that, we can drop `-sysroot $AndroidSysroot` here.
@("-sdk", $SwiftSDK, "-sysroot", $AndroidSysroot)
} else {
@()
Expand Down