depot/third_party/nixpkgs/pkgs/development/compilers/openjdk/openjfx/22.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

137 lines
3.8 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, fetchurl
, runCommand
, writeText
, openjdk21_headless
, gradle
, pkg-config
, perl
, cmake
, gperf
, gtk2
, gtk3
, libXtst
, libXxf86vm
, glib
, alsa-lib
, ffmpeg_4
, python3
, ruby
, withMedia ? true
, withWebKit ? false
}:
let
major = "22";
update = ".0.1";
build = "-ga";
repover = "${major}${update}${build}";
icuVersionWithSep = s: "73${s}1";
icuPath = "download/release-${icuVersionWithSep "-"}/icu4c-${icuVersionWithSep "_"}-data-bin-l.zip";
icuData = fetchurl {
url = "https://github.com/unicode-org/icu/releases/${icuPath}";
hash = "sha256-QDgpjuAqDDiRcYXvj/Tr3pyLVSx3f9A+TfbGtLGCXiA=";
};
icuFakeRepository = runCommand "icu-data-repository" {} ''
install -Dm644 ${icuData} $out/${icuPath}
'';
makePackage = args: stdenv.mkDerivation ({
version = "${major}${update}${build}";
src = fetchFromGitHub {
owner = "openjdk";
repo = "jfx22u";
rev = repover;
hash = "sha256-VoEufSO+LciUCvoAM86MG1iMjCA3FSb60Ik4OP2Rk/Q=";
};
buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg_4 ];
nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ];
dontUseCmakeConfigure = true;
config = writeText "gradle.properties" (''
CONF = Release
JDK_HOME = ${openjdk21_headless.home}
'' + args.gradleProperties or "");
buildPhase = ''
runHook preBuild
export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
export GRADLE_USER_HOME=$(mktemp -d)
ln -s $config gradle.properties
export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
gradle --no-daemon --console=plain $gradleFlags sdk
runHook postBuild
'';
} // args);
# Fake build to pre-download deps into fixed-output derivation.
# We run nearly full build because I see no other way to download everything that's needed.
# Anyone who knows a better way?
deps = makePackage {
pname = "openjfx-deps";
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
installPhase = ''
find $GRADLE_USER_HOME -type f -regex '.*/modules.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
rm -rf $out/tmp
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-2I7LvYcudlB4DKJ/wEiTjY6nICUxUY52euosUqOA+Bs=";
};
in
makePackage {
pname = "openjfx-modular-sdk";
gradleProperties = ''
COMPILE_MEDIA = ${lib.boolToString withMedia}
COMPILE_WEBKIT = ${lib.boolToString withWebKit}
${lib.optionalString withWebKit "icuRepositoryURL = file://${icuFakeRepository}"}
'';
preBuild = ''
swtJar="$(find ${deps} -name org.eclipse.swt\*.jar)"
substituteInPlace build.gradle \
--replace 'mavenCentral()' 'mavenLocal(); maven { url uri("${deps}") }' \
--replace 'name: SWT_FILE_NAME' "files('$swtJar')"
'';
installPhase = ''
cp -r build/modular-sdk $out
'';
stripDebugList = [ "." ];
postFixup = ''
# Remove references to bootstrap.
export openjdkOutPath='${openjdk21_headless.outPath}'
find "$out" -name \*.so | while read lib; do
new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E[^:]*,,')"
patchelf --set-rpath "$new_refs" "$lib"
done
'';
disallowedReferences = [ openjdk21_headless openjdk21_headless ];
passthru.deps = deps;
meta = with lib; {
homepage = "https://openjdk.org/projects/openjfx/";
license = licenses.gpl2Classpath;
description = "Next-generation Java client toolkit";
maintainers = with maintainers; [ abbradar ];
platforms = platforms.unix;
};
}