graalvmCEPackages.buildGraalvmProduct: add passthru.graalvmPhases

This way it is easier to differentiate between phases running in the
`buildGraalvmProduct` and `buildGraalvm`.
This commit is contained in:
Thiago Kenji Okada 2023-02-14 16:01:43 +00:00
parent 140046c422
commit acf8579307
7 changed files with 30 additions and 18 deletions

View file

@ -23,10 +23,10 @@
let
runtimeLibraryPath = lib.makeLibraryPath
([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]);
mapProducts = key: default: (map (p: p.${key} or default) products);
mapProducts = key: default: (map (p: p.graalvmPhases.${key} or default) products);
concatProducts = key: lib.concatStringsSep "\n" (mapProducts key "");
graalvmXXX-ce = stdenv.mkDerivation (args // {
graalvmXXX-ce = stdenv.mkDerivation ({
pname = "graalvm${javaVersion}-ce";
unpackPhase = ''
@ -146,5 +146,5 @@ let
mainProgram = "java";
maintainers = with maintainers; teams.graalvm-ce.members ++ [ ];
} // meta);
});
} // (builtins.removeAttrs args [ "javaVersion" "meta" "products" ]));
in graalvmXXX-ce

View file

@ -9,13 +9,14 @@
}:
{ product
, javaVersion
, extraNativeBuildInputs ? [ ]
, extraBuildInputs ? [ ]
, extraNativeBuildInputs ? [ ]
, graalvmPhases ? { }
, meta ? { }
, passthru ? { }
, ... } @ args:
stdenv.mkDerivation (args // {
stdenv.mkDerivation ({
pname = "${product}-java${javaVersion}";
nativeBuildInputs = [ perl unzip makeWrapper ]
@ -56,16 +57,27 @@ stdenv.mkDerivation (args // {
dontInstall = true;
dontBuild = true;
dontStrip = true;
# installCheckPhase is going to run in GraalVM main derivation (see buildGraalvm.nix)
# to make sure that it has everything it needs to run correctly.
# Other hooks like fixupPhase/installPhase are also going to run there for the
# same reason.
doInstallCheck = false;
passthru = { inherit product; } // passthru;
passthru = {
inherit product javaVersion;
# build phases that are going to run during GraalVM derivation build,
# since they depend in having the fully setup GraalVM environment
# e.g.: graalvmPhases.installCheckPhase will run the checks only after
# GraalVM+products is build
# see buildGraalvm.nix file for the available phases
inherit graalvmPhases;
} // passthru;
meta = with lib; ({
inherit (graalvm-ce.meta) homepage license sourceProvenance maintainers platforms;
description = "High-Performance Polyglot VM (Product: ${product})";
} // meta);
})
} // (builtins.removeAttrs args [
"product"
"javaVersion"
"extraBuildInputs"
"extraNativeBuildInputs"
"graalvmPhases"
"meta"
"passthru"
]))

View file

@ -15,7 +15,7 @@ graalvmCEPackages.buildGraalvmProduct rec {
'';
# TODO: improve this test
installCheckPhase = ''
graalvmPhases.installCheckPhase = ''
echo "Testing llvm"
$out/bin/lli --help
'';

View file

@ -27,14 +27,14 @@ graalvmCEPackages.buildGraalvmProduct rec {
inherit src javaVersion version;
product = "native-image-installable-svm";
postInstall = lib.optionalString stdenv.isLinux ''
graalvmPhases.postInstall = lib.optionalString stdenv.isLinux ''
wrapProgram $out/bin/native-image \
--prefix PATH : ${binPath} \
${lib.concatStringsSep " "
(map (l: "--add-flags '-H:CLibraryPath=${l}/lib'") cLibs)}
'';
installCheckPhase = ''
graalvmPhases.installCheckPhase = ''
echo "Ahead-Of-Time compilation"
$out/bin/native-image -H:-CheckToolchain -H:+ReportExceptionStackTraces HelloWorld
./helloworld | fgrep 'Hello World'

View file

@ -10,7 +10,7 @@ graalvmCEPackages.buildGraalvmProduct rec {
inherit src javaVersion version;
product = "python-installable-svm";
installCheckPhase = ''
graalvmPhases.installCheckPhase = ''
echo "Testing GraalPython"
$out/bin/graalpy -c 'print(1 + 1)'
echo '1 + 1' | $out/bin/graalpy

View file

@ -24,7 +24,7 @@ graalvmCEPackages.buildGraalvmProduct rec {
--replace-needed libcrypto.so.10 libcrypto.so
'';
installCheckPhase = ''
graalvmPhases.installCheckPhase = ''
echo "Testing TruffleRuby"
# Hide warnings about wrong locale
export LANG=C

View file

@ -12,7 +12,7 @@ graalvmCEPackages.buildGraalvmProduct rec {
product = "wasm-installable-svm";
# TODO: improve this test
installCheckPhase = ''
graalvmPhases.installCheckPhase = ''
echo "Testing wasm"
$out/bin/wasm --help
'';