Skip to content
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

build stdlib on macOS #210

Merged
merged 6 commits into from
May 7, 2024
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
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build only
- name: Build debug
run: |
swift --version
swift build

- name: Build release
run: |
swift build -c release

- name: Test SymbolGraphBuilder
run: |
swift run -c release SymbolGraphBuilderTests
126 changes: 82 additions & 44 deletions Sources/SymbolGraphBuilder/Builds/SSGC.SpecialBuild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,92 @@ extension SSGC.SpecialBuild:SSGC.DocumentationBuild
with swift:SSGC.Toolchain) throws -> (SymbolGraphMetadata, SSGC.PackageSources)
{
// https://forums.swift.org/t/dependency-graph-of-the-standard-library-modules/59267
let sources:[SSGC.NominalSources] =
[
// 0:
.toolchain(module: "Swift"),
// 1:
.toolchain(module: "_Concurrency",
dependencies: 0),
// 2:
.toolchain(module: "Distributed",
dependencies: 0, 1),
let sources:[SSGC.NominalSources]
switch try swift.platform()
{
case .macOS:
sources =
[
// 0:
.toolchain(module: "Swift"),
// 1:
.toolchain(module: "_Concurrency",
dependencies: 0),
// 2:
.toolchain(module: "Distributed",
dependencies: 0, 1),

// 3:
.toolchain(module: "_StringProcessing",
dependencies: 0),
// 4:
.toolchain(module: "RegexBuilder",
dependencies: 0, 3),

// 5:
.toolchain(module: "Dispatch",
dependencies: 0),
// 6:
.toolchain(module: "DispatchIntrospection",
dependencies: 0),
// 7:
.toolchain(module: "Foundation",
dependencies: 0, 5),
]

// 3:
.toolchain(module: "_Differentiation",
dependencies: 0),
case .linux:
fallthrough

// 4:
.toolchain(module: "_RegexParser",
dependencies: 0),
// 5:
.toolchain(module: "_StringProcessing",
dependencies: 0, 4),
// 6:
.toolchain(module: "RegexBuilder",
dependencies: 0, 4, 5),
default:
sources =
[
// 0:
.toolchain(module: "Swift"),
// 1:
.toolchain(module: "_Concurrency",
dependencies: 0),
// 2:
.toolchain(module: "Distributed",
dependencies: 0, 1),

// 3:
.toolchain(module: "_Differentiation",
dependencies: 0),

// 7:
.toolchain(module: "Cxx",
dependencies: 0),
// 4:
.toolchain(module: "_RegexParser",
dependencies: 0),
// 5:
.toolchain(module: "_StringProcessing",
dependencies: 0, 4),
// 6:
.toolchain(module: "RegexBuilder",
dependencies: 0, 4, 5),

// 8:
.toolchain(module: "Dispatch",
dependencies: 0),
// 9:
.toolchain(module: "DispatchIntrospection",
dependencies: 0),
// 10:
.toolchain(module: "Foundation",
dependencies: 0, 8),
// 11:
.toolchain(module: "FoundationNetworking",
dependencies: 0, 8, 10),
// 12:
.toolchain(module: "FoundationXML",
dependencies: 0, 8, 10),
// 12:
.toolchain(module: "XCTest",
dependencies: 0),
]
// 7:
.toolchain(module: "Cxx",
dependencies: 0),

// 8:
.toolchain(module: "Dispatch",
dependencies: 0),
// 9:
.toolchain(module: "DispatchIntrospection",
dependencies: 0),
// 10:
.toolchain(module: "Foundation",
dependencies: 0, 8),
// 11:
.toolchain(module: "FoundationNetworking",
dependencies: 0, 8, 10),
// 12:
.toolchain(module: "FoundationXML",
dependencies: 0, 8, 10),
// 12:
.toolchain(module: "XCTest",
dependencies: 0),
]
}

let metadata:SymbolGraphMetadata = .swift(swift.version,
commit: swift.commit,
Expand Down
10 changes: 9 additions & 1 deletion Sources/SymbolGraphBuilder/Toolchains/SSGC.Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,15 @@ extension SSGC.Toolchain
"-skip-inherited-docs",
]

if let swiftSDK:SSGC.AppleSDK = self.swiftSDK
#if os(macOS)
// On macOS, dumping symbols without specifying the SDK will always fail.
// Therefore, we always provide a default SDK.
let swiftSDK:SSGC.AppleSDK? = self.swiftSDK ?? .macOS
#else
let swiftSDK:SSGC.AppleSDK? = self.swiftSDK
#endif

if let swiftSDK:SSGC.AppleSDK
{
arguments.append("-sdk")
arguments.append(swiftSDK.path)
Expand Down
6 changes: 4 additions & 2 deletions Sources/SymbolGraphBuilderTests/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ enum Main:TestMain, TestBattery
docs.roundtrip(for: tests, in: workspace.artifacts)
}

// https://github.com/tayloraswift/swift-unidoc/issues/211
#if !os(macOS)
if let tests:TestGroup = tests / "swift-nio",
let docs:SymbolGraphObject<Void> = (tests.do
{
try workspace.build(package: try .remote(
package: "swift-nio",
from: "https://github.com/apple/swift-nio.git",
at: "2.63.0",
at: "2.65.0",
in: workspace),
with: toolchain)
})
Expand All @@ -101,8 +103,8 @@ enum Main:TestMain, TestBattery
])

docs.roundtrip(for: tests, in: workspace.artifacts)

}
#endif

// SwiftNIO has lots of dependencies. If we can handle SwiftNIO,
// we can handle anything!
Expand Down
20 changes: 12 additions & 8 deletions Sources/SymbolGraphCompiler/Declarations/SSGC.DeclObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ extension SSGC

/// The type of the superforms tracked by ``\.value.superforms``.
var superforms:(any SuperformRelationship.Type)?
/// The symbol this scalar is lexically-nested in. This may
/// be an extension block symbol.
var scope:Symbol.USR?
/// The symbols this scalar is lexically-nested in. This may include an extension block
/// symbol.
///
/// Remarkably, it is possible for certain (Objective C) declarations to have more than
/// one lexical parent. For example, base class methods can be shared by multiple
/// subclasses in addition to the base class.
var scopes:Set<Symbol.USR>

private(set)
var value:Decl
Expand All @@ -35,7 +39,7 @@ extension SSGC
self.culture = culture

self.superforms = nil
self.scope = nil
self.scopes = []

self.value = value
}
Expand Down Expand Up @@ -77,16 +81,16 @@ extension SSGC.DeclObject
throw SSGC.SemanticError.cannot(have: .scope, as: self.value.phylum)
}

// It is okay to restate the exact same nesting relationship multiple times. This
// sometimes happens when compiling C modules.
if let scope:Symbol.USR = self.scope,
// Only (Objective) C declarations can have multiple lexical scopes.
if case .s = self.id.language,
let scope:Symbol.USR = self.scopes.first,
scope != relationship.scope
{
throw SSGC.SemanticError.already(has: .scope(scope))
}
else
{
self.scope = relationship.scope
self.scopes.insert(relationship.scope)
self.kinks += relationship.kinks
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SymbolGraphCompiler/SSGC.TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ extension SSGC.TypeChecker
// implementations that implement requirements from protocols in the current module.
for decl:SSGC.DeclObject in others
{
guard case nil = decl.scope,
guard decl.scopes.isEmpty,
let parent:UnqualifiedPath = .init(decl.value.path.prefix),
let parent:Symbol.Decl = protocols[parent]
else
Expand Down
Loading