trezor / trezor-common

:lock: Don't post issues/PRs to here, use the new monorepo:
https://github.com/trezor/trezor-firmware
GNU Lesser General Public License v3.0
91 stars 232 forks source link

Monero integration - namespace #181

Closed ph4r05 closed 6 years ago

ph4r05 commented 6 years ago

Hi,

for integration to the Monero codebase, the generated messages should have a project-specific namespace.

I am experimenting with protoc --cpp_out=src/device/trezor/messages which works quite fine for the purpose but I would need to add package to each protob file:

package hw.trezor.messages;

As this is integration project specific package I understand it cannot be in general trezor-common repository.

So the question is how to add package to each protobuf file before calling protoc to generate C++ messages. A new tool pb2cpp may handle this.

Moreover I need only subset of protobuf files:

My idea is to add a new pb2cpp which would copy these protob files to temporary directory and add/replace package directive with Monero-specific package. Then compiles the messages.

What do you think? How would you address this? Thanks

ph4r05 commented 6 years ago

I've just tested the idea and it works quite fine.

prusnak commented 6 years ago

I think we can add package hw.trezor.messages; globally, because in Java we already override this via option java_package and Python generator's don't use package value. I added this in 279bc1f220d38db9562ac9e22d61c5b94a854f9f, but I also used more granular distinction - is that OK for you?

Moreover I need only subset of protobuf files:

Don't call protoc *.proto, but just protoc file1.proto file2.proto file3.proto file4.proto

ph4r05 commented 6 years ago

Thanks, this works just fine.

ph4r05 commented 6 years ago

My devel branch: https://github.com/ph4r05/monero/tree/ph4master-trezor

WireType <-> Message conversion works: https://github.com/ph4r05/monero/blob/ph4master-trezor/src/device/trezor/messages_map.cpp