Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Easier conversion from cc::Build to cpp_build::Config ? #110

Closed
ian-h-chamberlain opened this issue Apr 26, 2024 · 1 comment · Fixed by #111
Closed

Easier conversion from cc::Build to cpp_build::Config ? #110

ian-h-chamberlain opened this issue Apr 26, 2024 · 1 comment · Fixed by #111

Comments

@ian-h-chamberlain
Copy link
Contributor

Hi, I recently started looking at using this library as a way to generate tests that cross a C/Rust boundary, and so far it's working pretty well!

In our case, we are already using a cc::Build for some C libraries, so I thought it would be nice if there was a simple way to translate between the two, so we don't have to repeat all of our builder flags, e.g.

    cc::Build::new()
        .compiler(&cc)
        .archiver(&ar)
        .include(&include_path)
        .file(out_dir.join("libctru_statics_wrapper.c"))
        .flag("-march=armv6k")
        .flag("-mtune=mpcore")
        .flag("-mfloat-abi=hard")
        .flag("-mfpu=vfp")
        .flag("-mtp=soft")
        .flag("-Wno-deprecated-declarations")
        .compile("ctru_statics_wrapper");

    cpp_build::Config::default()
        .compiler(cc)
        .archiver(ar)
        .include(include_path)
        .flag("-march=armv6k")
        .flag("-mtune=mpcore")
        .flag("-mfloat-abi=hard")
        .flag("-mfpu=vfp")
        .flag("-mtp=soft")
        .flag("-Wno-deprecated-declarations")
        .build(generated_test_file);

Would you be open to a PR adding a From<cc::Build> implementation for cpp_build::Config? The downside would be adding cc as a public API (I don't think it is currently), but would make maintaining a set of flags/include paths/tools like this a bit simpler.

Thanks!

@ogoffart
Copy link
Collaborator

Would you be open to a PR adding a Fromcc::Build implementation for cpp_build::Config?

I think that makes sense

The downside would be adding cc as a public API (I don't think it is currently), but would make maintaining a set of flags/include paths/tools like this a bit simpler.

Given that cc has been in the 1.0 for so long and proven to be stable, I think this is not a problem. And probably a good thing to expose it directly

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants