Skip to content

Fix SPI doc build issue #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025
Merged
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
32 changes: 17 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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(
Expand All @@ -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 {
Expand Down