-
Notifications
You must be signed in to change notification settings - Fork 507
Support for building executables #46
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
Comments
Unfortunately this doesn't quite play well with this crate's cross compilation story. If you want to get the value of a |
Hmm, I hadn't thought of that. I can see it getting messy if the executable Maybe the most universal way for automatic defines extraction is closer to Anyway I still consider the option to fork gcc-rs to provide only On Sun, Jun 21, 2015, 15:20 Alex Crichton notifications@github.com wrote:
|
This crate could certainly provide the ability to build executables, but I think I'd prefer to not do so as it's not something that should be relied upon. That being said, if this crate could facilitate you in emitting a binary, feel free to open an issue! |
on a side-note for anyone reaching this issue: You can use this crate to create executables quite easily: let mut gcc = gcc::Config::new();
gcc.cpp(true);
gcc.include(".");
let mut cmd = gcc.get_compiler().to_command();
cmd.arg("main.cpp");
assert!(cmd.status().unwrap().success()); |
I'd appreciate proper support for creating executables as well. Our use case is that we have a crate with a C API that we want to compile tests for. We wouldn't mind building for the target and not for the build host if we are cross-compiling. Currently, we invoke |
I can create a pull request for this, but I wanted to discuss it first.
In some situations I find myself writing small C programs to generate Rust files with const's taken from header defines. For such it would practical to reuse gcc-rs abstractions over a C compiler.
Therefore, I propose a
compile_exectuable
function and to changeConfig::compile
behavior to detect whether to build an executable or a lib based on the simple pattern, lib.so* for a library, and "not . and not lib*" for executable.The text was updated successfully, but these errors were encountered: