Comments (2)
I think it would be a useful extension here, but I don't know a good way to accomplish it. The crude way would be to add -L target/$profile/deps
to the rustc
commands, if we can figure out that path, and you would also need extern crate libc;
in the probe code to load it. However, this would fail if there are multiple candidate libraries in that path, which can happen due to changing build flags or other factors.
The clean way to add dependency crates would be with --extern
, as cargo would pass to rustc itself. I think there's already a feature request issue on cargo to communicate that to build scripts, but I can't find it right now...
from autocfg.
Tried to mess a bit with autocfg but got blocked by the rustc_private
feature.
In the meantime I found a temporary solution:
extern crate autocfg;
use std::process::Command;
use std::process::Output;
fn main() {
// TODO how to get around rustc_private with autocfg
// FIXME temporary solution: rust-script compiles for and runs in the local system? I want to test-compile for the target system or similar
// does rust-script work? (warning: outputs to stdout/stderr)
let status = Command::new("rust-script").arg("--version").status().expect("rust-script is required, running 'cargo install rust-script' in the console should fix this error\n");
if !status.success() {
panic!("rust-script: {}", status);
}
// sanity check: libc::size_t should always exist
assert!(Command::new("rust-script").args(["--dep", "libc", "--expr", "{ let _: libc::size_t = 0; }"]).output().unwrap().status.success());
fn probe_dep_path(dep: &str, path: &str) -> Output {
let expr = format!("{{ use {}; }}", path);
Command::new("rust-script").args(["--dep", dep, "--expr", &expr]).output().unwrap()
}
fn emit_dep_path_cfg(dep: &str, path: &str, cfg: &str) {
if probe_dep_path(dep, path).status.success() {
autocfg::emit(cfg);
}
}
emit_dep_path_cfg("libc", "libc::B76800", "has_libc_B76800");
// ...
}
from autocfg.
Related Issues (20)
- Is there some way to hide the rustc output? HOT 6
- Can I probe for const generics support? HOT 3
- autocfg does not work in the presence of -Z build-std HOT 8
- hanging on aarch64 HOT 3
- error: could not compile `autocfg` HOT 4
- Backport CARGO_ENCODED_RUSTFLAGS to version 0.1 HOT 2
- Consider adding `--cap-lints=warn` to probe `rustc` invocations
- 'probe' does not work under Miri HOT 3
- Not compiling in Docker image running on M1 Mac using `--platform linux/amd64` HOT 3
- Build errors on riscv64-linux HOT 2
- Program unexpected panic when unwrap is used HOT 1
- Fails to detect crate std on NixOS HOT 7
- Test for specific named feature in std? HOT 2
- autocfg still calls rustc without the wrapper HOT 13
- Racy failures in `test_wrappers`
- Add support for `--check-cfg` [Rust 1.80]
- test suite unreliable since v1.2.0 HOT 3
- Add a check for supporting `extern "x"` values
- Add a method to control the `--edition`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autocfg.