diff --git a/CMakeLists.txt b/CMakeLists.txt index c3edc5bab66f8..70dbac7cf3601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ include(CMakeDependentOption) include(CheckLanguage) include(GNUInstallDirs) include(SwiftImplicitImport) +include(FetchContent) # Enable Swift for the host compiler build if we have the language. It is # optional until we have a bootstrap story. @@ -691,10 +692,9 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang) add_compile_options($<$:-Werror=c++98-compat-extra-semi>) endif() -# Make sure we know where swift-syntax is because we need it to build the parser. -if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}") - message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE") -endif() +option(SWIFT_BUILD_SWIFT_SYNTAX + "Enable building swift syntax" + FALSE) set(SWIFT_BUILD_HOST_DISPATCH FALSE) if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") @@ -829,7 +829,7 @@ elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*") else() set(BOOTSTRAPPING_MODE "HOSTTOOLS") endif() -elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_SWIFT_PARSER) +elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_BUILD_SWIFT_SYNTAX) # We are building using a pre-installed host toolchain but not bootstrapping # the Swift modules. This happens when building using 'build-tooling-libs' # where we haven't built a new Swift compiler. Use the Swift compiler from the @@ -943,19 +943,6 @@ if(XCODE) set(SWIFT_SDKS "OSX") endif() -# When we have the early SwiftSyntax build, we can include its parser. -if(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR) - set(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS - ${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/cmake/SwiftSyntaxTargets.cmake) - if(NOT EXISTS "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}") - message(STATUS "Skipping Swift Swift parser integration due to missing early SwiftSyntax") - else() - set(SWIFT_SWIFT_PARSER TRUE) - include(${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}) - endif() -endif() - - # FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics, # so we need to hard-code it. For example, the SDK for Android is just 'ANDROID', # and we have to specify SWIFT_SDK_ANDROID_ARCHITECTURES separately. @@ -1164,13 +1151,29 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND NOT CMAKE_CROSSCOMPILING) set(CMAKE_OSX_DEPLOYMENT_TARGET "") endif() +set(SWIFT_HOST_MODULE_TRIPLE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_MODULE}") +set(SWIFT_HOST_LIBRARIES_DEST_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/host") +if(SWIFT_BUILD_SWIFT_SYNTAX) + if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}") + message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE") + endif() + + set(BUILD_SHARED_LIBS_OLD "${BUILD_SHARED_LIBS}") + set(BUILD_SHARED_LIBS ON) + FetchContent_Declare(SwiftSyntax + SOURCE_DIR "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}" + ) + FetchContent_MakeAvailable(SwiftSyntax) + set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_OLD}") +endif() + if(SWIFT_INCLUDE_TOOLS) message(STATUS "Building host Swift tools for ${SWIFT_HOST_VARIANT_SDK} ${SWIFT_HOST_VARIANT_ARCH}") message(STATUS " Build type: ${CMAKE_BUILD_TYPE}") message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}") message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}") message(STATUS " Bootstrapping: ${BOOTSTRAPPING_MODE}") - message(STATUS " Swift parser: ${SWIFT_SWIFT_PARSER}") + message(STATUS " Swift parser: ${SWIFT_BUILD_SWIFT_SYNTAX}") message(STATUS "") else() message(STATUS "Not building host Swift tools") diff --git a/cmake/modules/AddPureSwift.cmake b/cmake/modules/AddPureSwift.cmake index 8d26200a551d3..70f56ad135798 100644 --- a/cmake/modules/AddPureSwift.cmake +++ b/cmake/modules/AddPureSwift.cmake @@ -103,7 +103,7 @@ endfunction() # source1 ... # Sources to add into this library. function(add_pure_swift_host_library name) - if (NOT SWIFT_SWIFT_PARSER) + if (NOT SWIFT_BUILD_SWIFT_SYNTAX) message(STATUS "Not building ${name} because swift-syntax is not available") return() endif() @@ -178,13 +178,15 @@ function(add_pure_swift_host_library name) # Make sure we can use the host libraries. target_include_directories(${name} PUBLIC - ${SWIFT_HOST_LIBRARIES_DEST_DIR}) + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + target_link_directories(${name} PUBLIC + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") if(APSHL_EMIT_MODULE) # Determine where Swift modules will be built and installed. - set(module_triple ${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_MODULE}) - set(module_dir ${SWIFT_HOST_LIBRARIES_DEST_DIR}) + set(module_triple "${SWIFT_HOST_MODULE_TRIPLE}") + set(module_dir "${SWIFT_HOST_LIBRARIES_DEST_DIR}") set(module_base "${module_dir}/${name}.swiftmodule") set(module_file "${module_base}/${module_triple}.swiftmodule") set(module_interface_file "${module_base}/${module_triple}.swiftinterface") @@ -216,6 +218,12 @@ function(add_pure_swift_host_library name) >) endif() + if(LLVM_USE_LINKER) + target_link_options(${name} PRIVATE + "-use-ld=${LLVM_USE_LINKER}" + ) + endif() + # Export this target. set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name}) endfunction() @@ -223,7 +231,7 @@ endfunction() # Add a new "pure" Swift host tool. # # "Pure" Swift host tools can only contain Swift code, and will be built -# with the host compiler. +# with the host compiler. # # Usage: # add_pure_swift_host_tool(name @@ -244,7 +252,7 @@ endfunction() # source1 ... # Sources to add into this tool. function(add_pure_swift_host_tool name) - if (NOT SWIFT_SWIFT_PARSER) + if (NOT SWIFT_BUILD_SWIFT_SYNTAX) message(STATUS "Not building ${name} because swift-syntax is not available") return() endif() @@ -302,7 +310,15 @@ function(add_pure_swift_host_tool name) # Make sure we can use the host libraries. target_include_directories(${name} PUBLIC - ${SWIFT_HOST_LIBRARIES_DEST_DIR}) + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + target_link_directories(${name} PUBLIC + "${SWIFT_HOST_LIBRARIES_DEST_DIR}") + + if(LLVM_USE_LINKER) + target_link_options(${name} PRIVATE + "-use-ld=${LLVM_USE_LINKER}" + ) + endif() # Workaround to touch the library and its objects so that we don't # continually rebuild (again, see corresponding change in swift-syntax). diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index d4f19d1e2d376..b5599f2bb094e 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -442,7 +442,7 @@ endfunction() function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping) if(NOT BOOTSTRAPPING_MODE) - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) set(ASRLF_BOOTSTRAPPING_MODE "HOSTTOOLS") else() return() @@ -575,10 +575,7 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping) endif() endif() - if(SWIFT_SWIFT_PARSER) - # Make sure we can find the early SwiftSyntax libraries. - target_link_directories(${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host") - + if(SWIFT_BUILD_SWIFT_SYNTAX) # For the "end step" of bootstrapping configurations, we need to be # able to fall back to the SDK directory for libswiftCore et al. if (BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*") @@ -656,7 +653,7 @@ function(add_swift_host_library name) translate_flags(ASHL "${options}") # Once the new Swift parser is linked, everything has Swift modules. - if (SWIFT_SWIFT_PARSER AND ASHL_SHARED) + if (SWIFT_BUILD_SWIFT_SYNTAX AND ASHL_SHARED) set(ASHL_HAS_SWIFT_MODULES ON) endif() @@ -702,7 +699,7 @@ function(add_swift_host_library name) add_library(${name} ${libkind} ${ASHL_SOURCES}) - target_link_directories(${name} PUBLIC ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + target_link_directories(${name} PUBLIC "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") # Respect LLVM_COMMON_DEPENDS if it is set. # @@ -889,7 +886,7 @@ function(add_swift_host_tool executable) endif() # Once the new Swift parser is linked in, every host tool has Swift modules. - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) set(ASHT_HAS_SWIFT_MODULES ON) endif() @@ -928,7 +925,7 @@ function(add_swift_host_tool executable) endif() endif() - if(SWIFT_SWIFT_PARSER) + if(SWIFT_BUILD_SWIFT_SYNTAX) set(extra_relative_rpath "") if(NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "") if(executable MATCHES "-bootstrapping") diff --git a/cmake/modules/AddSwiftUnittests.cmake b/cmake/modules/AddSwiftUnittests.cmake index a4573981c225c..c8749e40c3165 100644 --- a/cmake/modules/AddSwiftUnittests.cmake +++ b/cmake/modules/AddSwiftUnittests.cmake @@ -89,7 +89,7 @@ function(add_swift_unittest test_dirname) endif() endif() - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) _add_swift_runtime_link_flags(${test_dirname} "../../lib" "") set_property(TARGET ${test_dirname} PROPERTY BUILD_WITH_INSTALL_RPATH OFF) endif() diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt index 9e5590b7315db..4bf20a642f0f8 100644 --- a/lib/AST/CMakeLists.txt +++ b/lib/AST/CMakeLists.txt @@ -155,10 +155,10 @@ target_link_libraries(swiftAST INTERFACE clangAPINotes clangBasic) -if(SWIFT_SWIFT_PARSER) +if(SWIFT_BUILD_SWIFT_SYNTAX) target_compile_definitions(swiftAST PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) endif() diff --git a/lib/ASTGen/CMakeLists.txt b/lib/ASTGen/CMakeLists.txt index b80782f838e52..2628124156dfd 100644 --- a/lib/ASTGen/CMakeLists.txt +++ b/lib/ASTGen/CMakeLists.txt @@ -24,15 +24,15 @@ add_pure_swift_host_library(swiftASTGen STATIC DEPENDENCIES swiftAST SWIFT_DEPENDENCIES - SwiftSyntax::SwiftBasicFormat - SwiftSyntax::SwiftCompilerPluginMessageHandling - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftParser - SwiftSyntax::SwiftParserDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros - SwiftSyntax::SwiftSyntaxMacroExpansion + SwiftBasicFormat + SwiftCompilerPluginMessageHandling + SwiftDiagnostics + SwiftOperators + SwiftParser + SwiftParserDiagnostics + SwiftSyntax + SwiftSyntaxBuilder + SwiftSyntaxMacros + SwiftSyntaxMacroExpansion swiftLLVMJSON ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0f5e768073993..9054a85a5eb41 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -12,99 +12,6 @@ # directory. list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen clang-tablegen-targets) -# Set up for linking against swift-syntax. -if (SWIFT_SWIFT_PARSER) - # Set up linking against the swift-syntax modules. - # Link against the swift-syntax modules. - set(SWIFT_SYNTAX_MODULES - SwiftBasicFormat - SwiftParser - SwiftParserDiagnostics - SwiftDiagnostics - SwiftSyntax - SwiftOperators - SwiftSyntaxBuilder - SwiftSyntaxMacros - SwiftSyntaxMacroExpansion - SwiftCompilerPluginMessageHandling - ) - - # Compute the list of SwiftSyntax targets that we will link against. - list(TRANSFORM SWIFT_SYNTAX_MODULES PREPEND "SwiftSyntax::" - OUTPUT_VARIABLE SWIFT_SYNTAX_TARGETS) - - set(SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR - "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host") - set(SWIFT_HOST_LIBRARIES_DEST_DIR - "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/swift/host") - - # Determine the SwiftSyntax shared library files that were built as - # part of earlyswiftsyntax. - list(TRANSFORM SWIFT_SYNTAX_MODULES PREPEND ${CMAKE_SHARED_LIBRARY_PREFIX} - OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES) - list(TRANSFORM SWIFT_SYNTAX_SHARED_LIBRARIES APPEND - ${CMAKE_SHARED_LIBRARY_SUFFIX} - OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES) - - # Interface library to collect swiftinterfaces and swiftmodules from - # SwiftSyntax - add_library(swiftSyntaxLibraries INTERFACE) - - # Copy over all of the shared libraries from earlyswiftsyntax so they can - # be found via RPATH. - foreach (sharedlib ${SWIFT_SYNTAX_SHARED_LIBRARIES}) - add_custom_command( - OUTPUT "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}" - DEPENDS "${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR}/${sharedlib}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR}/${sharedlib} ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib} - ) - - add_custom_target(copy_swiftSyntaxLibrary_${sharedlib} - DEPENDS "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${sharedlib}" - COMMENT "Copying ${sharedlib}" - ) - - add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxLibrary_${sharedlib}) - endforeach() - - # Copy all of the Swift modules from earlyswiftsyntax so they can be found - # in the same relative place within the build directory as in the final - # toolchain. - list(TRANSFORM SWIFT_SYNTAX_MODULES APPEND ".swiftmodule" - OUTPUT_VARIABLE SWIFT_SYNTAX_MODULE_DIRS) - - foreach(module_dir ${SWIFT_SYNTAX_MODULE_DIRS}) - # Find all of the source module files. - file(GLOB module_files - "${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR}/${module_dir}/*.swiftinterface") - - # Determine the destination module files. - set(dest_module_files) - foreach(full_module_file ${module_files}) - get_filename_component(module_file ${full_module_file} NAME) - list(APPEND dest_module_files - "${SWIFT_HOST_LIBRARIES_DEST_DIR}/${module_dir}/${module_file}") - endforeach() - - add_custom_command( - OUTPUT ${dest_module_files} - DEPENDS ${module_files} - COMMAND ${CMAKE_COMMAND} -E make_directory ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${module_dir} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${module_files} ${SWIFT_HOST_LIBRARIES_DEST_DIR}/${module_dir}/ - ) - - add_custom_target(copy_swiftSyntaxModule_${module_dir} - DEPENDS ${dest_module_files} - COMMENT "Copying ${module_dir}" - ) - - add_dependencies(swiftSyntaxLibraries copy_swiftSyntaxModule_${module_dir}) - endforeach() - - # Add copied SwiftSyntax libraries to global dependencies. - list(APPEND LLVM_COMMON_DEPENDS swiftSyntaxLibraries) -endif() - add_subdirectory(APIDigester) add_subdirectory(AST) add_subdirectory(ASTGen) diff --git a/lib/Frontend/CMakeLists.txt b/lib/Frontend/CMakeLists.txt index c01fdcf7e174b..ebb9a2aeecabf 100644 --- a/lib/Frontend/CMakeLists.txt +++ b/lib/Frontend/CMakeLists.txt @@ -37,9 +37,9 @@ target_link_libraries(swiftFrontend PRIVATE set_swift_llvm_is_available(swiftFrontend) -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) target_compile_definitions(swiftFrontend PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) endif() diff --git a/lib/Frontend/PrintingDiagnosticConsumer.cpp b/lib/Frontend/PrintingDiagnosticConsumer.cpp index 828fdcce4d7e7..d876195cf82be 100644 --- a/lib/Frontend/PrintingDiagnosticConsumer.cpp +++ b/lib/Frontend/PrintingDiagnosticConsumer.cpp @@ -964,7 +964,7 @@ static void annotateSnippetWithInfo(SourceManager &SM, } } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX /// Enqueue a diagnostic with ASTGen's diagnostic rendering. static void enqueueDiagnostic( void *queuedDiagnostics, const DiagnosticInfo &info, SourceManager &SM @@ -1038,7 +1038,7 @@ static SmallVector getSourceBufferStack( } } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX void PrintingDiagnosticConsumer::queueBuffer( SourceManager &sourceMgr, unsigned bufferID) { QueuedBuffer knownSourceFile = queuedBuffers[bufferID]; @@ -1103,7 +1103,7 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM, switch (FormattingStyle) { case DiagnosticOptions::FormattingStyle::Swift: { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX // Use the swift-syntax formatter. auto bufferStack = getSourceBufferStack(SM, Info.Loc); if (!bufferStack.empty()) { @@ -1190,7 +1190,7 @@ void PrintingDiagnosticConsumer::flush(bool includeTrailingBreak) { currentSnippet.reset(); } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (queuedDiagnostics) { char *renderedString = nullptr; ptrdiff_t renderedStringLen = 0; diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index e4cc1de623c46..a8c7054278a19 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -1150,7 +1150,7 @@ static void addPoundDirectives(CodeCompletionResultSink &Sink) { Builder.addRightParen(); }); -#ifndef SWIFT_SWIFT_PARSER +#ifndef SWIFT_BUILD_SWIFT_SYNTAX addWithName("warning", CodeCompletionKeywordKind::pound_warning, [&] (CodeCompletionResultBuilder &Builder) { Builder.addLeftParen(); diff --git a/lib/Macros/CMakeLists.txt b/lib/Macros/CMakeLists.txt index ed98b3d9f5789..23cea5cf5802a 100644 --- a/lib/Macros/CMakeLists.txt +++ b/lib/Macros/CMakeLists.txt @@ -33,7 +33,7 @@ function(add_swift_macro_library name) # If we don't have the Swift swift parser, bail out, because the above # add_pure_swift_host_library did nothing. - if (NOT SWIFT_SWIFT_PARSER) + if (NOT SWIFT_BUILD_SWIFT_SYNTAX) return() endif() diff --git a/lib/Macros/Sources/ObservationMacros/CMakeLists.txt b/lib/Macros/Sources/ObservationMacros/CMakeLists.txt index 3afd3380125aa..c3deee2c4747a 100644 --- a/lib/Macros/Sources/ObservationMacros/CMakeLists.txt +++ b/lib/Macros/Sources/ObservationMacros/CMakeLists.txt @@ -15,9 +15,9 @@ add_swift_macro_library(ObservationMacros Extensions.swift ObservableMacro.swift SWIFT_DEPENDENCIES - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftSyntaxMacros + SwiftDiagnostics + SwiftOperators + SwiftSyntaxBuilder + SwiftSyntax + SwiftSyntaxMacros ) diff --git a/lib/Macros/Sources/SwiftMacros/CMakeLists.txt b/lib/Macros/Sources/SwiftMacros/CMakeLists.txt index 32a798260afdb..9d83b612b4987 100644 --- a/lib/Macros/Sources/SwiftMacros/CMakeLists.txt +++ b/lib/Macros/Sources/SwiftMacros/CMakeLists.txt @@ -13,8 +13,8 @@ add_swift_macro_library(SwiftMacros OptionSetMacro.swift SWIFT_DEPENDENCIES - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros + SwiftDiagnostics + SwiftSyntax + SwiftSyntaxBuilder + SwiftSyntaxMacros ) diff --git a/lib/Parse/CMakeLists.txt b/lib/Parse/CMakeLists.txt index 1b66331ad7e6d..8a01e55f893b0 100644 --- a/lib/Parse/CMakeLists.txt +++ b/lib/Parse/CMakeLists.txt @@ -25,35 +25,35 @@ target_link_libraries(swiftParse PRIVATE swiftAST ) -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) target_link_libraries(swiftParse PRIVATE - SwiftSyntax::SwiftBasicFormat - SwiftSyntax::SwiftParser - SwiftSyntax::SwiftParserDiagnostics - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros + SwiftBasicFormat + SwiftParser + SwiftParserDiagnostics + SwiftDiagnostics + SwiftSyntax + SwiftOperators + SwiftSyntaxBuilder + SwiftSyntaxMacros swiftASTGen ) add_dependencies(swiftParse - SwiftSyntax::SwiftBasicFormat - SwiftSyntax::SwiftParser - SwiftSyntax::SwiftParserDiagnostics - SwiftSyntax::SwiftDiagnostics - SwiftSyntax::SwiftSyntax - SwiftSyntax::SwiftOperators - SwiftSyntax::SwiftSyntaxBuilder - SwiftSyntax::SwiftSyntaxMacros + SwiftBasicFormat + SwiftParser + SwiftParserDiagnostics + SwiftDiagnostics + SwiftSyntax + SwiftOperators + SwiftSyntaxBuilder + SwiftSyntaxMacros swiftASTGen ) target_compile_definitions(swiftParse PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) endif() diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index fcdef55ad6032..d4c10e87c8bfd 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -163,7 +163,7 @@ extern "C" void parseTopLevelSwift(const char *buffer, void *outputContext, void (*)(void *, void *)); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX static void appendToVector(void *declPtr, void *vecPtr) { auto vec = static_cast *>(vecPtr); auto decl = static_cast(declPtr); @@ -209,7 +209,7 @@ extern "C" void swift_ASTGen_buildTopLevelASTNodes(void *sourceFile, /// decl-sil-stage [[only in SIL mode] /// \endverbatim void Parser::parseTopLevelItems(SmallVectorImpl &items) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX llvm::Optional existingParsingTransaction; parseSourceFileViaASTGen(items, existingParsingTransaction); #endif @@ -260,7 +260,7 @@ void Parser::parseTopLevelItems(SmallVectorImpl &items) { } } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (existingParsingTransaction) existingParsingTransaction->abort(); @@ -312,7 +312,7 @@ void Parser::parseTopLevelItems(SmallVectorImpl &items) { void *ExportedSourceFileRequest::evaluate(Evaluator &evaluator, const SourceFile *SF) const { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX // The SwiftSyntax parser doesn't (yet?) handle SIL. if (SF->Kind == SourceFileKind::SIL) return nullptr; @@ -345,7 +345,7 @@ void Parser::parseSourceFileViaASTGen( SmallVectorImpl &items, llvm::Optional &transaction, bool suppressDiagnostics) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX const auto &langOpts = Context.LangOpts; // We only need to do parsing if we either have ASTGen enabled, or want the diff --git a/lib/Parse/ParseIfConfig.cpp b/lib/Parse/ParseIfConfig.cpp index ef10f8fdde5b8..58d991841cab3 100644 --- a/lib/Parse/ParseIfConfig.cpp +++ b/lib/Parse/ParseIfConfig.cpp @@ -557,7 +557,7 @@ class EvaluateIfConfigCondition : // Check whether this is any one of the known compiler features. const auto &langOpts = Ctx.LangOpts; -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX const bool hasSwiftSwiftParser = true; #else const bool hasSwiftSwiftParser = false; diff --git a/lib/Parse/ParseType.cpp b/lib/Parse/ParseType.cpp index db7323c69dae8..83a86e4b9a342 100644 --- a/lib/Parse/ParseType.cpp +++ b/lib/Parse/ParseType.cpp @@ -601,7 +601,7 @@ extern "C" TypeRepr *swift_ASTGen_buildTypeRepr( /// ParserResult Parser::parseType( Diag<> MessageID, ParseTypeReason reason) { - #if SWIFT_SWIFT_PARSER + #if SWIFT_BUILD_SWIFT_SYNTAX auto astGenResult = parseASTFromSyntaxTree( [&](void *exportedSourceFile, const void *sourceLoc) { const void *endLocPtr = nullptr; diff --git a/lib/Sema/CMakeLists.txt b/lib/Sema/CMakeLists.txt index 16494b3ff76d2..6a80e3c20768d 100644 --- a/lib/Sema/CMakeLists.txt +++ b/lib/Sema/CMakeLists.txt @@ -86,10 +86,10 @@ target_link_libraries(swiftSema PRIVATE swiftParse swiftSerialization) -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) target_compile_definitions(swiftSema PRIVATE - SWIFT_SWIFT_PARSER + SWIFT_BUILD_SWIFT_SYNTAX ) target_link_libraries(swiftSema PRIVATE swiftASTGen) diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 25d36fcb3436f..869fd4df8f786 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -2934,7 +2934,7 @@ namespace { } Expr *visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *expr) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX auto &ctx = cs.getASTContext(); if (ctx.LangOpts.hasFeature(Feature::BuiltinMacros)) { auto expandedType = solution.simplifyType(solution.getType(expr)); diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index 7d10ce9b761dc..3462c9c90c4e0 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -1324,7 +1324,7 @@ namespace { } Type visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *expr) { -#ifdef SWIFT_SWIFT_PARSER +#ifdef SWIFT_BUILD_SWIFT_SYNTAX auto &ctx = CS.getASTContext(); if (ctx.LangOpts.hasFeature(Feature::BuiltinMacros)) { auto kind = MagicIdentifierLiteralExpr::getKindString(expr->getKind()) diff --git a/lib/Sema/TypeCheckMacros.cpp b/lib/Sema/TypeCheckMacros.cpp index 40e6b7ba9141c..113146e35798f 100644 --- a/lib/Sema/TypeCheckMacros.cpp +++ b/lib/Sema/TypeCheckMacros.cpp @@ -89,7 +89,7 @@ extern "C" bool swift_ASTGen_pluginServerLoadLibraryPlugin( void *handle, const char *libraryPath, const char *moduleName, void *diagEngine); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX /// Look for macro's type metadata given its external module and type name. static void const * lookupMacroTypeMetadataByExternalName(ASTContext &ctx, StringRef moduleName, @@ -185,7 +185,7 @@ MacroDefinition MacroDefinitionRequest::evaluate( auto sourceFile = macro->getParentSourceFile(); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX char *externalMacroNamePtr; ptrdiff_t externalMacroNameLength; ptrdiff_t *replacements; @@ -291,7 +291,7 @@ initializeExecutablePlugin(ASTContext &ctx, // FIXME: Ideally this should be done right after invoking the plugin. // But plugin loading is in libAST and it can't link ASTGen symbols. if (!executablePlugin->isInitialized()) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (!swift_ASTGen_initializePlugin(executablePlugin, &ctx.Diags)) { return nullptr; } @@ -312,7 +312,7 @@ initializeExecutablePlugin(ASTContext &ctx, // If this is a plugin server, load the library. if (!libraryPath.empty()) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX llvm::SmallString<128> resolvedLibraryPath; auto fs = ctx.SourceMgr.getFileSystem(); if (auto err = fs->getRealPath(libraryPath, resolvedLibraryPath)) { @@ -375,7 +375,7 @@ CompilerPluginLoadRequest::evaluate(Evaluator &evaluator, ASTContext *ctx, static llvm::Optional resolveInProcessMacro(ASTContext &ctx, Identifier moduleName, Identifier typeName, LoadedLibraryPlugin *plugin) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX /// Look for the type metadata given the external module and type names. auto macroMetatype = lookupMacroTypeMetadataByExternalName( ctx, moduleName.str(), typeName.str(), plugin); @@ -399,7 +399,7 @@ static llvm::Optional resolveExecutableMacro(ASTContext &ctx, LoadedExecutablePlugin *executablePlugin, Identifier moduleName, Identifier typeName) { -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX if (auto *execMacro = swift_ASTGen_resolveExecutableMacro( moduleName.str().data(), moduleName.str().size(), typeName.str().data(), typeName.str().size(), executablePlugin)) { @@ -970,7 +970,7 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion, LazyValue discriminator([&]() -> std::string { if (!discriminatorStr.empty()) return discriminatorStr.str(); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX Mangle::ASTMangler mangler; return mangler.mangleMacroExpansion(expansion); #else @@ -1031,7 +1031,7 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion, return nullptr; } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX PrettyStackTraceFreestandingMacroExpansion debugStack( "expanding freestanding macro", expansion); @@ -1210,7 +1210,7 @@ static SourceFile *evaluateAttachedMacro(MacroDecl *macro, Decl *attachedTo, LazyValue discriminator([&]() -> std::string { if (!discriminatorStr.empty()) return discriminatorStr.str(); -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX Mangle::ASTMangler mangler; return mangler.mangleAttachedMacroExpansion(attachedTo, attr, role); #else @@ -1288,7 +1288,7 @@ static SourceFile *evaluateAttachedMacro(MacroDecl *macro, Decl *attachedTo, return nullptr; } -#if SWIFT_SWIFT_PARSER +#if SWIFT_BUILD_SWIFT_SYNTAX PrettyStackTraceDecl debugStack("expanding attached macro", attachedTo); auto *astGenAttrSourceFile = attrSourceFile->getExportedSourceFile(); diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 4471ca0901149..1355a985028d2 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -167,7 +167,7 @@ elif "@BOOTSTRAPPING_MODE@" == 'BOOTSTRAPPING': elif "@BOOTSTRAPPING_MODE@" == 'BOOTSTRAPPING-WITH-HOSTLIBS': config.available_features.add('bootstrapping_with_hostlibs_mode') -if '@SWIFT_SWIFT_PARSER@' == 'TRUE': +if '@SWIFT_BUILD_SWIFT_SYNTAX@' == 'TRUE': config.available_features.add('swift_swift_parser') # Let the main config do the real work. diff --git a/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake index cc55ac113c9bc..c87add1abc47a 100644 --- a/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake +++ b/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake @@ -25,7 +25,7 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES) # to do it. set(ASKD_BOOTSTRAPPING_MODE ${BOOTSTRAPPING_MODE}) if (NOT ASKD_BOOTSTRAPPING_MODE) - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) set(ASKD_BOOTSTRAPPING_MODE HOSTTOOLS) endif() endif() @@ -154,10 +154,7 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES) endif() endif() - if(SWIFT_SWIFT_PARSER) - # Make sure we can find the early SwiftSyntax libraries. - target_link_directories(${target} PRIVATE "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/lib/swift/host") - + if(SWIFT_BUILD_SWIFT_SYNTAX) # Add rpath to the host Swift libraries. if (NOT SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) file(RELATIVE_PATH relative_hostlib_path "${path}" "${SWIFTLIB_DIR}/host") @@ -268,7 +265,7 @@ macro(add_sourcekit_library name) endif() # Once the new Swift parser is linked, everything has Swift modules. - if (SWIFT_SWIFT_PARSER AND SOURCEKITLIB_SHARED) + if (SWIFT_BUILD_SWIFT_SYNTAX AND SOURCEKITLIB_SHARED) set(SOURCEKITLIB_HAS_SWIFT_MODULES ON) endif() @@ -352,7 +349,7 @@ macro(add_sourcekit_executable name) set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX) - if(SWIFT_SWIFT_PARSER) + if(SWIFT_BUILD_SWIFT_SYNTAX) set(SKEXEC_HAS_SWIFT_MODULES TRUE) else() set(SKEXEC_HAS_SWIFT_MODULES FALSE) @@ -381,7 +378,7 @@ macro(add_sourcekit_framework name) set(framework_location "${lib_dir}/${name}.framework") # Once the new Swift parser is linked, everything has Swift modules. - if (SWIFT_SWIFT_PARSER) + if (SWIFT_BUILD_SWIFT_SYNTAX) set(SOURCEKITFW_HAS_SWIFT_MODULES ON) endif() diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index 16a194da9b5f9..1b350f229d4a5 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -4,7 +4,7 @@ # Add additional libraries to which we need to link when the Swift Swift # parser is built in. function(add_swift_parser_link_libraries target) - if(SWIFT_SWIFT_PARSER) + if(SWIFT_BUILD_SWIFT_SYNTAX) target_link_libraries(${target} PRIVATE swiftCore) diff --git a/tools/libSwiftScan/CMakeLists.txt b/tools/libSwiftScan/CMakeLists.txt index f675451160068..f4f4f82224fa0 100644 --- a/tools/libSwiftScan/CMakeLists.txt +++ b/tools/libSwiftScan/CMakeLists.txt @@ -30,7 +30,7 @@ set_target_properties(libSwiftScan PROPERTIES OUTPUT_NAME ${SWIFT_SCAN_LIB_NAME}) -if(SWIFT_SWIFT_PARSER) +if(SWIFT_BUILD_SWIFT_SYNTAX) # Ensure that we can find the host shared libraries. set_property( TARGET libSwiftScan diff --git a/tools/swift-plugin-server/CMakeLists.txt b/tools/swift-plugin-server/CMakeLists.txt index 09332309b10c9..a21b79ed26021 100644 --- a/tools/swift-plugin-server/CMakeLists.txt +++ b/tools/swift-plugin-server/CMakeLists.txt @@ -1,4 +1,4 @@ -if (SWIFT_SWIFT_PARSER) +if (SWIFT_BUILD_SWIFT_SYNTAX) # _swiftCSwiftPluginServer is just a C support library for swift-plugin-server # Don't bother to create '.a' for that. add_swift_host_library(_swiftCSwiftPluginServer OBJECT @@ -17,9 +17,9 @@ if (SWIFT_SWIFT_PARSER) swiftDemangling $ SWIFT_DEPENDENCIES - SwiftSyntax::SwiftSyntaxMacros - SwiftSyntax::SwiftSyntaxMacroExpansion - SwiftSyntax::SwiftCompilerPluginMessageHandling + SwiftSyntaxMacros + SwiftSyntaxMacroExpansion + SwiftCompilerPluginMessageHandling swiftLLVMJSON ) target_include_directories(swift-plugin-server PRIVATE diff --git a/utils/build-script-impl b/utils/build-script-impl index f16b13d7bd17c..8e88cd120a39f 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -844,16 +844,6 @@ function set_build_options_for_host() { swift_cmake_options+=( -DCOVERAGE_DB="${COVERAGE_DB}" ) - - if [[ "$(true_false ${SWIFT_EARLYSWIFTSYNTAX})" == "TRUE" ]]; then - early_swiftsyntax_build_dir="$(build_directory ${host} earlyswiftsyntax)" - swift_cmake_options+=( - -DSWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH="${early_swiftsyntax_build_dir}" - ) - lldb_cmake_options+=( - -DSWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR:PATH="${early_swiftsyntax_build_dir}" - ) - fi } function configure_default_options() { diff --git a/utils/swift_build_support/swift_build_support/build_script_invocation.py b/utils/swift_build_support/swift_build_support/build_script_invocation.py index 110a67d4d4f6b..f69f4da7b630f 100644 --- a/utils/swift_build_support/swift_build_support/build_script_invocation.py +++ b/utils/swift_build_support/swift_build_support/build_script_invocation.py @@ -251,13 +251,15 @@ def convert_to_impl_arguments(self): args.extra_cmake_options.append( '-DSWIFT_BACK_DEPLOY_CONCURRENCY:BOOL=TRUE') - swift_syntax_src = os.path.join(self.workspace.source_root, - "swift-syntax") - args.extra_cmake_options.append( - '-DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE:PATH={}'.format(swift_syntax_src)) if args.build_early_swiftsyntax: - impl_args += ["--swift-earlyswiftsyntax"] + swift_syntax_src = os.path.join(self.workspace.source_root, + "swift-syntax") + args.extra_cmake_options.append( + '-DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE:PATH={}'.format(swift_syntax_src)) + args.extra_cmake_options.append('-DSWIFT_BUILD_SWIFT_SYNTAX:BOOL=TRUE') + if self.args.assertions: + args.extra_cmake_options.append('-DSWIFTSYNTAX_ENABLE_ASSERTIONS:BOOL=TRUE') # Then add subproject install flags that either skip building them /or/ # if we are going to build them and install_all is set, we also install @@ -568,9 +570,6 @@ def compute_product_pipelines(self): builder.begin_pipeline() - builder.add_product(products.EarlySwiftSyntax, - is_enabled=self.args.build_early_swiftsyntax) - # If --skip-early-swift-driver is passed in, swift will be built # as usual, but relying on its own C++-based (Legacy) driver. # Otherwise, we build an "early" swift-driver using the host diff --git a/utils/swift_build_support/swift_build_support/products/__init__.py b/utils/swift_build_support/swift_build_support/products/__init__.py index 40fd43960af40..3294929bd1585 100644 --- a/utils/swift_build_support/swift_build_support/products/__init__.py +++ b/utils/swift_build_support/swift_build_support/products/__init__.py @@ -15,7 +15,6 @@ from .cmark import CMark from .curl import LibCurl from .earlyswiftdriver import EarlySwiftDriver -from .earlyswiftsyntax import EarlySwiftSyntax from .foundation import Foundation from .indexstoredb import IndexStoreDB from .libcxx import LibCXX @@ -65,7 +64,6 @@ 'SwiftPM', 'SwiftDriver', 'EarlySwiftDriver', - 'EarlySwiftSyntax', 'XCTest', 'SwiftSyntax', 'SKStressTester', diff --git a/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py b/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py index acd9fa841df13..46b64231b63d6 100644 --- a/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py +++ b/utils/swift_build_support/swift_build_support/products/earlyswiftdriver.py @@ -12,7 +12,6 @@ import os -from . import earlyswiftsyntax from . import product from .. import shell from .. import toolchain @@ -58,11 +57,7 @@ def should_build(self, host_target): @classmethod def get_dependencies(cls): - # FIXME: This isn't a real dependency, but is necessary to linearize the - # dependency graph from Swift to EarlySwiftSyntax. If we properly - # express the dependency from Swift -> EarlySwiftSyntax, build_graph.py - # asserts that there are multiple roots to the graph. - return [earlyswiftsyntax.EarlySwiftSyntax] + return [] def should_clean(self, host_target): return self.args.clean_early_swift_driver diff --git a/utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py b/utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py deleted file mode 100644 index 485be3c1a497d..0000000000000 --- a/utils/swift_build_support/swift_build_support/products/earlyswiftsyntax.py +++ /dev/null @@ -1,83 +0,0 @@ -# swift_build_support/products/earlyswiftsyntax.py --------------*- python -*- -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -# -# ---------------------------------------------------------------------------- - -from . import cmake_product -from .. import toolchain - - -# SwiftSyntax is a Swift module used to parse and manipulate Swift syntax. This -# build product is a "Special" SwiftSyntax that gets built with the host -# toolchain that can be linked into the Swift compiler itself, hence it does not -# depend on any other build product of `build-script`. -class EarlySwiftSyntax(cmake_product.CMakeProduct): - @classmethod - def product_source_name(cls): - return "swift-syntax" - - @classmethod - def is_build_script_impl_product(cls): - return False - - @classmethod - def is_before_build_script_impl_product(cls): - return True - - def should_build(self, host_target): - if self.args.build_early_swiftsyntax: - if toolchain.host_toolchain().find_tool("swift") is None: - warn_msg = 'Host toolchain could not locate a '\ - 'compiler to build early swift-syntax.' - print('-- Warning: {}', warn_msg) - return False - else: - return True - return False - - @classmethod - def get_dependencies(cls): - return [] - - def build(self, host_target): - self.cmake_options.define('CMAKE_BUILD_TYPE:STRING', - self.args.swift_build_variant) - self.cmake_options.define('BUILD_SHARED_LIBS:STRING', 'YES') - - self.generate_toolchain_file_for_darwin_or_linux(host_target) - - self.cmake_options.define('CMAKE_INSTALL_PREFIX:PATH', self.args.install_prefix) - self.cmake_options.define('SWIFTSYNTAX_ENABLE_ASSERTIONS:BOOL', - self.args.assertions) - self.build_with_cmake(["all"], self.args.swift_build_variant, []) - - def should_test(self, host_target): - # The normal SwiftSyntax target runs tests through SwiftPM. - return False - - def test(self, host_target): - pass - - def should_install(self, host_target): - """should_install() -> Bool - - Whether or not this product should be installed with the given - arguments. - """ - return self.should_build(host_target) and self.args.install_swiftsyntax - - def install(self, host_target): - """ - Perform the install phase for the product. - - This phase might copy the artifacts from the previous phases into a - destination directory. - """ - self.install_with_cmake(["install"], self.host_install_destdir(host_target))