Skip to content

Commit 322bbb0

Browse files
committed
we need to use absolute paths here, to prevent IndexStoreDB from crashing
1 parent dfd3e76 commit 322bbb0

File tree

5 files changed

+46
-34
lines changed

5 files changed

+46
-34
lines changed

Sources/SymbolGraphBuilder/Builds/SSGC.PackageBuild.swift

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -119,31 +119,18 @@ extension SSGC.PackageBuild
119119
as type:SSGC.ProjectType = .package,
120120
flags:Flags = .init()) -> Self
121121
{
122+
/// The projects path could be absolute or relative. If it’s relative, we need to
123+
/// convert it to an absolute path.
124+
let projects:FilePath.Directory = projects.absolute()
122125
let project:FilePath.Directory = projects / "\(projectName)"
123126
let scratch:SSGC.PackageBuildDirectory = .init(configuration: .debug,
124127
location: project / scratchName)
125128

126-
if project.path.isAbsolute
127-
{
128-
return .init(id: .unversioned(projectName),
129-
scratch: scratch,
130-
flags: flags,
131-
root: project,
132-
type: type)
133-
}
134-
else if
135-
let current:FilePath.Directory = .current()
136-
{
137-
return .init(id: .unversioned(projectName),
138-
scratch: scratch,
139-
flags: flags,
140-
root: .init(path: current.path.appending(project.path.components)),
141-
type: type)
142-
}
143-
else
144-
{
145-
fatalError("Couldn’t determine the current working directory.")
146-
}
129+
return .init(id: .unversioned(projectName),
130+
scratch: scratch,
131+
flags: flags,
132+
root: project,
133+
type: type)
147134
}
148135

149136
/// Clones or pulls the specified package from a git repository, checking out

Sources/SymbolGraphBuilder/Builds/SSGC.PackageBuildDirectory.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ extension SSGC
1010

1111
init(configuration:PackageBuildConfiguration, location:FilePath.Directory)
1212
{
13+
guard location.path.isAbsolute
14+
else
15+
{
16+
fatalError("""
17+
Package build directory must be an absolute path,
18+
for IndexStoreDB compatibility!
19+
""")
20+
}
21+
1322
self.configuration = configuration
1423
self.location = location
1524
}

Sources/SymbolGraphBuilder/Builds/SSGC.Workspace.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,7 @@ extension SSGC.Workspace
3131
private
3232
init(location:FilePath.Directory)
3333
{
34-
if location.path.isAbsolute
35-
{
36-
self.init(absolute: location)
37-
}
38-
else if
39-
let current:FilePath.Directory = .current()
40-
{
41-
self.init(absolute: .init(path: current.path.appending(location.path.components)))
42-
}
43-
else
44-
{
45-
fatalError("Couldn’t determine the current working directory.")
46-
}
34+
self.init(absolute: location.absolute())
4735
}
4836

4937
public static
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import System
2+
3+
extension FilePath
4+
{
5+
func absolute() -> Self
6+
{
7+
if self.isAbsolute
8+
{
9+
return self
10+
}
11+
else if
12+
let current:FilePath.Directory = .current()
13+
{
14+
return current.path.appending(self.components)
15+
}
16+
else
17+
{
18+
fatalError("Couldn’t determine the current working directory!")
19+
}
20+
}
21+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import System
2+
3+
extension FilePath.Directory
4+
{
5+
func absolute() -> Self { .init(path: self.path.absolute()) }
6+
}
7+

0 commit comments

Comments
 (0)