openjfx{17,21,23}: deduplicate into generic.nix

This commit is contained in:
Emily 2024-10-18 05:38:58 +01:00
parent 058999318f
commit f05216c373
11 changed files with 128 additions and 369 deletions

View File

@ -1,98 +0,0 @@
{ stdenv, lib, pkgs, fetchFromGitHub, writeText, openjdk17_headless, gradle_7
, pkg-config, perl, cmake, gperf, gtk2, gtk3, libXtst, libXxf86vm, glib, alsa-lib
, ffmpeg-headless, python3, ruby
, withMedia ? true
, withWebKit ? false
}:
let
pname = "openjfx-modular-sdk";
major = "17";
update = ".0.11";
build = "-ga";
repover = "${major}${update}${build}";
jdk = openjdk17_headless;
gradle = gradle_7;
in stdenv.mkDerivation {
inherit pname;
version = "${major}${update}${build}";
src = fetchFromGitHub {
owner = "openjdk";
repo = "jfx${major}u";
rev = repover;
sha256 = "sha256-9VfXk2EfMebMyVKPohPRP2QXRFf8XemUtfY0JtBCHyw=";
};
patches = [
../backport-ffmpeg-6-support-jfx11.patch
../backport-ffmpeg-7-support-jfx11.patch
];
buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg-headless ];
nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ];
dontUseCmakeConfigure = true;
config = writeText "gradle.properties" ''
CONF = Release
JDK_HOME = ${jdk.home}
COMPILE_MEDIA = ${lib.boolToString withMedia}
COMPILE_WEBKIT = ${lib.boolToString withWebKit}
'';
postPatch = ''
# Add missing includes for gcc-13 for webkit build:
sed -e '1i #include <cstdio>' \
-i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \
modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h
substituteInPlace modules/javafx.web/src/main/native/Source/JavaScriptCore/offlineasm/parser.rb \
--replace-fail "File.exists?" "File.exist?"
ln -s $config gradle.properties
'';
mitmCache = gradle.fetchDeps {
attrPath = "openjfx${major}";
pkg = pkgs."openjfx${major}".override { withWebKit = true; };
data = ./deps.json;
};
__darwinAllowLocalNetworking = true;
preBuild = ''
export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
'';
enableParallelBuilding = false;
gradleBuildTask = "sdk";
installPhase = ''
cp -r build/modular-sdk $out
'';
stripDebugList = [ "." ];
postFixup = ''
# Remove references to bootstrap.
export openjdkOutPath='${jdk.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 = [ jdk gradle.jdk ];
meta = with lib; {
homepage = "http://openjdk.java.net/projects/openjfx/";
license = licenses.gpl2;
description = "Next-generation Java client toolkit";
maintainers = with maintainers; [ abbradar ];
platforms = platforms.unix;
};
}

View File

@ -0,0 +1,6 @@
{
"owner": "openjdk",
"repo": "jfx17u",
"rev": "17.0.11-ga",
"sha256": "sha256-9VfXk2EfMebMyVKPohPRP2QXRFf8XemUtfY0JtBCHyw="
}

View File

@ -1,94 +0,0 @@
{ stdenv, lib, pkgs, fetchFromGitHub, writeText
, openjdk21_headless, gradle_7, pkg-config, perl, cmake, gperf, gtk2, gtk3, libXtst
, libXxf86vm, glib, alsa-lib, ffmpeg, python3, ruby
, withMedia ? true
, withWebKit ? false
}:
let
pname = "openjfx-modular-sdk";
major = "21";
update = ".0.3";
build = "-ga";
repover = "${major}${update}${build}";
jdk = openjdk21_headless;
gradle = gradle_7;
in stdenv.mkDerivation {
inherit pname;
version = "${major}${update}${build}";
src = fetchFromGitHub {
owner = "openjdk";
repo = "jfx21u";
rev = repover;
hash = "sha256-7z0GIbkQwG9mXY9dssaicqaKpMo3FkNEpyAvkswoQQ4=";
};
patches = [
../backport-ffmpeg-7-support-jfx21.patch
];
buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg ];
nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ];
dontUseCmakeConfigure = true;
config = writeText "gradle.properties" ''
CONF = Release
JDK_HOME = ${jdk.home}
COMPILE_MEDIA = ${lib.boolToString withMedia}
COMPILE_WEBKIT = ${lib.boolToString withWebKit}
'';
postPatch = ''
# Add missing includes for gcc-13 for webkit build:
sed -e '1i #include <cstdio>' \
-i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \
modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h
ln -s $config gradle.properties
'';
mitmCache = gradle.fetchDeps {
attrPath = "openjfx${major}";
pkg = pkgs."openjfx${major}".override { withWebKit = true; };
data = ./deps.json;
};
__darwinAllowLocalNetworking = true;
preBuild = ''
export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
'';
enableParallelBuilding = false;
gradleBuildTask = "sdk";
installPhase = ''
cp -r build/modular-sdk $out
'';
stripDebugList = [ "." ];
postFixup = ''
# Remove references to bootstrap.
export openjdkOutPath='${jdk.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 = [ jdk gradle.jdk ];
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;
};
}

