Skip to content

Fix flatbuffer builds for upcoming release #730

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

Merged
merged 4 commits into from
Jun 21, 2023
Merged

Conversation

pmai
Copy link
Contributor

@pmai pmai commented Jun 15, 2023

This pull request collects all fixes to the flatbuffer build to make it fully functional:

@pmai pmai added the Bug Problems in the build system, build scripts, etc or faults in the interface. label Jun 15, 2023
@pmai pmai added this to the V3.6.0 milestone Jun 15, 2023
@pmai pmai self-assigned this Jun 15, 2023
@pmai pmai force-pushed the fix/fix-flatbuffer-build branch from 46fab3e to af2de19 Compare June 15, 2023 18:02
@pmai pmai added the ReadyForCCBReview Indicates that this MR is ready for a final review and merge by the CCB. label Jun 15, 2023
Copy link
Contributor

@PhRosenberger PhRosenberger left a comment

Choose a reason for hiding this comment

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

I am not sure about the removing of the submodule and the usage of find_package instead. Let's discuss this in the CCB meeting?

@@ -1,3 +0,0 @@
[submodule "flatbuffers"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit surprised that the submodule is deleted here and find_package is used in CMakeLists instead. @pmai why do you suggest this particular change?

Background info: I find it very convenient to use a submodule here and not have the dependency on an (possibly) existing package. It is one of the pro-points on the list for flatbuffers that this is somehow possible..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While I also found this somewhat convenient, it has its own problems (both in nailing down the version of flatbuffers needlessly, and not making it easy to configure for different target settings), and it is not what we do for protobuf. And with todays availability of vcpkg and others for installing flatbuffers, it seems better to stay consistently out of the submodule business for these kinds of dependencies.

Copy link
Contributor

@PhRosenberger PhRosenberger Jun 16, 2023

Choose a reason for hiding this comment

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

Understood. On the other side, nailing down the version of flatbuffers (and possibly protobuf) could prevent some missunderstandings in combining different models / tool plugins. The flexibility to configure for different target settings is indeed very important for our project. So if using submodules can be a problem to this point, I am ok with the change here.

add_subdirectory("flatbuffers"
${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build
EXCLUDE_FROM_ALL)
find_package(flatbuffers REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment above.

COMMAND $<TARGET_FILE:flatc> -I "${PROTOBUF_IMPORT_DIRS}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${CMAKE_CURRENT_SOURCE_DIR}/${proto}"
DEPENDS "${proto}" flatc
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -I "${PROTOBUF_IMPORT_DIRS}" -I "${CMAKE_CURRENT_BINARY_DIR}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${proto}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change fixing an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes:

  • Use of -I due to the cleaner separation of SOURCE and BINARY directories (we formerly generated files in the SOURCE directory, which we shouldn't)
  • Since flatbuffers are not longer co-built, the flatc executable is not a target anymore, but rather referenced via variable.

osi_lane.proto Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

@pmai could you already test the changes and are they definetly fixing the problems when the flatbuffers compiler takes action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, everything builds correctly and the correct enums are referenced. These were the only instances where multiple same-named types were present in the same file, so this should fix it across the board. However further review testing should be conducted.

@PhRosenberger PhRosenberger removed the request for review from ClemensLinnhoff June 16, 2023 07:20
@ThomasNaderBMW
Copy link
Contributor

CCB Review, 19.06.23:

Can be merged.

@ThomasNaderBMW ThomasNaderBMW added ReadyToMerge This PR has been approved to merge and will be merged by a member of the CCB. and removed ReadyForCCBReview Indicates that this MR is ready for a final review and merge by the CCB. labels Jun 19, 2023
pmai added 4 commits June 21, 2023 12:10
This fixes the flatc calls which were broken due to clearer separation
of build and source directory usage.

Signed-off-by: Pierre R. Mai <pmai@pmsf.de>
Signed-off-by: Pierre R. Mai <pmai@pmsf.de>
This is a temporary work-around for a bug in the flatc compiler when
translating protobuf idl to fbs idl, where definition after use will
confuse the compiler when type names are reused in the same file but
different surrounding types.

Signed-off-by: Pierre R. Mai <pmai@pmsf.de>
Signed-off-by: Pierre R. Mai <pmai@pmsf.de>
@pmai pmai force-pushed the fix/fix-flatbuffer-build branch from af2de19 to ba5b394 Compare June 21, 2023 10:11
@PhRosenberger PhRosenberger self-requested a review June 21, 2023 10:12
@pmai pmai merged commit b2b979d into master Jun 21, 2023
@pmai pmai deleted the fix/fix-flatbuffer-build branch June 21, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Problems in the build system, build scripts, etc or faults in the interface. ReadyToMerge This PR has been approved to merge and will be merged by a member of the CCB.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants