diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b4dc4c712422..c367885a7c827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,6 +499,18 @@ include(CMakePushCheckState) print_versions() +include(SwiftSharedCMakeConfig) + +# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake +# functionality. +# Support building Swift as a standalone project, using LLVM as an +# external library. +if(SWIFT_BUILT_STANDALONE) + swift_common_standalone_build_config(SWIFT) +else() + swift_common_unified_build_config(SWIFT) +endif() + include(SwiftComponents) include(SwiftHandleGybSources) include(SwiftSetIfArchBitness) @@ -527,16 +539,6 @@ if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386") OUTPUT_STRIP_TRAILING_WHITESPACE) endif() -include(SwiftSharedCMakeConfig) - -# Support building Swift as a standalone project, using LLVM as an -# external library. -if(SWIFT_BUILT_STANDALONE) - swift_common_standalone_build_config(SWIFT) -else() - swift_common_unified_build_config(SWIFT) -endif() - get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH) set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") @@ -1051,6 +1053,7 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH) else() set(SOURCEKIT_RUNTIME_DIR lib) endif() + add_dependencies(sourcekit-inproc BlocksRuntime dispatch) swift_install_in_component(FILES $ $ diff --git a/apinotes/CMakeLists.txt b/apinotes/CMakeLists.txt index ab1ecd6811d8e..3480e6b17e725 100644 --- a/apinotes/CMakeLists.txt +++ b/apinotes/CMakeLists.txt @@ -26,6 +26,7 @@ add_custom_target("copy_apinotes" ALL COMMENT "Copying API notes to ${output_dir}" SOURCES "${sources}") +add_dependencies(compiler copy_apinotes) swift_install_in_component(DIRECTORY "${output_dir}" DESTINATION "lib/swift/" COMPONENT compiler) diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index b45204c400cc2..5d1317443ebbe 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -1506,6 +1506,7 @@ function(add_swift_host_library name) INSTALL_IN_COMPONENT "dev" ) + add_dependencies(dev ${name}) if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY) swift_install_in_component(TARGETS ${name} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT dev @@ -2117,6 +2118,7 @@ function(add_swift_target_library name) endif() if(sdk STREQUAL WINDOWS AND CMAKE_SYSTEM_NAME STREQUAL Windows) + add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${name}-windows-${SWIFT_PRIMARY_VARIANT_ARCH}) swift_install_in_component(TARGETS ${name}-windows-${SWIFT_PRIMARY_VARIANT_ARCH} RUNTIME DESTINATION "bin" @@ -2129,6 +2131,9 @@ function(add_swift_target_library name) COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}" PERMISSIONS ${file_permissions}) else() + # NOTE: ${UNIVERSAL_LIBRARY_NAME} is the output associated with the target + # ${lipo_target} + add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${lipo_target}) swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}" DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}" COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}" @@ -2139,6 +2144,7 @@ function(add_swift_target_library name) foreach(arch ${SWIFT_SDK_WINDOWS_ARCHITECTURES}) if(TARGET ${name}-windows-${arch}_IMPLIB) get_target_property(import_library ${name}-windows-${arch}_IMPLIB IMPORTED_LOCATION) + add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${name}-windows-${arch}_IMPLIB) swift_install_in_component(FILES ${import_library} DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${arch}" COMPONENT ${SWIFTLIB_INSTALL_IN_COMPONENT} @@ -2205,6 +2211,7 @@ function(add_swift_target_library name) OUTPUT "${UNIVERSAL_LIBRARY_NAME}" ${THIN_INPUT_TARGETS_STATIC}) + add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${lipo_target_static}) swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}" DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}" PERMISSIONS @@ -2406,6 +2413,7 @@ function(add_swift_host_tool executable) ARCHITECTURE ${SWIFT_HOST_VARIANT_ARCH} ${ASHT_UNPARSED_ARGUMENTS}) + add_dependencies(${ASHT_SWIFT_COMPONENT} ${executable}) swift_install_in_component(TARGETS ${executable} RUNTIME DESTINATION bin diff --git a/cmake/modules/SwiftComponents.cmake b/cmake/modules/SwiftComponents.cmake index b0e3c8ed74431..401cff7a6ef86 100644 --- a/cmake/modules/SwiftComponents.cmake +++ b/cmake/modules/SwiftComponents.cmake @@ -92,11 +92,23 @@ macro(swift_configure_components) "A semicolon-separated list of components to install from the set ${_SWIFT_DEFINED_COMPONENTS}") foreach(component ${_SWIFT_DEFINED_COMPONENTS}) + add_custom_target(${component}) + add_llvm_install_targets(install-${component} + DEPENDS ${component} + COMPONENT ${component}) + string(TOUPPER "${component}" var_name_piece) string(REPLACE "-" "_" var_name_piece "${var_name_piece}") set(SWIFT_INSTALL_${var_name_piece} FALSE) endforeach() + # NOTE: never_install is a dummy component to indicate something should not + # be installed. We explicitly do not add an install target for this. + add_custom_target(never_install) + + add_custom_target(swift-components) + add_custom_target(install-swift-components) + foreach(component ${SWIFT_INSTALL_COMPONENTS}) if(NOT "${component}" IN_LIST _SWIFT_DEFINED_COMPONENTS) message(FATAL_ERROR "unknown install component: ${component}") @@ -106,6 +118,8 @@ macro(swift_configure_components) string(REPLACE "-" "_" var_name_piece "${var_name_piece}") if(NOT SWIFT_INSTALL_EXCLUDE_${var_name_piece}) set(SWIFT_INSTALL_${var_name_piece} TRUE) + add_dependencies(swift-components ${component}) + add_dependencies(install-swift-components install-${component}) endif() endforeach() endmacro() @@ -173,6 +187,10 @@ function(swift_install_symlink_component component) precondition(INSTALL_SYMLINK MESSAGE "LLVMInstallSymlink script must be available.") + # Create the directory if it doesn't exist. It will fail to create a symlink + # otherwise. + install(DIRECTORY DESTINATION "${ARG_DESTINATION}" COMPONENT ${component}) install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(${ARG_LINK_NAME} ${ARG_TARGET} ${ARG_DESTINATION})") + CODE "install_symlink(${ARG_LINK_NAME} ${ARG_TARGET} ${ARG_DESTINATION})" + COMPONENT ${component}) endfunction() diff --git a/cmake/modules/SwiftManpage.cmake b/cmake/modules/SwiftManpage.cmake index 8b7af1c30a3cc..f8aa4049f2025 100644 --- a/cmake/modules/SwiftManpage.cmake +++ b/cmake/modules/SwiftManpage.cmake @@ -27,7 +27,7 @@ function(manpage) "${CMAKE_CURRENT_BINARY_DIR}/${MP_MAN_FILE_BASENAME}.${MP_MAN_SECTION}") add_custom_command_target( - unused_var + manpage_target COMMAND "${POD2MAN}" "--section" "${MP_MAN_SECTION}" "--center" "${MP_PAGE_HEADER}" "--release=\"swift ${SWIFT_VERSION}\"" @@ -38,6 +38,7 @@ function(manpage) DEPENDS "${MP_SOURCE}" ALL) + add_dependencies(${MP_INSTALL_IN_COMPONENT} ${manpage_target}) swift_install_in_component(FILES "${output_file_name}" DESTINATION "share/man/man${MP_MAN_SECTION}" COMPONENT "${MP_INSTALL_IN_COMPONENT}") diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 5d99a813089a0..c748bd36ebad7 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -68,6 +68,7 @@ if (DOXYGEN_FOUND) add_dependencies(doxygen doxygen-swift) endif() + add_dependencies(dev doxygen-swift) swift_install_in_component(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen/html" DESTINATION "docs/html" COMPONENT dev) diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt index fe06fa38591c7..ed21de8722ad2 100644 --- a/lib/Driver/CMakeLists.txt +++ b/lib/Driver/CMakeLists.txt @@ -62,4 +62,5 @@ if(SWIFT_BUILD_STATIC_STDLIB) endif() endforeach() add_custom_target(swift_static_lnk_args ALL DEPENDS ${static_stdlib_lnk_file_list}) + add_dependencies(stdlib swift_static_lnk_args) endif() diff --git a/lib/SwiftDemangle/CMakeLists.txt b/lib/SwiftDemangle/CMakeLists.txt index 728b2b366675d..b2c775a76a1c7 100644 --- a/lib/SwiftDemangle/CMakeLists.txt +++ b/lib/SwiftDemangle/CMakeLists.txt @@ -6,6 +6,7 @@ target_compile_definitions(swiftDemangle PRIVATE target_link_libraries(swiftDemangle PRIVATE swiftDemangling) +add_dependencies(compiler swiftDemangle) swift_install_in_component(TARGETS swiftDemangle LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" diff --git a/stdlib/public/Platform/CMakeLists.txt b/stdlib/public/Platform/CMakeLists.txt index d869b23e76c66..90fba95ec1b4e 100644 --- a/stdlib/public/Platform/CMakeLists.txt +++ b/stdlib/public/Platform/CMakeLists.txt @@ -125,3 +125,4 @@ foreach(sdk ${SWIFT_SDKS}) endforeach() add_custom_target(glibc_modulemap DEPENDS ${glibc_modulemap_target_list}) set_property(TARGET glibc_modulemap PROPERTY FOLDER "Miscellaneous") +add_dependencies(sdk-overlay glibc_modulemap) diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index f7e611bbd886a..fbe6cc277b9f7 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -111,6 +111,7 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX") "${LibraryLocation}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}" DEPENDS ${FragileSupportLibrary}) + add_dependencies(stdlib ${FragileSupportLibrary}) swift_install_in_component(FILES $ DESTINATION "lib/swift_static/${lowercase_sdk}/${arch}" COMPONENT stdlib) @@ -125,6 +126,7 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX") "${LibraryLocationPrimary}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}" DEPENDS ${FragileSupportLibraryPrimary}) + add_dependencies(stdlib ${FragileSupportLibraryPrimary}) swift_install_in_component(FILES $ DESTINATION "lib/swift_static/${lowercase_sdk}" COMPONENT stdlib) @@ -150,6 +152,7 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX") add_dependencies(static_binary_magic ${swift_image_inspection_${arch}_static}) endforeach() add_dependencies(static_binary_magic ${swift_image_inspection_static_primary_arch}) + add_dependencies(stdlib static_binary_magic) add_swift_target_library(swiftImageInspectionSharedObject OBJECT_LIBRARY ImageInspectionELF.cpp @@ -250,6 +253,7 @@ foreach(sdk ${SWIFT_CONFIGURED_SDKS}) add_custom_target(swiftImageRegistration-${arch_suffix} ALL DEPENDS ${swiftImageRegistration-${arch_suffix}}) + add_dependencies(stdlib swift-stdlib-${arch_suffix} swiftImageRegistration-${arch_suffix}) endif() endforeach() endforeach() diff --git a/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake index c58bd1d0bb97b..a544e07e8a7df 100644 --- a/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake +++ b/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake @@ -188,6 +188,7 @@ macro(add_sourcekit_library name) set(SOURCEKITLIB_INSTALL_IN_COMPONENT dev) endif() endif() + add_dependencies(${SOURCEKITLIB_INSTALL_IN_COMPONENT} ${name}) swift_install_in_component(TARGETS ${name} LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" @@ -345,6 +346,7 @@ macro(add_sourcekit_framework name) MACOSX_FRAMEWORK_SHORT_VERSION_STRING "1.0" MACOSX_FRAMEWORK_BUNDLE_VERSION "${SOURCEKIT_VERSION_STRING}" PUBLIC_HEADER "${headers}") + add_dependencies(${SOURCEKITFW_INSTALL_IN_COMPONENT} ${name}) swift_install_in_component(TARGETS ${name} FRAMEWORK DESTINATION lib${LLVM_LIBDIR_SUFFIX} diff --git a/tools/SourceKit/tools/complete-test/CMakeLists.txt b/tools/SourceKit/tools/complete-test/CMakeLists.txt index 00cd93236b698..f65a890c4c2b6 100644 --- a/tools/SourceKit/tools/complete-test/CMakeLists.txt +++ b/tools/SourceKit/tools/complete-test/CMakeLists.txt @@ -24,6 +24,7 @@ if(SWIFT_ANALYZE_CODE_COVERAGE) LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping") endif() +add_dependencies(tools complete-test) swift_install_in_component(TARGETS complete-test RUNTIME DESTINATION bin diff --git a/tools/SourceKit/tools/sourcekitd-repl/CMakeLists.txt b/tools/SourceKit/tools/sourcekitd-repl/CMakeLists.txt index 8a94a5bbf6fcf..32e49a17b6e7f 100644 --- a/tools/SourceKit/tools/sourcekitd-repl/CMakeLists.txt +++ b/tools/SourceKit/tools/sourcekitd-repl/CMakeLists.txt @@ -27,6 +27,7 @@ if(HAVE_UNICODE_LIBEDIT) LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping") endif() + add_dependencies(tools sourcekitd-repl) swift_install_in_component(TARGETS sourcekitd-repl RUNTIME DESTINATION bin diff --git a/tools/SourceKit/tools/sourcekitd-test/CMakeLists.txt b/tools/SourceKit/tools/sourcekitd-test/CMakeLists.txt index baee48ff1811a..09f1106705a89 100644 --- a/tools/SourceKit/tools/sourcekitd-test/CMakeLists.txt +++ b/tools/SourceKit/tools/sourcekitd-test/CMakeLists.txt @@ -32,6 +32,7 @@ if(SWIFT_ANALYZE_CODE_COVERAGE) LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping") endif() +add_dependencies(tools sourcekitd-test) swift_install_in_component(TARGETS sourcekitd-test RUNTIME DESTINATION bin diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index 66fcda27dbaea..8e326d0aea316 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -37,12 +37,15 @@ if(NOT SWIFT_BUILT_STANDALONE) add_dependencies(swift clang-headers) endif() +add_dependencies(compiler swift) swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swiftc${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION "bin" COMPONENT compiler) +add_dependencies(autolink-driver swift) swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-autolink-extract${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION "bin" COMPONENT autolink-driver) +add_dependencies(editor-integration swift) swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-indent${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION "bin" COMPONENT editor-integration) diff --git a/tools/libSwiftSyntaxParser/CMakeLists.txt b/tools/libSwiftSyntaxParser/CMakeLists.txt index 1808e7a6ff98d..2743fb1502de0 100644 --- a/tools/libSwiftSyntaxParser/CMakeLists.txt +++ b/tools/libSwiftSyntaxParser/CMakeLists.txt @@ -46,6 +46,7 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH) target_link_libraries(libSwiftSyntaxParser PRIVATE BlocksRuntime) endif() +add_dependencies(parser-lib libSwiftSyntaxParser) swift_install_in_component(FILES "${SWIFT_LIBRARY_OUTPUT_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${SYNTAX_PARSER_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}" diff --git a/utils/build-script-impl b/utils/build-script-impl index 1d5fbf9fe8c21..5758487f1ba6e 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -3554,6 +3554,7 @@ for host in "${ALL_HOSTS[@]}"; do if [[ -z "${INSTALL_SWIFT}" ]] ; then continue fi + INSTALL_TARGETS=install-swift-components # Swift syntax parser is currently a sub-product of Swift; # We need to specify the install target separately here. if [ "${BUILD_LIBPARSER_ONLY}" ]; then