3
0
Fork 0
forked from mirrors/nixpkgs

antlr4: simplify package definitions

This does not require a rebuild.
This commit is contained in:
Bryan Tan 2022-10-21 22:39:37 -07:00
parent a195a65efe
commit 98b114eee2

View file

@ -1,5 +1,8 @@
{ lib, stdenv, fetchurl, jre
, fetchFromGitHub, cmake, ninja, pkg-config, darwin
, fetchFromGitHub, cmake, ninja, pkg-config
# darwin only
, CoreFoundation ? null
# ANTLR 4.8 & 4.9
, libuuid
@ -9,7 +12,12 @@
let
mkAntlr = { version, sourceSha256, jarSha256 }: lib.fixedPoints.makeExtensible (self: {
mkAntlr = {
version, sourceSha256, jarSha256,
extraCppPatchFlags ? [],
extraCppBuildInputs ? [],
extraCppCmakeFlags ? []
}: rec {
source = fetchFromGitHub {
owner = "antlr";
repo = "antlr4";
@ -45,8 +53,8 @@ let
inherit jre;
passthru = {
inherit (self) runtime;
jarLocation = "${self.antlr}/share/java/antlr-${version}-complete.jar";
inherit runtime;
jarLocation = "${antlr}/share/java/antlr-${version}-complete.jar";
};
meta = with lib; {
@ -69,18 +77,26 @@ let
cpp = stdenv.mkDerivation {
pname = "antlr-runtime-cpp";
inherit version;
src = self.source;
src = source;
outputs = [ "out" "dev" "doc" ];
nativeBuildInputs = [ cmake ninja pkg-config ];
buildInputs =
lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation;
postUnpack = ''
export sourceRoot=$sourceRoot/runtime/Cpp
'';
patchFlags =
if extraCppPatchFlags == []
then null
else extraCppPatchFlags;
nativeBuildInputs = [ cmake ninja pkg-config ];
buildInputs =
lib.optional stdenv.isDarwin CoreFoundation ++
extraCppBuildInputs;
cmakeFlags = extraCppCmakeFlags;
meta = with lib; {
description = "C++ target for ANTLR 4";
homepage = "https://www.antlr.org/";
@ -89,69 +105,48 @@ let
};
};
};
});
};
in {
antlr4_11 = (
(mkAntlr {
version = "4.11.1";
sourceSha256 = "sha256-SUeDgfqLjYQorC8r/CKlwbYooTThMOILkizwQV8pocc=";
jarSha256 = "sha256-YpdeGStK8mIrcrXwExVT7jy86X923CpBYy3MVeJUc+E=";
}).extend (self: super: {
runtime.cpp = super.runtime.cpp.overrideAttrs {
cmakeFlags = [
# Generate CMake config files, which are not installed by default.
"-DANTLR4_INSTALL=ON"
antlr4_11 = (mkAntlr {
version = "4.11.1";
sourceSha256 = "sha256-SUeDgfqLjYQorC8r/CKlwbYooTThMOILkizwQV8pocc=";
jarSha256 = "sha256-YpdeGStK8mIrcrXwExVT7jy86X923CpBYy3MVeJUc+E=";
extraCppCmakeFlags = [
# Generate CMake config files, which are not installed by default.
"-DANTLR4_INSTALL=ON"
# Disable tests, since they require downloading googletest, which is
# not available in a sandboxed build.
"-DANTLR_BUILD_CPP_TESTS=OFF"
];
};
})
).antlr;
# Disable tests, since they require downloading googletest, which is
# not available in a sandboxed build.
"-DANTLR_BUILD_CPP_TESTS=OFF"
];
}).antlr;
antlr4_10 = (
(mkAntlr {
version = "4.10.1";
sourceSha256 = "sha256-Z1P81L0aPbimitzrHH/9rxsMCA6Qn3i42jFbUmVqu1E=";
jarSha256 = "sha256-QZSdQfINMdW4J3GHc13XVRCN9Ss422yGUQjTOCBA+Rg=";
}).extend (self: super: {
runtime.cpp = super.runtime.cpp.overrideAttrs (attrs: {
buildInputs = lib.optional stdenv.isLinux libuuid ++ attrs.buildInputs;
cmakeFlags = [
"-DANTLR4_INSTALL=ON"
"-DANTLR_BUILD_CPP_TESTS=OFF"
];
});
})
).antlr;
antlr4_10 = (mkAntlr {
version = "4.10.1";
sourceSha256 = "sha256-Z1P81L0aPbimitzrHH/9rxsMCA6Qn3i42jFbUmVqu1E=";
jarSha256 = "sha256-QZSdQfINMdW4J3GHc13XVRCN9Ss422yGUQjTOCBA+Rg=";
extraCppBuildInputs = lib.optional stdenv.isLinux libuuid;
extraCppCmakeFlags = [
"-DANTLR4_INSTALL=ON"
"-DANTLR_BUILD_CPP_TESTS=OFF"
];
}).antlr;
antlr4_9 = (
(mkAntlr {
version = "4.9.3";
sourceSha256 = "1af3cfqwk7lq1b5qsh1am0922fyhy7wmlpnrqdnvch3zzza9n1qm";
jarSha256 = "0dnz2x54kigc58bxnynjhmr5iq49f938vj6p50gdir1xdna41kdg";
}).extend (self: super: {
runtime.cpp = super.runtime.cpp.overrideAttrs (attrs: {
patchFlags = [ "-p3" ];
buildInputs = [ utf8cpp ]
++ lib.optional stdenv.isLinux libuuid
++ attrs.buildInputs;
});
})
).antlr;
antlr4_9 = (mkAntlr {
version = "4.9.3";
sourceSha256 = "1af3cfqwk7lq1b5qsh1am0922fyhy7wmlpnrqdnvch3zzza9n1qm";
jarSha256 = "0dnz2x54kigc58bxnynjhmr5iq49f938vj6p50gdir1xdna41kdg";
extraCppPatchFlags = [ "-p3" ];
extraCppBuildInputs = [ utf8cpp ]
++ lib.optional stdenv.isLinux libuuid;
}).antlr;
antlr4_8 = (
(mkAntlr {
version = "4.8";
sourceSha256 = "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m";
jarSha256 = "0nms976cnqyr1ndng3haxkmknpdq6xli4cpf4x4al0yr21l9v93k";
}).extend (self: super: {
runtime.cpp = super.runtime.cpp.overrideAttrs (attrs: {
cmakeFlags = ["-DANTLR4_INSTALL=ON"];
buildInputs = lib.optional stdenv.isLinux libuuid ++ attrs.buildInputs;
});
})
).antlr;
antlr4_8 = (mkAntlr {
version = "4.8";
sourceSha256 = "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m";
jarSha256 = "0nms976cnqyr1ndng3haxkmknpdq6xli4cpf4x4al0yr21l9v93k";
extraCppBuildInputs = lib.optional stdenv.isLinux libuuid;
extraCppCmakeFlags = [ "-DANTLR4_INSTALL=ON" ];
}).antlr;
}