-
Notifications
You must be signed in to change notification settings - Fork 29
Add script to compare core bazel and CMake headers #379
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
This gives us the most important portion of #255. In fact, it's even better than what we originally suggested, which was a blocking checkbox in code review. This solution uses `bazel query` to get the authoritative set of headers included in our main targets, `//au` and `//au:io`. It compares them to the CMake target `au`, which encompasses both of these targets. The script returns an exit code of `0` if the headers are an exact match, and `1` otherwise. If any files differ, it prints out the list of every file that is found in only bazel or only CMake. A good way to test this is to run: ```sh check-cmake-headers && echo $? ``` This should print `0` on the last line. Then, if we edit `au/code/au/CMakeLists.txt`, and _change the name_ of one of the files (say, prepend `asdf`), we should see the discrepancy printed out, and the printed exit code should change to `1`. A future PR will add a GitHub action to call this script and gate PRs on its result.
We'll revert this commit before landing this PR.
|
For proof that the script will actually work in CI, see this passed build for 1805ffa (which temporarily made it gating), and this failed build for 82e6727 (which intentionally created an error condition). |
| subprocess.run( | ||
| [ | ||
| "cmake", | ||
| "-S", |
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 tend to lean towards long arguments when using scripts to make them more self documenting. Not being a regular cmake user I have no idea what -B and -S do. Well, I have have a decent guess as to -S.
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.
Interestingly, cmake --help didn't seem to suggest a long-form alternative!
Usage
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
cmake [options] -S <path-to-source> -B <path-to-build>
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Options
-S <path-to-source> = Explicitly specify a source directory.
-B <path-to-build> = Explicitly specify a build directory.
-C <initial-cache> = Pre-load a script to populate the cache.
-D <var>[:<type>]=<value> = Create or update a cmake cache entry.
-U <globbing_expr> = Remove matching entries from CMake cache.
...
Anyway, I don't know them from memory either, but this command was basically pasted from our installation instructions. I've added a link here in a comment; thanks for pointing it out!
This gives us the most important portion of #255. In fact, it's even
better than what we originally suggested, which was a blocking checkbox
in code review. This solution uses
bazel queryto get theauthoritative set of headers included in our main targets,
//auand//au:io. It compares them to the CMake targetau, which encompassesboth of these targets.
The script returns an exit code of
0if the headers are an exactmatch, and
1otherwise. If any files differ, it prints out the listof every file that is found in only bazel or only CMake.
A good way to test this is to run:
This should print
0on the last line. Then, if we editau/code/au/CMakeLists.txt, and change the name of one of the files(say, prepend
asdf), we should see the discrepancy printed out, andthe printed exit code should change to
1.A future PR will add a GitHub action to call this script and gate PRs on
its result.