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
2 changes: 1 addition & 1 deletion Package.resolved

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

44 changes: 23 additions & 21 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ if libraryEvolutionCondition {
sharedSwiftSettings.append(.unsafeFlags(["-enable-library-evolution", "-no-verify-emitted-module-interface"]))
}

// MARK: - [env] OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST

let compatibilityTestCondition = envEnable("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST", default: false)
sharedCSettings.append(.define("OPENATTRIBUTEGRAPH", to: compatibilityTestCondition ? "1" : "0"))
if !compatibilityTestCondition {
sharedSwiftSettings.append(.define("OPENATTRIBUTEGRAPH"))
}

// MARK: - Targets

let openAttributeGraphTarget = Target.target(
Expand Down Expand Up @@ -192,7 +200,7 @@ let openAttributeGraphCompatibilityTestsTarget = Target.testTarget(
name: "OpenAttributeGraphCompatibilityTests",
dependencies: [
.product(name: "Numerics", package: "swift-numerics"),
],
] + (compatibilityTestCondition ? [] : ["OpenAttributeGraph"]),
exclude: ["README.md"],
cSettings: sharedCSettings,
swiftSettings: sharedSwiftSettings
Expand All @@ -213,11 +221,6 @@ let package = Package(
openAttributeGraphTarget,
openAttributeGraphSPITarget,
openAttributeGraphShimsTarget,

openAttributeGraphTestsTarget,
openAttributeGraphCxxTestsTarget,
openAttributeGraphShimsTestsTarget,
openAttributeGraphCompatibilityTestsTarget,
],
cxxLanguageStandard: .cxx20
)
Expand All @@ -231,15 +234,20 @@ extension Target {
swiftSettings.append(.define("OPENATTRIBUTEGRAPH_ATTRIBUTEGRAPH"))
self.swiftSettings = swiftSettings
}

func addCompatibilitySettings() {
dependencies.append(
.product(name: "AttributeGraph", package: "DarwinPrivateFrameworks")
)
var swiftSettings = swiftSettings ?? []
swiftSettings.append(.define("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST"))
self.swiftSettings = swiftSettings
}
}

if !compatibilityTestCondition {
package.targets += [
openAttributeGraphTestsTarget,
openAttributeGraphCxxTestsTarget,
openAttributeGraphShimsTestsTarget,
]
} else {
openAttributeGraphCompatibilityTestsTarget.addAGSettings()
}

if buildForDarwinPlatform {
package.targets.append(openAttributeGraphCompatibilityTestsTarget)
}

let useLocalDeps = envEnable("OPENATTRIBUTEGRAPH_USE_LOCAL_DEPS")
Expand Down Expand Up @@ -267,12 +275,6 @@ if attributeGraphCondition {
package.platforms = [.iOS(.v13), .macOS(.v10_15), .macCatalyst(.v13), .tvOS(.v13), .watchOS(.v5)]
}

let compatibilityTestCondition = envEnable("OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST")
if compatibilityTestCondition && attributeGraphCondition {
openAttributeGraphCompatibilityTestsTarget.addCompatibilitySettings()
} else {
openAttributeGraphCompatibilityTestsTarget.dependencies.append("OpenAttributeGraph")
}

extension [Platform] {
static var nonDarwinPlatforms: [Platform] {
Expand Down
18 changes: 9 additions & 9 deletions Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
// GraphShims.swift
// OpenAttributeGraphCompatibilityTests

#if OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST
#if OPENATTRIBUTEGRAPH
@_exported import OpenAttributeGraph
let compatibilityTestEnabled = false
#if OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
public let swiftToolchainSupported = true
#else
public let swiftToolchainSupported = false
#endif
#else
@_exported public import AttributeGraph
public typealias OAGAttributeInfo = AGAttributeInfo
public typealias OAGCachedValueOptions = AGCachedValueOptions
Expand All @@ -12,12 +20,4 @@ public typealias OAGValue = AGValue
public typealias OAGValueOptions = AGValueOptions
public let compatibilityTestEnabled = true
public let swiftToolchainSupported = true
#else
@_exported import OpenAttributeGraph
let compatibilityTestEnabled = false
#if OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
public let swiftToolchainSupported = true
#else
public let swiftToolchainSupported = false
#endif
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// VersionTests.swift
// VersionCompatibilityTests.swift
// OpenAttributeGraphCompatibilityTests

import Testing
Expand All @@ -9,18 +9,7 @@ struct VersionTests {
@Test
func versionNumber() async {
await confirmation { confirm in
#if OPENATTRIBUTEGRAPH_COMPATIBILITY_TEST
switch Int32(ATTRIBUTEGRAPH_RELEASE) {
case ATTRIBUTEGRAPH_RELEASE_2021:
#expect(AGVersion == 0x20014)
confirm()
case ATTRIBUTEGRAPH_RELEASE_2024:
#expect(AGVersion == 0x2001e)
confirm()
default:
break
}
#else
#if OPENATTRIBUTEGRAPH
switch Int32(OPENATTRIBUTEGRAPH_RELEASE) {
case OPENATTRIBUTEGRAPH_RELEASE_2021:
#expect(OpenAttributeGraphVersionNumber.isApproximatelyEqual(to: 3.2))
Expand All @@ -33,6 +22,17 @@ struct VersionTests {
default:
break
}
#else
switch Int32(ATTRIBUTEGRAPH_RELEASE) {
case ATTRIBUTEGRAPH_RELEASE_2021:
#expect(AGVersion == 0x20014)
confirm()
case ATTRIBUTEGRAPH_RELEASE_2024:
#expect(AGVersion == 0x2001e)
confirm()
default:
break
}
#endif
}
}
Expand Down