-
Notifications
You must be signed in to change notification settings - Fork 16k
Added staleness test to keep ruby-upb.{c,h} amalgamation files in sync with upb repo #10496
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
Conversation
ruby/BUILD.bazel
Outdated
| cmd = "cp $< $@", | ||
| ) | ||
|
|
||
| generated_file_staleness_test( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this staleness test fails what are the mitigation steps? If the upb repo is the source of truth and nobody is editing these directly, this makes sense but might warrant a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the staleness test fails it will tell you how to fix it. It will output a message like:
To fix run THIS command:
bazel-bin/cmake/test_generated_files --fix
The expectation is that this will (temporarily) fail whenever we update our protobuf->upb dep to point to a newer commit:
Line 118 in f718818
| commit = "470f06cccbf26f98dd2df7ddecf24a78f140fe11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my point is more that this strategy only works for 1 directional changes. If changes are coming from both sides this won't work
| genrule( | ||
| name = "copy_ruby_amalgamation_c", | ||
| srcs = ["@upb//:ruby-upb.c"], | ||
| outs = ["generated-in/ext/google/protobuf_c/ruby-upb.c"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to allow the staleness test to more compactly support this case (i.e. just pass it the @upb targets). These genrules seem a bit hacky
Background
The Ruby C extension embeds an "amalgamation" of the upb sources into
ruby-upb.candruby-upb.h. This amalgamation is a .c/.h file pair that concatenates all the sources from upb into a single .c and .h, similar to the SQLite amalgamation: https://www.sqlite.org/amalgamation.htmlPrior to this PR, the amalgamation was only updated on an ad hoc basis, whenever someone decided to do it. This meant that the amalgamation was often months behind the canonical sources in https://github.com/protocolbuffers/upb.
PR Summary
This PR adds a staleness test, so that
ruby-upb.candruby-upb.hwill always be compared against the amalgamation as generated from the upb repo. If the amalgamation is out of date, the test will fail and the user will need to run:Initially the PR contains a patch file against upb that makes
generated_file_staleness_test()andamalgamate.pywork properly across repos. However this will be submitted separately to the upb repo, andupb.patchwill be reverted before merging this PR.