Skip to content

Commit dfb9785

Browse files
committed
Reuse computed localization and platform properties in ResolvedProduct.init(product:targets:)
1 parent 2d5b8cc commit dfb9785

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

Sources/PackageGraph/ResolvedProduct.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,28 @@ public final class ResolvedProduct {
5959
self.underlyingProduct = product
6060
self.targets = targets
6161

62+
// defaultLocalization is currently shared across the entire package
63+
// this may need to be enhanced if / when we support localization per target or product
64+
let defaultLocalization = self.targets.first?.defaultLocalization
65+
self.defaultLocalization = defaultLocalization
66+
67+
let platforms = Self.computePlatforms(targets: targets)
68+
self.platforms = platforms
69+
6270
self.testEntryPointTarget = underlyingProduct.testEntryPointPath.map { testEntryPointPath in
6371
// Create an executable resolved target with the entry point file, adding product's targets as dependencies.
6472
let dependencies: [Target.Dependency] = product.targets.map { .target($0, conditions: []) }
6573
let swiftTarget = SwiftTarget(name: product.name,
6674
dependencies: dependencies,
6775
packageAccess: true, // entry point target so treated as a part of the package
6876
testEntryPointPath: testEntryPointPath)
69-
let (defaultLocalization, platforms) = if let firstTarget = targets.first {
70-
(firstTarget.defaultLocalization, firstTarget.platforms)
71-
} else {
72-
(.none, .init(declared: [], derivedXCTestPlatformProvider: .none)) // safe since this is a derived product
73-
}
7477
return ResolvedTarget(
7578
target: swiftTarget,
7679
dependencies: targets.map { .target($0, conditions: []) },
77-
defaultLocalization: defaultLocalization,
80+
defaultLocalization: defaultLocalization ?? .none, // safe since this is a derived product
7881
platforms: platforms
7982
)
8083
}
81-
82-
// defaultLocalization is currently shared across the entire package
83-
// this may need to be enhanced if / when we support localization per target or product
84-
self.defaultLocalization = self.targets.first?.defaultLocalization
85-
86-
self.platforms = Self.computePlatforms(targets: targets)
8784
}
8885

8986
/// True if this product contains Swift targets.

0 commit comments

Comments
 (0)