Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ add_compile_definitions(USE_STATIC_PLUGIN_INITIALIZATION)
find_package(ArgumentParser)
find_package(LLBuild)
find_package(SwiftDriver)
find_package(SwiftToolsProtocols)
find_package(SwiftSystem)
find_package(TSC)
# NOTE: these two are required for LLBuild dependencies
Expand Down
14 changes: 13 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,17 @@ let package = Package(
// Libraries
.target(
name: "SwiftBuild",
dependencies: ["SWBCSupport", "SWBCore", "SWBProtocol", "SWBUtil", "SWBProjectModel"],
dependencies: [
"SWBCSupport",
"SWBCore",
"SWBProtocol",
"SWBUtil",
"SWBProjectModel",
.product(name: "BuildServerProtocol", package: "swift-tools-protocols"),
.product(name: "LanguageServerProtocol", package: "swift-tools-protocols"),
.product(name: "LanguageServerProtocolTransport", package: "swift-tools-protocols")

],
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSettings(languageMode: .v5)),
.target(
Expand Down Expand Up @@ -460,6 +470,7 @@ if useLocalDependencies {
.package(path: "../swift-driver"),
.package(path: "../swift-system"),
.package(path: "../swift-argument-parser"),
.package(path: "../swift-tools-protocols"),
]
if !useLLBuildFramework {
package.dependencies += [.package(path: "../llbuild"),]
Expand All @@ -469,6 +480,7 @@ if useLocalDependencies {
.package(url: "https://github.com/swiftlang/swift-driver.git", branch: "main"),
.package(url: "https://github.com/apple/swift-system.git", .upToNextMajor(from: "1.5.0")),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.3"),
.package(url: "https://github.com/swiftlang/swift-tools-protocols.git", .upToNextMinor(from: "0.0.2")),
]
if !useLLBuildFramework {
package.dependencies += [.package(url: "https://github.com/swiftlang/swift-llbuild.git", branch: "main"),]
Expand Down
13 changes: 11 additions & 2 deletions Plugins/cmake-smoke-test/cmake-smoke-test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ struct CMakeSmokeTest: CommandPlugin {
let swiftDriverURL = try findDependency("swift-driver", pluginContext: context)
let swiftDriverBuildURL = context.pluginWorkDirectoryURL.appending(component: "swift-driver")

for url in [swiftToolsSupportCoreBuildURL, swiftSystemBuildURL, llbuildBuildURL, swiftArgumentParserBuildURL, swiftDriverBuildURL, swiftBuildBuildURL] {
let swiftToolsProtocolsURL = try findDependency("swift-tools-protocols", pluginContext: context)
let swiftToolsProtocolsBuildURL = context.pluginWorkDirectoryURL.appending(component: "swift-tools-protocols")

for url in [swiftToolsSupportCoreBuildURL, swiftSystemBuildURL, llbuildBuildURL, swiftArgumentParserBuildURL, swiftDriverBuildURL, swiftToolsProtocolsBuildURL, swiftBuildBuildURL] {
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
}

Expand All @@ -75,7 +78,8 @@ struct CMakeSmokeTest: CommandPlugin {
"-DLLBuild_DIR=\(llbuildBuildURL.appending(components: "cmake", "modules").filePath)",
"-DTSC_DIR=\(swiftToolsSupportCoreBuildURL.appending(components: "cmake", "modules").filePath)",
"-DSwiftDriver_DIR=\(swiftDriverBuildURL.appending(components: "cmake", "modules").filePath)",
"-DSwiftSystem_DIR=\(swiftSystemBuildURL.appending(components: "cmake", "modules").filePath)"
"-DSwiftSystem_DIR=\(swiftSystemBuildURL.appending(components: "cmake", "modules").filePath)",
"-DSwiftToolsProtocols_DIR=\(swiftToolsProtocolsBuildURL.appending(components: "cmake", "modules").filePath)"
]

let sharedCMakeArgs = [
Expand Down Expand Up @@ -112,6 +116,11 @@ struct CMakeSmokeTest: CommandPlugin {
try await Process.checkNonZeroExit(url: ninjaURL, arguments: [], workingDirectory: swiftDriverBuildURL)
Diagnostics.progress("Built swift-driver")

Diagnostics.progress("Building swift-tools-protocols")
try await Process.checkNonZeroExit(url: cmakeURL, arguments: sharedCMakeArgs + [swiftToolsProtocolsURL.filePath], workingDirectory: swiftToolsProtocolsBuildURL)
try await Process.checkNonZeroExit(url: ninjaURL, arguments: [], workingDirectory: swiftToolsProtocolsBuildURL)
Diagnostics.progress("Built swift-tools-protocols")

Diagnostics.progress("Building swift-build in \(swiftBuildBuildURL)")
try await Process.checkNonZeroExit(url: cmakeURL, arguments: sharedCMakeArgs + [swiftBuildURL.filePath], workingDirectory: swiftBuildBuildURL)
try await Process.checkNonZeroExit(url: ninjaURL, arguments: [], workingDirectory: swiftBuildBuildURL)
Expand Down
2 changes: 2 additions & 0 deletions Sources/SWBCore/Settings/BuiltinMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ public final class BuiltinMacros {
public static let BUILD_DIR = BuiltinMacros.declarePathMacro("BUILD_DIR")
public static let BUILD_LIBRARY_FOR_DISTRIBUTION = BuiltinMacros.declareBooleanMacro("BUILD_LIBRARY_FOR_DISTRIBUTION")
public static let BUILD_PACKAGE_FOR_DISTRIBUTION = BuiltinMacros.declareBooleanMacro("BUILD_PACKAGE_FOR_DISTRIBUTION")
public static let BUILD_SERVER_PROTOCOL_TARGET_TAGS = BuiltinMacros.declareBooleanMacro("BUILD_SERVER_PROTOCOL_TARGET_TAGS")
public static let BUILD_VARIANTS = BuiltinMacros.declareStringListMacro("BUILD_VARIANTS")
public static let BuiltBinaryPath = BuiltinMacros.declareStringMacro("BuiltBinaryPath")
public static let BUNDLE_FORMAT = BuiltinMacros.declareStringMacro("BUNDLE_FORMAT")
Expand Down Expand Up @@ -1478,6 +1479,7 @@ public final class BuiltinMacros {
BUILD_DIR,
BUILD_LIBRARY_FOR_DISTRIBUTION,
BUILD_PACKAGE_FOR_DISTRIBUTION,
BUILD_SERVER_PROTOCOL_TARGET_TAGS,
BUILD_STYLE,
BUILD_VARIANTS,
BUILT_PRODUCTS_DIR,
Expand Down
20 changes: 20 additions & 0 deletions Sources/SWBUtil/Lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,23 @@ extension SWBMutex where Value: ~Copyable, Value == Void {
try withLock { _ throws(E) -> sending Result in return try body() }
}
}

extension SWBMutex where Value: BinaryInteger & Sendable {
public func fetchAndIncrement() -> Value {
withLock { value in
let retVal = value
value += 1
return retVal
}
}
}

extension SWBMutex {
public func takeValue<T>() -> Value where Value == Optional<T> {
withLock { value in
let retVal = value
value = nil
return retVal
}
}
}
8 changes: 7 additions & 1 deletion Sources/SwiftBuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ add_library(SwiftBuild
SWBBuildOperationBacktraceFrame.swift
SWBBuildParameters.swift
SWBBuildRequest.swift
SWBBuildServer.swift
SWBBuildService.swift
SWBBuildServiceConnection.swift
SWBBuildServiceConsole.swift
Expand Down Expand Up @@ -70,7 +71,12 @@ target_link_libraries(SwiftBuild PUBLIC
SWBCore
SWBProtocol
SWBUtil
SWBProjectModel)
SWBProjectModel
SwiftToolsProtocols::SKLogging
SwiftToolsProtocols::ToolsProtocolsSwiftExtensions
SwiftToolsProtocols::BuildServerProtocol
SwiftToolsProtocols::LanguageServerProtocol
SwiftToolsProtocols::LanguageServerProtocolTransport)

set_target_properties(SwiftBuild PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
Expand Down
Loading
Loading