Fix bundled GraalVM path (#7948)

close #7871
close #7698

Changelog:
- fix: the `run` script logic to place the GraalVM runtime in the expected directory when building the bundle
- fix: the `makeBundles` SBT logic to place the GraalVM runtime in the expected directory
This commit is contained in:
Dmitry Bushev 2023-10-06 19:49:57 +01:00 committed by GitHub
parent 9ba7be20af
commit f348083dfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 14 deletions

View File

@ -20,8 +20,7 @@ import java.io.File
// ============================================================================
val scalacVersion = "2.13.11"
// Since the release of GraalVM 23.0.0, the versioning is the same for Graal and OpenJDK.
val graalVersion = "17.0.7"
val graalVersion = "17.0.7"
// Version used for the Graal/Truffle related Maven packages
val graalMavenPackagesVersion = "23.0.0"
val targetJavaVersion = graalVersion.split("\\.")(0)

View File

@ -4,6 +4,7 @@
use crate::prelude::*;
use crate::get_graal_packages_version;
use crate::get_graal_version;
use crate::paths::generated;
@ -26,6 +27,7 @@ pub mod env;
pub mod package;
pub mod sbt;
use crate::engine::bundle::GraalVmVersion;
pub use context::RunContext;
@ -310,3 +312,13 @@ pub async fn deduce_graal(
arch: TARGET_ARCH,
})
}
pub async fn deduce_graal_bundle(
build_sbt: &generated::RepoRootBuildSbt,
) -> Result<GraalVmVersion> {
let build_sbt_content = ide_ci::fs::tokio::read_to_string(build_sbt).await?;
Ok(GraalVmVersion {
graal: get_graal_version(&build_sbt_content)?,
packages: get_graal_packages_version(&build_sbt_content)?,
})
}

View File

