From be31f72fc29cb329aa42dfe02e4d7a3f9bce1515 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 26 Dec 2024 13:43:40 +0100 Subject: [PATCH 1/3] Turn isLocal into Target.type --- Sources/XcodeGraph/Models/TargetType.swift | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Sources/XcodeGraph/Models/TargetType.swift diff --git a/Sources/XcodeGraph/Models/TargetType.swift b/Sources/XcodeGraph/Models/TargetType.swift new file mode 100644 index 00000000..e69de29b From 850d3085bfb0e47f1fccfae75123eb70327d4bdf Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 26 Dec 2024 13:45:01 +0100 Subject: [PATCH 2/3] fix: Turn isLocal into Target.type --- Package.swift | 7 +++++++ .../Models/Metadata/TargetMetadata.swift | 16 +++------------- Sources/XcodeGraph/Models/Target.swift | 9 +++++++-- Sources/XcodeGraph/Models/TargetType.swift | 6 ++++++ 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Package.swift b/Package.swift index e63cef20..781feed7 100644 --- a/Package.swift +++ b/Package.swift @@ -13,6 +13,13 @@ var targets: [Target] = [ .enableExperimentalFeature("StrictConcurrency"), ] ), + .testTarget( + name: "XcodeGraphTests", + dependencies: [.target(name: "XcodeGraph")], + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency"), + ] + ), ] let package = Package( diff --git a/Sources/XcodeGraph/Models/Metadata/TargetMetadata.swift b/Sources/XcodeGraph/Models/Metadata/TargetMetadata.swift index d137a4d1..2f1d51eb 100644 --- a/Sources/XcodeGraph/Models/Metadata/TargetMetadata.swift +++ b/Sources/XcodeGraph/Models/Metadata/TargetMetadata.swift @@ -4,23 +4,15 @@ public struct TargetMetadata: Codable, Equatable, Sendable { /// Some Tuist features can leverage that information for doing things like filtering. public var tags: Set - /// Projects can be external or not, which means they are declared or not using the Tuist Projects' DSL - /// and the targets of those projects can fall into two categories: - /// - Local: They've been linked from a local directory (e.g., a local package) - /// - Remote: They've been resolved and pulled by a package manager (e.g. SPM) - public var isLocal: Bool - @available(*, deprecated, renamed: "metadata(tags:)", message: "Use the static 'metadata' initializer instead") public init( tags: Set ) { self.tags = tags - isLocal = true } - init(tags: Set, isLocal: Bool) { + init(tags: Set, isLocal _: Bool) { self.tags = tags - self.isLocal = isLocal } public static func metadata(tags: Set = Set(), isLocal: Bool = true) -> TargetMetadata { @@ -31,12 +23,10 @@ public struct TargetMetadata: Codable, Equatable, Sendable { #if DEBUG extension TargetMetadata { public static func test( - tags: Set = [], - isLocal: Bool = true + tags: Set = [] ) -> TargetMetadata { TargetMetadata.metadata( - tags: tags, - isLocal: isLocal + tags: tags ) } } diff --git a/Sources/XcodeGraph/Models/Target.swift b/Sources/XcodeGraph/Models/Target.swift index 941df996..58844188 100644 --- a/Sources/XcodeGraph/Models/Target.swift +++ b/Sources/XcodeGraph/Models/Target.swift @@ -50,6 +50,7 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { public let mergeable: Bool public let onDemandResourcesTags: OnDemandResourcesTags? public let metadata: TargetMetadata + public let type: TargetType // MARK: - Init @@ -81,7 +82,8 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { mergedBinaryType: MergedBinaryType = .disabled, mergeable: Bool = false, onDemandResourcesTags: OnDemandResourcesTags? = nil, - metadata: TargetMetadata = .init(tags: []) + metadata: TargetMetadata = .metadata(tags: []), + type: TargetType = .local ) { self.name = name self.product = product @@ -111,6 +113,7 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { self.mergeable = mergeable self.onDemandResourcesTags = onDemandResourcesTags self.metadata = metadata + self.type = type } /// Given a target name, it obtains the product name by turning "-" characters into "_" and "/" into "_" @@ -312,7 +315,8 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { lhs.dependencies == rhs.dependencies && lhs.mergedBinaryType == rhs.mergedBinaryType && lhs.mergeable == rhs.mergeable && - lhs.environmentVariables == rhs.environmentVariables + lhs.environmentVariables == rhs.environmentVariables && + lhs.type == rhs.type } public func hash(into hasher: inout Hasher) { @@ -322,6 +326,7 @@ public struct Target: Equatable, Hashable, Comparable, Codable, Sendable { hasher.combine(bundleId) hasher.combine(productName) hasher.combine(environmentVariables) + hasher.combine(type) } /// Returns a new copy of the target with the given InfoPlist set. diff --git a/Sources/XcodeGraph/Models/TargetType.swift b/Sources/XcodeGraph/Models/TargetType.swift index e69de29b..7355312d 100644 --- a/Sources/XcodeGraph/Models/TargetType.swift +++ b/Sources/XcodeGraph/Models/TargetType.swift @@ -0,0 +1,6 @@ +public enum TargetType: Codable, Hashable, Equatable, Sendable { + /// A target is local when it hasn't been resolved and pulled by a package manager (e.g., SPM). + case local + /// A target is remote, when it has been resolved and pulled by a package manager (e.g., SPM). + case remote +} From e4becb3912192ceb2e5589cbfe2a2edb66e5bdc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Pi=C3=B1era=20Buend=C3=ADa?= <663605+pepicrft@users.noreply.github.com> Date: Thu, 26 Dec 2024 15:08:28 +0100 Subject: [PATCH 3/3] Update TargetType.swift --- Sources/XcodeGraph/Models/TargetType.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XcodeGraph/Models/TargetType.swift b/Sources/XcodeGraph/Models/TargetType.swift index 7355312d..7c818350 100644 --- a/Sources/XcodeGraph/Models/TargetType.swift +++ b/Sources/XcodeGraph/Models/TargetType.swift @@ -1,6 +1,6 @@ public enum TargetType: Codable, Hashable, Equatable, Sendable { /// A target is local when it hasn't been resolved and pulled by a package manager (e.g., SPM). case local - /// A target is remote, when it has been resolved and pulled by a package manager (e.g., SPM). + /// A target is remote, when it has been resolved and pulled by a package manager (e.g., SwiftPM). case remote }