From 36019e6120219339b9921977548eeb7521f81893 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Thu, 15 Sep 2022 01:07:07 -0700 Subject: [PATCH 1/5] antlr4_11: init --- pkgs/development/tools/parsing/antlr/4.11.nix | 96 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 98 insertions(+) create mode 100644 pkgs/development/tools/parsing/antlr/4.11.nix diff --git a/pkgs/development/tools/parsing/antlr/4.11.nix b/pkgs/development/tools/parsing/antlr/4.11.nix new file mode 100644 index 000000000000..7f719fe0d41e --- /dev/null +++ b/pkgs/development/tools/parsing/antlr/4.11.nix @@ -0,0 +1,96 @@ +{ lib, stdenv, fetchurl, jre +, fetchpatch, fetchFromGitHub, cmake, ninja, pkg-config, darwin }: + +let + version = "4.11.1"; + source = fetchFromGitHub { + owner = "antlr"; + repo = "antlr4"; + rev = version; + sha256 = "sha256-SUeDgfqLjYQorC8r/CKlwbYooTThMOILkizwQV8pocc="; + }; + + runtime = { + cpp = stdenv.mkDerivation { + pname = "antlr-runtime-cpp"; + inherit version; + src = source; + + outputs = [ "out" "dev" "doc" ]; + + patchFlags = [ "-p3" ]; + + nativeBuildInputs = [ cmake ninja pkg-config ]; + buildInputs = + lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation; + + cmakeFlags = [ + # 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" + ]; + + postUnpack = '' + export sourceRoot=$sourceRoot/runtime/Cpp + ''; + + meta = with lib; { + description = "C++ target for ANTLR 4"; + homepage = "https://www.antlr.org/"; + license = licenses.bsd3; + platforms = platforms.unix; + }; + }; + }; + + antlr = stdenv.mkDerivation { + pname = "antlr"; + inherit version; + + src = fetchurl { + url = "https://www.antlr.org/download/antlr-${version}-complete.jar"; + sha256 = "sha256-YpdeGStK8mIrcrXwExVT7jy86X923CpBYy3MVeJUc+E="; + }; + + dontUnpack = true; + + installPhase = '' + mkdir -p "$out"/{share/java,bin} + cp "$src" "$out/share/java/antlr-${version}-complete.jar" + + echo "#! ${stdenv.shell}" >> "$out/bin/antlr" + echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr" + + echo "#! ${stdenv.shell}" >> "$out/bin/grun" + echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun" + + chmod a+x "$out/bin/antlr" "$out/bin/grun" + ln -s "$out/bin/antlr"{,4} + ''; + + inherit jre; + + passthru = { + inherit runtime; + jarLocation = "${antlr}/share/java/antlr-${version}-complete.jar"; + }; + + meta = with lib; { + description = "Powerful parser generator"; + longDescription = '' + ANTLR (ANother Tool for Language Recognition) is a powerful parser + generator for reading, processing, executing, or translating structured + text or binary files. It's widely used to build languages, tools, and + frameworks. From a grammar, ANTLR generates a parser that can build and + walk parse trees. + ''; + homepage = "https://www.antlr.org/"; + sourceProvenance = with sourceTypes; [ binaryBytecode ]; + license = licenses.bsd3; + platforms = platforms.unix; + }; + }; +in antlr diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2feb82460f3d..bc70eaedb383 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15983,6 +15983,8 @@ with pkgs; antlr4_9 = callPackage ../development/tools/parsing/antlr/4.9.nix { }; + antlr4_11 = callPackage ../development/tools/parsing/antlr/4.11.nix { }; + antlr4 = antlr4_8; antlr = antlr4; From 35dd06d6e75b689108724064e33943e44c2069b6 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Thu, 13 Oct 2022 00:24:52 -0700 Subject: [PATCH 2/5] antlr4_8, antlr4_9, antlr4_11: refactor definition This commit refactors the antlr 4.8, 4.9, and 4.11 derivations to use common code, greatly reducing the amount of code duplication, but at the expense of slightly increased complexity. --- pkgs/development/tools/parsing/antlr/4.11.nix | 96 ------------ pkgs/development/tools/parsing/antlr/4.8.nix | 89 ----------- pkgs/development/tools/parsing/antlr/4.9.nix | 88 ----------- pkgs/development/tools/parsing/antlr/4.nix | 141 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 10 +- 5 files changed, 146 insertions(+), 278 deletions(-) delete mode 100644 pkgs/development/tools/parsing/antlr/4.11.nix delete mode 100644 pkgs/development/tools/parsing/antlr/4.8.nix delete mode 100644 pkgs/development/tools/parsing/antlr/4.9.nix create mode 100644 pkgs/development/tools/parsing/antlr/4.nix diff --git a/pkgs/development/tools/parsing/antlr/4.11.nix b/pkgs/development/tools/parsing/antlr/4.11.nix deleted file mode 100644 index 7f719fe0d41e..000000000000 --- a/pkgs/development/tools/parsing/antlr/4.11.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ lib, stdenv, fetchurl, jre -, fetchpatch, fetchFromGitHub, cmake, ninja, pkg-config, darwin }: - -let - version = "4.11.1"; - source = fetchFromGitHub { - owner = "antlr"; - repo = "antlr4"; - rev = version; - sha256 = "sha256-SUeDgfqLjYQorC8r/CKlwbYooTThMOILkizwQV8pocc="; - }; - - runtime = { - cpp = stdenv.mkDerivation { - pname = "antlr-runtime-cpp"; - inherit version; - src = source; - - outputs = [ "out" "dev" "doc" ]; - - patchFlags = [ "-p3" ]; - - nativeBuildInputs = [ cmake ninja pkg-config ]; - buildInputs = - lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation; - - cmakeFlags = [ - # 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" - ]; - - postUnpack = '' - export sourceRoot=$sourceRoot/runtime/Cpp - ''; - - meta = with lib; { - description = "C++ target for ANTLR 4"; - homepage = "https://www.antlr.org/"; - license = licenses.bsd3; - platforms = platforms.unix; - }; - }; - }; - - antlr = stdenv.mkDerivation { - pname = "antlr"; - inherit version; - - src = fetchurl { - url = "https://www.antlr.org/download/antlr-${version}-complete.jar"; - sha256 = "sha256-YpdeGStK8mIrcrXwExVT7jy86X923CpBYy3MVeJUc+E="; - }; - - dontUnpack = true; - - installPhase = '' - mkdir -p "$out"/{share/java,bin} - cp "$src" "$out/share/java/antlr-${version}-complete.jar" - - echo "#! ${stdenv.shell}" >> "$out/bin/antlr" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr" - - echo "#! ${stdenv.shell}" >> "$out/bin/grun" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun" - - chmod a+x "$out/bin/antlr" "$out/bin/grun" - ln -s "$out/bin/antlr"{,4} - ''; - - inherit jre; - - passthru = { - inherit runtime; - jarLocation = "${antlr}/share/java/antlr-${version}-complete.jar"; - }; - - meta = with lib; { - description = "Powerful parser generator"; - longDescription = '' - ANTLR (ANother Tool for Language Recognition) is a powerful parser - generator for reading, processing, executing, or translating structured - text or binary files. It's widely used to build languages, tools, and - frameworks. From a grammar, ANTLR generates a parser that can build and - walk parse trees. - ''; - homepage = "https://www.antlr.org/"; - sourceProvenance = with sourceTypes; [ binaryBytecode ]; - license = licenses.bsd3; - platforms = platforms.unix; - }; - }; -in antlr diff --git a/pkgs/development/tools/parsing/antlr/4.8.nix b/pkgs/development/tools/parsing/antlr/4.8.nix deleted file mode 100644 index 5d35af921ec2..000000000000 --- a/pkgs/development/tools/parsing/antlr/4.8.nix +++ /dev/null @@ -1,89 +0,0 @@ -{ lib, stdenv, fetchurl, jre -, fetchFromGitHub, cmake, ninja, pkg-config, libuuid, darwin }: - -let - version = "4.8"; - source = fetchFromGitHub { - owner = "antlr"; - repo = "antlr4"; - rev = version; - sha256 = "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m"; - }; - - runtime = { - cpp = stdenv.mkDerivation { - pname = "antlr-runtime-cpp"; - inherit version; - src = source; - - outputs = [ "out" "dev" "doc" ]; - - nativeBuildInputs = [ cmake ninja pkg-config ]; - buildInputs = lib.optional stdenv.isLinux libuuid - ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation; - - # Install CMake config files, used to locate the runtime from another - # CMake project, using the find_package function. - cmakeFlags = [ "-DANTLR4_INSTALL=ON" ]; - - postUnpack = '' - export sourceRoot=$sourceRoot/runtime/Cpp - ''; - - meta = with lib; { - description = "C++ target for ANTLR 4"; - homepage = "https://www.antlr.org/"; - license = licenses.bsd3; - platforms = platforms.unix; - }; - }; - }; - - antlr = stdenv.mkDerivation { - pname = "antlr"; - inherit version; - - src = fetchurl { - url ="https://www.antlr.org/download/antlr-${version}-complete.jar"; - sha256 = "0nms976cnqyr1ndng3haxkmknpdq6xli4cpf4x4al0yr21l9v93k"; - }; - - dontUnpack = true; - - installPhase = '' - mkdir -p "$out"/{share/java,bin} - cp "$src" "$out/share/java/antlr-${version}-complete.jar" - - echo "#! ${stdenv.shell}" >> "$out/bin/antlr" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr" - - echo "#! ${stdenv.shell}" >> "$out/bin/grun" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun" - - chmod a+x "$out/bin/antlr" "$out/bin/grun" - ln -s "$out/bin/antlr"{,4} - ''; - - inherit jre; - - passthru = { - inherit runtime; - jarLocation = "${antlr}/share/java/antlr-${version}-complete.jar"; - }; - - meta = with lib; { - description = "Powerful parser generator"; - longDescription = '' - ANTLR (ANother Tool for Language Recognition) is a powerful parser - generator for reading, processing, executing, or translating structured - text or binary files. It's widely used to build languages, tools, and - frameworks. From a grammar, ANTLR generates a parser that can build and - walk parse trees. - ''; - homepage = "https://www.antlr.org/"; - sourceProvenance = with sourceTypes; [ binaryBytecode ]; - license = licenses.bsd3; - platforms = platforms.unix; - }; - }; -in antlr diff --git a/pkgs/development/tools/parsing/antlr/4.9.nix b/pkgs/development/tools/parsing/antlr/4.9.nix deleted file mode 100644 index 3046f3e17caa..000000000000 --- a/pkgs/development/tools/parsing/antlr/4.9.nix +++ /dev/null @@ -1,88 +0,0 @@ -{ lib, stdenv, fetchurl, jre -, fetchpatch, fetchFromGitHub, cmake, ninja, pkg-config, libuuid, utf8cpp, darwin }: - -let - version = "4.9.3"; - source = fetchFromGitHub { - owner = "antlr"; - repo = "antlr4"; - rev = version; - sha256 = "1af3cfqwk7lq1b5qsh1am0922fyhy7wmlpnrqdnvch3zzza9n1qm"; - }; - - runtime = { - cpp = stdenv.mkDerivation { - pname = "antlr-runtime-cpp"; - inherit version; - src = source; - - outputs = [ "out" "dev" "doc" ]; - - patchFlags = [ "-p3" ]; - - nativeBuildInputs = [ cmake ninja pkg-config ]; - buildInputs = [ utf8cpp ] - ++ lib.optional stdenv.isLinux libuuid - ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation; - - postUnpack = '' - export sourceRoot=$sourceRoot/runtime/Cpp - ''; - - meta = with lib; { - description = "C++ target for ANTLR 4"; - homepage = "https://www.antlr.org/"; - license = licenses.bsd3; - platforms = platforms.unix; - }; - }; - }; - - antlr = stdenv.mkDerivation { - pname = "antlr"; - inherit version; - - src = fetchurl { - url = "https://www.antlr.org/download/antlr-${version}-complete.jar"; - sha256 = "0dnz2x54kigc58bxnynjhmr5iq49f938vj6p50gdir1xdna41kdg"; - }; - - dontUnpack = true; - - installPhase = '' - mkdir -p "$out"/{share/java,bin} - cp "$src" "$out/share/java/antlr-${version}-complete.jar" - - echo "#! ${stdenv.shell}" >> "$out/bin/antlr" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr" - - echo "#! ${stdenv.shell}" >> "$out/bin/grun" - echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun" - - chmod a+x "$out/bin/antlr" "$out/bin/grun" - ln -s "$out/bin/antlr"{,4} - ''; - - inherit jre; - - passthru = { - inherit runtime; - jarLocation = "${antlr}/share/java/antlr-${version}-complete.jar"; - }; - - meta = with lib; { - description = "Powerful parser generator"; - longDescription = '' - ANTLR (ANother Tool for Language Recognition) is a powerful parser - generator for reading, processing, executing, or translating structured - text or binary files. It's widely used to build languages, tools, and - frameworks. From a grammar, ANTLR generates a parser that can build and - walk parse trees. - ''; - homepage = "https://www.antlr.org/"; - sourceProvenance = with sourceTypes; [ binaryBytecode ]; - license = licenses.bsd3; - platforms = platforms.unix; - }; - }; -in antlr diff --git a/pkgs/development/tools/parsing/antlr/4.nix b/pkgs/development/tools/parsing/antlr/4.nix new file mode 100644 index 000000000000..3ddab6a9b17b --- /dev/null +++ b/pkgs/development/tools/parsing/antlr/4.nix @@ -0,0 +1,141 @@ +{ lib, stdenv, fetchurl, jre +, fetchFromGitHub, cmake, ninja, pkg-config, darwin + +# ANTLR 4.8 & 4.9 +, libuuid + +# ANTLR 4.9 +, utf8cpp }: + +let + + mkAntlr = { version, sourceSha256, jarSha256 }: lib.fixedPoints.makeExtensible (self: { + source = fetchFromGitHub { + owner = "antlr"; + repo = "antlr4"; + rev = version; + sha256 = sourceSha256; + }; + + antlr = stdenv.mkDerivation { + pname = "antlr"; + inherit version; + + src = fetchurl { + url = "https://www.antlr.org/download/antlr-${version}-complete.jar"; + sha256 = jarSha256; + }; + + dontUnpack = true; + + installPhase = '' + mkdir -p "$out"/{share/java,bin} + cp "$src" "$out/share/java/antlr-${version}-complete.jar" + + echo "#! ${stdenv.shell}" >> "$out/bin/antlr" + echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr" + + echo "#! ${stdenv.shell}" >> "$out/bin/grun" + echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun" + + chmod a+x "$out/bin/antlr" "$out/bin/grun" + ln -s "$out/bin/antlr"{,4} + ''; + + inherit jre; + + passthru = { + inherit (self) runtime; + jarLocation = "${self.antlr}/share/java/antlr-${version}-complete.jar"; + }; + + meta = with lib; { + description = "Powerful parser generator"; + longDescription = '' + ANTLR (ANother Tool for Language Recognition) is a powerful parser + generator for reading, processing, executing, or translating structured + text or binary files. It's widely used to build languages, tools, and + frameworks. From a grammar, ANTLR generates a parser that can build and + walk parse trees. + ''; + homepage = "https://www.antlr.org/"; + sourceProvenance = with sourceTypes; [ binaryBytecode ]; + license = licenses.bsd3; + platforms = platforms.unix; + }; + }; + + runtime = { + cpp = stdenv.mkDerivation { + pname = "antlr-runtime-cpp"; + inherit version; + src = self.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 + ''; + + meta = with lib; { + description = "C++ target for ANTLR 4"; + homepage = "https://www.antlr.org/"; + license = licenses.bsd3; + platforms = platforms.unix; + }; + }; + }; + }); + +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" + + # Disable tests, since they require downloading googletest, which is + # not available in a sandboxed build. + "-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_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; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bc70eaedb383..b9104329c660 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15977,13 +15977,13 @@ with pkgs; }; antlr3 = antlr3_5; - antlr4_8 = callPackage ../development/tools/parsing/antlr/4.8.nix { + inherit (callPackages ../development/tools/parsing/antlr/4.nix { jre = jre8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731 - }; + }) antlr4_8; - antlr4_9 = callPackage ../development/tools/parsing/antlr/4.9.nix { }; - - antlr4_11 = callPackage ../development/tools/parsing/antlr/4.11.nix { }; + inherit (callPackages ../development/tools/parsing/antlr/4.nix { }) + antlr4_9 + antlr4_11; antlr4 = antlr4_8; From a195a65efe8fd561c256eaea2c9c2076f8ce4220 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Tue, 18 Oct 2022 23:57:45 -0700 Subject: [PATCH 3/5] antlr4_10: init --- pkgs/development/tools/parsing/antlr/4.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/development/tools/parsing/antlr/4.nix b/pkgs/development/tools/parsing/antlr/4.nix index 3ddab6a9b17b..cae89e63c3b0 100644 --- a/pkgs/development/tools/parsing/antlr/4.nix +++ b/pkgs/development/tools/parsing/antlr/4.nix @@ -111,6 +111,22 @@ in { }) ).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_9 = ( (mkAntlr { version = "4.9.3"; From 98b114eee2bd625d3172724ca68ae988774b1360 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Fri, 21 Oct 2022 22:39:37 -0700 Subject: [PATCH 4/5] antlr4: simplify package definitions This does not require a rebuild. --- pkgs/development/tools/parsing/antlr/4.nix | 131 ++++++++++----------- 1 file changed, 63 insertions(+), 68 deletions(-) diff --git a/pkgs/development/tools/parsing/antlr/4.nix b/pkgs/development/tools/parsing/antlr/4.nix index cae89e63c3b0..3dbcda7e18ec 100644 --- a/pkgs/development/tools/parsing/antlr/4.nix +++ b/pkgs/development/tools/parsing/antlr/4.nix @@ -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; } From 83b0d09f1c0988883af87a3e469c51d1a6c12444 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Fri, 21 Oct 2022 22:43:18 -0700 Subject: [PATCH 5/5] antlr4: remove redundant settings - Remove unneeded patch flags - Move sourceRoot out of postUnpack This change requires a rebuild. --- pkgs/development/tools/parsing/antlr/4.nix | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pkgs/development/tools/parsing/antlr/4.nix b/pkgs/development/tools/parsing/antlr/4.nix index 3dbcda7e18ec..85938153862c 100644 --- a/pkgs/development/tools/parsing/antlr/4.nix +++ b/pkgs/development/tools/parsing/antlr/4.nix @@ -14,7 +14,6 @@ let mkAntlr = { version, sourceSha256, jarSha256, - extraCppPatchFlags ? [], extraCppBuildInputs ? [], extraCppCmakeFlags ? [] }: rec { @@ -78,18 +77,10 @@ let pname = "antlr-runtime-cpp"; inherit version; src = source; + sourceRoot = "runtime/Cpp"; outputs = [ "out" "dev" "doc" ]; - postUnpack = '' - export sourceRoot=$sourceRoot/runtime/Cpp - ''; - - patchFlags = - if extraCppPatchFlags == [] - then null - else extraCppPatchFlags; - nativeBuildInputs = [ cmake ninja pkg-config ]; buildInputs = lib.optional stdenv.isDarwin CoreFoundation ++ @@ -137,7 +128,6 @@ in { version = "4.9.3"; sourceSha256 = "1af3cfqwk7lq1b5qsh1am0922fyhy7wmlpnrqdnvch3zzza9n1qm"; jarSha256 = "0dnz2x54kigc58bxnynjhmr5iq49f938vj6p50gdir1xdna41kdg"; - extraCppPatchFlags = [ "-p3" ]; extraCppBuildInputs = [ utf8cpp ] ++ lib.optional stdenv.isLinux libuuid; }).antlr;