mirror of
https://github.com/enso-org/enso.git
synced 2025-01-03 17:14:33 +03:00
Generate index when invoking buildStdLib
tasks (#6000)
The change adds support for generating suggestions and bindings when using the convenient task for building individual stdlib components. By default commands do not generate index since it adds build time. But `buildStdLibAllWithIndex` will. Closes #5999.
This commit is contained in:
parent
d1c52fef0b
commit
49e2c5ac1b
32
build.sbt
32
build.sbt
@ -2137,8 +2137,9 @@ runEngineDistribution := {
|
||||
)
|
||||
}
|
||||
|
||||
val allStdBitsSuffix = List("All", "AllWithIndex")
|
||||
val stdBitsProjects =
|
||||
List("Base", "Database", "Google_Api", "Image", "Table", "All")
|
||||
List("Base", "Database", "Google_Api", "Image", "Table") ++ allStdBitsSuffix
|
||||
val allStdBits: Parser[String] =
|
||||
stdBitsProjects.map(v => v: Parser[String]).reduce(_ | _)
|
||||
|
||||
@ -2168,10 +2169,12 @@ buildStdLib := Def.inputTaskDyn {
|
||||
|
||||
lazy val pkgStdLibInternal = inputKey[Unit]("Use `buildStdLib`")
|
||||
pkgStdLibInternal := Def.inputTask {
|
||||
val cmd = allStdBits.parsed
|
||||
val root = engineDistributionRoot.value
|
||||
val log: sbt.Logger = streams.value.log
|
||||
val cacheFactory = streams.value.cacheStoreFactory
|
||||
val cmd = allStdBits.parsed
|
||||
val root = engineDistributionRoot.value
|
||||
val log: sbt.Logger = streams.value.log
|
||||
val cacheFactory = streams.value.cacheStoreFactory
|
||||
val standardNamespace = "Standard"
|
||||
val buildAllCmd = allStdBitsSuffix.contains(cmd)
|
||||
cmd match {
|
||||
case "Base" =>
|
||||
(`std-base` / Compile / packageBin).value
|
||||
@ -2185,7 +2188,7 @@ pkgStdLibInternal := Def.inputTask {
|
||||
(`std-table` / Compile / packageBin).value
|
||||
case "TestHelpers" =>
|
||||
(`enso-test-java-helpers` / Compile / packageBin).value
|
||||
case "All" =>
|
||||
case _ if buildAllCmd =>
|
||||
(`std-base` / Compile / packageBin).value
|
||||
(`enso-test-java-helpers` / Compile / packageBin).value
|
||||
(`std-table` / Compile / packageBin).value
|
||||
@ -2195,13 +2198,14 @@ pkgStdLibInternal := Def.inputTask {
|
||||
case _ =>
|
||||
}
|
||||
val libs =
|
||||
if (cmd != "All") Seq(cmd)
|
||||
if (!buildAllCmd) Seq(cmd)
|
||||
else {
|
||||
val prefix = "Standard."
|
||||
val prefix = s"$standardNamespace."
|
||||
Editions.standardLibraries
|
||||
.filter(_.startsWith(prefix))
|
||||
.map(_.stripPrefix(prefix))
|
||||
}
|
||||
val generateIndex = cmd.endsWith("WithIndex")
|
||||
libs.foreach { lib =>
|
||||
StdBits.buildStdLibPackage(
|
||||
lib,
|
||||
@ -2210,6 +2214,18 @@ pkgStdLibInternal := Def.inputTask {
|
||||
log,
|
||||
defaultDevEnsoVersion
|
||||
)
|
||||
if (generateIndex) {
|
||||
val stdlibStandardRoot = root / "lib" / standardNamespace
|
||||
DistributionPackage.indexStdLib(
|
||||
libMajor = stdlibStandardRoot,
|
||||
libName = stdlibStandardRoot / lib,
|
||||
stdLibVersion = defaultDevEnsoVersion,
|
||||
ensoVersion = defaultDevEnsoVersion,
|
||||
ensoExecutable = root / "bin" / "enso",
|
||||
cacheFactory = cacheFactory.sub("stdlib"),
|
||||
log = log
|
||||
)
|
||||
}
|
||||
}
|
||||
}.evaluated
|
||||
|
||||
|
@ -171,7 +171,7 @@ object DistributionPackage {
|
||||
javaVersion = javaVersion
|
||||
)
|
||||
|
||||
indexStdLib(
|
||||
indexStdLibs(
|
||||
stdLibVersion = targetStdlibVersion,
|
||||
ensoVersion = ensoVersion,
|
||||
stdLibRoot = distributionRoot / "lib",
|
||||
@ -181,7 +181,7 @@ object DistributionPackage {
|
||||
)
|
||||
}
|
||||
|
||||
def indexStdLib(
|
||||
def indexStdLibs(
|
||||
stdLibVersion: String,
|
||||
ensoVersion: String,
|
||||
stdLibRoot: File,
|
||||
@ -193,32 +193,55 @@ object DistributionPackage {
|
||||
libMajor <- stdLibRoot.listFiles()
|
||||
libName <- (stdLibRoot / libMajor.getName).listFiles()
|
||||
} yield {
|
||||
val cache = cacheFactory.make(s"$libName.$ensoVersion")
|
||||
val path = libName / ensoVersion
|
||||
Tracked.diffInputs(cache, FileInfo.lastModified)(
|
||||
path.globRecursive("*.enso").get().toSet
|
||||
) { diff =>
|
||||
if (diff.modified.nonEmpty) {
|
||||
log.info(s"Generating index for $libName")
|
||||
val command = Seq(
|
||||
Platform.executableFileName(ensoExecutable.toString),
|
||||
"--no-compile-dependencies",
|
||||
"--no-global-cache",
|
||||
"--compile",
|
||||
path.toString
|
||||
)
|
||||
log.debug(command.mkString(" "))
|
||||
val exitCode = Process(
|
||||
command,
|
||||
None,
|
||||
"JAVA_OPTS" -> "-Dorg.jline.terminal.dumb=true"
|
||||
).!
|
||||
if (exitCode != 0) {
|
||||
throw new RuntimeException(s"Cannot compile $libMajor.$libName.")
|
||||
}
|
||||
} else {
|
||||
println(s"No modified files. Not generating index for ${libName} ")
|
||||
indexStdLib(
|
||||
libMajor,
|
||||
libName,
|
||||
stdLibVersion,
|
||||
ensoVersion,
|
||||
ensoExecutable,
|
||||
cacheFactory,
|
||||
log
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def indexStdLib(
|
||||
libMajor: File,
|
||||
libName: File,
|
||||
stdLibVersion: String,
|
||||
ensoVersion: String,
|
||||
ensoExecutable: File,
|
||||
cacheFactory: CacheStoreFactory,
|
||||
log: Logger
|
||||
): Unit = {
|
||||
object FileOnlyFilter extends sbt.io.FileFilter {
|
||||
def accept(arg: File): Boolean = arg.isFile
|
||||
}
|
||||
val cache = cacheFactory.make(s"$libName.$ensoVersion")
|
||||
val path = libName / ensoVersion
|
||||
Tracked.diffInputs(cache, FileInfo.lastModified)(
|
||||
path.globRecursive("*.enso" && FileOnlyFilter).get().toSet
|
||||
) { diff =>
|
||||
if (diff.modified.nonEmpty) {
|
||||
log.info(s"Generating index for ${libName} ")
|
||||
val command = Seq(
|
||||
Platform.executableFileName(ensoExecutable.toString),
|
||||
"--no-compile-dependencies",
|
||||
"--no-global-cache",
|
||||
"--compile",
|
||||
path.toString
|
||||
)
|
||||
log.debug(command.mkString(" "))
|
||||
val exitCode = Process(
|
||||
command,
|
||||
None,
|
||||
"JAVA_OPTS" -> "-Dorg.jline.terminal.dumb=true"
|
||||
).!
|
||||
if (exitCode != 0) {
|
||||
throw new RuntimeException(s"Cannot compile $libMajor.$libName.")
|
||||
}
|
||||
} else {
|
||||
log.info(s"No modified files. Not generating index for ${libName} ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user