2018-08-08 22:47:31 +01:00
|
|
|
{ stdenv, fetchurl, jre
|
|
|
|
, fetchFromGitHub, cmake, ninja, pkgconfig, libuuid, darwin }:
|
2017-06-15 12:01:42 +01:00
|
|
|
|
2018-08-08 22:47:31 +01:00
|
|
|
let
|
2019-08-14 21:45:12 +01:00
|
|
|
version = "4.7.2";
|
2018-08-08 22:47:31 +01:00
|
|
|
source = fetchFromGitHub {
|
|
|
|
owner = "antlr";
|
|
|
|
repo = "antlr4";
|
|
|
|
rev = version;
|
2019-08-14 21:45:12 +01:00
|
|
|
sha256 = "1pl0zs6c6wx9nmq30s7ccpc3dl72az55i8vfp574fw9sywmvxmlj";
|
2017-06-15 12:01:42 +01:00
|
|
|
};
|
|
|
|
|
2018-08-08 22:47:31 +01:00
|
|
|
runtime = {
|
|
|
|
cpp = stdenv.mkDerivation {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "antlr-runtime-cpp";
|
|
|
|
inherit version;
|
2018-08-08 22:47:31 +01:00
|
|
|
src = source;
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "doc" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ninja pkgconfig ];
|
|
|
|
buildInputs = stdenv.lib.optional stdenv.isLinux libuuid
|
|
|
|
++ stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation;
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
export sourceRoot=$sourceRoot/runtime/Cpp
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "C++ target for ANTLR 4";
|
2019-04-22 09:14:28 +01:00
|
|
|
homepage = https://www.antlr.org/;
|
2018-08-11 14:40:00 +01:00
|
|
|
license = licenses.bsd3;
|
2018-08-08 22:47:31 +01:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
antlr = stdenv.mkDerivation {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "antlr";
|
|
|
|
inherit version;
|
2019-08-14 21:45:12 +01:00
|
|
|
|
2018-08-08 22:47:31 +01:00
|
|
|
src = fetchurl {
|
|
|
|
url ="https://www.antlr.org/download/antlr-${version}-complete.jar";
|
2019-08-14 21:45:12 +01:00
|
|
|
sha256 = "1d40nfkq3ws8g4ksx4gj6l6m2l9j4b605q6sf68z5vvmg5nkhlk8";
|
2018-08-08 22:47:31 +01:00
|
|
|
};
|
|
|
|
|
2019-06-19 16:45:34 +01:00
|
|
|
dontUnpack = true;
|
2018-08-08 22:47:31 +01: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 12:01:42 +01:00
|
|
|
'';
|
2018-08-08 22:47:31 +01:00
|
|
|
|
|
|
|
inherit jre;
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit runtime;
|
|
|
|
jarLocation = "${antlr}/share/java/antlr-${version}-complete.jar";
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with stdenv.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.
|
|
|
|
'';
|
2019-04-15 00:25:45 +01:00
|
|
|
homepage = https://www.antlr.org/;
|
2018-08-11 14:40:00 +01:00
|
|
|
license = licenses.bsd3;
|
2018-08-08 22:47:31 +01:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
2017-06-15 12:01:42 +01:00
|
|
|
};
|
2018-08-08 22:47:31 +01:00
|
|
|
in antlr
|