Skip to content

Commit 488e335

Browse files
authored
Merge pull request #3594 from jpsim/sourcekit-link-libdispatch
[SourceKit] Link with libdispatch & libswiftCore on Linux
2 parents f207607 + d3d211b commit 488e335

File tree

8 files changed

+38
-7
lines changed

8 files changed

+38
-7
lines changed

tools/SourceKit/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,5 +506,19 @@ include_directories(BEFORE
506506
${SOURCEKIT_SOURCE_DIR}/include
507507
)
508508

509+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
510+
include_directories(AFTER ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
511+
512+
add_library(dispatch SHARED IMPORTED)
513+
set_target_properties(dispatch PROPERTIES
514+
IMPORTED_LOCATION ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so)
515+
516+
add_library(swiftCore SHARED IMPORTED)
517+
set_target_properties(swiftCore PROPERTIES
518+
IMPORTED_LOCATION ${SOURCEKIT_BINARY_DIR}/lib/swift/linux/libswiftCore.so)
519+
520+
set(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH TRUE)
521+
endif()
522+
509523
add_subdirectory(lib)
510524
add_subdirectory(tools)
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(SourceKitSupport_sources
2+
Concurrency-libdispatch.cpp
23
FuzzyStringMatcher.cpp
34
Logging.cpp
45
ImmutableTextBuffer.cpp
@@ -7,14 +8,12 @@ set(SourceKitSupport_sources
78
UIDRegistry.cpp
89
)
910

10-
set(SourceKitSupport_Darwin_sources
11-
Concurrency-Mac.cpp)
12-
set(LLVM_OPTIONAL_SOURCES ${SourceKitSupport_Darwin_sources})
13-
if(APPLE)
14-
list(APPEND SourceKitSupport_sources ${SourceKitSupport_Darwin_sources})
11+
set(SOURCEKIT_SUPPORT_DEPEND swiftBasic clangBasic clangRewrite)
12+
if(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH)
13+
list(APPEND SOURCEKIT_SUPPORT_DEPEND dispatch BlocksRuntime)
1514
endif()
1615

1716
add_sourcekit_library(SourceKitSupport
1817
${SourceKitSupport_sources}
19-
DEPENDS swiftBasic clangBasic clangRewrite
18+
DEPENDS ${SOURCEKIT_SUPPORT_DEPEND}
2019
)

tools/SourceKit/lib/Support/Concurrency-Mac.cpp renamed to tools/SourceKit/lib/Support/Concurrency-libdispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- Concurrency-Mac.cpp ----------------------------------------------===//
1+
//===--- Concurrency-libdispatch.cpp --------------------------------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//

tools/SourceKit/tools/complete-test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ else()
44
set(SOURCEKITD_TEST_DEPEND sourcekitd)
55
endif()
66

7+
if(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH)
8+
set(SOURCEKITD_TEST_DEPEND ${SOURCEKITD_TEST_DEPEND} dispatch swiftCore)
9+
endif()
10+
711
add_sourcekit_executable(complete-test
812
complete-test.cpp
913
DEPENDS ${SOURCEKITD_TEST_DEPEND}

tools/SourceKit/tools/sourcekitd-repl/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ if(HAVE_UNICODE_LIBEDIT)
88
set(SOURCEKITD_REPL_DEPEND sourcekitd)
99
endif()
1010

11+
if(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH)
12+
set(SOURCEKITD_REPL_DEPEND ${SOURCEKITD_REPL_DEPEND} dispatch swiftCore)
13+
endif()
14+
1115
add_sourcekit_executable(sourcekitd-repl
1216
sourcekitd-repl.cpp
1317
DEPENDS ${SOURCEKITD_REPL_DEPEND} edit

tools/SourceKit/tools/sourcekitd-test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ else()
88
set(SOURCEKITD_TEST_DEPEND sourcekitd)
99
endif()
1010

11+
if(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH)
12+
set(SOURCEKITD_TEST_DEPEND ${SOURCEKITD_TEST_DEPEND} dispatch swiftCore)
13+
endif()
14+
1115
add_sourcekit_executable(sourcekitd-test
1216
sourcekitd-test.cpp
1317
TestOptions.cpp

tools/SourceKit/tools/sourcekitd/bin/InProc/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ else()
2323
)
2424
endif()
2525

26+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
27+
target_link_libraries(sourcekitdInProc PUBLIC BlocksRuntime)
28+
endif()
29+
2630
if (SOURCEKIT_BUILT_STANDALONE)
2731
# Create the symlinks necessary to find the swift runtime.
2832
add_custom_command(TARGET sourcekitdInProc PRE_BUILD

utils/build-script-impl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,8 @@ for host in "${ALL_HOSTS[@]}"; do
19791979
-DSWIFT_PATH_TO_LLVM_BUILD:PATH="${llvm_build_dir}"
19801980
-DSWIFT_PATH_TO_CMARK_SOURCE:PATH="${CMARK_SOURCE_DIR}"
19811981
-DSWIFT_PATH_TO_CMARK_BUILD:PATH="$(build_directory ${host} cmark)"
1982+
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH="${LIBDISPATCH_SOURCE_DIR}"
1983+
-DSWIFT_PATH_TO_LIBDISPATCH_BUILD:PATH="$(build_directory ${host} libdispatch)"
19821984
)
19831985

19841986
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then

0 commit comments

Comments
 (0)