Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchurl,
5 jre,
6 fetchFromGitHub,
7 cmake,
8 ninja,
9 pkg-config,
10
11 # darwin only
12 CoreFoundation ? null,
13
14 # ANTLR 4.8 & 4.9
15 libuuid,
16
17 # ANTLR 4.9
18 utf8cpp,
19}:
20
21let
22
23 mkAntlr =
24 {
25 version,
26 sourceSha256,
27 jarSha256,
28 extraCppBuildInputs ? [ ],
29 extraCppCmakeFlags ? [ ],
30 extraPatches ? [ ],
31 }:
32 rec {
33 source = fetchFromGitHub {
34 owner = "antlr";
35 repo = "antlr4";
36 tag = version;
37 sha256 = sourceSha256;
38 };
39
40 antlr = stdenv.mkDerivation {
41 pname = "antlr";
42 inherit version;
43
44 src = fetchurl {
45 url = "https://www.antlr.org/download/antlr-${version}-complete.jar";
46 sha256 = jarSha256;
47 };
48
49 dontUnpack = true;
50
51 installPhase = ''
52 mkdir -p "$out"/{share/java,bin}
53 ln -s "$src" "$out/share/java/antlr-${version}-complete.jar"
54
55 echo "#! ${stdenv.shell}" >> "$out/bin/antlr"
56 echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr"
57
58 echo "#! ${stdenv.shell}" >> "$out/bin/antlr-parse"
59 echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.gui.Interpreter \"\$@\"" >> "$out/bin/antlr-parse"
60
61 echo "#! ${stdenv.shell}" >> "$out/bin/grun"
62 echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun"
63
64 chmod a+x "$out/bin/antlr" "$out/bin/antlr-parse" "$out/bin/grun"
65 ln -s "$out/bin/antlr"{,4}
66 ln -s "$out/bin/antlr"{,4}-parse
67 '';
68
69 inherit jre;
70
71 passthru = {
72 inherit runtime;
73 jarLocation = antlr.src;
74 };
75
76 meta = {
77 description = "Powerful parser generator";
78 longDescription = ''
79 ANTLR (ANother Tool for Language Recognition) is a powerful parser
80 generator for reading, processing, executing, or translating structured
81 text or binary files. It's widely used to build languages, tools, and
82 frameworks. From a grammar, ANTLR generates a parser that can build and
83 walk parse trees.
84 '';
85 homepage = "https://www.antlr.org/";
86 sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
87 license = lib.licenses.bsd3;
88 platforms = lib.platforms.unix;
89 };
90 };
91
92 runtime = {
93 cpp = stdenv.mkDerivation {
94 pname = "antlr-runtime-cpp";
95 inherit version;
96 src = source;
97
98 patches = extraPatches;
99
100 outputs = [
101 "out"
102 "dev"
103 "doc"
104 ];
105
106 nativeBuildInputs = [
107 cmake
108 ninja
109 pkg-config
110 ];
111 buildInputs = extraCppBuildInputs;
112
113 cmakeDir = "../runtime/Cpp";
114
115 cmakeFlags = extraCppCmakeFlags;
116
117 meta = {
118 description = "C++ target for ANTLR 4";
119 homepage = "https://www.antlr.org/";
120 license = lib.licenses.bsd3;
121 platforms = lib.platforms.unix;
122 };
123 };
124 };
125 };
126
127in
128{
129 antlr4_13 =
130 (mkAntlr {
131 version = "4.13.2";
132 sourceSha256 = "sha256-DxxRL+FQFA+x0RudIXtLhewseU50aScHKSCDX7DE9bY=";
133 jarSha256 = "sha256-6uLfoRmmQydERnKv9j6ew1ogGA3FuAkLemq4USXfTXY=";
134 extraCppCmakeFlags = [
135 # Generate CMake config files, which are not installed by default.
136 (lib.cmakeBool "ANTLR4_INSTALL" true)
137
138 # Disable tests, since they require downloading googletest, which is
139 # not available in a sandboxed build.
140 (lib.cmakeBool "ANTLR_BUILD_CPP_TESTS" false)
141 ];
142 extraPatches = [
143 ./include-dir-issue-379757.patch
144 ];
145 }).antlr;
146
147 antlr4_12 =
148 (mkAntlr {
149 version = "4.12.0";
150 sourceSha256 = "sha256-0JMG8UYFT+IAWvARY2KnuXSr5X6LlVZN4LJHy5d4x08=";
151 jarSha256 = "sha256-iPGKK/rA3eEAntpcfc41ilKHf673ho9WIjpbzBUynkM=";
152 extraCppCmakeFlags = [
153 # Generate CMake config files, which are not installed by default.
154 (lib.cmakeBool "ANTLR4_INSTALL" true)
155
156 # Disable tests, since they require downloading googletest, which is
157 # not available in a sandboxed build.
158 (lib.cmakeBool "ANTLR_BUILD_CPP_TESTS" false)
159 ];
160 }).antlr;
161
162 antlr4_11 =
163 (mkAntlr {
164 version = "4.11.1";
165 sourceSha256 = "sha256-SUeDgfqLjYQorC8r/CKlwbYooTThMOILkizwQV8pocc=";
166 jarSha256 = "sha256-YpdeGStK8mIrcrXwExVT7jy86X923CpBYy3MVeJUc+E=";
167 extraCppCmakeFlags = [
168 # Generate CMake config files, which are not installed by default.
169 (lib.cmakeBool "ANTLR4_INSTALL" true)
170
171 # Disable tests, since they require downloading googletest, which is
172 # not available in a sandboxed build.
173 (lib.cmakeBool "ANTLR_BUILD_CPP_TESTS" false)
174 ];
175 }).antlr;
176
177 antlr4_10 =
178 (mkAntlr {
179 version = "4.10.1";
180 sourceSha256 = "sha256-Z1P81L0aPbimitzrHH/9rxsMCA6Qn3i42jFbUmVqu1E=";
181 jarSha256 = "sha256-QZSdQfINMdW4J3GHc13XVRCN9Ss422yGUQjTOCBA+Rg=";
182 extraCppBuildInputs = lib.optional stdenv.hostPlatform.isLinux libuuid;
183 extraCppCmakeFlags = [
184 (lib.cmakeBool "ANTLR4_INSTALL" true)
185 (lib.cmakeBool "ANTLR_BUILD_CPP_TESTS" false)
186 ];
187 }).antlr;
188
189 antlr4_9 =
190 (mkAntlr {
191 version = "4.9.3";
192 sourceSha256 = "1af3cfqwk7lq1b5qsh1am0922fyhy7wmlpnrqdnvch3zzza9n1qm";
193 jarSha256 = "0dnz2x54kigc58bxnynjhmr5iq49f938vj6p50gdir1xdna41kdg";
194 extraCppBuildInputs = [ utf8cpp ] ++ lib.optional stdenv.hostPlatform.isLinux libuuid;
195 extraCppCmakeFlags = [
196 (lib.cmakeFeature "CMAKE_CXX_FLAGS" "-I${lib.getDev utf8cpp}/include/utf8cpp")
197 ];
198 extraPatches = [
199 ./utf8cpp.patch
200 ];
201 }).antlr;
202
203 antlr4_8 =
204 (mkAntlr {
205 version = "4.8";
206 sourceSha256 = "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m";
207 jarSha256 = "0nms976cnqyr1ndng3haxkmknpdq6xli4cpf4x4al0yr21l9v93k";
208 extraCppBuildInputs = lib.optional stdenv.hostPlatform.isLinux libuuid;
209 extraCppCmakeFlags = [
210 (lib.cmakeBool "ANTLR4_INSTALL" true)
211 ];
212 }).antlr;
213}