Skip to content

Commit f3912f8

Browse files
authored
Merge pull request #317 from tayloraswift/cache-stdlib
Cache stdlib
2 parents 8683df8 + 322bbb0 commit f3912f8

26 files changed

+356
-229
lines changed

Sources/SymbolGraphBuilder/Artifacts/SSGC.SymbolCache.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ extension SSGC.SymbolCache
3131
as language:Phylum.Language) throws -> SSGC.SymbolCulture?
3232
{
3333
guard
34-
var parts:[SymbolGraphPart.ID] = self.symbols.modules[module]
34+
var files:SSGC.SymbolFiles = self.symbols.modules[module]
3535
else
3636
{
3737
return nil
3838
}
3939

40-
parts.removeAll
40+
files.parts.removeAll
4141
{
4242
if let colony:Symbol.Module = $0.colony, !filter.isEmpty
4343
{
@@ -49,19 +49,19 @@ extension SSGC.SymbolCache
4949
}
5050
}
5151

52-
if parts.isEmpty
52+
if files.parts.isEmpty
5353
{
5454
return nil
5555
}
5656

57-
parts.sort { $0.basename < $1.basename }
57+
files.parts.sort { $0.basename < $1.basename }
5858

59-
let dumps:[SSGC.SymbolDump] = try parts.map
59+
let dumps:[SSGC.SymbolDump] = try files.parts.map
6060
{
6161
(id:SymbolGraphPart.ID) in try
6262
{
6363
let symbols:SSGC.SymbolDump = try $0 ?? .init(loading: id,
64-
from: self.symbols.location,
64+
from: files.location,
6565
base: base)
6666

6767
$0 = symbols

Sources/SymbolGraphBuilder/Artifacts/SSGC.SymbolDumps.swift

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,68 @@ extension SSGC
77
@_spi(testable) public
88
struct SymbolDumps
99
{
10-
let location:FilePath.Directory
11-
let modules:[Symbol.Module: [SymbolGraphPart.ID]]
10+
let modules:[Symbol.Module: SymbolFiles]
1211

1312
private
14-
init(location:FilePath.Directory, modules:[Symbol.Module: [SymbolGraphPart.ID]])
13+
init(modules:[Symbol.Module: SymbolFiles])
1514
{
16-
self.location = location
1715
self.modules = modules
1816
}
1917
}
2018
}
2119
extension SSGC.SymbolDumps
2220
{
2321
@_spi(testable) public
24-
static func collect(from location:FilePath.Directory) throws -> Self
22+
static func collect(from locations:FilePath.Directory...) throws -> Self
2523
{
26-
let symbols:[Symbol.Module: [SymbolGraphPart.ID]] = try location.reduce(
24+
try .collect(from: locations)
25+
}
26+
27+
static func collect(from locations:[FilePath.Directory]) throws -> Self
28+
{
29+
let symbols:[Symbol.Module: SSGC.SymbolFiles] = try locations.reduce(
2730
into: [:])
2831
{
29-
// We don’t want to *parse* the JSON yet to discover the culture,
30-
// because the JSON can be very large, and parsing JSON is very
31-
// expensive (compared to parsing BSON). So we trust that the file
32-
// name is correct and indicates what is contained within the file.
33-
let filename:FilePath.Component = try $1.get()
34-
guard
35-
let id:SymbolGraphPart.ID = .init("\(filename)")
36-
else
32+
for filename:Result<FilePath.Component, any Error> in $1
3733
{
38-
return
39-
}
34+
// We don’t want to *parse* the JSON yet to discover the culture,
35+
// because the JSON can be very large, and parsing JSON is very
36+
// expensive (compared to parsing BSON). So we trust that the file
37+
// name is correct and indicates what is contained within the file.
38+
let filename:FilePath.Component = try filename.get()
4039

41-
switch id.namespace
42-
{
43-
case "CDispatch", // too low-level
44-
"CFURLSessionInterface", // too low-level
45-
"CFXMLInterface", // too low-level
46-
"CoreFoundation", // too low-level
47-
"Glibc", // linux-gnu specific
48-
"SwiftGlibc", // linux-gnu specific
49-
"SwiftOnoneSupport", // contains no symbols
50-
"SwiftOverlayShims", // too low-level
51-
"SwiftShims", // contains no symbols
52-
"_Builtin_intrinsics", // contains only one symbol, free(_:)
53-
"_Builtin_stddef_max_align_t", // contains only two symbols
54-
"_InternalStaticMirror", // unbuildable
55-
"_InternalSwiftScan", // unbuildable
56-
"_SwiftConcurrencyShims", // contains only two symbols
57-
"std": // unbuildable
58-
return
40+
guard
41+
let id:SymbolGraphPart.ID = .init("\(filename)")
42+
else
43+
{
44+
continue
45+
}
46+
47+
switch id.namespace
48+
{
49+
case "CDispatch", // too low-level
50+
"CFURLSessionInterface", // too low-level
51+
"CFXMLInterface", // too low-level
52+
"CoreFoundation", // too low-level
53+
"Glibc", // linux-gnu specific
54+
"SwiftGlibc", // linux-gnu specific
55+
"SwiftOnoneSupport", // contains no symbols
56+
"SwiftOverlayShims", // too low-level
57+
"SwiftShims", // contains no symbols
58+
"_Builtin_intrinsics", // contains only one symbol, free(_:)
59+
"_Builtin_stddef_max_align_t", // contains only two symbols
60+
"_InternalStaticMirror", // unbuildable
61+
"_InternalSwiftScan", // unbuildable
62+
"_SwiftConcurrencyShims", // contains only two symbols
63+
"std": // unbuildable
64+
continue
5965

60-
default:
61-
$0[id.culture, default: []].append(id)
66+
default:
67+
$0[id.culture, default: .init(location: $1)].parts.append(id)
68+
}
6269
}
6370
}
6471

65-
return .init(location: location, modules: symbols)
72+
return .init(modules: symbols)
6673
}
6774
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import SymbolGraphParts
2+
import System
3+
4+
extension SSGC
5+
{
6+
struct SymbolFiles
7+
{
8+
let location:FilePath.Directory
9+
var parts:[SymbolGraphPart.ID]
10+
11+
init(location:FilePath.Directory, parts:[SymbolGraphPart.ID] = [])
12+
{
13+
self.location = location
14+
self.parts = parts
15+
}
16+
}
17+
}

Sources/SymbolGraphBuilder/Builds/SSGC.DocumentationBuild.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extension SSGC
77
{
88
mutating
99
func compile(updating status:SSGC.StatusStream?,
10-
into artifacts:FilePath.Directory,
10+
cache:FilePath.Directory,
1111
with swift:Toolchain,
1212
clean:Bool) throws -> (SymbolGraphMetadata, any DocumentationSources)
1313
}

0 commit comments

Comments
 (0)