Skip to content
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

build: treat SourceKit as a host tool #29457

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions tools/SourceKit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

project(SourceKit
LANGUAGES CXX)

add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fblocks>)

include(CheckSymbolExists)

# Append our own modules to the module path.
Expand Down
52 changes: 0 additions & 52 deletions tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,6 @@ function(add_sourcekit_symbol_exports target_name export_file)
endif()
endfunction()

# Add default compiler and linker flags to 'target'.
#
# FIXME: this is a HACK. All SourceKit CMake code using this function should be
# rewritten to use 'add_swift_host_library' or 'add_swift_target_library'.
function(add_sourcekit_default_compiler_flags target)
set(sdk "${SWIFT_HOST_VARIANT_SDK}")
set(arch "${SWIFT_HOST_VARIANT_ARCH}")
set(c_compile_flags)
set(link_flags)

# Add variant-specific flags.
set(build_type "${CMAKE_BUILD_TYPE}")
set(enable_assertions "${LLVM_ENABLE_ASSERTIONS}")
set(analyze_code_coverage "${SWIFT_ANALYZE_CODE_COVERAGE}")
_add_variant_c_compile_flags(
SDK "${sdk}"
ARCH "${arch}"
BUILD_TYPE "${build_type}"
ENABLE_ASSERTIONS "${enable_assertions}"
ANALYZE_CODE_COVERAGE "${analyze_code_coverage}"
ENABLE_LTO "${SWIFT_TOOLS_ENABLE_LTO}"
RESULT_VAR_NAME c_compile_flags)
_add_variant_link_flags(
SDK "${sdk}"
ARCH "${arch}"
BUILD_TYPE "${build_type}"
ENABLE_ASSERTIONS "${enable_assertions}"
ENABLE_LTO "${SWIFT_TOOLS_ENABLE_LTO}"
LTO_OBJECT_NAME "${target}-${sdk}-${arch}"
ANALYZE_CODE_COVERAGE "${analyze_code_coverage}"
RESULT_VAR_NAME link_flags
LINK_LIBRARIES_VAR_NAME link_libraries
LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories)

# Convert variables to space-separated strings.
_list_escape_for_shell("${c_compile_flags}" c_compile_flags)
_list_escape_for_shell("${link_flags}" link_flags)

# Set compilation and link flags.
set_property(TARGET "${target}" APPEND_STRING PROPERTY
COMPILE_FLAGS " ${c_compile_flags} -fblocks")
set_property(TARGET "${target}" APPEND_STRING PROPERTY
LINK_FLAGS " ${link_flags}")
set_property(TARGET "${target}" APPEND PROPERTY LINK_LIBRARIES ${link_libraries})
swift_target_link_search_directories("${target}" "${library_search_directories}")
endfunction()

# Add a new SourceKit library.
#
# Usage:
Expand Down Expand Up @@ -197,7 +150,6 @@ macro(add_sourcekit_library name)
DESTINATION "include/SourceKit"
COMPONENT "${SOURCEKITLIB_INSTALL_IN_COMPONENT}")
set_target_properties(${name} PROPERTIES FOLDER "SourceKit libraries")
add_sourcekit_default_compiler_flags("${name}")

swift_is_installing_component("${SOURCEKITLIB_INSTALL_IN_COMPONENT}" is_installing)
if(NOT is_installing)
Expand Down Expand Up @@ -240,7 +192,6 @@ macro(add_sourcekit_executable name)
target_link_libraries(${name} PRIVATE ${LLVM_COMMON_LIBS})

set_target_properties(${name} PROPERTIES FOLDER "SourceKit executables")
add_sourcekit_default_compiler_flags("${name}")
endmacro()

# Add a new SourceKit framework.
Expand Down Expand Up @@ -371,8 +322,6 @@ macro(add_sourcekit_framework name)
else()
set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name})
endif()

add_sourcekit_default_compiler_flags("${name}")
endmacro(add_sourcekit_framework)

# Add a new SourceKit XPC service to a framework.
Expand Down Expand Up @@ -449,5 +398,4 @@ macro(add_sourcekit_xpc_service name framework_target)
LINK_FLAGS "-Wl,-exported_symbol,_main")
endif()
endif()
add_sourcekit_default_compiler_flags("${name}")
endmacro()