Skip to content

llbuild: Support is-mutated/is-command-timestamp nodes #7020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 18, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import struct Basics.AbsolutePath
import struct Basics.RelativePath
import struct Basics.TSCAbsolutePath
import struct LLBuildManifest.Node
import struct LLBuildManifest.BuildManifest
import struct LLBuildManifest.LLBuildManifest
import struct SPMBuildCore.BuildParameters
import class PackageGraph.ResolvedTarget
import protocol TSCBasic.FileSystem
Expand Down
6 changes: 3 additions & 3 deletions Sources/Build/BuildManifest/LLBuildManifestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class LLBuildManifestBuilder {
/// ObservabilityScope with which to emit diagnostics
public let observabilityScope: ObservabilityScope

public internal(set) var manifest: BuildManifest = .init()
public internal(set) var manifest: LLBuildManifest = .init()

var buildConfig: String { self.buildParameters.configuration.dirname }
var buildParameters: BuildParameters { self.plan.buildParameters }
Expand All @@ -73,7 +73,7 @@ public class LLBuildManifestBuilder {

/// Generate manifest at the given path.
@discardableResult
public func generateManifest(at path: AbsolutePath) throws -> BuildManifest {
public func generateManifest(at path: AbsolutePath) throws -> LLBuildManifest {
self.swiftGetVersionFiles.removeAll()

self.manifest.createTarget(TargetKind.main.targetName)
Expand Down Expand Up @@ -109,7 +109,7 @@ public class LLBuildManifestBuilder {
try self.createProductCommand(description)
}

try ManifestWriter(fileSystem: self.fileSystem).write(self.manifest, at: path)
try LLBuildManifestWriter.write(self.manifest, at: path, fileSystem: self.fileSystem)
return self.manifest
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
}
}

public func getBuildManifest() throws -> LLBuildManifest.BuildManifest {
public func getBuildManifest() throws -> LLBuildManifest {
return try self.plan().manifest
}

Expand Down Expand Up @@ -418,7 +418,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
}

/// Create the build plan and return the build description.
private func plan() throws -> (description: BuildDescription, manifest: LLBuildManifest.BuildManifest) {
private func plan() throws -> (description: BuildDescription, manifest: LLBuildManifest) {
// Load the package graph.
let graph = try getPackageGraph()

Expand Down Expand Up @@ -703,7 +703,7 @@ extension BuildOperation {
}

extension BuildDescription {
static func create(with plan: BuildPlan, disableSandboxForPluginCommands: Bool, fileSystem: Basics.FileSystem, observabilityScope: ObservabilityScope) throws -> (BuildDescription, LLBuildManifest.BuildManifest) {
static func create(with plan: BuildPlan, disableSandboxForPluginCommands: Bool, fileSystem: Basics.FileSystem, observabilityScope: ObservabilityScope) throws -> (BuildDescription, LLBuildManifest) {
// Generate the llbuild manifest.
let llbuild = LLBuildManifestBuilder(plan, disableSandboxForPluginCommands: disableSandboxForPluginCommands, fileSystem: fileSystem, observabilityScope: observabilityScope)
let buildManifest = try llbuild.generateManifest(at: plan.buildParameters.llbuildManifest)
Expand Down
36 changes: 18 additions & 18 deletions Sources/Build/BuildOperationBuildSystemDelegateHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
try fileSystem.writeFileContents(path, string: content)
}

private func execute(fileSystem: Basics.FileSystem, tool: LLBuildManifest.TestDiscoveryTool) throws {
private func execute(fileSystem: Basics.FileSystem, tool: TestDiscoveryTool) throws {
let index = self.context.buildParameters.indexStore
let api = try self.context.indexStoreAPI.get()
let store = try IndexStore.open(store: TSCAbsolutePath(index), api: api)
Expand All @@ -121,7 +121,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
let testsByModule = Dictionary(grouping: tests, by: { $0.module.spm_mangledToC99ExtendedIdentifier() })

func isMainFile(_ path: AbsolutePath) -> Bool {
path.basename == LLBuildManifest.TestDiscoveryTool.mainFileName
path.basename == TestDiscoveryTool.mainFileName
}

var maybeMainFile: AbsolutePath?
Expand Down Expand Up @@ -153,7 +153,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
}

guard let mainFile = maybeMainFile else {
throw InternalError("main output (\(LLBuildManifest.TestDiscoveryTool.mainFileName)) not found")
throw InternalError("main output (\(TestDiscoveryTool.mainFileName)) not found")
}

let testsKeyword = tests.isEmpty ? "let" : "var"
Expand Down Expand Up @@ -201,7 +201,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
}

final class TestEntryPointCommand: CustomLLBuildCommand, TestBuildCommand {
private func execute(fileSystem: Basics.FileSystem, tool: LLBuildManifest.TestEntryPointTool) throws {
private func execute(fileSystem: Basics.FileSystem, tool: TestEntryPointTool) throws {
// Find the inputs, which are the names of the test discovery module(s)
let inputs = tool.inputs.compactMap { try? AbsolutePath(validating: $0.name) }
let discoveryModuleNames = inputs.map(\.basenameWithoutExt)
Expand All @@ -210,9 +210,9 @@ final class TestEntryPointCommand: CustomLLBuildCommand, TestBuildCommand {

// Find the main output file
guard let mainFile = outputs.first(where: { path in
path.basename == LLBuildManifest.TestEntryPointTool.mainFileName
path.basename == TestEntryPointTool.mainFileName
}) else {
throw InternalError("main file output (\(LLBuildManifest.TestEntryPointTool.mainFileName)) not found")
throw InternalError("main file output (\(TestEntryPointTool.mainFileName)) not found")
}

let testObservabilitySetup: String
Expand Down Expand Up @@ -300,22 +300,22 @@ public struct BuildDescription: Codable {
public typealias CommandLineFlag = String

/// The Swift compiler invocation targets.
let swiftCommands: [BuildManifest.CmdName: SwiftCompilerTool]
let swiftCommands: [LLBuildManifest.CmdName: SwiftCompilerTool]

/// The Swift compiler frontend invocation targets.
let swiftFrontendCommands: [BuildManifest.CmdName: SwiftFrontendTool]
let swiftFrontendCommands: [LLBuildManifest.CmdName: SwiftFrontendTool]

/// The map of test discovery commands.
let testDiscoveryCommands: [BuildManifest.CmdName: LLBuildManifest.TestDiscoveryTool]
let testDiscoveryCommands: [LLBuildManifest.CmdName: TestDiscoveryTool]

/// The map of test entry point commands.
let testEntryPointCommands: [BuildManifest.CmdName: LLBuildManifest.TestEntryPointTool]
let testEntryPointCommands: [LLBuildManifest.CmdName: TestEntryPointTool]

/// The map of copy commands.
let copyCommands: [BuildManifest.CmdName: LLBuildManifest.CopyTool]
let copyCommands: [LLBuildManifest.CmdName: CopyTool]

/// The map of write commands.
let writeCommands: [BuildManifest.CmdName: LLBuildManifest.WriteAuxiliaryFile]
let writeCommands: [LLBuildManifest.CmdName: WriteAuxiliaryFile]

/// A flag that indicates this build should perform a check for whether targets only import
/// their explicitly-declared dependencies
Expand All @@ -338,12 +338,12 @@ public struct BuildDescription: Codable {

public init(
plan: BuildPlan,
swiftCommands: [BuildManifest.CmdName: SwiftCompilerTool],
swiftFrontendCommands: [BuildManifest.CmdName: SwiftFrontendTool],
testDiscoveryCommands: [BuildManifest.CmdName: LLBuildManifest.TestDiscoveryTool],
testEntryPointCommands: [BuildManifest.CmdName: LLBuildManifest.TestEntryPointTool],
copyCommands: [BuildManifest.CmdName: LLBuildManifest.CopyTool],
writeCommands: [BuildManifest.CmdName: LLBuildManifest.WriteAuxiliaryFile],
swiftCommands: [LLBuildManifest.CmdName: SwiftCompilerTool],
swiftFrontendCommands: [LLBuildManifest.CmdName: SwiftFrontendTool],
testDiscoveryCommands: [LLBuildManifest.CmdName: TestDiscoveryTool],
testEntryPointCommands: [LLBuildManifest.CmdName: TestEntryPointTool],
copyCommands: [LLBuildManifest.CmdName: CopyTool],
writeCommands: [LLBuildManifest.CmdName: WriteAuxiliaryFile],
pluginDescriptions: [PluginDescription]
) throws {
self.swiftCommands = swiftCommands
Expand Down
4 changes: 2 additions & 2 deletions Sources/Commands/Utilities/DOTManifestSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import protocol TSCBasic.OutputByteStream
public struct DOTManifestSerializer {
var kindCounter = [String: Int]()
var hasEmittedStyling = Set<String>()
let manifest: LLBuildManifest.BuildManifest
let manifest: LLBuildManifest

/// Creates a serializer that will serialize the given manifest.
public init(manifest: LLBuildManifest.BuildManifest) {
public init(manifest: LLBuildManifest) {
self.manifest = manifest
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/LLBuildManifest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_library(LLBuildManifest STATIC
BuildManifest.swift
Command.swift
ManifestWriter.swift
LLBuildManifest.swift
LLBuildManifestWriter.swift
Node.swift
Target.swift
Tools.swift)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public enum WriteAuxiliary {
}
}

public struct BuildManifest {
public struct LLBuildManifest {
public typealias TargetName = String
public typealias CmdName = String

Expand Down
Loading