depot/third_party/nixpkgs/pkgs/development/libraries/nanopb/test-simple-proto3/default.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

26 lines
975 B
Nix

{ lib, stdenv, protobuf, nanopb }:
stdenv.mkDerivation {
name = "nanopb-test-simple-proto3";
meta.timeout = 60;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [ ./simple.proto ];
};
# 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.
dontInstall = true;
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)
'';
}