Skip to content

Commit 3c1bf92

Browse files
committed
Fix compile issue
1 parent b0c947d commit 3c1bf92

File tree

5 files changed

+87
-21
lines changed

5 files changed

+87
-21
lines changed

Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let libraryEvolutionCondition = envBoolValue("LIBRARY_EVOLUTION", default: build
145145
let compatibilityTestCondition = envBoolValue("COMPATIBILITY_TEST", default: false)
146146

147147
let useLocalDeps = envBoolValue("USE_LOCAL_DEPS")
148-
let computeCondition = envBoolValue("OPENATTRIBUTESHIMS_COMPUTE", default: true)
148+
let computeCondition = envBoolValue("OPENATTRIBUTESHIMS_COMPUTE", default: false)
149149
let attributeGraphCondition = envBoolValue("OPENATTRIBUTESHIMS_ATTRIBUTEGRAPH", default: buildForDarwinPlatform && !isSPIBuild)
150150

151151
// MARK: - Shared Settings
@@ -381,7 +381,31 @@ let package = Package(
381381
cxxLanguageStandard: .cxx20
382382
)
383383

384+
private var hasSetupDPFDependency = false
385+
386+
@MainActor
387+
func setupDPFDependency() {
388+
guard !hasSetupDPFDependency else { return }
389+
let privateFrameworkRepo: Package.Dependency
390+
if useLocalDeps {
391+
privateFrameworkRepo = Package.Dependency.package(path: "../DarwinPrivateFrameworks")
392+
} else {
393+
privateFrameworkRepo = Package.Dependency.package(url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", branch: "main")
394+
}
395+
package.dependencies.append(privateFrameworkRepo)
396+
397+
let agVersion = EnvManager.shared.withDomain("DarwinPrivateFrameworks") {
398+
envIntValue("TARGET_RELEASE", default: 2024)
399+
}
400+
package.platforms = switch agVersion {
401+
case 2024: [.iOS(.v18), .macOS(.v15), .macCatalyst(.v18), .tvOS(.v18), .watchOS(.v10), .visionOS(.v2)]
402+
case 2021: [.iOS(.v15), .macOS(.v12), .macCatalyst(.v15), .tvOS(.v15), .watchOS(.v7)]
403+
default: nil
404+
}
405+
}
406+
384407
if compatibilityTestCondition {
408+
setupDPFDependency()
385409
openAttributeGraphCompatibilityTestsTarget.addAGSettings()
386410
} else {
387411
package.targets += [
@@ -414,23 +438,8 @@ if computeCondition {
414438
}
415439
package.platforms = [.iOS(.v18), .macOS(.v15), .macCatalyst(.v18), .tvOS(.v18), .watchOS(.v10), .visionOS(.v2)]
416440
} else if attributeGraphCondition {
417-
let privateFrameworkRepo: Package.Dependency
418-
if useLocalDeps {
419-
privateFrameworkRepo = Package.Dependency.package(path: "../DarwinPrivateFrameworks")
420-
} else {
421-
privateFrameworkRepo = Package.Dependency.package(url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", branch: "main")
422-
}
423-
package.dependencies.append(privateFrameworkRepo)
441+
setupDPFDependency()
424442
openAttributeGraphShimsTarget.addAGSettings()
425-
426-
let agVersion = EnvManager.shared.withDomain("DarwinPrivateFrameworks") {
427-
envIntValue("TARGET_RELEASE", default: 2024)
428-
}
429-
package.platforms = switch agVersion {
430-
case 2024: [.iOS(.v18), .macOS(.v15), .macCatalyst(.v18), .tvOS(.v18), .watchOS(.v10), .visionOS(.v2)]
431-
case 2021: [.iOS(.v15), .macOS(.v12), .macCatalyst(.v15), .tvOS(.v15), .watchOS(.v7)]
432-
default: nil
433-
}
434443
} else {
435444
openAttributeGraphShimsTarget.dependencies.append(.target(name: openAttributeGraphTarget.name))
436445
package.platforms = [.iOS(.v13), .macOS(.v10_15), .macCatalyst(.v13), .tvOS(.v13), .watchOS(.v5)]

Sources/OpenAttributeGraphShims/Graph+Debug.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Graph+Debug.swift
33
// OpenAttributeGraphShims
44

5-
#if canImport(Darwin)
5+
#if canImport(Darwin) && !OPENATTRIBUTEGRAPH_COMPUTE // Compute's descriptionFormatDictionary API is not aligned with OAG yet.
66

77
import Foundation
88

Sources/OpenAttributeGraphShims/GraphShims.swift

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,53 @@
22
// GraphShims.swift
33
// OpenAttributeGraphShims
44

5-
#if OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH
5+
#if OPENATTRIBUTEGRAPH_COMPUTE
6+
7+
@_exported public import Compute
8+
public typealias OAGAttributeInfo = AGAttributeInfo
9+
public typealias OAGCachedValueOptions = CachedValueOptions
10+
public typealias OAGChangedValueFlags = AGChangedValueFlags
11+
public typealias OAGInputOptions = AGInputOptions
12+
public typealias OAGValue = AGChangedValue
13+
public typealias OAGValueOptions = AGValueOptions
14+
15+
extension AnyAttribute {
16+
public typealias Flags = Subgraph.Flags
17+
}
18+
19+
extension AnyAttribute {
20+
public var subgraph2: Subgraph? { nil }
21+
}
22+
23+
24+
extension Subgraph {
25+
public typealias ChildFlags = AnyAttribute.Flags
26+
}
27+
28+
extension Graph {
29+
public func startProfiling() {
30+
// TODO: placeholder
31+
}
32+
33+
public func stopProfiling() {
34+
// TODO: placeholder
35+
}
36+
37+
public func resetProfile() {
38+
// TODO: placeholder
39+
}
40+
}
41+
42+
extension _AttributeBody {
43+
public typealias Flags = _AttributeType.Flags
44+
}
45+
46+
extension CachedValueOptions {
47+
public static var _1: CachedValueOptions = .unprefetched
48+
}
49+
50+
public let attributeGraphEnabled = true
51+
#elseif OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH
652
@_exported public import AttributeGraph
753
#if os(iOS) && !targetEnvironment(simulator)
854
@_exported public import _AttributeGraphDeviceSwiftShims
@@ -19,3 +65,6 @@ public let attributeGraphEnabled = true
1965

2066
public let attributeGraphEnabled = false
2167
#endif
68+
69+
@available(*, deprecated, message: "swiftToolchainSupported is always true")
70+
public let swiftToolchainSupported = true

Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#if OPENATTRIBUTEGRAPH
66
@_exported import OpenAttributeGraph
7-
87
let compatibilityTestEnabled = false
98
#else
109
@_exported public import AttributeGraph

0 commit comments

Comments
 (0)