Blizzard / s2client-proto

StarCraft II Client - protocol definitions used to communicate with StarCraft II.
MIT License
3.76k stars 431 forks source link

generating protos with protoc #40

Closed ttdonovan closed 6 years ago

ttdonovan commented 6 years ago

I'm trying to generate the protos from a git submodule in my project - running the following command errors out.

$ protoc -I s2client-proto/s2clientprotocol --rust_out src/protos --proto_path s2client-proto/s2clientprotocol s2client-proto/s2clientprotocol/*.proto
s2clientprotocol/common.proto: File not found.
data.proto: Import "s2clientprotocol/common.proto" was not found or had errors.
data.proto:82:12: "SC2APIProtocol.Race" seems to be defined in "common.proto", which is not imported by "data.proto".  To use it here, please add the necessary import.

I've also tried created a symbolic link and executing this command but get a lot of "file not found" and "is not defined".

$ protoc -I ./s2clientprotocol --rust_out ./src/protos --proto_path ./s2clientprotocol ./s2clientprotocol/sc2api.proto

Any advise would greatly be appreciated.

KevinCalderone commented 6 years ago

We recently had to change how the proto files include each other to fix an issue with python.

Since the proto file is trying to include the other one as "s2clientprotocol/common.proto", the include search path has to point to the folder that contains the s2clientprotocol folder.

So, try using this as your include path option: -I s2client-proto/

I am also not sure what your proto_path option does. We don't use that in our command line options.

ttdonovan commented 6 years ago

@KevinCalderone thank you that worked I guess I mis-understood how the include path worked.

protoc -I s2client-proto --rust_out src/protos s2client-proto/s2clientprotocol/*.proto

Maybe it might be worthwhile to include instructions or an example of how to generate the protobuf code manually with protoc.

KevinCalderone commented 6 years ago

Cool I will close this then.

If you run the cmake of our s2client-api repo, it generates a "sc2protocol" project that has the protoc command line we use.

The CMake can be found here: https://github.com/KevinCalderone/s2client-api/blob/master/src/CMakeLists.txt

Example command line it generates:

..\bin\protoc -I=D:/Git5/s2client-api/src/../protocol/ --cpp_out=D:/Git5/s2client-api/build/generated D:/Git5/s2client-api/src/../protocol/s2clientprotocol/common.proto