Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate messages in downstream builds #339

Merged
merged 46 commits into from
Jun 23, 2023

Conversation

mjcarroll
Copy link
Contributor

@mjcarroll mjcarroll commented May 11, 2023

🎉 New feature

Expose message generation functionality to downstream packages and remove message generation from the msgs package.

Summary

Background

Up until now, we have:

  • Distributed proto files - each describing a gz-msgs message
  • Generated .cc and .hh files in the gz-msgs package
  • The cc and hh files are compiled into a gz-msgs library that is also distributed in the binary package.

The issue with this approach is that it means that each change to a proto message will cause the ABI to break, which is inconvenient. We have multiple issues addressing this in

New Approach

This new approach will now distribute the proto files, but will no longer distribute a binary library that downstream users will link against. Instead, downstream users can generate the messages that they need themselves or add new message definitions in their own packages.

A summary of the changes required to make this happen:

  • Expose the mechanisms we use for message generation
    • This requires installing the protoc generator as well as our python script.
    • Add cmake functionality to let downstream users discover available messages and retrieve the installation path of the generator and python script (handled via cmake extras)
  • Create a core library that has the gz-msgs functionality minus the generated code.
  • Create a compiled library that maintains the CLI functionality.
  • Make conversions a header-only operation, so that the core library doesn't need to depend on the generated messages.

Downstream changes required:

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@github-actions github-actions bot added the 🎵 harmonic Gazebo Harmonic label May 11, 2023
@mjcarroll mjcarroll force-pushed the mjcarroll/rework-message-generation2 branch 5 times, most recently from 8eca9ee to 9e55508 Compare May 11, 2023 20:50
@mjcarroll mjcarroll marked this pull request as ready for review May 18, 2023 13:11
@mjcarroll mjcarroll requested a review from caguero as a code owner May 18, 2023 13:11
@mjcarroll mjcarroll force-pushed the mjcarroll/rework-message-generation2 branch from 79041c4 to 3a66601 Compare May 19, 2023 14:30
@caguero
Copy link
Collaborator

caguero commented May 19, 2023

Just checking, we can't compile the whole harmonic yet with only this PR, right?

@caguero
Copy link
Collaborator

caguero commented May 19, 2023

Could you help me a bit with the expectations after this PR? What can I do and what can't I do yet (if any)?

@caguero
Copy link
Collaborator

caguero commented May 19, 2023

@mjcarroll
Copy link
Contributor Author

Just checking, we can't compile the whole harmonic yet with only this PR, right?

Correct, I am working on the corresponding downstream modifications.

Could you help me a bit with the expectations after this PR? What can I do and what can't I do yet (if any)?

I still owe some documentation here. The general expectation is that gz-msgs will only install proto files as part of the debians, rather than generated headers and libraries. Downstream libraries will generate the cc/hh files from protos as part of their build process.

We should expect that with this PR, you should be able to add messages to your project, as demonstrated in this example: https://github.com/mjcarroll/mjcarroll-custom-msgs

This will also provide users a way to define custom messages downstream with simple cmake macros.

Does this PR require https://github.com/gazebosim/gz-cmake/pull/345/files?

Correct, it was just merged, and I'm going to cut a release shortly.

@mjcarroll
Copy link
Contributor Author

@osrf-jenkins retest this please

Copy link
Collaborator

@caguero caguero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm compiling Harmonic with the understanding that it won't successfully compile all libraries. After running colcon I see generated .pb.h files under ./build/gz-msgs10/gz_msgs_gen/gz/msgs. Is that expected?

@caguero
Copy link
Collaborator

caguero commented May 22, 2023

I also see these two warning messages:

--- stderr: gz-msgs10                                                                                               
warning: tag INPUT: input source '/home/caguero/harmonic_ws/build/gz-msgs10/include/gz/msgs/details' does not exist
warning: tag INPUT: input source '/home/caguero/harmonic_ws/build/gz-msgs10/include/gz/msgs/details' does not exist

cmake/gz_msgs_protoc.cmake Outdated Show resolved Hide resolved
core/generator/Generator.cc Outdated Show resolved Hide resolved
compiled/CMakeLists.txt Outdated Show resolved Hide resolved
test/integration/CMakeLists.txt Outdated Show resolved Hide resolved
@mjcarroll
Copy link
Contributor Author

I'm compiling Harmonic with the understanding that it won't successfully compile all libraries. After running colcon I see generated .pb.h files under ./build/gz-msgs10/gz_msgs_gen/gz/msgs. Is that expected?

Yes, this is correct. They are being generated to run the tests.

@mjcarroll
Copy link
Contributor Author

@caguero I have opened PRs for all downstream libraries and added examples/READMEs.

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update Migradtion.md guide?

tools/gz_msgs_generate_factory.py Outdated Show resolved Hide resolved
examples/generating_custom_msgs/main.cc Outdated Show resolved Hide resolved
examples/using_gz_msgs/main.cc Outdated Show resolved Hide resolved
examples/generating_custom_msgs/main.cc Show resolved Hide resolved
mjcarroll and others added 15 commits June 23, 2023 13:36
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Co-authored-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll mjcarroll force-pushed the mjcarroll/rework-message-generation2 branch from d299cbb to a775cb5 Compare June 23, 2023 13:36
@mjcarroll
Copy link
Contributor Author

Okay, all feedback addressed and rebased to get DCO happy. I think we are good here, and then a prerelease?

@mjcarroll mjcarroll merged commit 0c78b96 into main Jun 23, 2023
@mjcarroll mjcarroll deleted the mjcarroll/rework-message-generation2 branch June 23, 2023 17:04
include(${@PROJECT_NAME@_DIR}/gz_msgs_generate.cmake)
include(${@PROJECT_NAME@_DIR}/target_link_messages.cmake)

set(@PROJECT_NAME@_INSTALL_PATH "${@PROJECT_NAME@_DIR}/../../..")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the other issues I've been seeing with the /usr/lib/<arch> folder in gazebo-release/gz-msgs10-release#3 and gazebosim/gz-cmake#360, I'm a bit suspicious that this hard-coded ../../.. is wrong

mjcarroll added a commit that referenced this pull request Jul 12, 2023
This reverts commit 0c78b96.

Signed-off-by: Michael Carroll <[email protected]>
mjcarroll added a commit that referenced this pull request Jul 12, 2023
* Revert "Use cmake extras path variables (#359)"

This reverts commit 786b42a.

Signed-off-by: Michael Carroll <[email protected]>

* Revert "Unconditionally find the python interpreter (#356)"

This reverts commit 16de9ef.

Signed-off-by: Michael Carroll <[email protected]>

* Revert "Generate messages in downstream builds (#339)"

This reverts commit 0c78b96.

Signed-off-by: Michael Carroll <[email protected]>

---------

Signed-off-by: Michael Carroll <[email protected]>
@azeey azeey mentioned this pull request Jul 15, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants