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

Add a public file iterator #987

Merged
merged 2 commits into from
Mar 3, 2024
Merged

Add a public file iterator #987

merged 2 commits into from
Mar 3, 2024

Conversation

gzz2000
Copy link
Contributor

@gzz2000 gzz2000 commented Mar 3, 2024

Hi, I am adding a public interface for iterating the files to be compiled.
My use case is to generate compile_commands.json outside. This configuration is needed by various language servers/IDEs and contains the mapping between source files and their compile commands. We can already get the compile commands using get_compiler, but the files are not exposed through any public interface yet.
I've made this interface a little more general by not exposing Arc<Path> but give an iterator instead.

I am also wondering if adding a compile_commands.json-generator directly into cc-rs might be useful as this is a built-in feature for many build systems including cmake, bazel, makefile, ninja, and some rust ones etc. It is better if one can generate one json combined from multiple cc::Build instances.

src/lib.rs Outdated Show resolved Hide resolved
@NobodyXu
Copy link
Collaborator

NobodyXu commented Mar 3, 2024

Thank you!

I am also wondering if adding a compile_commands.json-generator directly into cc-rs might be useful

I think that is a bit too much, cc is often used in build.rs, so it should strive to be as simple/small as possible.

I think it's better to write another crate generating compile_command.json, given the API in this PR should be enough for a third-party crate to use it directly or indirectly.

clarified the interface according to suggestion

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
@gzz2000 gzz2000 requested a review from NobodyXu March 3, 2024 08:17
Copy link
Collaborator

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

Will cut a release soon

@gzz2000
Copy link
Contributor Author

gzz2000 commented Mar 3, 2024

Thank you very much!

@NobodyXu NobodyXu merged commit acde7a1 into rust-lang:main Mar 3, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants