Skip to content

Commit 11842ba

Browse files
committed
Revert "wip"
This reverts commit c302c3e. This was accidentally commited.
1 parent c08a5dc commit 11842ba

File tree

8 files changed

+6
-149
lines changed

8 files changed

+6
-149
lines changed

Sources/Build/BuildDelegate.swift

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ public struct BuildDescription: Codable {
195195
/// The map of test discovery commands.
196196
let testDiscoveryCommands: [CommandName: TestDiscoveryTool]
197197

198-
let copyCommands: [CommandName: CopyTool]
199-
200198
/// The built test products.
201199
public let builtTestProducts: [BuiltTestProduct]
202200

@@ -206,11 +204,7 @@ public struct BuildDescription: Codable {
206204
/// The list of executable products in the root package.
207205
public let rootExecutables: [String]
208206

209-
public init(
210-
plan: BuildPlan,
211-
testDiscoveryCommands: [CommandName: TestDiscoveryTool],
212-
copyCommands: [CommandName: CopyTool]
213-
) {
207+
public init(plan: BuildPlan, testDiscoveryCommands: [CommandName: TestDiscoveryTool]) {
214208
let buildConfig = plan.buildParameters.configuration.dirname
215209

216210
swiftTargetMap = Dictionary(uniqueKeysWithValues: plan.targetMap.values.compactMap{
@@ -219,7 +213,6 @@ public struct BuildDescription: Codable {
219213
})
220214

221215
self.testDiscoveryCommands = testDiscoveryCommands
222-
self.copyCommands = copyCommands
223216

224217
self.builtTestProducts = plan.buildProducts.filter{ $0.product.type == .test }.map { desc in
225218
// FIXME(perf): Provide faster lookups.
@@ -316,32 +309,6 @@ final class PackageStructureCommand: CustomLLBuildCommand {
316309
}
317310
}
318311

319-
final class CopyCommand: CustomLLBuildCommand {
320-
override func execute(_ command: SPMLLBuild.Command) -> Bool {
321-
// This tool will never run without the build description.
322-
let buildDescription = ctx.buildDescription!
323-
guard let tool = buildDescription.copyCommands[command.name] else {
324-
print("command \(command.name) not registered")
325-
return false
326-
}
327-
328-
do {
329-
let input = tool.inputs[0]
330-
let output = tool.outputs[0]
331-
try localFileSystem.createDirectory(AbsolutePath(output).parentDirectory, recursive: true)
332-
333-
// FIXME: We should shim this through our FileSystem APIs.
334-
try? FileManager.default.removeItem(atPath: output)
335-
try FileManager.default.copyItem(atPath: input, toPath: output)
336-
} catch {
337-
// FIXME: Shouldn't use "print" here.
338-
print("error:", error)
339-
return false
340-
}
341-
return true
342-
}
343-
}
344-
345312
private let newLineByte: UInt8 = 10
346313
public final class BuildDelegate: BuildSystemDelegate, SwiftCompilerOutputParserDelegate {
347314
private let diagnostics: DiagnosticsEngine
@@ -385,8 +352,6 @@ public final class BuildDelegate: BuildSystemDelegate, SwiftCompilerOutputParser
385352
return InProcessTool(buildExecutionContext, type: TestDiscoveryCommand.self)
386353
case PackageStructureTool.name:
387354
return InProcessTool(buildExecutionContext, type: PackageStructureCommand.self)
388-
case CopyTool.name:
389-
return InProcessTool(buildExecutionContext, type: CopyCommand.self)
390355
default:
391356
return nil
392357
}

Sources/Build/BuildPlan.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,6 @@ public final class SwiftTargetBuildDescription {
504504
/// These are the source files generated during the build.
505505
private var derivedSources: Sources
506506

507-
/// Path to the bundle generated for this module (if any).
508-
let bundlePath: AbsolutePath?
509-
510507
/// The list of all source files in the target, including the derived ones.
511508
var sources: [AbsolutePath] { target.sources.paths + derivedSources.paths }
512509

@@ -570,9 +567,6 @@ public final class SwiftTargetBuildDescription {
570567
self.fs = fs
571568
self.tempsPath = buildParameters.buildPath.appending(component: target.c99name + ".build")
572569
self.derivedSources = Sources(paths: [], root: tempsPath.appending(component: "DerivedSources"))
573-
self.bundlePath = target.underlyingTarget.bundleName
574-
.map{ $0 + buildParameters.triple.nsbundleExtension }
575-
.map(buildParameters.buildPath.appending(component:))
576570

577571
if shouldEmitObjCCompatibilityHeader {
578572
self.moduleMap = try self.generateModuleMap()
@@ -584,10 +578,10 @@ public final class SwiftTargetBuildDescription {
584578
/// Generate the resource bundle accessor, if appropriate.
585579
private func generateResourceAccessor() throws {
586580
// Do nothing if we're not generating a bundle.
587-
guard let bundlePath = self.bundlePath else { return }
581+
guard let bundleName = target.underlyingTarget.bundleName else { return }
588582

589583
// Compute the basename of the bundle.
590-
let bundleBasename = bundlePath.basename
584+
let bundleBasename = bundleName + buildParameters.triple.nsbundleExtension
591585

592586
let stream = BufferedOutputByteStream()
593587
stream <<< """
@@ -608,13 +602,8 @@ public final class SwiftTargetBuildDescription {
608602
// Write this file out.
609603
// FIXME: We should generate this file during the actual build.
610604
let path = derivedSources.root.appending(subpath)
611-
try fs.createDirectory(path.parentDirectory, recursive: true)
612-
613-
// Return early if the contents are identical.
614-
if fs.isFile(path), try fs.readFileContents(path) == stream.bytes {
615-
return
616-
}
617605

606+
try fs.createDirectory(path.parentDirectory, recursive: true)
618607
try fs.writeFileContents(path, bytes: stream.bytes)
619608
}
620609

Sources/Build/ToolProtocol.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ public struct TestDiscoveryTool: ToolProtocol, Codable {
5252
}
5353
}
5454

55-
public struct CopyTool: ToolProtocol, Codable {
56-
static let name: String = "copy-tool"
57-
58-
public let inputs: [String]
59-
public let outputs: [String]
60-
61-
public func append(to stream: OutputByteStream) {
62-
stream <<< " tool: \(Self.name)\n"
63-
stream <<< " inputs: " <<< Format.asJSON(inputs) <<< "\n"
64-
stream <<< " outputs: " <<< Format.asJSON(outputs) <<< "\n"
65-
}
66-
}
67-
6855
/// Package strcuture tool is used to determine if the package has changed in some way
6956
/// that requires regenerating the build manifest file. This allows us to skip a lot of
7057
/// redundent work (package graph loading, build planning, manifest generation) during

Sources/Build/llbuild.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ public final class LLBuildManifestGenerator {
210210
/// Map of command -> tool that is used during the build for in-process tools.
211211
public private(set) var testDiscoveryCommands: [String: TestDiscoveryTool] = [:]
212212

213-
public private(set) var copyCommands: [String: CopyTool] = [:]
214-
215213
/// Create a llbuild target for a product description.
216214
private func createProductTarget(_ buildProduct: ProductBuildDescription) -> Target {
217215
let tool: ToolProtocol
@@ -312,34 +310,9 @@ public final class LLBuildManifestGenerator {
312310
buildTarget.cmds.insert(Command(name: target.wrappedModuleOutputPath.pathString, tool: modulewrapTool))
313311
}
314312

315-
createResourcesBundle(for: target, buildTarget: &buildTarget)
316-
317313
return buildTarget
318314
}
319315

320-
private func createResourcesBundle(
321-
for target: SwiftTargetBuildDescription,
322-
buildTarget: inout Target
323-
) {
324-
guard let bundlePath = target.bundlePath else { return }
325-
326-
var cmds: [Command] = []
327-
328-
for item in target.target.underlyingTarget.resources {
329-
switch item.rule {
330-
case .copy, .process:
331-
let output = bundlePath.appending(component: item.path.basename)
332-
let tool = CopyTool(inputs: [item.path.pathString], outputs: [output.pathString])
333-
let cmd = Command(name: output.pathString, tool: tool)
334-
copyCommands[cmd.name] = tool
335-
cmds.append(cmd)
336-
}
337-
}
338-
339-
buildTarget.cmds += cmds
340-
buildTarget.outputs += cmds.flatMap{ $0.tool.outputs }
341-
}
342-
343316
/// Create a llbuild target for a Clang target description.
344317
private func createClangCompileTarget(_ target: ClangTargetBuildDescription) throws -> Target {
345318

Sources/Commands/SwiftTool.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,7 @@ public class SwiftTool<Options: ToolOptions> {
674674
try llbuild.generateManifest(at: plan.buildParameters.llbuildManifest)
675675

676676
// Create the build description.
677-
let buildDescription = BuildDescription(
678-
plan: plan,
679-
testDiscoveryCommands: llbuild.testDiscoveryCommands,
680-
copyCommands: llbuild.copyCommands
681-
)
677+
let buildDescription = BuildDescription(plan: plan, testDiscoveryCommands: llbuild.testDiscoveryCommands)
682678
try localFileSystem.createDirectory(plan.buildParameters.buildDescriptionPath.parentDirectory, recursive: true)
683679
try buildDescription.write(to: plan.buildParameters.buildDescriptionPath)
684680
return buildDescription

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,6 @@ public final class PackageBuilder {
718718

719719
// Create the build setting assignment table for this target.
720720
let buildSettings = try self.buildSettings(for: manifestTarget, targetRoot: potentialModule.path)
721-
let resources = self.computeResources(for: manifestTarget, targetRoot: potentialModule.path)
722721

723722
// Create and return the right kind of target depending on what kind of sources we found.
724723
if clangSources.isEmpty {
@@ -730,7 +729,7 @@ public final class PackageBuilder {
730729
var bundleName: String?
731730
// FIXME: This needs to depend on if we have *any* resources, not just explicitly
732731
// declared ones.
733-
if !resources.isEmpty {
732+
if manifestTarget?.resources.isEmpty == false {
734733
bundleName = manifest.name + "_" + potentialModule.name
735734
}
736735

@@ -741,7 +740,6 @@ public final class PackageBuilder {
741740
platforms: self.platforms(),
742741
isTest: potentialModule.isTest,
743742
sources: Sources(paths: swiftSources, root: potentialModule.path),
744-
resources: resources,
745743
dependencies: moduleDependencies,
746744
productDependencies: productDeps,
747745
swiftVersion: try swiftVersion(),
@@ -770,23 +768,6 @@ public final class PackageBuilder {
770768
}
771769
}
772770

773-
/// Compute the resources in the target.
774-
// FIXME: This is prelimary logic just to get things started.
775-
func computeResources(
776-
for target: TargetDescription?,
777-
targetRoot: AbsolutePath
778-
) -> [Resource] {
779-
guard let target = target else { return [] }
780-
var result: [Resource] = []
781-
782-
for resource in target.resources {
783-
let path = targetRoot.appending(RelativePath(resource.path))
784-
result += [Resource(rule: resource.rule, path: path)]
785-
}
786-
787-
return result
788-
}
789-
790771
/// Creates build setting assignment table for the given target.
791772
func buildSettings(for target: TargetDescription?, targetRoot: AbsolutePath) throws -> BuildSettings.AssignmentTable {
792773
var table = BuildSettings.AssignmentTable()

Sources/PackageModel/Resource.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.

Sources/PackageModel/Target.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public class Target: ObjectIdentifierProtocol {
4646
/// The sources for the target.
4747
public let sources: Sources
4848

49-
/// The resource files in the target.
50-
public let resources: [Resource]
51-
5249
/// The list of platforms that are supported by this target.
5350
public let platforms: [SupportedPlatform]
5451

@@ -66,7 +63,6 @@ public class Target: ObjectIdentifierProtocol {
6663
platforms: [SupportedPlatform],
6764
type: Kind,
6865
sources: Sources,
69-
resources: [Resource] = [],
7066
dependencies: [Target],
7167
productDependencies: [(name: String, package: String?)] = [],
7268
buildSettings: BuildSettings.AssignmentTable
@@ -76,7 +72,6 @@ public class Target: ObjectIdentifierProtocol {
7672
self.platforms = platforms
7773
self.type = type
7874
self.sources = sources
79-
self.resources = resources
8075
self.dependencies = dependencies
8176
self.productDependencies = productDependencies
8277
self.c99name = self.name.spm_mangledToC99ExtendedIdentifier()
@@ -141,7 +136,6 @@ public class SwiftTarget: Target {
141136
platforms: [SupportedPlatform] = [],
142137
isTest: Bool = false,
143138
sources: Sources,
144-
resources: [Resource] = [],
145139
dependencies: [Target] = [],
146140
productDependencies: [(name: String, package: String?)] = [],
147141
swiftVersion: SwiftLanguageVersion,
@@ -155,7 +149,6 @@ public class SwiftTarget: Target {
155149
platforms: platforms,
156150
type: type,
157151
sources: sources,
158-
resources: resources,
159152
dependencies: dependencies,
160153
productDependencies: productDependencies,
161154
buildSettings: buildSettings

0 commit comments

Comments
 (0)