graalvmXX-ce: add review suggestions

Co-authored-by: Thiago Kenji Okada <thiagokokada@gmail.com>
This commit is contained in:
Thibault Gagnaux 2022-04-02 10:54:44 +02:00
parent 440d4f9ff7
commit bfc501493f
No known key found for this signature in database
GPG key ID: 44BD0764ACAE8E25
2 changed files with 34 additions and 42 deletions

View file

@ -44,7 +44,7 @@ let
version = platform.version; version = platform.version;
name = "graalvm${javaVersion}-ce"; name = "graalvm${javaVersion}-ce";
sourcesFilename = "${name}-sources.json"; sourcesFilename = "${name}-sources.json";
sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}")); sources = builtins.fromJSON (builtins.readFile (./${sourcesFilename}));
runtimeLibraryPath = lib.makeLibraryPath runtimeLibraryPath = lib.makeLibraryPath
([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]); ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]);
@ -132,48 +132,40 @@ let
outputs = [ "out" "lib" ]; outputs = [ "out" "lib" ];
installPhase = installPhase = ''
let # ensure that $lib/lib exists to avoid breaking builds
copyClibrariesToOut = basepath: '' mkdir -p $lib/lib
# provide libraries needed for static compilation # jni.h expects jni_md.h to be in the header search path.
${ ln -s $out/include/linux/*_md.h $out/include/
if useMusl then
"for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do"
else
"for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do"
}
ln -s $f ${basepath}/${platform.arch}/$(basename $f)
done
'';
copyClibrariesToLib = ''
# add those libraries to $lib output too, so we can use them with
# `native-image -H:CLibraryPath=''${lib.getLib graalvm11-ce}/lib ...` and reduce
# closure size by not depending on GraalVM $out (that is much bigger)
mkdir -p $lib/lib
for f in ${glibc}/lib/*; do
ln -s $f $lib/lib/$(basename $f)
done
'';
in
''
# ensure that $lib/lib exists to avoid breaking builds
mkdir -p $lib/lib
# jni.h expects jni_md.h to be in the header search path.
ln -s $out/include/linux/*_md.h $out/include/
# copy-paste openjdk's preFixup # copy-paste openjdk's preFixup
# Set JAVA_HOME automatically. # Set JAVA_HOME automatically.
mkdir -p $out/nix-support mkdir -p $out/nix-support
cat > $out/nix-support/setup-hook << EOF cat > $out/nix-support/setup-hook << EOF
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
EOF EOF
${
lib.optionalString (stdenv.isLinux) ''
# provide libraries needed for static compilation
${ ${
lib.optionalString (stdenv.isLinux) '' if useMusl then
${copyClibrariesToOut "$out/lib/svm/clibraries"} "for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do"
${copyClibrariesToLib} else
'' "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do"
} }
''; ln -s $f $out/lib/svm/clibraries/${platform.arch}/$(basename $f)
done
# add those libraries to $lib output too, so we can use them with
# `native-image -H:CLibraryPath=''${lib.getLib graalvmXX-ce}/lib ...` and reduce
# closure size by not depending on GraalVM $out (that is much bigger)
mkdir -p $lib/lib
for f in ${glibc}/lib/*; do
ln -s $f $lib/lib/$(basename $f)
done
''
}
'';
dontStrip = true; dontStrip = true;

View file

@ -183,7 +183,7 @@ let
newVersion = getLatestVersion graalVersion; newVersion = getLatestVersion graalVersion;
sourcesJson = genSources javaVersion config; sourcesJson = genSources javaVersion config;
sourcesJsonPath = lib.strings.escapeShellArg ././${sourcesFilename}; sourcesJsonPath = lib.strings.escapeShellArg ./${sourcesFilename};
# versionKeyInDefaultNix String -> String # versionKeyInDefaultNix String -> String
versionKeyInDefaultNix = graalVersion: versionKeyInDefaultNix = graalVersion:
@ -208,7 +208,7 @@ let
export PATH="${lib.makeBinPath [ jq gnused ]}:$PATH" export PATH="${lib.makeBinPath [ jq gnused ]}:$PATH"
jq . ${sourcesJson} > ${sourcesJsonPath} jq . ${sourcesJson} > ${sourcesJsonPath}
sed -i 's|${versionKey} = "${currentVersion}";|${versionKey} = "${newVersion}";|' \ sed -i 's|${versionKey} = "${currentVersion}";|${versionKey} = "${newVersion}";|' \
${lib.strings.escapeShellArg ././default.nix} ${lib.strings.escapeShellArg ./default.nix}
'' ''
else ''echo "No new version found. Skip updating."''; else ''echo "No new version found. Skip updating."'';