Skip to content

Enable SourceKit building by default on Linux #5903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2017
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
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,14 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "")
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if(EXISTS ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
else()
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
endif()
else()
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
endif()
option(SWIFT_BUILD_SOURCEKIT
"Build SourceKit"
Expand Down
22 changes: 22 additions & 0 deletions tools/SourceKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ macro(add_sourcekit_library name)
endif()
endif()

if(SWIFT_BUILD_SOURCEKIT AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
add_dependencies(${name} needs-libdispatch)
endif()

if("${SOURCEKITLIB_INSTALL_IN_COMPONENT}" STREQUAL "")
if(SOURCEKITLIB_SHARED)
set(SOURCEKITLIB_INSTALL_IN_COMPONENT tools)
Expand Down Expand Up @@ -508,6 +512,24 @@ include_directories(BEFORE
)

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if(SWIFT_BUILD_SOURCEKIT)
add_custom_command(
OUTPUT "${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so"
COMMAND /bin/sh ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/autogen.sh
COMMAND /bin/sh ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/configure
COMMAND /usr/bin/make
Copy link
Contributor

@dgrove-oss dgrove-oss Nov 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to make sure that there is no way the libdispatch.so you are building here is going to get mixed into the "real" build of libdispatch.so that probably happens later. The configure command is missing the --with-swift-toolchain --prefix and --with-build-variant arguments that are supplied when it is build from swift/utils/build-script-impl. Is also missing the setting of CC and CXX environment variables to the clang that is being built as part of building swift.

COMMAND /bin/mkdir -p ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/
COMMAND /bin/cp ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/src/.libs/libdispatch.so ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so
COMMAND /usr/bin/make distclean
WORKING_DIRECTORY ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}
COMMENT "Generating libdispatch.so"
USES_TERMINAL
)
add_custom_target(needs-libdispatch
DEPENDS "${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so"
)
endif()

include_directories(AFTER ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})

add_library(dispatch SHARED IMPORTED)
Expand Down