Skip to content
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
44 changes: 31 additions & 13 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Sources/XcodeGraph/Graph/ConditionalGraphTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ public struct GraphTargetReference: Equatable, Comparable, Hashable, CustomDebug
/// Path to the directory that contains the project where the target is defined.
public let graphTarget: GraphTarget

public var target: Target { graphTarget.target }
public var target: Target {
graphTarget.target
}

/// Platforms the target is conditionally deployed to.
public let condition: PlatformCondition?
Expand Down
48 changes: 48 additions & 0 deletions Sources/XcodeGraph/Graph/GraphDependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
}
}

public struct ForeignBuildOutput: Hashable, CustomStringConvertible, Comparable, Codable, Sendable {
public var name: String
public var path: AbsolutePath
public var linking: BinaryLinking

public init(name: String, path: AbsolutePath, linking: BinaryLinking) {
self.name = name
self.path = path
self.linking = linking
}

public var description: String {
"foreign build output '\(name)'"
}

public static func < (lhs: ForeignBuildOutput, rhs: ForeignBuildOutput) -> Bool {
lhs.description < rhs.description
}
}

case foreignBuildOutput(ForeignBuildOutput)

case xcframework(GraphDependency.XCFramework)

/// A dependency that represents a pre-compiled framework.
Expand Down Expand Up @@ -97,6 +119,9 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
switch self {
case let .macro(path):
hasher.combine(path)
case let .foreignBuildOutput(output):
hasher.combine("foreignBuildOutput")
hasher.combine(output)
case let .xcframework(xcframework):
hasher.combine(xcframework)
case let .framework(path, _, _, _, _, _, _):
Expand Down Expand Up @@ -129,6 +154,7 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
public var isTarget: Bool {
switch self {
case .macro: return false
case .foreignBuildOutput: return false
case .xcframework: return false
case .framework: return false
case .library: return false
Expand All @@ -145,6 +171,7 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
public var isStaticPrecompiled: Bool {
switch self {
case .macro: return false
case let .foreignBuildOutput(output): return output.linking == .static
case let .xcframework(xcframework):
return xcframework.linking == .static
case let .framework(_, _, _, _, linking, _, _),
Expand All @@ -162,6 +189,7 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
public var isDynamicPrecompiled: Bool {
switch self {
case .macro: return false
case let .foreignBuildOutput(output): return output.linking == .dynamic
case let .xcframework(xcframework):
return xcframework.linking == .dynamic
case let .framework(_, _, _, _, linking, _, _),
Expand All @@ -176,6 +204,7 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
public var isPrecompiled: Bool {
switch self {
case .macro: return true
case .foreignBuildOutput: return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the output of a foreign-built one of the existing types? (i.e. .xcframework, .library, or .library). If so, but we need to know it's from a foreignBuildOutput, can't we adjust the existing cases?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as here: tuist/tuist#9400 (comment)

For the foreign build, we don't know everything about the .xcframework in advance.

case .xcframework: return true
case .framework: return true
case .library: return true
Expand All @@ -189,6 +218,7 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
public var isLinkable: Bool {
switch self {
case .macro: return false
case .foreignBuildOutput: return true
case .xcframework: return true
case .framework: return true
case .library: return true
Expand All @@ -202,6 +232,7 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
public var isPrecompiledMacro: Bool {
switch self {
case .macro: return true
case .foreignBuildOutput: return false
case .xcframework: return false
case .framework: return false
case .library: return false
Expand All @@ -215,6 +246,7 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
public var isPrecompiledDynamicAndLinkable: Bool {
switch self {
case .macro: return false
case let .foreignBuildOutput(output): return output.linking == .dynamic
case let .xcframework(xcframework):
return xcframework.linking == .dynamic
case let .framework(_, _, _, _, linking, _, _),
Expand Down Expand Up @@ -245,6 +277,8 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
switch self {
case .macro:
return "macro '\(name)'"
case let .foreignBuildOutput(output):
return output.description
case .xcframework:
return "xcframework '\(name)'"
case .framework:
Expand All @@ -266,6 +300,8 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
switch self {
case let .macro(path):
return path.basename
case let .foreignBuildOutput(output):
return output.name
case let .xcframework(xcframework):
return xcframework.path.basename
case let .framework(path, _, _, _, _, _, _):
Expand Down Expand Up @@ -382,6 +418,18 @@ public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Coda
)
}

public static func testForeignBuildOutput(
name: String = "SharedKMP",
path: AbsolutePath = AbsolutePath.root.appending(try! RelativePath(validating: "SharedKMP.xcframework")),
linking: BinaryLinking = .dynamic
) -> GraphDependency {
.foreignBuildOutput(GraphDependency.ForeignBuildOutput(
name: name,
path: path,
linking: linking
))
}

public static func testBundle(path: AbsolutePath = .root.appending(component: "test.bundle")) -> GraphDependency {
.bundle(path: path)
}
Expand Down
43 changes: 43 additions & 0 deletions Sources/XcodeGraph/Models/ForeignBuild.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Path

public struct ForeignBuild: Equatable, Hashable, Codable, Sendable {
public let script: String
public let inputs: [Input]
public let output: Artifact

public init(
script: String,
inputs: [Input],
output: Artifact
) {
self.script = script
self.inputs = inputs
self.output = output
}
}

extension ForeignBuild {
public enum Input: Equatable, Hashable, Codable, Sendable {
case file(AbsolutePath)
case folder(AbsolutePath)
case script(String)
}
}

extension ForeignBuild {
public enum Artifact: Equatable, Hashable, Codable, Sendable {
case xcframework(path: AbsolutePath, linking: BinaryLinking)

public var path: AbsolutePath {
switch self {
case let .xcframework(path, _): return path
}
}

public var linking: BinaryLinking {
switch self {
case let .xcframework(_, linking): return linking
}
}
}
}
24 changes: 12 additions & 12 deletions Sources/XcodeGraph/Models/Plist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,21 @@ extension Dictionary where Value == Plist.Value {
// MARK: - InfoPlist

public enum InfoPlist: Equatable, Codable, Sendable {
// Path to a user defined info.plist file (already exists on disk).
/// Path to a user defined info.plist file (already exists on disk).
case file(path: AbsolutePath, configuration: BuildConfiguration? = nil)

// Path to a generated info.plist file (may not exist on disk at the time of project generation).
// Data of the generated file
/// Path to a generated info.plist file (may not exist on disk at the time of project generation).
/// Data of the generated file
case generatedFile(path: AbsolutePath, data: Data, configuration: BuildConfiguration? = nil)

// User defined dictionary of keys/values for an info.plist file.
/// User defined dictionary of keys/values for an info.plist file.
case dictionary([String: Plist.Value], configuration: BuildConfiguration? = nil)

// A user defined xcconfig variable map to .entitlements file
/// A user defined xcconfig variable map to .entitlements file
case variable(String, configuration: BuildConfiguration? = nil)

// User defined dictionary of keys/values for an info.plist file extending the default set of keys/values
// for the target type.
/// User defined dictionary of keys/values for an info.plist file extending the default set of keys/values
/// for the target type.
case extendingDefault(with: [String: Plist.Value], configuration: BuildConfiguration? = nil)

// MARK: - Public
Expand Down Expand Up @@ -138,17 +138,17 @@ extension InfoPlist: ExpressibleByStringLiteral {
// MARK: - Entitlements

public enum Entitlements: Equatable, Codable, Sendable {
// Path to a user defined .entitlements file (already exists on disk).
/// Path to a user defined .entitlements file (already exists on disk).
case file(path: AbsolutePath, configuration: BuildConfiguration? = nil)

// Path to a generated .entitlements file (may not exist on disk at the time of project generation).
// Data of the generated file
/// Path to a generated .entitlements file (may not exist on disk at the time of project generation).
/// Data of the generated file
case generatedFile(path: AbsolutePath, data: Data, configuration: BuildConfiguration? = nil)

// User defined dictionary of keys/values for an .entitlements file.
/// User defined dictionary of keys/values for an .entitlements file.
case dictionary([String: Plist.Value], configuration: BuildConfiguration? = nil)

// A user defined xcconfig variable map to .entitlements file
/// A user defined xcconfig variable map to .entitlements file
case variable(String, configuration: BuildConfiguration? = nil)

// MARK: - Public
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGraph/Models/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable, Sen
case bundle
case commandLineTool
case appExtension = "app_extension"
// case watchApp = "watch_app"
/// case watchApp = "watch_app"
case watch2App = "watch_2_app"
// case watchExtension = "watch_extension"
case watch2Extension = "watch_2_extension"
Expand Down
5 changes: 4 additions & 1 deletion Sources/XcodeGraph/Models/ResourceSynthesizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public struct ResourceSynthesizer: Equatable, Hashable, Codable, Sendable {
case files

public struct Option: Equatable, Hashable, Codable, Sendable {
public var value: Any { anyCodableValue.value }
public var value: Any {
anyCodableValue.value
}

private let anyCodableValue: AnyCodable

public init(value: some Any) {
Expand Down
32 changes: 16 additions & 16 deletions Sources/XcodeGraph/Models/RunActionOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ public struct RunActionOptions: Equatable, Codable, Sendable {
/// Configure your project to work with the Metal frame debugger.
public let enableGPUFrameCaptureMode: GPUFrameCaptureMode

/// Creates an `RunActionOptions` instance
///
/// - Parameters:
/// - language: language (e.g. "pl").
///
/// - storeKitConfigurationPath: The absolute path of the
/// [StoreKit configuration
/// file](https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode#3625700).
/// The default value is `nil`, which results in no
/// configuration defined for the scheme
///
/// - simulatedLocation: The simulated GPS location to use when running the app.
///
/// - enableGPUFrameCaptureMode: The Metal Frame Capture mode to use. e.g: .disabled
/// If your target links to the Metal framework, Xcode enables GPU Frame Capture.
/// You can disable it to test your app in best performance.
// Creates an `RunActionOptions` instance
//
// - Parameters:
// - language: language (e.g. "pl").
//
// - storeKitConfigurationPath: The absolute path of the
// [StoreKit configuration
// file](https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode#3625700).
// The default value is `nil`, which results in no
// configuration defined for the scheme
//
// - simulatedLocation: The simulated GPS location to use when running the app.
//
// - enableGPUFrameCaptureMode: The Metal Frame Capture mode to use. e.g: .disabled
// If your target links to the Metal framework, Xcode enables GPU Frame Capture.
// You can disable it to test your app in best performance.

public init(
language: String? = nil,
Expand Down
Loading