Skip to content

Commit 96c3957

Browse files
committed
Make scaladoc a bootstrapped-only project
Previously, we had both a non-bootstrapped and bootstrapped version of that project as well as its dependencies (scala3-library-js, scala3-tasty-inspector, scaladoc-testcases, scaladoc-js), the main reason for this is that it allowed the non-boostrapped scaladoc to be part of the `scalaInstance` of all bootstrapped projects, allowing us to run `scala3-library-bootstrapped/doc` for example. But this also meant that simply trying to run the compiler would compiler scaladoc as well as its dependencies even if no documentation needed to be generated, and since `scaladoc-js` runs the Scala.js optimizer this could be quite slow. This commit fixes that by using a separate `scalaInstance` for the `doc` task, which means the regular `scalaInstance` no longer needs to depend on scaladoc and also allows us to remove all the non-bootstrapped projects related to scaladoc (thus simplifying the build a lot) since we can safely use the bootstrapped version in `doc / scalaInstance` without running into a loop.
1 parent 83acd4b commit 96c3957

File tree

4 files changed

+194
-235
lines changed

4 files changed

+194
-235
lines changed

build.sbt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ val `scala3-interfaces` = Build.`scala3-interfaces`
44
val `scala3-compiler` = Build.`scala3-compiler`
55
val `scala3-compiler-bootstrapped` = Build.`scala3-compiler-bootstrapped`
66
val `scala3-library` = Build.`scala3-library`
7-
val `scala3-library-js` = Build.`scala3-library-js`
87
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
98
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`
109
val `scala3-sbt-bridge` = Build.`scala3-sbt-bridge`
1110
val `scala3-sbt-bridge-tests` = Build.`scala3-sbt-bridge-tests`
1211
val `scala3-staging` = Build.`scala3-staging`
1312
val `scala3-tasty-inspector` = Build.`scala3-tasty-inspector`
14-
val `scala3-tasty-inspector-nonbootstrapped` = Build.`scala3-tasty-inspector-nonbootstrapped`
1513
val `scala3-language-server` = Build.`scala3-language-server`
1614
val `scala3-bench` = Build.`scala3-bench`
1715
val `scala3-bench-bootstrapped` = Build.`scala3-bench-bootstrapped`
@@ -21,11 +19,8 @@ val `tasty-core` = Build.`tasty-core`
2119
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
2220
val `tasty-core-scala2` = Build.`tasty-core-scala2`
2321
val scaladoc = Build.scaladoc
24-
val `scaladoc-nonBootstrapped` = Build.`scaladoc-nonBootstrapped`
2522
val `scaladoc-testcases` = Build.`scaladoc-testcases`
26-
val `scaladoc-testcases-nonBootstrapped` = Build.`scaladoc-testcases-nonBootstrapped`
2723
val `scaladoc-js` = Build.`scaladoc-js`
28-
val `scaladoc-js-nonBootstrapped` = Build.`scaladoc-js-nonBootstrapped`
2924
val `scala3-bench-run` = Build.`scala3-bench-run`
3025
val dist = Build.dist
3126
val `community-build` = Build.`community-build`

project/Bootstrap.scala

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,51 @@ import sbt.internal.inc.ScalaInstance
55

66
// This class needs to be in package sbt to access the ClassLoaderCache
77
object Bootstrap {
8+
/** A ScalaInstance (without scaladoc). */
89
def makeScalaInstance(
910
state: State,
1011
version: String,
1112
libraryJars: Array[File],
1213
compilerJars: Array[File],
13-
docJars: Array[File],
1414
topLoader: ClassLoader
1515
): ScalaInstance = {
1616
// `extendedClassLoaderCache` is package private in package sbt
1717
val cache = state.extendedClassLoaderCache
1818

1919
val libraryLoader = cache(libraryJars.toList, topLoader)
2020
val compilerLoader = cache(compilerJars.toList, libraryLoader)
21-
val fullLoader = cache(docJars.toList, compilerLoader)
2221

2322
new ScalaInstance(
2423
version = version,
25-
loader = fullLoader,
24+
loader = compilerLoader,
2625
loaderCompilerOnly = compilerLoader,
2726
loaderLibraryOnly = libraryLoader,
2827
libraryJars = libraryJars,
2928
compilerJars = compilerJars,
30-
allJars = libraryJars ++ compilerJars ++ docJars,
29+
allJars = libraryJars ++ compilerJars,
3130
explicitActual = Some(version)
3231
)
3332
}
34-
}
33+
34+
/** A ScalaInstance identical to `base` but with additional jars for scaladoc. */
35+
def makeDocScalaInstance(
36+
state: State,
37+
base: ScalaInstance,
38+
docJars: Array[File]
39+
): ScalaInstance = {
40+
val cache = state.extendedClassLoaderCache
41+
42+
val fullLoader = cache(docJars.toList, base.loaderCompilerOnly)
43+
44+
new ScalaInstance(
45+
version = base.version,
46+
loader = fullLoader,
47+
loaderCompilerOnly = base.loaderCompilerOnly,
48+
loaderLibraryOnly = base.loaderLibraryOnly,
49+
libraryJars = base.libraryJars,
50+
compilerJars = base.compilerJars,
51+
allJars = base.allJars ++ docJars,
52+
explicitActual = base.explicitActual
53+
)
54+
}
55+
}

0 commit comments

Comments
 (0)