Skip to content

Commit 7595d42

Browse files
committed
Run SwiftFormat
1 parent ca066af commit 7595d42

File tree

5 files changed

+80
-58
lines changed

5 files changed

+80
-58
lines changed

Sources/SwiftBuildSupport/PackagePIFBuilder+Helpers.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ extension PackageGraph.ResolvedModule {
500500
}
501501

502502
struct AllBuildSettings {
503-
typealias BuildSettingsByPlatform = [ProjectModel.BuildSettings.Platform?: [BuildSettings.Declaration: [String]]]
503+
typealias BuildSettingsByPlatform =
504+
[ProjectModel.BuildSettings.Platform?: [BuildSettings.Declaration: [String]]]
504505

505506
/// Target-specific build settings declared in the manifest and that apply to the target itself.
506507
var targetSettings: [BuildConfiguration: BuildSettingsByPlatform] = [:]
@@ -543,7 +544,7 @@ extension PackageGraph.ResolvedModule {
543544

544545
for platform in platforms {
545546
let pifPlatform = platform.map { ProjectModel.BuildSettings.Platform(from: $0) }
546-
547+
547548
if pifDeclaration == .OTHER_LDFLAGS {
548549
var settingsByDeclaration: [ProjectModel.BuildSettings.Declaration: [String]]
549550

@@ -556,7 +557,7 @@ extension PackageGraph.ResolvedModule {
556557
for configuration in configurations {
557558
var settingsByDeclaration: [ProjectModel.BuildSettings.Declaration: [String]]
558559
settingsByDeclaration = allSettings.targetSettings[configuration]?[pifPlatform] ?? [:]
559-
560+
560561
if declaration.allowsMultipleValues {
561562
settingsByDeclaration[pifDeclaration, default: []].append(contentsOf: values)
562563
} else {
@@ -848,7 +849,7 @@ extension ProjectModel.BuildSettings {
848849
/// values, i.e. those in `ProjectModel.BuildSettings.Declaration`. If a platform is specified,
849850
/// it must be one of the known platforms in `ProjectModel.BuildSettings.Platform`.
850851
mutating func append(values: [String], to setting: Declaration, platform: Platform? = nil) {
851-
// This dichotomy is quite unfortunate but that's currently the underlying model in `ProjectModel.BuildSettings`.
852+
// This dichotomy is quite unfortunate but that's currently the underlying model in ProjectModel.BuildSettings.
852853
if let platform {
853854
switch setting {
854855
case .FRAMEWORK_SEARCH_PATHS,
@@ -861,10 +862,10 @@ extension ProjectModel.BuildSettings {
861862
.SWIFT_ACTIVE_COMPILATION_CONDITIONS:
862863
// Appending implies the setting is resilient to having ["$(inherited)"]
863864
self.platformSpecificSettings[platform]![setting]!.append(contentsOf: values)
864-
865+
865866
case .SWIFT_VERSION:
866867
self.platformSpecificSettings[platform]![setting] = values // We are not resilient to $(inherited).
867-
868+
868869
case .ARCHS, .IPHONEOS_DEPLOYMENT_TARGET, .SPECIALIZATION_SDK_OPTIONS:
869870
fatalError("Unexpected BuildSettings.Declaration: \(setting)")
870871
}
@@ -883,7 +884,7 @@ extension ProjectModel.BuildSettings {
883884

884885
case .SWIFT_VERSION:
885886
self[.SWIFT_VERSION] = values.only.unwrap(orAssert: "Invalid values for 'SWIFT_VERSION': \(values)")
886-
887+
887888
case .ARCHS, .IPHONEOS_DEPLOYMENT_TARGET, .SPECIALIZATION_SDK_OPTIONS:
888889
fatalError("Unexpected BuildSettings.Declaration: \(setting)")
889890
}

Sources/SwiftBuildSupport/PackagePIFBuilder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public final class PackagePIFBuilder {
139139
func shouldSetInstallPathForDynamicLib(productName: String) -> Bool
140140

141141
// FIXME: Let's try to replace `WritableKeyPath><_, Foo>` with `inout Foo` —— Paulo
142-
142+
143143
/// Provides additional configuration and files for the specified library product.
144144
func configureLibraryProduct(
145145
product: PackageModel.Product,
@@ -246,20 +246,20 @@ public final class PackagePIFBuilder {
246246

247247
return project
248248
}
249-
249+
250250
public func buildPlaceholderPIF(id: String, path: String, projectDir: String, name: String) -> ModuleOrProduct {
251251
var project = ProjectModel.Project(
252252
id: GUID(id),
253253
path: path,
254254
projectDir: projectDir,
255255
name: name
256256
)
257-
257+
258258
let projectSettings = ProjectModel.BuildSettings()
259259

260260
project.addBuildConfig { id in ProjectModel.BuildConfig(id: id, name: "Debug", settings: projectSettings) }
261261
project.addBuildConfig { id in ProjectModel.BuildConfig(id: id, name: "Release", settings: projectSettings) }
262-
262+
263263
let targetKeyPath = try! project.addAggregateTarget { _ in
264264
ProjectModel.AggregateTarget(id: "PACKAGE-PLACEHOLDER:\(id)", name: id)
265265
}

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import enum SwiftBuild.ProjectModel
3131

3232
/// Extension to create PIF **modules** for a given package.
3333
extension PackagePIFProjectBuilder {
34-
3534
// MARK: - Plugin Modules
3635

3736
mutating func makePluginModule(_ pluginModule: PackageGraph.ResolvedModule) throws {
@@ -60,7 +59,7 @@ extension PackagePIFProjectBuilder {
6059
// This assertion is temporarily disabled since we may see targets from
6160
// _other_ packages, but this should be resolved; see rdar://95467710.
6261
/* assert(moduleDependency.packageName == self.package.name) */
63-
62+
6463
let dependencyPlatformFilters = packageConditions
6564
.toPlatformFilter(toolsVersion: self.package.manifest.toolsVersion)
6665

@@ -179,7 +178,7 @@ extension PackagePIFProjectBuilder {
179178
)
180179
dynamicLibraryVariant.isDynamicLibraryVariant = true
181180
self.builtModulesAndProducts.append(dynamicLibraryVariant)
182-
181+
183182
guard let pifTarget = staticLibrary.pifTarget,
184183
let pifTargetKeyPath = self.project.findTarget(id: pifTarget.id),
185184
let dynamicPifTarget = dynamicLibraryVariant.pifTarget
@@ -284,9 +283,10 @@ extension PackagePIFProjectBuilder {
284283
}
285284
do {
286285
let sourceModuleTarget = self.project[keyPath: sourceModuleTargetKeyPath]
287-
log(.debug,
286+
log(
287+
.debug,
288288
"Created \(sourceModuleTarget.productType) '\(sourceModuleTarget.id)' " +
289-
"with name '\(sourceModuleTarget.name)' and product name '\(sourceModuleTarget.productName)'"
289+
"with name '\(sourceModuleTarget.name)' and product name '\(sourceModuleTarget.productName)'"
290290
)
291291
}
292292

@@ -324,7 +324,9 @@ extension PackagePIFProjectBuilder {
324324
}
325325

326326
// Find the PIF target for the resource bundle, if any. Otherwise fall back to the module.
327-
let resourceBundleTargetKeyPath = self.resourceBundleTargetKeyPath(forModuleName: sourceModule.name) ?? sourceModuleTargetKeyPath
327+
let resourceBundleTargetKeyPath = self.resourceBundleTargetKeyPath(
328+
forModuleName: sourceModule.name
329+
) ?? sourceModuleTargetKeyPath
328330

329331
// Add build tool commands to the resource bundle target.
330332
if desiredModuleType != .executable && desiredModuleType != .macro && addBuildToolPluginCommands {
@@ -512,7 +514,11 @@ extension PackagePIFProjectBuilder {
512514
}
513515
impartedSettings[.OTHER_LDFLAGS] = (sourceModule.isCxx ? ["-lc++"] : []) + baselineOTHER_LDFLAGS
514516
impartedSettings[.OTHER_LDRFLAGS] = []
515-
log(.debug, indent: 1, "Added '\(String(describing: impartedSettings[.OTHER_LDFLAGS]))' to imparted OTHER_LDFLAGS")
517+
log(
518+
.debug,
519+
indent: 1,
520+
"Added '\(String(describing: impartedSettings[.OTHER_LDFLAGS]))' to imparted OTHER_LDFLAGS"
521+
)
516522

517523
// This should be only for dynamic targets, but that isn't possible today.
518524
// Improvement is tracked by rdar://77403529 (Only impart `PackageFrameworks` search paths to clients of dynamic
@@ -542,7 +548,7 @@ extension PackagePIFProjectBuilder {
542548
id: id,
543549
path: try! resolveSymlinks(sourceModule.sourceDirAbsolutePath).pathString,
544550
pathBase: .absolute
545-
)
551+
)
546552
}
547553
do {
548554
let targetSourceFileGroup = self.project.mainGroup[keyPath: targetSourceFileGroupKeyPath]
@@ -606,7 +612,7 @@ extension PackagePIFProjectBuilder {
606612
// This assertion is temporarily disabled since we may see targets from
607613
// _other_ packages, but this should be resolved; see rdar://95467710.
608614
/* assert(moduleDependency.packageName == self.package.name) */
609-
615+
610616
let dependencyPlatformFilters = packageConditions
611617
.toPlatformFilter(toolsVersion: self.package.manifest.toolsVersion)
612618

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import enum SwiftBuild.ProjectModel
3333

3434
/// Extension to create PIF **products** for a given package.
3535
extension PackagePIFProjectBuilder {
36-
3736
// MARK: - Main Module Products
3837

3938
mutating func makeMainModuleProduct(_ product: PackageGraph.ResolvedProduct) throws {
@@ -86,7 +85,7 @@ extension PackagePIFProjectBuilder {
8685
log(
8786
.debug,
8887
"Created \(mainModuleTarget.productType)) '\(mainModuleTarget.id)' " +
89-
"with name '\(mainModuleTarget.name)' and product name '\(mainModuleTarget.productName)'"
88+
"with name '\(mainModuleTarget.name)' and product name '\(mainModuleTarget.productName)'"
9089
)
9190
}
9291

@@ -114,14 +113,19 @@ extension PackagePIFProjectBuilder {
114113
settings[.PACKAGE_RESOURCE_TARGET_KIND] = "regular"
115114
settings[.PRODUCT_NAME] = "$(TARGET_NAME)"
116115
settings[.PRODUCT_MODULE_NAME] = product.c99name
117-
settings[.PRODUCT_BUNDLE_IDENTIFIER] = "\(self.package.identity).\(product.name)".spm_mangledToBundleIdentifier()
116+
settings[.PRODUCT_BUNDLE_IDENTIFIER] = "\(self.package.identity).\(product.name)"
117+
.spm_mangledToBundleIdentifier()
118118
settings[.EXECUTABLE_NAME] = product.name
119119
settings[.CLANG_ENABLE_MODULES] = "YES"
120120
settings[.SWIFT_PACKAGE_NAME] = mainModule.packageName
121121

122122
if mainModule.type == .test {
123123
// FIXME: we shouldn't always include both the deep and shallow bundle paths here, but for that we'll need rdar://31867023
124-
settings[.LD_RUNPATH_SEARCH_PATHS] = ["@loader_path/Frameworks", "@loader_path/../Frameworks", "$(inherited)"]
124+
settings[.LD_RUNPATH_SEARCH_PATHS] = [
125+
"@loader_path/Frameworks",
126+
"@loader_path/../Frameworks",
127+
"$(inherited)",
128+
]
125129
settings[.GENERATE_INFOPLIST_FILE] = "YES"
126130
settings[.SKIP_INSTALL] = "NO"
127131
settings[.SWIFT_ACTIVE_COMPILATION_CONDITIONS].lazilyInitialize { ["$(inherited)"] }
@@ -179,13 +183,14 @@ extension PackagePIFProjectBuilder {
179183
// Note that the indexer requires them to have any symbolic links resolved.
180184
var indexableFileURLs: [SourceControlURL] = []
181185
for sourcePath in mainModule.sourceFileRelativePaths {
182-
let sourceFileRef = self.project.mainGroup[keyPath: mainTargetSourceFileGroupKeyPath].addFileReference { id in
183-
FileReference(
184-
id: id,
185-
path: sourcePath.pathString,
186-
pathBase: .groupDir
187-
)
188-
}
186+
let sourceFileRef = self.project.mainGroup[keyPath: mainTargetSourceFileGroupKeyPath]
187+
.addFileReference { id in
188+
FileReference(
189+
id: id,
190+
path: sourcePath.pathString,
191+
pathBase: .groupDir
192+
)
193+
}
189194
self.project[keyPath: mainModuleTargetKeyPath].addSourceFile { id in
190195
BuildFile(id: id, fileRef: sourceFileRef)
191196
}
@@ -199,13 +204,14 @@ extension PackagePIFProjectBuilder {
199204

200205
// Add any additional source files emitted by custom build commands.
201206
for path in generatedSourceFiles {
202-
let sourceFileRef = self.project.mainGroup[keyPath: mainTargetSourceFileGroupKeyPath].addFileReference { id in
203-
FileReference(
204-
id: id,
205-
path: path.pathString,
206-
pathBase: .absolute
207-
)
208-
}
207+
let sourceFileRef = self.project.mainGroup[keyPath: mainTargetSourceFileGroupKeyPath]
208+
.addFileReference { id in
209+
FileReference(
210+
id: id,
211+
path: path.pathString,
212+
pathBase: .absolute
213+
)
214+
}
209215
self.project[keyPath: mainModuleTargetKeyPath].addSourceFile { id in
210216
BuildFile(id: id, fileRef: sourceFileRef)
211217
}
@@ -285,7 +291,7 @@ extension PackagePIFProjectBuilder {
285291
// Add build tool commands to the resource bundle target.
286292
let mainResourceBundleTargetKeyPath = self.resourceBundleTargetKeyPath(forModuleName: mainModule.name)
287293
let resourceBundleTargetKeyPath = mainResourceBundleTargetKeyPath ?? mainModuleTargetKeyPath
288-
294+
289295
addBuildToolCommands(
290296
module: mainModule,
291297
sourceModuleTargetKeyPath: mainModuleTargetKeyPath,
@@ -357,7 +363,7 @@ extension PackagePIFProjectBuilder {
357363

358364
// Link with a testable version of the macro if appropriate.
359365
if product.type == .test {
360-
self.project[keyPath:mainModuleTargetKeyPath].common.addDependency(
366+
self.project[keyPath: mainModuleTargetKeyPath].common.addDependency(
361367
on: moduleDependency.pifTargetGUID(suffix: .testable),
362368
platformFilters: packageConditions
363369
.toPlatformFilter(toolsVersion: package.manifest.toolsVersion),
@@ -620,7 +626,7 @@ extension PackagePIFProjectBuilder {
620626
log(
621627
.debug,
622628
"Created target '\(librayTarget.id)' of type '\(librayTarget.productType)' with " +
623-
"name '\(librayTarget.name)' and product name '\(librayTarget.productName)'"
629+
"name '\(librayTarget.name)' and product name '\(librayTarget.productName)'"
624630
)
625631
}
626632

@@ -651,7 +657,10 @@ extension PackagePIFProjectBuilder {
651657
for module in product.modules where module.underlying.isSourceModule && module.resources.hasContent {
652658
// FIXME: Find a way to determine whether a module has generated resources
653659
// here so that we can embed resources into dynamic targets.
654-
self.project[keyPath: librayUmbrellaTargetKeyPath].common.addDependency(on: pifTargetIdForResourceBundle(module.name), platformFilters: [])
660+
self.project[keyPath: librayUmbrellaTargetKeyPath].common.addDependency(
661+
on: pifTargetIdForResourceBundle(module.name),
662+
platformFilters: []
663+
)
655664

656665
let packageName = self.package.name
657666
let fileRef = self.project.mainGroup.addFileReference { id in
@@ -663,7 +672,11 @@ extension PackagePIFProjectBuilder {
663672
}
664673
log(.debug, indent: 1, "Added use of resource bundle '\(fileRef.path)'")
665674
} else {
666-
log(.debug, indent: 1, "Ignored resource bundle '\(fileRef.path)' because resource embedding is disabled")
675+
log(
676+
.debug,
677+
indent: 1,
678+
"Ignored resource bundle '\(fileRef.path)' because resource embedding is disabled"
679+
)
667680
}
668681
}
669682

@@ -708,7 +721,7 @@ extension PackagePIFProjectBuilder {
708721
// This assertion is temporarily disabled since we may see targets from
709722
// _other_ packages, but this should be resolved; see rdar://95467710.
710723
/* assert(moduleDependency.packageName == self.package.name) */
711-
724+
712725
if moduleDependency.type == .systemModule {
713726
log(.debug, indent: 1, "Noted use of system module '\(moduleDependency.name)'")
714727
return
@@ -920,7 +933,7 @@ extension PackagePIFProjectBuilder {
920933
name: pluginProduct.name
921934
)
922935
}
923-
do {
936+
do {
924937
let pluginTarget = self.project[keyPath: pluginTargetKeyPath]
925938
log(.debug, "Created aggregate target '\(pluginTarget.id)' with name '\(pluginTarget.name)'")
926939
}

0 commit comments

Comments
 (0)