biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / parsing / antlr / 4.nix
blob79db5301add9cfaa78e668b5da9bc39e939f807c
1 { lib, stdenv, fetchurl, jre
2 , fetchFromGitHub, cmake, ninja, pkg-config
4 # darwin only
5 , CoreFoundation ? null
7 # ANTLR 4.8 & 4.9
8 , libuuid
10 # ANTLR 4.9
11 , utf8cpp }:
13 let
15   mkAntlr = {
16     version, sourceSha256, jarSha256,
17     extraCppBuildInputs ? [],
18     extraCppCmakeFlags ? [],
19     extraPatches ? [ ]
20   }: rec {
21     source = fetchFromGitHub {
22       owner = "antlr";
23       repo = "antlr4";
24       rev = version;
25       sha256 = sourceSha256;
26     };
28     antlr = stdenv.mkDerivation {
29       pname = "antlr";
30       inherit version;
32       src = fetchurl {
33         url = "https://www.antlr.org/download/antlr-${version}-complete.jar";
34         sha256 = jarSha256;
35       };
37       dontUnpack = true;
39       installPhase = ''
40         mkdir -p "$out"/{share/java,bin}
41         ln -s "$src" "$out/share/java/antlr-${version}-complete.jar"
43         echo "#! ${stdenv.shell}" >> "$out/bin/antlr"
44         echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr"
46         echo "#! ${stdenv.shell}" >> "$out/bin/antlr-parse"
47         echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.gui.Interpreter \"\$@\"" >> "$out/bin/antlr-parse"
49         echo "#! ${stdenv.shell}" >> "$out/bin/grun"
50         echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun"
52         chmod a+x "$out/bin/antlr" "$out/bin/antlr-parse" "$out/bin/grun"
53         ln -s "$out/bin/antlr"{,4}
54         ln -s "$out/bin/antlr"{,4}-parse
55       '';
57       inherit jre;
59       passthru = {
60         inherit runtime;
61         jarLocation = antlr.src;
62       };
64       meta = with lib; {
65         description = "Powerful parser generator";
66         longDescription = ''
67           ANTLR (ANother Tool for Language Recognition) is a powerful parser
68           generator for reading, processing, executing, or translating structured
69           text or binary files. It's widely used to build languages, tools, and
70           frameworks. From a grammar, ANTLR generates a parser that can build and
71           walk parse trees.
72         '';
73         homepage = "https://www.antlr.org/";
74         sourceProvenance = with sourceTypes; [ binaryBytecode ];
75         license = licenses.bsd3;
76         platforms = platforms.unix;
77       };
78     };
80     runtime = {
81       cpp = stdenv.mkDerivation {
82         pname = "antlr-runtime-cpp";
83         inherit version;
84         src = source;
86         patches = extraPatches;
88         outputs = [ "out" "dev" "doc" ];
90         nativeBuildInputs = [ cmake ninja pkg-config ];
91         buildInputs =
92           lib.optional stdenv.isDarwin CoreFoundation ++
93           extraCppBuildInputs;
95         cmakeDir = "../runtime/Cpp";
97         cmakeFlags = extraCppCmakeFlags;
99         meta = with lib; {
100           description = "C++ target for ANTLR 4";
101           homepage = "https://www.antlr.org/";
102           license = licenses.bsd3;
103           platforms = platforms.unix;
104         };
105       };
106     };
107   };
109 in {
110   antlr4_13 = (mkAntlr {
111     version = "4.13.0";
112     sourceSha256 = "sha256-s1yAdScMYg1wFpYNsBAtpifIhQsnSAgJg7JjPDx+htc=";
113     jarSha256 = "sha256-vG9KvA0iWidXASbFFAJWnwAKje2jSHtw52QoQOVw5KY=";
114     extraCppCmakeFlags = [
115       # Generate CMake config files, which are not installed by default.
116       "-DANTLR4_INSTALL=ON"
118       # Disable tests, since they require downloading googletest, which is
119       # not available in a sandboxed build.
120       "-DANTLR_BUILD_CPP_TESTS=OFF"
121     ];
122   }).antlr;
124   antlr4_12 = (mkAntlr {
125     version = "4.12.0";
126     sourceSha256 = "sha256-0JMG8UYFT+IAWvARY2KnuXSr5X6LlVZN4LJHy5d4x08=";
127     jarSha256 = "sha256-iPGKK/rA3eEAntpcfc41ilKHf673ho9WIjpbzBUynkM=";
128     extraCppCmakeFlags = [
129       # Generate CMake config files, which are not installed by default.
130       "-DANTLR4_INSTALL=ON"
132       # Disable tests, since they require downloading googletest, which is
133       # not available in a sandboxed build.
134       "-DANTLR_BUILD_CPP_TESTS=OFF"
135     ];
136   }).antlr;
138   antlr4_11 = (mkAntlr {
139     version = "4.11.1";
140     sourceSha256 = "sha256-SUeDgfqLjYQorC8r/CKlwbYooTThMOILkizwQV8pocc=";
141     jarSha256 = "sha256-YpdeGStK8mIrcrXwExVT7jy86X923CpBYy3MVeJUc+E=";
142     extraCppCmakeFlags = [
143       # Generate CMake config files, which are not installed by default.
144       "-DANTLR4_INSTALL=ON"
146       # Disable tests, since they require downloading googletest, which is
147       # not available in a sandboxed build.
148       "-DANTLR_BUILD_CPP_TESTS=OFF"
149     ];
150   }).antlr;
152   antlr4_10 = (mkAntlr {
153     version = "4.10.1";
154     sourceSha256 = "sha256-Z1P81L0aPbimitzrHH/9rxsMCA6Qn3i42jFbUmVqu1E=";
155     jarSha256 = "sha256-QZSdQfINMdW4J3GHc13XVRCN9Ss422yGUQjTOCBA+Rg=";
156     extraCppBuildInputs = lib.optional stdenv.isLinux libuuid;
157     extraCppCmakeFlags = [
158       "-DANTLR4_INSTALL=ON"
159       "-DANTLR_BUILD_CPP_TESTS=OFF"
160     ];
161   }).antlr;
163   antlr4_9 = (mkAntlr {
164     version = "4.9.3";
165     sourceSha256 = "1af3cfqwk7lq1b5qsh1am0922fyhy7wmlpnrqdnvch3zzza9n1qm";
166     jarSha256 = "0dnz2x54kigc58bxnynjhmr5iq49f938vj6p50gdir1xdna41kdg";
167     extraCppBuildInputs = [ utf8cpp ]
168       ++ lib.optional stdenv.isLinux libuuid;
169     extraCppCmakeFlags = [
170       "-DCMAKE_CXX_FLAGS='-I${lib.getDev utf8cpp}/include/utf8cpp'"
171     ];
172     extraPatches = [
173       ./utf8cpp.patch
174     ];
175   }).antlr;
177   antlr4_8 = (mkAntlr {
178     version = "4.8";
179     sourceSha256 = "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m";
180     jarSha256 = "0nms976cnqyr1ndng3haxkmknpdq6xli4cpf4x4al0yr21l9v93k";
181     extraCppBuildInputs = lib.optional stdenv.isLinux libuuid;
182     extraCppCmakeFlags = [ "-DANTLR4_INSTALL=ON" ];
183   }).antlr;