diff --git a/Package.swift b/Package.swift index 40871f9..8e9bdf4 100644 --- a/Package.swift +++ b/Package.swift @@ -17,6 +17,18 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool { } } +#if os(macOS) +// NOTE: #if os(macOS) check is not accurate if we are cross compiling for Linux platform. So we add an env key to specify it. +let buildForDarwinPlatform = envEnable("OPENSWIFTUI_BUILD_FOR_DARWIN_PLATFORM", default: true) +#else +let buildForDarwinPlatform = envEnable("OPENSWIFTUI_BUILD_FOR_DARWIN_PLATFORM") +#endif + + +// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/3061#issuecomment-2118821061 +// By-pass https://github.com/swiftlang/swift-package-manager/issues/7580 +let isSPIDocGenerationBuild = envEnable("SPI_GENERATE_DOCS", default: false) + // MARK: - Env and Config let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode" @@ -112,11 +124,7 @@ if warningsAsErrorsCondition { // MARK: - [env] OPENGRAPH_LIBRARY_EVOLUTION -#if os(macOS) -let libraryEvolutionCondition = envEnable("OPENGRAPH_LIBRARY_EVOLUTION", default: true) -#else -let libraryEvolutionCondition = envEnable("OPENGRAPH_LIBRARY_EVOLUTION") -#endif +let libraryEvolutionCondition = envEnable("OPENGRAPH_LIBRARY_EVOLUTION", default: buildForDarwinPlatform) if libraryEvolutionCondition { // NOTE: -enable-library-evolution will cause module verify failure for `swift build`. @@ -223,16 +231,6 @@ let package = Package( cxxLanguageStandard: .cxx20 ) - -#if os(macOS) -// FIXME: Enable it by default will cause non-iOS/macOS Apple OS build fail currently. -// Add the corresponding tbd file and framework to fix it. -let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: true) -#else -let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH") -#endif -let useLocalDeps = envEnable("OPENGRAPH_USE_LOCAL_DEPS") - extension Target { func addAGSettings() { dependencies.append( @@ -253,6 +251,10 @@ extension Target { } } +let useLocalDeps = envEnable("OPENGRAPH_USE_LOCAL_DEPS") + +let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: buildForDarwinPlatform && !isSPIDocGenerationBuild) + if attributeGraphCondition { let privateFrameworkRepo: Package.Dependency if useLocalDeps {