Only single native image is built at a time (#11497)

#10783 introduced another definition of a buildnativeimage task. Since that time, our CI is transiently failing on out of memory error. This PR ensures that there can be just a single `buildNativeImage` task running at a time.

# Important Notes
Manually tested by running
```
sbt:enso> all engine-runner/buildNativeImage project-manager/buildNativeImage
```
And looking at spawn subprocesses. On develop, I have two `native-image` processes, on this PR, there is just a single one.
This commit is contained in:
Pavel Marek 2024-11-05 19:33:58 +01:00 committed by GitHub
parent 73abe909ef
commit 3df57557ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -106,6 +106,11 @@ ThisBuild / publish / skip := true
val simpleLibraryServerTag = Tags.Tag("simple-library-server") val simpleLibraryServerTag = Tags.Tag("simple-library-server")
Global / concurrentRestrictions += Tags.limit(simpleLibraryServerTag, 1) Global / concurrentRestrictions += Tags.limit(simpleLibraryServerTag, 1)
/** Tag limiting the concurrent spawning of `native-image` subprocess.
*/
val nativeImageBuildTag = NativeImage.nativeImageBuildTag
Global / concurrentRestrictions += Tags.limit(nativeImageBuildTag, 1)
lazy val gatherLicenses = lazy val gatherLicenses =
taskKey[Unit]( taskKey[Unit](
"Gathers licensing information for relevant dependencies of all distributions" "Gathers licensing information for relevant dependencies of all distributions"

View File

@ -49,6 +49,12 @@ object NativeImage {
val NATIVE_IMAGE_ARG_FILE = "native-image-args.txt" val NATIVE_IMAGE_ARG_FILE = "native-image-args.txt"
/** Tag limiting the concurrent access to `native-image` subprocess spawning, i.e.,
* there should be just a single such subprocess. This should ensure that we do
* not run out of memory.
*/
val nativeImageBuildTag = Tags.Tag("native-image-build")
/** Creates a task that builds a native image for the current project. /** Creates a task that builds a native image for the current project.
* *
* This task must be setup in such a way that the assembly JAR is built * This task must be setup in such a way that the assembly JAR is built
@ -262,6 +268,7 @@ object NativeImage {
} }
log.info(s"$targetLoc native image build successful.") log.info(s"$targetLoc native image build successful.")
} }
.tag(nativeImageBuildTag)
.dependsOn(Compile / compile) .dependsOn(Compile / compile)
/** Creates a task which watches for changes of any compiled files or /** Creates a task which watches for changes of any compiled files or