diff options
Diffstat (limited to 'pkgs/development/libraries/nanopb/test-message-with-annotations')
-rw-r--r-- | pkgs/development/libraries/nanopb/test-message-with-annotations/default.nix | 27 | ||||
-rw-r--r-- | pkgs/development/libraries/nanopb/test-message-with-annotations/withannotations.proto | 7 |
2 files changed, 34 insertions, 0 deletions
diff --git a/pkgs/development/libraries/nanopb/test-message-with-annotations/default.nix b/pkgs/development/libraries/nanopb/test-message-with-annotations/default.nix new file mode 100644 index 0000000000000..618d7c521ce00 --- /dev/null +++ b/pkgs/development/libraries/nanopb/test-message-with-annotations/default.nix @@ -0,0 +1,27 @@ +{ stdenv, protobuf, nanopb }: + +stdenv.mkDerivation { + name = "nanopb-test-message-with-annotations"; + 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 --proto_path=. --proto_path=${nanopb}/share/nanopb/generator/proto --plugin=protoc-gen-nanopb=${nanopb}/bin/protoc-gen-nanopb --nanopb_out=$out withannotations.proto + ''; + + docheck = true; + checkphase = '' + grep -q WithAnnotations $out/withannotations.pb.c || (echo "error: WithAnnotations not found in $out/withannotations.pb.c"; exit 1) + grep -q WithAnnotations $out/withannotations.pb.h || (echo "error: WithAnnotations not found in $out/withannotations.pb.h"; exit 1) + grep -q "pb_byte_t uuid\[16\]" $out/withannotations.pb.h || (echo "error: uuid is not of type pb_byte_t and of size 16 in $out/withannotations.pb.h"; exit 1) + grep -q "FIXED_LENGTH_BYTES, uuid" $out/withannotations.pb.h || (echo "error: uuid is not of fixed lenght bytes in $out/withannotations.pb.h"; exit 1) + grep -q "#define WithAnnotations_size" $out/withannotations.pb.h || (echo "error: the size of WithAnnotations is not known in $out/withannotations.pb.h"; exit 1) + ''; +} diff --git a/pkgs/development/libraries/nanopb/test-message-with-annotations/withannotations.proto b/pkgs/development/libraries/nanopb/test-message-with-annotations/withannotations.proto new file mode 100644 index 0000000000000..d8109e877d68b --- /dev/null +++ b/pkgs/development/libraries/nanopb/test-message-with-annotations/withannotations.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +import "nanopb.proto"; + +message WithAnnotations { + bytes uuid = 1 [(nanopb).max_size = 16, (nanopb).fixed_length = true]; +} |