Skip to content

Commit 0df7b2f

Browse files
committed
SourceKit: enable builds for Windows
SourceKit's build is now ammenable to building for Windows. Generalize the path to enable building it for Windows as well as Linux. The libdispatch build for the compiler is needed for all non-Darwin targets currently.
1 parent f2bdce8 commit 0df7b2f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tools/SourceKit/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND NOT CMAKE_CROSSCOMPILING)
3535
endif()
3636

3737
# If we were don't have XPC, just build inproc.
38-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND NOT HAVE_XPC_H)
38+
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" OR NOT HAVE_XPC_H)
3939
set(SWIFT_SOURCEKIT_USE_INPROC_LIBRARY TRUE)
4040
endif()
4141

@@ -95,12 +95,11 @@ include_directories(BEFORE
9595
${SOURCEKIT_BINARY_DIR}/tools/SourceKit/include
9696
)
9797

98-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
99-
set(SOURCEKIT_DEFAULT_TARGET_SDK "LINUX")
98+
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
99+
string(TOUPPER "${CMAKE_SYSTEM_NAME}" SOURCEKIT_DEFAULT_TARGET_SDK)
100100
set(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH TRUE)
101101

102102
if(SWIFT_BUILD_SOURCEKIT)
103-
104103
include(ExternalProject)
105104
ExternalProject_Add(libdispatch
106105
SOURCE_DIR

tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ function(add_sourcekit_default_compiler_flags target)
6969
# TODO(compnerd) this should really use target_compile_options but the use
7070
# of keyword and non-keyword flags prevents this
7171
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
72-
list(APPEND c_compile_flags "-fblocks")
72+
list(APPEND c_compile_flags -fblocks)
73+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
74+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
75+
list(APPEND c_compile_flags -Xclang;-fblocks)
76+
else()
77+
list(APPEND c_compile_flags -fblocks)
78+
endif()
7379
endif()
7480

7581
# Convert variables to space-separated strings.

0 commit comments

Comments
 (0)