View File

@ -0,0 +1,6 @@
{
"hash": "sha256-7z0GIbkQwG9mXY9dssaicqaKpMo3FkNEpyAvkswoQQ4=",
"owner": "openjdk",
"repo": "jfx21u",
"rev": "21.0.3-ga"
}

View File

@ -1,111 +0,0 @@
{ stdenv
, lib
, pkgs
, fetchFromGitHub
, fetchpatch2
, writeText
, openjdk23_headless
, gradle
, pkg-config
, perl
, cmake
, gperf
, gtk2
, gtk3
, libXtst
, libXxf86vm
, glib
, alsa-lib
, ffmpeg
, python3
, ruby
, withMedia ? true
, withWebKit ? false
}:
let
pname = "openjfx-modular-sdk";
major = "23";
update = "";
build = "-ga";
repover = "${major}${update}${build}";
jdk = openjdk23_headless;
in stdenv.mkDerivation {
inherit pname;
version = "${major}${update}${build}";
src = fetchFromGitHub {
owner = "openjdk";
repo = "jfx23u";
rev = repover;
hash = "sha256-a/ev91Rq7D3z9O56ZZQCgvvbfj5GBt5Lonow2NH3s/E=";
};
patches = [
# 8338701: Provide media support for libavcodec version 61
# <https://github.com/openjdk/jfx23u/pull/18>
(fetchpatch2 {
url = "https://github.com/openjdk/jfx23u/commit/aba60fda1c82f00e8e685107592305c403a31287.patch?full_index=1";
hash = "sha256-+aRhTwi4VQthAq1SH1jxPl0mTosNMKoTY52jm+jiKso=";
})
];
buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg ];
nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ];
dontUseCmakeConfigure = true;
config = writeText "gradle.properties" ''
CONF = Release
JDK_HOME = ${jdk.home}
COMPILE_MEDIA = ${lib.boolToString withMedia}
COMPILE_WEBKIT = ${lib.boolToString withWebKit}
'';
postPatch = ''
ln -s $config gradle.properties
'';
mitmCache = gradle.fetchDeps {
attrPath = "openjfx${major}";
pkg = pkgs."openjfx${major}".override { withWebKit = true; };
data = ./deps.json;
};
__darwinAllowLocalNetworking = true;
preBuild = ''
export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
'';
enableParallelBuilding = false;
gradleBuildTask = "sdk";
installPhase = ''
cp -r build/modular-sdk $out
'';
stripDebugList = [ "." ];
postFixup = ''
# Remove references to bootstrap.
export openjdkOutPath='${jdk.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 = [ jdk gradle.jdk ];
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;
};
}

View File

@ -0,0 +1,6 @@
{
"hash": "sha256-a/ev91Rq7D3z9O56ZZQCgvvbfj5GBt5Lonow2NH3s/E=",
"owner": "openjdk",
"repo": "jfx23u",
"rev": "23-ga"
}

View File

