1

Im trying to build my proto files in a way that what proto files I include is publicly available when I build to the various languages. I have tried import public "webrtc/signaling.proto" and it removes the "is not used" message, but the message type of RTCMessage is still not included in my c# build Mafia.cs when I use the command ./protoc.exe -I=G:/MafiaProject/MafiaProtobuf/protofiles --csharp_out=G:/MafiaProject/MafiaProtobuf/csharp_out G:/MafiaProject/MafiaProtobuf/protofiles/mafia.proto but seemingly is included when I build for go.

syntax = "proto3";
option go_package = "github.com/rgeorgeoff/webRTCProto";
package webrtc;

enum ReqType {
  SDP = 0;
  ICE = 1;
}

message RTCMessage {
  ReqType req_type = 1;
  bytes data = 2;
}

And in mafia.proto which is a directory above:

syntax = "proto3";
option go_package = "github.com/rgeorgeoff/SlimePartyGoServer/protobuf3";
package mafia;
import "webrtc/signaling.proto";

... other definitions...

I just want the message types/enums to be available in the build files (python/go/etc) in my build. Do I have to build all the files individually as well for c# and copy them over individually?

Matteo
  • 37,680
  • 11
  • 100
  • 115
Teddy
  • 53
  • 4

1 Answers1

1

You should pass all the path of your proto files as input argument to the protoc command, as example:

protoc -I="."/MafiaProject/MafiaProtobuf/protofiles --csharp_out="."/MafiaProject/MafiaProtobuf/csharp_out MafiaProject/MafiaProtobuf/protofiles/.proto MafiaProject/MafiaProtobuf/protofiles/webrtc/.proto

Considering a tree structure like:

MafiaProject
└── MafiaProtobuf
    ├── csharp_out
    │   ├── Mafia.cs
    │   └── Signaling.cs
    └── protofiles
        ├── mafia.proto
        └── webrtc
            └── signaling.proto
Matteo
  • 37,680
  • 11
  • 100
  • 115
  • 1
    Yep, this worked, thanks. My work around was just to have a bash script to build a file and then bash scripts calling bash scripts. A right mess really. For some extra context, you can also include multiple -I= if they are not in the same root directory! :D – Teddy Dec 08 '20 at 11:36