summary refs log tree commit diff
path: root/pkgs/development/libraries/nanopb/test-simple-proto2/default.nix
blob: a915e7785370c28e38eb8da23082fdbb7b3373d9 (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
{ stdenv, protobuf, nanopb }:

stdenv.mkDerivation {
  name = "nanopb-test-simple-proto2";
  meta.timeout = 60;
  src = ./.;

  # protoc requires any .proto file to be compiled to reside within it's
  # proto_path. By default the current directory is automatically added to the
  # proto_path. I tried using --proto_path ${./.} ${./simple.proto} and it did
  # not work because they end up in the store at different locations.
  installPhase = ":";
  buildPhase = ''
    mkdir $out

    ${protobuf}/bin/protoc --plugin=protoc-gen-nanopb=${nanopb}/bin/protoc-gen-nanopb --nanopb_out=$out simple.proto
  '';

  doCheck = true;
  checkPhase = ''
    grep -q SimpleMessage $out/simple.pb.c || (echo "ERROR: SimpleMessage not found in $out/simple.pb.c"; exit 1)
    grep -q SimpleMessage $out/simple.pb.h || (echo "ERROR: SimpleMessage not found in $out/simple.pb.h"; exit 1)
  '';
}