@ -7,6 +7,15 @@ use ide_ci::cache::goodie::graalvm::locate_graal;
/// Version of the bundled GraalVM.
#[derive(Clone, Debug)]
pub struct GraalVmVersion {
/// Version of the GraalVM runtime. Corresponds to the `graalVersion` in build.sbt.
pub graal: Version,
/// Version of the Maven packages. Corresponds to the `graalMavenPackagesVersion` in build.sbt.
pub packages: Version,
}
/// Bundle is like a [package][crate::paths::IsPackage] but with additional components bundled to
/// make it redistributable.
///
@ -42,7 +51,11 @@ pub trait IsBundle: AsRef<Path> + IsArtifact {
/// ```text
/// H:\NBO\enso\built-distribution\enso-engine-0.0.0-SNAPSHOT.2022-01-19-windows-amd64\enso-0.0.0-SNAPSHOT.2022-01-19
/// ```
fn create(&self, repo_root: &RepoRoot) -> BoxFuture<'static, Result> {
fn create(
&self,
repo_root: &RepoRoot,
graal_version: &GraalVmVersion,
) -> BoxFuture<'static, Result> {
let bundle_dir = self.as_ref().to_path_buf();
let base_component = self.base_component(repo_root);
let engine_src_path =
@ -50,6 +63,7 @@ pub trait IsBundle: AsRef<Path> + IsArtifact {
let engine_target_dir = self.engine_dir();
let graalvm_dir = self.graalvm_dir();
let distribution_marker = self.distribution_marker();
let graalvm_version = graal_version.clone();
async move {
ide_ci::fs::tokio::remove_dir_if_exists(&bundle_dir).await?;
@ -58,7 +72,7 @@ pub trait IsBundle: AsRef<Path> + IsArtifact {
// Add engine.
ide_ci::fs::mirror_directory(&engine_src_path, &engine_target_dir).await?;
// Add GraalVM runtime.
place_graal_under(graalvm_dir).await?;
place_graal_under(graalvm_dir, &graalvm_version).await?;
// Add portable distribution marker.
ide_ci::fs::create(distribution_marker)?;
Ok(())
@ -111,8 +125,12 @@ impl IsBundle for crate::paths::generated::LauncherBundle {
///
/// The GraalVM installation will be located using [`locate_graal`] function.
#[context("Failed to place a GraalVM package under {}.", target_directory.as_ref().display())]
pub async fn place_graal_under(target_directory: impl AsRef<Path>) -> Result {
pub async fn place_graal_under(
target_directory: impl AsRef<Path>,
graal_version: &GraalVmVersion,
) -> Result {
let graal_path = locate_graal()?;
let graal_dirname = graal_path.try_file_name()?;
let graal_dirname =
format!("graalvm-ce-java{}-{}", graal_version.graal, graal_version.packages);
ide_ci::fs::mirror_directory(&graal_path, target_directory.as_ref().join(graal_dirname)).await
}

View File

@ -579,8 +579,9 @@ impl RunContext {
}
}
let graal_version = crate::engine::deduce_graal_bundle(&self.repo_root.build_sbt).await?;
for bundle in ret.bundles() {
bundle.create(&self.repo_root).await?;
bundle.create(&self.repo_root, &graal_version).await?;
}
Ok(ret)

View File

@ -106,6 +106,11 @@ pub fn get_graal_version(build_sbt_contents: &str) -> Result<Version> {
get_string_assignment_value(build_sbt_contents, "graalVersion")?.parse2()
}
/// Get version of GraalVM packages from the `build.sbt` file contents.
pub fn get_graal_packages_version(build_sbt_contents: &str) -> Result<Version> {
get_string_assignment_value(build_sbt_contents, "graalMavenPackagesVersion")?.parse2()
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -45,6 +45,7 @@ use anyhow::Context;
use arg::BuildDescription;
use clap::Parser;
use derivative::Derivative;
use enso_build::config::Config;
use enso_build::context::BuildContext;
use enso_build::engine::context::EnginePackageProvider;
use enso_build::engine::Benchmarks;
@ -795,11 +796,11 @@ impl WatchResolvable for Gui {
}
#[tracing::instrument(err, skip(config))]
pub async fn main_internal(config: Option<enso_build::config::Config>) -> Result {
pub async fn main_internal(config: Option<Config>) -> Result {
trace!("Starting the build process.");
let config = config.unwrap_or_else(|| {
warn!("No config provided, using default config.");
enso_build::config::Config::default()
Config::default()
});
trace!("Creating the build context.");
@ -958,7 +959,7 @@ pub async fn main_internal(config: Option<enso_build::config::Config>) -> Result
Ok(())
}
pub fn lib_main(config: Option<enso_build::config::Config>) -> Result {
pub fn lib_main(config: Option<Config>) -> Result {
trace!("Starting the tokio runtime.");
let rt = tokio::runtime::Runtime::new()?;
trace!("Entering main.");

View File

@ -551,8 +551,8 @@ object DistributionPackage {
if (!packageDir.exists()) {
IO.createDirectory(packageDir)
}
val archiveName = s"graalvm-${os.name}-${architecture.name}-" +
s"$graalVersion-$graalJavaVersion"
val archiveName =
s"graalvm-${os.name}-${architecture.name}-$graalVersion-$graalJavaVersion"
packageDir / (archiveName + os.archiveExt)
}
@ -848,7 +848,11 @@ object DistributionPackage {
if (launcher.exists()) {
fixLauncher(launcher, os)
copyEngine(os, arch, launcher / "enso" / "dist")
copyGraal(os, arch, launcher / "enso" / "runtime")
copyGraal(
os,
arch,
launcher / "enso" / "runtime" / s"graalvm-ce-java$graalJavaVersion-$graalVersion/"
)
val archive = builtArchive("bundle", os, arch)
makeArchive(launcher, "enso", archive)
@ -866,7 +870,11 @@ object DistributionPackage {
}
copyEngine(os, arch, pm / "enso" / "dist")
copyGraal(os, arch, pm / "enso" / "runtime")
copyGraal(
os,
arch,
pm / "enso" / "runtime" / s"graalvm-ce-java$graalJavaVersion-$graalVersion/"
)
IO.copyFile(
file("distribution/enso.bundle.template"),