Skip to content

Commit ae33121

Browse files
authored
Fix SPI doc build issue (#124)
1 parent cc2df5a commit ae33121

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

Package.swift

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
1717
}
1818
}
1919

20+
#if os(macOS)
21+
// 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.
22+
let buildForDarwinPlatform = envEnable("OPENSWIFTUI_BUILD_FOR_DARWIN_PLATFORM", default: true)
23+
#else
24+
let buildForDarwinPlatform = envEnable("OPENSWIFTUI_BUILD_FOR_DARWIN_PLATFORM")
25+
#endif
26+
27+
28+
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/3061#issuecomment-2118821061
29+
// By-pass https://github.com/swiftlang/swift-package-manager/issues/7580
30+
let isSPIDocGenerationBuild = envEnable("SPI_GENERATE_DOCS", default: false)
31+
2032
// MARK: - Env and Config
2133

2234
let isXcodeEnv = Context.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
@@ -112,11 +124,7 @@ if warningsAsErrorsCondition {
112124

113125
// MARK: - [env] OPENGRAPH_LIBRARY_EVOLUTION
114126

115-
#if os(macOS)
116-
let libraryEvolutionCondition = envEnable("OPENGRAPH_LIBRARY_EVOLUTION", default: true)
117-
#else
118-
let libraryEvolutionCondition = envEnable("OPENGRAPH_LIBRARY_EVOLUTION")
119-
#endif
127+
let libraryEvolutionCondition = envEnable("OPENGRAPH_LIBRARY_EVOLUTION", default: buildForDarwinPlatform)
120128

121129
if libraryEvolutionCondition {
122130
// NOTE: -enable-library-evolution will cause module verify failure for `swift build`.
@@ -223,16 +231,6 @@ let package = Package(
223231
cxxLanguageStandard: .cxx20
224232
)
225233

226-
227-
#if os(macOS)
228-
// FIXME: Enable it by default will cause non-iOS/macOS Apple OS build fail currently.
229-
// Add the corresponding tbd file and framework to fix it.
230-
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: true)
231-
#else
232-
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH")
233-
#endif
234-
let useLocalDeps = envEnable("OPENGRAPH_USE_LOCAL_DEPS")
235-
236234
extension Target {
237235
func addAGSettings() {
238236
dependencies.append(
@@ -253,6 +251,10 @@ extension Target {
253251
}
254252
}
255253

254+
let useLocalDeps = envEnable("OPENGRAPH_USE_LOCAL_DEPS")
255+
256+
let attributeGraphCondition = envEnable("OPENGRAPH_ATTRIBUTEGRAPH", default: buildForDarwinPlatform && !isSPIDocGenerationBuild)
257+
256258
if attributeGraphCondition {
257259
let privateFrameworkRepo: Package.Dependency
258260
if useLocalDeps {

0 commit comments

Comments
 (0)