2022-09-09 14:08:57 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, runCommand
|
|
|
|
, dieHook
|
|
|
|
, cmake
|
|
|
|
, icu
|
|
|
|
, boost
|
|
|
|
}:
|
|
|
|
|
|
|
|
let cg3 = stdenv.mkDerivation rec {
|
|
|
|
pname = "cg3";
|
2022-10-21 18:38:19 +00:00
|
|
|
version = "1.3.9";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "GrammarSoft";
|
|
|
|
repo = "${pname}";
|
|
|
|
rev = "v${version}";
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-TiEhhk90w5GibGZ4yalIf+4qLA8NoU6+GIPN6QNTz2A=";
|
2022-09-09 14:08:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
icu
|
|
|
|
boost
|
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
postFixup = ''
|
|
|
|
substituteInPlace "$out"/lib/pkgconfig/cg3.pc \
|
|
|
|
--replace '=''${prefix}//' '=/'
|
|
|
|
'';
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
passthru.tests.minimal = runCommand "${pname}-test" {
|
|
|
|
buildInputs = [
|
|
|
|
cg3
|
|
|
|
dieHook
|
|
|
|
];
|
|
|
|
} ''
|
|
|
|
echo 'DELIMITERS = "."; ADD (tag) (*);' >grammar.cg3
|
|
|
|
printf '"<a>"\n\t"a" tag\n\n' >want.txt
|
|
|
|
printf '"<a>"\n\t"a"\n\n' | vislcg3 -g grammar.cg3 >got.txt
|
|
|
|
diff -s want.txt got.txt || die "Grammar application did not produce expected parse"
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
# TODO, consider optionals:
|
|
|
|
# - Enable tcmalloc unless darwin?
|
|
|
|
# - Enable python bindings?
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/GrammarSoft/cg3";
|
|
|
|
description = "Constraint Grammar interpreter, compiler and applicator vislcg3";
|
|
|
|
maintainers = with maintainers; [ unhammer ];
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
cg3
|