diff --git a/Package.swift b/Package.swift index 28ce8e242..83dfe9c99 100644 --- a/Package.swift +++ b/Package.swift @@ -68,20 +68,6 @@ let package = Package( .linkedLibrary("pthread", .when(platforms: [.linux]))] ), - /// The custom build tool used by the Swift package manager (SwiftPM). - /// - /// SwiftPM has now switched to using llbuild's Swift bindings API to - /// build, but this tool is still used for SwiftPM's bootstrapping. Once - /// that step has been eliminated, this tool can be removed. - .target( - name: "swift-build-tool", - dependencies: ["llbuildBuildSystem"], - path: "products/swift-build-tool", - linkerSettings: [ - .linkedLibrary("dl", .when(platforms: [.linux])), - .linkedLibrary("pthread", .when(platforms: [.linux]))] - ), - /// The public llbuild C API. .target( name: "libllbuild", @@ -304,8 +290,6 @@ let llvmTargets: Set = [ "llbuildBuildSystemTests", "llbuildCoreTests", "llbuildNinjaTests", - - "swift-build-tool", ] if !useTerminfo { @@ -353,7 +337,7 @@ if let target = package.targets.first(where: { $0.name == "llvmSupport" }) { if let target = package.targets.first(where: { $0.name == "llvmSupport" }) { target.linkerSettings = ["execinfo", "m", "pthread", "ncurses"].map { .linkedLibrary($0) } } -package.targets.filter({ $0.name == "llbuild" || $0.name == "swift-build-tool" }).forEach { +package.targets.filter({ $0.name == "llbuild" }).forEach { $0.linkerSettings = [.linkedLibrary("dl"), .linkedLibrary("pthread")] } #endif diff --git a/README.md b/README.md index 3903c696e..b926da7b9 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ llbuild currently includes: Usage ----- -The project currently produces three top-level products; `llbuild`, `swift-build-tool`, +The project currently produces two top-level products; `llbuild` and `libllbuild` / `llbuild.framework`. ### `llbuild` Command Line Tool @@ -80,15 +80,6 @@ is for a build of llbuild itself: ![llbuild build profile](docs/llbuild-profile.png) -### `swift-build-tool` Command Line Tool - -The `swift-build-tool` product is the command line interface to the build system -used by the [Swift Package Manager](https://swift.org/package-manager/). It is -built as part of the [Swift](https://swift.org) project build and incorporated -into the Swift language snapshots. - -This tool is built on top of the [BuildSystem](docs/buildsystem.rst) library. - ### `libllbuild` Library The `libllbuild` library exposes a C API for the llbuild libraries, which can be diff --git a/docs/development.rst b/docs/development.rst index 5425c28ba..cce3fdb4a 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -191,10 +191,6 @@ Swift conventions. A C API for llbuild. - **swift-build-tool** - - The command line build tool used by the Swift package manager. - * Examples of using `llbuild` are available under `examples/`. * There are three kinds of correctness tests include in the project: diff --git a/llbuild.xcodeproj/project.pbxproj b/llbuild.xcodeproj/project.pbxproj index fb49e9583..4576b2b63 100644 --- a/llbuild.xcodeproj/project.pbxproj +++ b/llbuild.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ ); dependencies = ( E178FCC61A1BF32F0039F8B5 /* PBXTargetDependency */, - E1604CB71BB9E07B001153A1 /* PBXTargetDependency */, E1B839631B541CDE00DB876B /* PBXTargetDependency */, ); name = "B&I"; @@ -518,13 +517,6 @@ E15305952236C8EE0097CDE6 /* BuildSystemExtensionManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15305942236C8EE0097CDE6 /* BuildSystemExtensionManager.cpp */; }; E15B6EC51B546A1600643066 /* ConvertUTFWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15B6EC31B546A0D00643066 /* ConvertUTFWrapper.cpp */; }; E15B6EC71B546A2C00643066 /* libcurses.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = E15B6EC61B546A2C00643066 /* libcurses.tbd */; }; - E1604CA51BB9E01D001153A1 /* libcurses.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = E15B6EC61B546A2C00643066 /* libcurses.tbd */; }; - E1604CA61BB9E01D001153A1 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = E1E221081A00B82100957481 /* libsqlite3.tbd */; }; - E1604CA71BB9E01D001153A1 /* libllvmSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E1B838A21B52E7DE00DB876B /* libllvmSupport.a */; }; - E1604CA81BB9E01D001153A1 /* libllbuildBasic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E1A2242519F991B40059043E /* libllbuildBasic.a */; }; - E1604CAA1BB9E01D001153A1 /* libllbuildCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E1A2243E19F997150059043E /* libllbuildCore.a */; }; - E1604CAB1BB9E01D001153A1 /* libllbuildBuildSystem.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E1B839571B541BFD00DB876B /* libllbuildBuildSystem.a */; }; - E1604CB51BB9E03E001153A1 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1604CB41BB9E032001153A1 /* main.cpp */; }; E162C5822233158A0078FD2E /* ShellCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E162C5812233158A0078FD2E /* ShellCommand.cpp */; }; E162C584223315A20078FD2E /* ShellCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = E162C583223315A20078FD2E /* ShellCommand.h */; }; E171538D1A0BF702004CD598 /* CorePerfTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E171538C1A0BF702004CD598 /* CorePerfTests.mm */; }; @@ -1231,41 +1223,6 @@ remoteGlobalIDString = E1B838981B52E7DE00DB876B; remoteInfo = llvmSupport; }; - E1604C971BB9E01D001153A1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = E1A223E919F98F1C0059043E /* Project object */; - proxyType = 1; - remoteGlobalIDString = E1B838981B52E7DE00DB876B; - remoteInfo = llvmSupport; - }; - E1604C991BB9E01D001153A1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = E1A223E919F98F1C0059043E /* Project object */; - proxyType = 1; - remoteGlobalIDString = E1A2242419F991B40059043E; - remoteInfo = llbuildBasic; - }; - E1604C9D1BB9E01D001153A1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = E1A223E919F98F1C0059043E /* Project object */; - proxyType = 1; - remoteGlobalIDString = E1A2243D19F997150059043E; - remoteInfo = llbuildCore; - }; - E1604C9F1BB9E01D001153A1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = E1A223E919F98F1C0059043E /* Project object */; - proxyType = 1; - remoteGlobalIDString = E1B839481B541BFD00DB876B; - remoteInfo = llbuildBuildFile; - }; - E1604CB61BB9E07B001153A1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = E1A223E919F98F1C0059043E /* Project object */; - proxyType = 1; - remoteGlobalIDString = E1604C951BB9E01D001153A1; - remoteInfo = "swift-build-tool"; - }; E178FCC51A1BF32F0039F8B5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = E1A223E919F98F1C0059043E /* Project object */; @@ -1490,13 +1447,6 @@ remoteGlobalIDString = E1D191BD1B47232B000C4E95; remoteInfo = "llbuild-framework"; }; - E1DE1CBF1BB9E34700A902C1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = E1A223E919F98F1C0059043E /* Project object */; - proxyType = 1; - remoteGlobalIDString = E1604C951BB9E01D001153A1; - remoteInfo = "swift-build-tool"; - }; E1E15C521A859732002CD50D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = E1A223E919F98F1C0059043E /* Project object */; @@ -1550,15 +1500,6 @@ ); runOnlyForDeploymentPostprocessing = 1; }; - E1604CAD1BB9E01D001153A1 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; E1A224C119F999B80059043E /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -4026,9 +3967,6 @@ E15305942236C8EE0097CDE6 /* BuildSystemExtensionManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BuildSystemExtensionManager.cpp; sourceTree = ""; }; E15B6EC31B546A0D00643066 /* ConvertUTFWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertUTFWrapper.cpp; sourceTree = ""; }; E15B6EC61B546A2C00643066 /* libcurses.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcurses.tbd; path = usr/lib/libcurses.tbd; sourceTree = SDKROOT; }; - E1604CB11BB9E01D001153A1 /* swift-build-tool */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "swift-build-tool"; sourceTree = BUILT_PRODUCTS_DIR; }; - E1604CB31BB9E032001153A1 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; - E1604CB41BB9E032001153A1 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; E162C5812233158A0078FD2E /* ShellCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShellCommand.cpp; sourceTree = ""; }; E162C583223315A20078FD2E /* ShellCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShellCommand.h; sourceTree = ""; }; E171538C1A0BF702004CD598 /* CorePerfTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CorePerfTests.mm; sourceTree = ""; }; @@ -4399,19 +4337,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - E1604CA41BB9E01D001153A1 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - E1604CA51BB9E01D001153A1 /* libcurses.tbd in Frameworks */, - E1604CA61BB9E01D001153A1 /* libsqlite3.tbd in Frameworks */, - E1604CA71BB9E01D001153A1 /* libllvmSupport.a in Frameworks */, - E1604CA81BB9E01D001153A1 /* libllbuildBasic.a in Frameworks */, - E1604CAA1BB9E01D001153A1 /* libllbuildCore.a in Frameworks */, - E1604CAB1BB9E01D001153A1 /* libllbuildBuildSystem.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; E1A2242219F991B40059043E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -8291,15 +8216,6 @@ path = Basic; sourceTree = ""; }; - E1604CB21BB9E032001153A1 /* swift-build-tool */ = { - isa = PBXGroup; - children = ( - E1604CB31BB9E032001153A1 /* CMakeLists.txt */, - E1604CB41BB9E032001153A1 /* main.cpp */, - ); - path = "swift-build-tool"; - sourceTree = ""; - }; E1A223E819F98F1C0059043E = { isa = PBXGroup; children = ( @@ -8351,7 +8267,6 @@ E1B838A21B52E7DE00DB876B /* libllvmSupport.a */, E1B839571B541BFD00DB876B /* libllbuildBuildSystem.a */, E147DF161BA81D330032D08E /* BasicTests */, - E1604CB11BB9E01D001153A1 /* swift-build-tool */, 9DB047A81DF9D43D006CDF52 /* BuildSystemTests */, 40B3C91A20D3AEC9007C5847 /* CAPITests */, B546B39422C65CFB007046C0 /* llbuildSwiftTests.xctest */, @@ -8376,7 +8291,6 @@ E1D191B71B472305000C4E95 /* llbuild-framework */, 4072B4B32C51993F00B68221 /* llbuild3 */, BC8DEF0420300AAF00E9EF0C /* llbuildSwift */, - E1604CB21BB9E032001153A1 /* swift-build-tool */, 147018862097909B0079261E /* ui */, ); path = products; @@ -9427,7 +9341,6 @@ 9D2107C41DF9FBFA00BE26FF /* PBXTargetDependency */, E18043341A00123600662FE7 /* PBXTargetDependency */, E180436E1A001E6C00662FE7 /* PBXTargetDependency */, - E1DE1CC01BB9E34700A902C1 /* PBXTargetDependency */, E147DF1E1BA81DB80032D08E /* PBXTargetDependency */, E18043781A001E7600662FE7 /* PBXTargetDependency */, E180437A1A001E7700662FE7 /* PBXTargetDependency */, @@ -9479,27 +9392,6 @@ productReference = E147DF161BA81D330032D08E /* BasicTests */; productType = "com.apple.product-type.tool"; }; - E1604C951BB9E01D001153A1 /* swift-build-tool */ = { - isa = PBXNativeTarget; - buildConfigurationList = E1604CAE1BB9E01D001153A1 /* Build configuration list for PBXNativeTarget "swift-build-tool" */; - buildPhases = ( - E1604CA21BB9E01D001153A1 /* Sources */, - E1604CA41BB9E01D001153A1 /* Frameworks */, - E1604CAD1BB9E01D001153A1 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - E1604C961BB9E01D001153A1 /* PBXTargetDependency */, - E1604C981BB9E01D001153A1 /* PBXTargetDependency */, - E1604C9C1BB9E01D001153A1 /* PBXTargetDependency */, - E1604C9E1BB9E01D001153A1 /* PBXTargetDependency */, - ); - name = "swift-build-tool"; - productName = llbuild; - productReference = E1604CB11BB9E01D001153A1 /* swift-build-tool */; - productType = "com.apple.product-type.tool"; - }; E1A2242419F991B40059043E /* llbuildBasic */ = { isa = PBXNativeTarget; buildConfigurationList = E1A2242619F991B40059043E /* Build configuration list for PBXNativeTarget "llbuildBasic" */; @@ -9981,7 +9873,6 @@ targets = ( E178FCC11A1BF3270039F8B5 /* B&I */, E1A224C219F999B80059043E /* llbuild Tool */, - E1604C951BB9E01D001153A1 /* swift-build-tool */, E1D191BD1B47232B000C4E95 /* llbuild-framework */, E1ADC2391A85936400D5387C /* libllbuild */, E1B838981B52E7DE00DB876B /* llvmSupport */, @@ -11023,14 +10914,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - E1604CA21BB9E01D001153A1 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - E1604CB51BB9E03E001153A1 /* main.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; E1A2242119F991B40059043E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -11415,31 +11298,6 @@ target = E1B838981B52E7DE00DB876B /* llvmSupport */; targetProxy = E14C2CF21BDAC8A70033CA2A /* PBXContainerItemProxy */; }; - E1604C961BB9E01D001153A1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = E1B838981B52E7DE00DB876B /* llvmSupport */; - targetProxy = E1604C971BB9E01D001153A1 /* PBXContainerItemProxy */; - }; - E1604C981BB9E01D001153A1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = E1A2242419F991B40059043E /* llbuildBasic */; - targetProxy = E1604C991BB9E01D001153A1 /* PBXContainerItemProxy */; - }; - E1604C9C1BB9E01D001153A1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = E1A2243D19F997150059043E /* llbuildCore */; - targetProxy = E1604C9D1BB9E01D001153A1 /* PBXContainerItemProxy */; - }; - E1604C9E1BB9E01D001153A1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = E1B839481B541BFD00DB876B /* llbuildBuildSystem */; - targetProxy = E1604C9F1BB9E01D001153A1 /* PBXContainerItemProxy */; - }; - E1604CB71BB9E07B001153A1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = E1604C951BB9E01D001153A1 /* swift-build-tool */; - targetProxy = E1604CB61BB9E07B001153A1 /* PBXContainerItemProxy */; - }; E178FCC61A1BF32F0039F8B5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = E1A224C219F999B80059043E /* llbuild Tool */; @@ -11600,11 +11458,6 @@ target = E1D191BD1B47232B000C4E95 /* llbuild-framework */; targetProxy = E1B839621B541CDE00DB876B /* PBXContainerItemProxy */; }; - E1DE1CC01BB9E34700A902C1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = E1604C951BB9E01D001153A1 /* swift-build-tool */; - targetProxy = E1DE1CBF1BB9E34700A902C1 /* PBXContainerItemProxy */; - }; E1E15C531A859732002CD50D /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = E1A2242419F991B40059043E /* llbuildBasic */; @@ -12101,28 +11954,6 @@ }; name = Release; }; - E1604CAF1BB9E01D001153A1 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "$(LLBUILD_CODE_SIGN_IDENTITY)"; - DEVELOPMENT_TEAM = ""; - INSTALL_PATH = "$(DT_TOOLCHAIN_INSTALL_DIR:standardizepath)/usr/bin"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = "$(SKIP_INSTALL_CLI_TOOLS)"; - }; - name = Debug; - }; - E1604CB01BB9E01D001153A1 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "$(LLBUILD_CODE_SIGN_IDENTITY)"; - DEVELOPMENT_TEAM = ""; - INSTALL_PATH = "$(DT_TOOLCHAIN_INSTALL_DIR:standardizepath)/usr/bin"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = "$(SKIP_INSTALL_CLI_TOOLS)"; - }; - name = Release; - }; E178FCC21A1BF3270039F8B5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -12710,15 +12541,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - E1604CAE1BB9E01D001153A1 /* Build configuration list for PBXNativeTarget "swift-build-tool" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - E1604CAF1BB9E01D001153A1 /* Debug */, - E1604CB01BB9E01D001153A1 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; E178FCC41A1BF3270039F8B5 /* Build configuration list for PBXAggregateTarget "B&I" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/products/CMakeLists.txt b/products/CMakeLists.txt index ffc46a7df..2d8be9602 100644 --- a/products/CMakeLists.txt +++ b/products/CMakeLists.txt @@ -1,6 +1,5 @@ # Command line tools. add_subdirectory(llbuild) -add_subdirectory(swift-build-tool) # Public API products. add_subdirectory(libllbuild) diff --git a/products/swift-build-tool/CMakeLists.txt b/products/swift-build-tool/CMakeLists.txt deleted file mode 100644 index 7ccc9abed..000000000 --- a/products/swift-build-tool/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -add_executable(swift-build-tool - main.cpp) - -target_link_libraries(swift-build-tool PRIVATE - llbuildBuildSystem - llbuildCore - llbuildBasic - llvmSupport - SQLite::SQLite3) - -if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - target_link_libraries(swift-build-tool PRIVATE - curses) -endif() - -install(TARGETS swift-build-tool - COMPONENT swift-build-tool - DESTINATION bin) - -add_custom_target(install-swift-build-tool - DEPENDS swift-build-tool - COMMENT "Installing swift-build-tool..." - COMMAND "${CMAKE_COMMAND}" - -DCMAKE_INSTALL_COMPONENT=swift-build-tool - -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") diff --git a/products/swift-build-tool/main.cpp b/products/swift-build-tool/main.cpp deleted file mode 100644 index 860f39ef4..000000000 --- a/products/swift-build-tool/main.cpp +++ /dev/null @@ -1,113 +0,0 @@ -//===-- swift-build-tool.cpp - Swift Build Tool ---------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See http://swift.org/LICENSE.txt for license information -// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#include "llbuild/BuildSystem/BuildSystemFrontend.h" - -#include "llbuild/Basic/FileSystem.h" -#include "llbuild/Basic/Version.h" -#include "llbuild/BuildSystem/BuildDescription.h" -#include "llbuild/BuildSystem/BuildFile.h" -#include "llbuild/BuildSystem/Command.h" -#include "llbuild/BuildSystem/Tool.h" - -#include "llvm/Support/SourceMgr.h" -#include "llvm/Support/Signals.h" -#include "llvm/Support/raw_ostream.h" - -using namespace llbuild; -using namespace llbuild::buildsystem; - -class BasicBuildSystemFrontendDelegate : public BuildSystemFrontendDelegate { -public: - BasicBuildSystemFrontendDelegate(llvm::SourceMgr& sourceMgr, - const BuildSystemInvocation& invocation) - : BuildSystemFrontendDelegate(sourceMgr, - "swift-build", /*version=*/0) {} - - virtual void hadCommandFailure() override { - // Call the base implementation. - BuildSystemFrontendDelegate::hadCommandFailure(); - - // Cancel the build, by default. - cancel(); - } - - virtual std::unique_ptr lookupTool(StringRef name) override { - return nullptr; - } - - virtual void cycleDetected(const std::vector& items) override { - auto message = BuildSystemInvocation::formatDetectedCycle(items); - error(message); - } -}; - -static void usage(int exitCode) { - int optionWidth = 25; - fprintf(stderr, "Usage: swift-build-tool [options] []\n"); - fprintf(stderr, "\nOptions:\n"); - BuildSystemInvocation::getUsage(optionWidth, llvm::errs()); - ::exit(exitCode); -} - -static int execute(ArrayRef args) { - // The source manager to use for diagnostics. - llvm::SourceMgr sourceMgr; - - // Create the invocation. - BuildSystemInvocation invocation{}; - - // Initialize defaults. - invocation.dbPath = "build.db"; - invocation.buildFilePath = "build.swift-build"; - invocation.parse(args, sourceMgr); - - // Handle invocation actions. - if (invocation.showUsage) { - usage(0); - } else if (invocation.showVersion) { - // Print the version and exit. - printf("%s\n", getLLBuildFullVersion("swift-build-tool").c_str()); - return 0; - } else if (invocation.hadErrors) { - usage(1); - } - - if (invocation.positionalArgs.size() > 1) { - fprintf(stderr, "swift-build-tool: error: invalid number of arguments\n"); - usage(1); - } - - // Select the target to build. - std::string targetToBuild = - invocation.positionalArgs.empty() ? "" : invocation.positionalArgs[0]; - - // Create the frontend object. - BasicBuildSystemFrontendDelegate delegate(sourceMgr, invocation); - BuildSystemFrontend frontend(delegate, invocation, basic::createLocalFileSystem()); - if (!frontend.build(targetToBuild)) { - return 1; - } - - return 0; -} - -int main(int argc, const char **argv) { - // Print stacks on error. - llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); - - std::vector args; - for (int i = 1; i != argc; ++i) { - args.push_back(argv[i]); - } - return execute(args); -} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 12001a593..c8b0b58e0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,7 +34,7 @@ if(Python3_Interpreter_FOUND AND LIT_FOUND AND FILECHECK_FOUND) --param build_mode=${build_mode}) set(test_target_dependencies - llbuild-tool llbuild swift-build-tool UnitTests adjust-times) + llbuild-tool llbuild UnitTests adjust-times) add_custom_target(test-llbuild COMMAND ${lit_command} ${CMAKE_CURRENT_BINARY_DIR} diff --git a/tests/SwiftBuildTool/Inputs/pseudo-swiftc b/tests/SwiftBuildTool/Inputs/pseudo-swiftc deleted file mode 100755 index f39b70789..000000000 --- a/tests/SwiftBuildTool/Inputs/pseudo-swiftc +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python3 - - -import argparse -import json -import os -import shlex -import sys - -def main(): - parser = argparse.ArgumentParser(description='Fake Swift Compiler.') - parser.add_argument('--add-dep', type=str, nargs='+') - parser.add_argument('-module-name', type=str) - parser.add_argument('-output-file-map', type=str) - parser.add_argument('-incremental', action='store_true') - parser.add_argument('-emit-library', dest='emit_library', action='store_true') - parser.add_argument('-emit-module', action='store_true') - parser.add_argument('-emit-module-path', type=str) - parser.add_argument('-emit-dependencies', action='store_true') - parser.add_argument('-parse-as-library', action='store_true') - parser.add_argument('-whole-module-optimization', action='store_true') - parser.add_argument('-num-threads', type=int) - parser.add_argument('-I', type=str) - parser.add_argument('-O', type=str) - parser.add_argument('-o', dest='output_file', type=str) - parser.add_argument('-c', dest="compile", action='store_true') - parser.add_argument('-###', dest="show_commands", action='store_true') - parser.add_argument('-v', dest="verbose", action='store_true') - parser.add_argument('--version', dest="version", action='store_true') - parser.add_argument('sources', type=str, nargs='*') - args = parser.parse_args() - - # Parse the output file map. - if args.output_file_map: - with open(args.output_file_map) as f: - output_file_map = json.load(f) - else: - output_file_map = None - - # If run in verbose mode, print a fake version. - if args.verbose or args.version: - print("Pseudo Swift version 1.2.3 (%s)" % ( - os.environ.get("PSEUDO_SWIFT_VERSION", "12.1"),)) - print("Target: bla bla bla") - if args.version: - return - - # If run in show commands mode, print some dummy output. - if args.show_commands: - print(' '.join(map(shlex.quote, [ - sys.argv[0], "-frontend", "...blablabla..."]))) - return - - # Write dummy outputs. - if output_file_map is not None: - writeAllDeps = True - deps = None - if args.whole_module_optimization: - # Write only one dep file for entire module. - writeAllDeps = False - deps = output_file_map[""]["dependencies"] - if os.path.exists(deps): - os.remove(deps) - # Non-parallel WMO mode. - if not args.num_threads > 0: - # Write only one object file for entiremodule. - object = output_file_map[""]["object"] - writeObject(object) - writeDeps(object, deps, args.add_dep, False) - return - - for key,item in list(output_file_map.items()): - if key == "": - continue - object = item["object"] - writeObject(object) - # Write dummy dependencies. - if writeAllDeps: - deps = item["dependencies"] - writeDeps(object, deps, args.add_dep, not writeAllDeps) - if args.emit_library: - writeObject(args.output_file) - -def writeDeps(object, deps, add_dep, append): - with open(deps, "a" if append else "w") as f: - f.write("%s: %s\n" % (object, ' '.join(add_dep or []))) - -def writeObject(object): - with open(object, "w") as f: - f.write("") - -if __name__ == '__main__': - main() diff --git a/tests/SwiftBuildTool/basic.swift-build b/tests/SwiftBuildTool/basic.swift-build deleted file mode 100644 index 4c2d55c04..000000000 --- a/tests/SwiftBuildTool/basic.swift-build +++ /dev/null @@ -1,23 +0,0 @@ -# Check that the tool works. -# -# RUN: rm -rf %t.build -# RUN: mkdir -p %t.build -# RUN: cp %s %t.build/build.swift-build -# RUN: %{swift-build-tool} --chdir %t.build > %t.out -# RUN: %{FileCheck} < %t.out %s -# -# CHECK: ECHO -# CHECK: Hello Swift Build Tool - -client: - name: swift-build - -targets: - "": [""] - -commands: - C1: - tool: shell - outputs: [""] - description: ECHO - args: echo "Hello Swift Build Tool" diff --git a/tests/SwiftBuildTool/changed-commands.swift-build b/tests/SwiftBuildTool/changed-commands.swift-build deleted file mode 100644 index 06bcf5d87..000000000 --- a/tests/SwiftBuildTool/changed-commands.swift-build +++ /dev/null @@ -1,70 +0,0 @@ -# Windows doesn't have a way to exec python files -# UNSUPPORTED: platform=Windows -# Check that we behave properly when a command changes. -# -# This is a regression test for a subtle bug when our hash function was too -# trivial, and ended up reversing itself due to trivial XOR combining. -# -# We use 'grep' to slice out two different subfiles from the same file. -# -# RUN: rm -rf %t.build -# RUN: mkdir -p %t.build -# RUN: touch %t.build/s1.swift %t.build/s2.swift -# -# RUN: grep -A1000 "VERSION-BEGIN-[1]" %s | grep -B10000 "VERSION-END-1" | grep -ve '^--$' > %t.build/build.swift-build.tmp -# RUN: sed -e "s#SOURCEDIR#%S#g" -e "s#TMPDIR#%t#g" < %t.build/build.swift-build.tmp > %t.build/build.swift-build -# RUN: %{swift-build-tool} -v --chdir %t.build > %t1.out -# RUN: %{FileCheck} --check-prefix CHECK-VERSION-1 --input-file %t1.out %s -# -# RUN: grep -A1000 "VERSION-BEGIN-[2]" %s | grep -B10000 "VERSION-END-2" | grep -ve '^--$' > %t.build/build.swift-build.tmp -# RUN: sed -e "s#SOURCEDIR#%S#g" -e "s#TMPDIR#%t#g" < %t.build/build.swift-build.tmp > %t.build/build.swift-build -# RUN: %{swift-build-tool} -v --chdir %t.build > %t2.out -# RUN: %{FileCheck} --check-prefix CHECK-VERSION-2 --input-file %t2.out %s - -##### VERSION-BEGIN-1 ##### - -# CHECK-VERSION-1: swiftc {{.*}} s1.swift s2.swift -client: - name: swift-build - -targets: - "": ["s1.o"] - -commands: - C1: - tool: swift-compiler - inputs: ["s1.swift", "s2.swift"] - outputs: ["s1.o", "s2.o"] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Foo - module-output-path: Foo.swiftmodule - sources: ["s1.swift", "s2.swift"] - objects: ["s1.o", "s2.o"] - temps-path: temps - is-library: true - -##### VERSION-END-1 ##### - -##### VERSION-BEGIN-2 ##### - -# CHECK-VERSION-2: swiftc {{.*}} s1.swift -client: - name: swift-build - -targets: - "": ["s1.o"] - -commands: - C1: - tool: swift-compiler - inputs: ["s1.swift"] - outputs: ["s1.o"] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Foo - module-output-path: Foo.swiftmodule - sources: ["s1.swift"] - objects: ["s1.o"] - temps-path: temps - is-library: true - -##### VERSION-END-2 ##### diff --git a/tests/SwiftBuildTool/dependencies.swift-build b/tests/SwiftBuildTool/dependencies.swift-build deleted file mode 100644 index d413cd303..000000000 --- a/tests/SwiftBuildTool/dependencies.swift-build +++ /dev/null @@ -1,45 +0,0 @@ -# Windows doesn't have a way to exec python files -# UNSUPPORTED: platform=Windows -# Check that we properly pick up dependencies from the Swift compiler. -# -# RUN: rm -rf %t.build -# RUN: mkdir -p %t.build -# RUN: touch %t.build/input -# RUN: sed -e "s#SOURCEDIR#%S#g" -e "s#TMPDIR#%t#g" < %s > %t.build/build.swift-build -# RUN: %{swift-build-tool} -v --chdir %t.build > %t.out -# RUN: %{FileCheck} --check-prefix=CHECK-INITIAL --input-file %t.out %s -# -# CHECK-INITIAL: {{.*}}/pseudo-swiftc - -# Check that the next build is null. -# -# RUN: %{swift-build-tool} -v --chdir %t.build > %t.out -# RUN: echo "END-OF-INPUT" >> %t.out -# RUN: %{FileCheck} --check-prefix=CHECK-NULL --input-file %t.out %s -# -# CHECK-NULL-NOT: swiftc - -# Modify the input and check that things rebuild. -# -# RUN: echo "mod" >> %t.build/input -# RUN: %{swift-build-tool} -v --chdir %t.build > %t.out -# RUN: %{FileCheck} --check-prefix=CHECK-REBUILD --input-file %t.out %s -# -# CHECK-REBUILD: {{.*}}/pseudo-swiftc - -client: - name: swift-build - -targets: - "": [""] - -commands: - C1: - tool: swift-compiler - outputs: [""] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Foo - sources: input.swift - objects: output.o - temps-path: temps - other-args: ["--add-dep", "TMPDIR.build/input"] diff --git a/tests/SwiftBuildTool/lit.local.cfg b/tests/SwiftBuildTool/lit.local.cfg deleted file mode 100644 index 6f7210b37..000000000 --- a/tests/SwiftBuildTool/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.swift-build'] diff --git a/tests/SwiftBuildTool/swift-compiler-whole-module-optimization.swift-build b/tests/SwiftBuildTool/swift-compiler-whole-module-optimization.swift-build deleted file mode 100644 index d78486e46..000000000 --- a/tests/SwiftBuildTool/swift-compiler-whole-module-optimization.swift-build +++ /dev/null @@ -1,64 +0,0 @@ -# Windows doesn't have a way to exec python files -# UNSUPPORTED: platform=Windows -# Check that we communicate properly with the Swift compiler. -# -# RUN: rm -rf %t.build -# RUN: mkdir -p %t.build -# RUN: sed -e "s#SOURCEDIR#%S#g" -e "s#TMPDIR#%t#g" < %s > %t.build/build.swift-build -# RUN: %{swift-build-tool} --no-db --chdir %t.build > %t.out -# RUN: %{swift-build-tool} --no-db -v --chdir %t.build > %t-verbose.out -# RUN: %{FileCheck} --input-file=%t.out %s -# RUN: %{FileCheck} --check-prefix=CHECK-VERBOSE --input-file=%t-verbose.out %s -# -# CHECK: Compiling Swift Module 'Foo' -# CHECK-VERBOSE: swiftc -module-name Bar -emit-dependencies -emit-module -emit-module-path Bar.swiftmodule -output-file-map bar.build/output-file-map.json -parse-as-library -whole-module-optimization -num-threads 1 -c s1.swift -I importB -# CHECK-VERBOSE: swiftc -module-name Foo -emit-dependencies -emit-module -emit-module-path Foo.swiftmodule -output-file-map foo.build/output-file-map.json -parse-as-library -whole-module-optimization -num-threads 0 -c s1.swift s2.swift -I importA -I importB -Onone -I somePath - -# # Sanity check the output file map. -# -# RUN: %{FileCheck} --check-prefix=CHECK-OUTPUT-FILE-MAP --input-file=%t.build/foo.build/output-file-map.json %s -# CHECK-OUTPUT-FILE-MAP: "": { -# CHECK-OUTPUT-FILE-MAP-NEXT: "dependencies": "foo.build/Foo.d" -# CHECK-OUTPUT-FILE-MAP-NEXT: "object": "foo.build/Foo.o" -# -# RUN: %{FileCheck} --check-prefix=CHECK-OUTPUT-FILE-MAP-BAR --input-file=%t.build/bar.build/output-file-map.json %s -# CHECK-OUTPUT-FILE-MAP-BAR: "": { -# CHECK-OUTPUT-FILE-MAP-BAR-NEXT: "dependencies": "bar.build/Bar.d" - - -client: - name: swift-build - -targets: - "": [""] - -commands: - C0: - tool: swift-compiler - outputs: [""] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Bar - module-output-path: Bar.swiftmodule - sources: ["s1.swift"] - import-paths: ["importB"] - objects: ["bar.build/s1.o"] - other-args: [] - temps-path: bar.build - is-library: true - enable-whole-module-optimization: true - num-threads: 1 - - C1: - tool: swift-compiler - inputs: [""] - outputs: [""] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Foo - module-output-path: Foo.swiftmodule - sources: ["s1.swift", "s2.swift"] - import-paths: ["importA", "importB"] - objects: ["foo.build/s1.o", "foo.build/s2.o"] - other-args: ["-Onone", "-I", "somePath"] - temps-path: foo.build - is-library: true - enable-whole-module-optimization: true diff --git a/tests/SwiftBuildTool/swift-compiler.swift-build b/tests/SwiftBuildTool/swift-compiler.swift-build deleted file mode 100644 index 5e82bfa8c..000000000 --- a/tests/SwiftBuildTool/swift-compiler.swift-build +++ /dev/null @@ -1,44 +0,0 @@ -# Windows doesn't have a way to exec python files -# UNSUPPORTED: platform=Windows -# Check that we communicate properly with the Swift compiler. -# -# RUN: rm -rf %t.build -# RUN: mkdir -p %t.build/temps/nested -# RUN: sed -e "s#SOURCEDIR#%S#g" -e "s#TMPDIR#%t#g" < %s > %t.build/build.swift-build -# RUN: %{swift-build-tool} --no-db --chdir %t.build > %t.out -# RUN: %{swift-build-tool} --no-db -v --chdir %t.build > %t-verbose.out -# RUN: %{FileCheck} --input-file=%t.out %s -# RUN: %{FileCheck} --check-prefix=CHECK-VERBOSE --input-file=%t-verbose.out %s -# -# CHECK: Compiling Swift Module 'Foo' -# FIXME: This should quote output paths. -# CHECK-VERBOSE: swiftc -module-name Foo -emit-dependencies -emit-module -emit-module-path Foo.swiftmodule -output-file-map temps/output-file-map.json -parse-as-library -incremental -c "s 1.swift" "s 2.swift" -I "import A" -I "import B" -Onone -I "path with spaces" - -# Sanity check the output file map. -# -# RUN: %{FileCheck} --check-prefix=CHECK-OUTPUT-FILE-MAP --input-file=%t.build/temps/output-file-map.json %s -# CHECK-OUTPUT-FILE-MAP: "s 1.swift": { -# CHECK-OUTPUT-FILE-MAP-NEXT: "dependencies": "temps/s 1.d" -# CHECK-OUTPUT-FILE-MAP: "s 2.swift": { -# CHECK-OUTPUT-FILE-MAP-NEXT: "dependencies": "temps/nested/s 2.d" - -client: - name: swift-build - -targets: - "": [""] - -commands: - C1: - tool: swift-compiler - outputs: [""] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Foo - module-output-path: Foo.swiftmodule - sources: ["s 1.swift", "s 2.swift"] - import-paths: ["import A", "import B"] - # FIXME: We can't use spaces in filenames here yet, because of a Swift compiler bug. - objects: ["temps/s1.o", "temps/nested/s2.o"] - other-args: ["-Onone", "-I", "path with spaces"] - temps-path: temps - is-library: true diff --git a/tests/SwiftBuildTool/swift-shared-library.swift-build b/tests/SwiftBuildTool/swift-shared-library.swift-build deleted file mode 100644 index 2439f5681..000000000 --- a/tests/SwiftBuildTool/swift-shared-library.swift-build +++ /dev/null @@ -1,36 +0,0 @@ -# Check the shared libraryu tool. -# -# RUN: rm -rf %t.build -# RUN: mkdir -p %t.build -# RUN: sed -e "s#SOURCEDIR#%S#g" -e "s#TMPDIR#%t#g" < %s > %t.build/build.swift-build -# RUN: echo "" > %t.build/s1.swift -# RUN: echo "" > %t.build/s2.swift -# -# RUN: %{swift-build-tool} -v --chdir %t.build > %t3.out -# RUN: %{FileCheck} --check-prefix=CHECK-CONTENTS --input-file=%t.build/Foo.so %s -# CHECK-CONTENTS: - -client: - name: swift-build - -targets: - "": ["Foo.so"] - -commands: - C1.makeObjects: - tool: swift-compiler - sources: ["s1.swift", "s2.swift"] - inputs: ["s1.swift", "s2.swift"] - objects: ["s1.o", "s2.o"] - outputs: ["s1.o", "s2.o"] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Foo - module-output-path: Foo.swiftmodule - temps-path: temps - is-library: true - C2.sharedlib: - tool: shared-library - executable: SOURCEDIR/Inputs/pseudo-swiftc - compiler-style: swiftc - inputs: ["s1.o", "s2.o"] - outputs: ["Foo.so"] diff --git a/tests/SwiftBuildTool/swift-version.swift-build b/tests/SwiftBuildTool/swift-version.swift-build deleted file mode 100644 index 3c2143c51..000000000 --- a/tests/SwiftBuildTool/swift-version.swift-build +++ /dev/null @@ -1,52 +0,0 @@ -# Windows doesn't have a way to exec python files -# UNSUPPORTED: platform=Windows -# Check that we properly rebuild when the Swift compiler changes. -# -# RUN: rm -rf %t.build -# RUN: mkdir -p %t.build -# RUN: touch %t.build/input -# RUN: sed -e "s#SOURCEDIR#%S#g" -e "s#TMPDIR#%t#g" < %s > %t.build/build.swift-build -# RUN: %{swift-build-tool} -v --chdir %t.build > %t.out -# RUN: %{FileCheck} --check-prefix=CHECK-INITIAL --input-file %t.out %s -# -# CHECK-INITIAL: {{.*}}/pseudo-swiftc - -# Check that the next build is null. -# -# RUN: %{swift-build-tool} -v --chdir %t.build > %t.out -# RUN: echo "END-OF-INPUT" >> %t.out -# RUN: %{FileCheck} --check-prefix=CHECK-NULL --input-file %t.out %s -# -# CHECK-NULL-NOT: swiftc - -# Tell the swift-compiler to change its version (via environment) -# -# RUN: env PSEUDO_SWIFT_VERSION=99.99 %{swift-build-tool} -v --chdir %t.build > %t.out -# RUN: echo "END-OF-INPUT" >> %t.out -# RUN: %{FileCheck} --check-prefix=CHECK-REBUILD --input-file %t.out %s -# -# CHECK-REBUILD: {{.*}}/pseudo-swiftc - -# Check one more null build. -# -# RUN: env PSEUDO_SWIFT_VERSION=99.99 %{swift-build-tool} -v --chdir %t.build > %t.out -# RUN: echo "END-OF-INPUT" >> %t.out -# RUN: %{FileCheck} --check-prefix=CHECK-REBUILD-NULL --input-file %t.out %s -# -# CHECK-REBUILD-NULL-NOT: {{.*}}/pseudo-swiftc - -client: - name: swift-build - -targets: - "": [""] - -commands: - C1: - tool: swift-compiler - outputs: [""] - executable: SOURCEDIR/Inputs/pseudo-swiftc - module-name: Foo - sources: input.swift - objects: output.o - temps-path: temps diff --git a/tests/SwiftBuildTool/version.swift-build b/tests/SwiftBuildTool/version.swift-build deleted file mode 100644 index f00fc03e6..000000000 --- a/tests/SwiftBuildTool/version.swift-build +++ /dev/null @@ -1,6 +0,0 @@ -# Check that the version information is sensible. -# -# RUN: %{swift-build-tool} --version > %t.out -# RUN: %{FileCheck} < %t.out %s -# -# CHECK: swift-build-tool version diff --git a/tests/lit.cfg b/tests/lit.cfg index 6f6f8c117..aeef53c2a 100644 --- a/tests/lit.cfg +++ b/tests/lit.cfg @@ -118,8 +118,6 @@ def inferSwiftBinary(binaryName): # Define our supported substitutions. config.substitutions.append( ('%{llbuild}', "%r" % ( os.path.join(llbuild_tools_dir, 'llbuild'),)) ) -config.substitutions.append( ('%{swift-build-tool}', "%r" % ( - os.path.join(llbuild_tools_dir, 'swift-build-tool'),)) ) config.substitutions.append( ('%{adjust-times}', "%r" % ( os.path.join(llbuild_tools_dir, 'adjust-times'),)) ) config.substitutions.append( ('%{FileCheck}', config.filecheck_path) )