diff --git a/Package.resolved b/Package.resolved index 25a2bd3e..333c172c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "9a0c6977a60be4c351b05b7d8aab7de908342d5638eaaadf034c914fbe903558", + "originHash" : "f0a7e4585ea57e5ac436c40b5e53baef22001edb75274a051d2606cc73d92795", "pins" : [ { "identity" : "darwinprivateframeworks", diff --git a/Package.swift b/Package.swift index a1e4c423..32129fd2 100644 --- a/Package.swift +++ b/Package.swift @@ -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( @@ -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 @@ -213,11 +221,6 @@ let package = Package( openAttributeGraphTarget, openAttributeGraphSPITarget, openAttributeGraphShimsTarget, - - openAttributeGraphTestsTarget, - openAttributeGraphCxxTestsTarget, - openAttributeGraphShimsTestsTarget, - openAttributeGraphCompatibilityTestsTarget, ], cxxLanguageStandard: .cxx20 ) @@ -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") @@ -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] { diff --git a/Tests/OpenAttributeGraphCompatibilityTests/Attribute/AttributeTestBase.swift b/Tests/OpenAttributeGraphCompatibilityTests/Attribute/AttributeTestBase.swift deleted file mode 100644 index e69de29b..00000000 diff --git a/Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift b/Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift index 43dccc9b..496c2e7f 100644 --- a/Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift @@ -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 @@ -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 diff --git a/Tests/OpenAttributeGraphCompatibilityTests/VersionTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/VersionCompatibilityTests.swift similarity index 93% rename from Tests/OpenAttributeGraphCompatibilityTests/VersionTests.swift rename to Tests/OpenAttributeGraphCompatibilityTests/VersionCompatibilityTests.swift index bd710777..556c2ea7 100644 --- a/Tests/OpenAttributeGraphCompatibilityTests/VersionTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/VersionCompatibilityTests.swift @@ -1,5 +1,5 @@ // -// VersionTests.swift +// VersionCompatibilityTests.swift // OpenAttributeGraphCompatibilityTests import Testing @@ -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)) @@ -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 } }