rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

What is the real difference between compile and library? #278

Closed yeukhon closed 1 year ago

yeukhon commented 1 year ago

Description

For example, I was generating proto with python_proto_compile and python_proto_library and they both generate the same pb2.py file.

I am not sure if I really understand the differnce based on the doc:

python_proto_compile | Generates Python protobuf .py files python_proto_library | Generates a Python protobuf library using py_library from rules_python

aaliddell commented 1 year ago

The compile rules will simply run protoc on the inputs and return the output files; it's then up to you to integrate these files into your build with the correct prefixes.

The library rules take the files from protoc and wrap them in a py_library target that has the import path setup etc, so that your py_binary targets can directly depend on this library.

yeukhon commented 1 year ago

Oh, so let me put this more plainly. They both generate the same .py file, but for the purpose of BUILD targets, the library rule is a regular py_library that I can use like any other py_library, while the compile rule does none of that, just the file generation alone. Thanks

aaliddell commented 1 year ago

Yep 👍