@ -1,16 +1,22 @@
{
stdenv,
featureVersion ? "17",
lib,
stdenv,
pkgs,
fetchFromGitHub,
fetchpatch2,
writeText,
openjdk23_headless,
gradle,
pkg-config,
gradle_7,
perl,
pkg-config,
cmake,
gperf,
python3,
ruby,
gtk2,
gtk3,
libXtst,
@ -18,39 +24,73 @@
glib,
alsa-lib,
ffmpeg,
python3,
ruby,
ffmpeg-headless,
writeText,
withMedia ? true,
withWebKit ? false,
jdk17_headless,
jdk21_headless,
jdk23_headless,
jdk-bootstrap ?
{
"17" = jdk17_headless;
"21" = jdk21_headless;
"23" = jdk23_headless;
}
.${featureVersion},
}:
let
pname = "openjfx-modular-sdk";
major = "23";
update = "";
build = "-ga";
repover = "${major}${update}${build}";
jdk = openjdk23_headless;
sourceFile = ./. + "/${featureVersion}/source.json";
sourceInfo = lib.importJSON sourceFile;
atLeast21 = lib.versionAtLeast featureVersion "21";
atLeast23 = lib.versionAtLeast featureVersion "23";
gradle_openjfx = if atLeast23 then gradle else gradle_7;
in
assert lib.assertMsg (lib.pathExists sourceFile)
"OpenJFX ${featureVersion} is not a supported version";
stdenv.mkDerivation {
inherit pname;
version = "${major}${update}${build}";
pname = "openjfx-modular-sdk";
version = lib.removePrefix "refs/tags/" sourceInfo.rev;
src = fetchFromGitHub {
owner = "openjdk";
repo = "jfx23u";
rev = repover;
hash = "sha256-a/ev91Rq7D3z9O56ZZQCgvvbfj5GBt5Lonow2NH3s/E=";
};
# TODO: Tighten up after update scripts are run.
src = fetchFromGitHub sourceInfo;
patches = [
# 8338701: Provide media support for libavcodec version 61
# <https://github.com/openjdk/jfx23u/pull/18>
(fetchpatch2 {
url = "https://github.com/openjdk/jfx23u/commit/aba60fda1c82f00e8e685107592305c403a31287.patch?full_index=1";
hash = "sha256-+aRhTwi4VQthAq1SH1jxPl0mTosNMKoTY52jm+jiKso=";
})
patches =
if featureVersion == "23" then
[
# 8338701: Provide media support for libavcodec version 61
# <https://github.com/openjdk/jfx23u/pull/18>
(fetchpatch2 {
url = "https://github.com/openjdk/jfx23u/commit/aba60fda1c82f00e8e685107592305c403a31287.patch?full_index=1";
hash = "sha256-+aRhTwi4VQthAq1SH1jxPl0mTosNMKoTY52jm+jiKso=";
})
]
else if atLeast21 then
[
./21/patches/backport-ffmpeg-7-support-jfx21.patch
]
else
[
./17/patches/backport-ffmpeg-6-support-jfx11.patch
./17/patches/backport-ffmpeg-7-support-jfx11.patch
];
nativeBuildInputs = [
gradle_openjfx
perl
pkg-config
cmake
gperf
python3
ruby
];
buildInputs = [
@ -60,57 +100,61 @@ stdenv.mkDerivation {
libXxf86vm
glib
alsa-lib
ffmpeg
];
nativeBuildInputs = [
gradle
perl
pkg-config
cmake
gperf
python3
ruby
(if atLeast21 then ffmpeg else ffmpeg-headless)
];
dontUseCmakeConfigure = true;
mitmCache = gradle_openjfx.fetchDeps {
attrPath = "openjfx${featureVersion}";
pkg = pkgs."openjfx${featureVersion}".override { withWebKit = true; };
data = ./. + "/${featureVersion}/deps.json";
};
config = writeText "gradle.properties" ''
gradleBuildTask = "sdk";
stripDebugList = [ "." ];
enableParallelBuilding = false;
__darwinAllowLocalNetworking = true;
env.config = writeText "gradle.properties" ''
CONF = Release
JDK_HOME = ${jdk.home}
JDK_HOME = ${jdk-bootstrap.home}
COMPILE_MEDIA = ${lib.boolToString withMedia}
COMPILE_WEBKIT = ${lib.boolToString withWebKit}
'';
postPatch = ''
ln -s $config gradle.properties
'';
dontUseCmakeConfigure = true;
mitmCache = gradle.fetchDeps {
attrPath = "openjfx${major}";
pkg = pkgs."openjfx${major}".override { withWebKit = true; };
data = ./deps.json;
};
postPatch =
lib.optionalString (!atLeast23) ''
# Add missing includes for gcc-13 for webkit build:
sed -e '1i #include <cstdio>' \
-i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \
modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h
__darwinAllowLocalNetworking = true;
''
+ lib.optionalString (!atLeast21) ''
substituteInPlace modules/javafx.web/src/main/native/Source/JavaScriptCore/offlineasm/parser.rb \
--replace-fail "File.exists?" "File.exist?"
''
+ ''
ln -s $config gradle.properties
'';
preBuild = ''
export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
'';
enableParallelBuilding = false;
gradleBuildTask = "sdk";
installPhase = ''
cp -r build/modular-sdk $out
'';
stripDebugList = [ "." ];
postFixup = ''
# Remove references to bootstrap.
export openjdkOutPath='${jdk.outPath}'
export openjdkOutPath='${jdk-bootstrap.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"
@ -118,15 +162,15 @@ stdenv.mkDerivation {
'';
disallowedReferences = [
jdk
gradle.jdk
jdk-bootstrap
gradle_openjfx.jdk
];
meta = with lib; {
homepage = "https://openjdk.org/projects/openjfx/";
license = licenses.gpl2Classpath;
meta = {
description = "Next-generation Java client toolkit";
maintainers = with maintainers; [ abbradar ];
platforms = platforms.unix;
homepage = "https://openjdk.org/projects/openjfx/";
license = lib.licenses.gpl2Classpath;
maintainers = with lib.maintainers; [ abbradar ];
platforms = lib.platforms.unix;
};
}

View File

@ -3,9 +3,9 @@
with pkgs;
let
openjfx17 = callPackage ../development/compilers/openjdk/openjfx/17 { };
openjfx21 = callPackage ../development/compilers/openjdk/openjfx/21 { };
openjfx23 = callPackage ../development/compilers/openjdk/openjfx/23 { };
openjfx17 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVersion = "17"; };
openjfx21 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVerison = "21"; };
openjfx23 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVersion = "23"; };
in {
inherit openjfx17 openjfx21 openjfx23;