about summary refs log tree commit diff
path: root/pkgs/development/interpreters/cg3/default.nix
blob: 8aa0d412c1cf3bfe93a5ddfad20d62fb9d0e7d75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ lib
, stdenv
, fetchFromGitHub
, runCommand
, dieHook
, cmake
, icu
, boost
}:

let cg3 = stdenv.mkDerivation rec {
  pname = "cg3";
  version = "1.3.9";

  src = fetchFromGitHub {
    owner = "GrammarSoft";
    repo = "${pname}";
    rev = "v${version}";
    sha256 = "sha256-TiEhhk90w5GibGZ4yalIf+4qLA8NoU6+GIPN6QNTz2A=";
  };

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [
    icu
    boost
  ];

  doCheck = true;

  postFixup = ''
    substituteInPlace "$out"/lib/pkgconfig/cg3.pc \
      --replace '=''${prefix}//' '=/'
  '';

  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