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

Allow c2rust transpile to accept a single C file without a compile_commands.json #76

Open
rinon opened this issue Apr 19, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@rinon
Copy link
Contributor

rinon commented Apr 19, 2019

We already support adding compiler flags to a transpiler run, so we can do without compile_commands.json if we're doing a one-off translation of a single file.

@rinon rinon added the enhancement New feature or request label Apr 19, 2019
@kkysen kkysen changed the title Allow transpiler to accept a single C file without compile_commands.json Allow c2rust transpile to accept a single C file without a compile_commands.json Jun 29, 2022
@kornelski
Copy link

kornelski commented Sep 15, 2022

That would be great. I assumed c2rust command would behave like cc or bindgen and was utterly confused by the errors it reported.

intercept-build command requires Python, which is a major pain.

An example 1-file commands.json in the repo would be very useful, so that I could fudge it to refer to whatever file I need. When migrating projects the first thing I do is moving to build.rs and Rust's cc crate to build my C code, which ironically makes intercept-build unusable. When migrating C projects I always want to migrate them file by file, not the whole thing at once.

@kkysen
Copy link
Contributor

kkysen commented Sep 15, 2022

intercept-build command requires Python, which is a major pain.

bear is written in C++ now; you could try that. That's usually what I use.

An example 1-file commands.json in the repo would be very useful, so that I could fudge it to refer to whatever file I need. When migrating projects the first thing I do is moving to build.rs and Rust's cc crate to build my C code, which ironically makes c2rust unusable. When migrating C projects I always want to migrate them file by file, not the whole thing at once.

c2rust allows you to transpile the whole project at once since the semantics should be identical, and then refactor to safe Rust file by file, or whatever granularity you want. That way you don't have to deal with mixing C and Rust at any point, just C-like unsafe and C ABI Rust and idiomatic Rust.

@thedataking
Copy link
Contributor

@kkysen I think this is a very reasonable request. Happy to brainstorm with you or review a PR that lifts the requirement to provide compile_commands.json. We need to make sure that we do not attempt to emit Rust unless all included files were found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants