2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv, fetchurl, jre
|
2021-01-19 07:50:56 +01:00
|
|
|
, fetchFromGitHub, cmake, ninja, pkg-config, libuuid, darwin }:
|
2017-06-15 13:01:42 +02:00
|
|
|
|
2018-08-08 23:47:31 +02:00
|
|
|
let
|
2020-11-04 19:58:32 +01:00
|
|
|
version = "4.8";
|
2018-08-08 23:47:31 +02:00
|
|
|
source = fetchFromGitHub {
|
|
|
|
owner = "antlr";
|
|
|
|
repo = "antlr4";
|
|
|
|
rev = version;
|
2020-11-04 19:58:32 +01:00
|
|
|
sha256 = "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m";
|
2017-06-15 13:01:42 +02:00
|
|
|
};
|
|
|
|
|
2018-08-08 23:47:31 +02:00
|
|
|
runtime = {
|
|
|
|
cpp = stdenv.mkDerivation {
|
2019-08-13 23:52:01 +02:00
|
|
|
pname = "antlr-runtime-cpp";
|
|
|
|
inherit version;
|
2018-08-08 23:47:31 +02:00
|
|
|
src = source;
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "doc" ];
|
|
|
|
|
2021-01-19 07:50:56 +01:00
|
|
|
nativeBuildInputs = [ cmake ninja pkg-config ];
|
2021-01-23 13:26:19 +01:00
|
|
|
buildInputs = lib.optional stdenv.isLinux libuuid
|
|
|
|
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation;
|
2018-08-08 23:47:31 +02:00
|
|
|
|
2021-11-25 12:40:11 +01:00
|
|
|
# Install CMake config files, used to locate the runtime from another
|
|
|
|
# CMake project, using the find_package function.
|
|
|
|
cmakeFlags = [ "-DANTLR4_INSTALL=ON" ];
|
|
|
|
|
2018-08-08 23:47:31 +02:00
|
|
|
postUnpack = ''
|
|
|
|
export sourceRoot=$sourceRoot/runtime/Cpp
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2018-08-08 23:47:31 +02:00
|
|
|
description = "C++ target for ANTLR 4";
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://www.antlr.org/";
|
2018-08-11 15:40:00 +02:00
|
|
|
license = licenses.bsd3;
|
2018-08-08 23:47:31 +02:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
antlr = stdenv.mkDerivation {
|
2019-08-13 23:52:01 +02:00
|
|
|
pname = "antlr";
|
|
|
|
inherit version;
|
2019-08-14 22:45:12 +02:00
|
|
|
|
2018-08-08 23:47:31 +02:00
|
|
|
src = fetchurl {
|
|
|
|
url ="https://www.antlr.org/download/antlr-${version}-complete.jar";
|
2020-11-04 19:58:32 +01:00
|
|
|
sha256 = "0nms976cnqyr1ndng3haxkmknpdq6xli4cpf4x4al0yr21l9v93k";
|
2018-08-08 23:47:31 +02:00
|
|
|
};
|
|
|
|
|
2019-06-19 17:45:34 +02:00
|
|
|
dontUnpack = true;
|
2018-08-08 23:47:31 +02:00
|
|
|
|
|
|
|
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}
|
2017-06-15 13:01:42 +02:00
|
|
|
'';
|
2018-08-08 23:47:31 +02:00
|
|
|
|
|
|
|
inherit jre;
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit runtime;
|
|
|
|
jarLocation = "${antlr}/share/java/antlr-${version}-complete.jar";
|
|
|
|
};
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2018-08-08 23:47:31 +02:00
|
|
|
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.
|
|
|
|
'';
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://www.antlr.org/";
|
2022-06-02 15:38:41 +02:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
2018-08-11 15:40:00 +02:00
|
|
|
license = licenses.bsd3;
|
2018-08-08 23:47:31 +02:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
2017-06-15 13:01:42 +02:00
|
|
|
};
|
2018-08-08 23:47:31 +02:00
|
|
|
in antlr
|