Repository navigation
Resolve CMake File API source paths against the top-level source dir - #61
Open
mateusz-olczyk wants to merge 1 commit into
Open
mateusz-olczyk wants to merge 1 commit into
mateusz-olczyk wants to merge 1 commit into
Conversation
The File API reports `sources[].path` relative to the top-level source directory (`codemodel.paths.source`, i.e. `cmake -S`) whenever the file is inside it, and absolute otherwise. extract_cmake passed those paths through unchanged, and reconstruct only rebases absolute paths onto `<repo_root>`. This is fine when `-S` is the repo root, but when the CMake project lives in a subdirectory of the Bazel workspace (`cmake -S sub/proj`), TU keys came out as `src/a.c` instead of `sub/proj/src/a.c`. Those sources then looked missing on the CMake side and extra on the Bazel side, even though both builds compiled the same files. Only sources under the project dir were affected; sources outside it were already reported absolute and keyed correctly, so a target could show a mix of correct and bogus keys. extract_cmake now makes source paths absolute against `codemodel.paths.source` (falling back to `<repo_root>` for replies without `paths`), in both the synthesized `-c` argument and the action inputs. Repo-relative keying then works as it already does for include directories. Out-of-tree absolute sources are unchanged. A new extractor test covers a project configured from a subdirectory with one in-tree and one out-of-tree source; it fails without the fix. docs/REFERENCE-cmake.md notes that `-S` may be any directory under `<repo_root>`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The File API reports
sources[].pathrelative to the top-level source directory (codemodel.paths.source, i.e.cmake -S) whenever the file is inside it, and absolute otherwise. extract_cmake passed those paths through unchanged, and reconstruct only rebases absolute paths onto<repo_root>.This is fine when
-Sis the repo root, but when the CMake project lives in a subdirectory of the Bazel workspace (cmake -S sub/proj), TU keys came out assrc/a.cinstead ofsub/proj/src/a.c. Those sources then looked missing on the CMake side and extra on the Bazel side, even though both builds compiled the same files. Only sources under the project dir were affected; sources outside it were already reported absolute and keyed correctly, so a target could show a mix of correct and bogus keys.extract_cmake now makes source paths absolute against
codemodel.paths.source(falling back to<repo_root>for replies withoutpaths), in both the synthesized-cargument and the action inputs. Repo-relative keying then works as it already does for include directories. Out-of-tree absolute sources are unchanged.A new extractor test covers a project configured from a subdirectory with one in-tree and one out-of-tree source; it fails without the fix. docs/REFERENCE-cmake.md notes that
-Smay be any directory under<repo_root>.