4 releases
Uses new Rust 2024
| 0.3.2 | May 4, 2026 |
|---|---|
| 0.3.1 | Dec 3, 2025 |
| 0.3.0 | Jun 12, 2024 |
| 0.2.0 | Nov 2, 2019 |
#788 in Build Utils
129 downloads per month
Used in 3 crates
14KB
231 lines
libperl-config
Build-time helper for crates that link against libperl. Reads the
local Perl installation's Config.pm (via perl -V:...) and turns
the answers into cargo: directives + cfg(...) flags.
Used by libperl-sys and
libperl-rs build scripts to:
- emit
cargo:rustc-link-search/rustc-link-lib/rustc-link-argfrom$Config{ccopts}and$Config{ldopts}, - expose feature toggles like
cfg(perl_useithreads)based on$Config{useithreads}, - emit per-API-version cfgs (
cfg(perlapi_ver26)...cfg(perlapi_ver42)) so source can branch on Perl version.
Typical usage in a downstream build.rs:
use libperl_config::PerlConfig;
fn main() {
let config = PerlConfig::default();
config.emit_cargo_ldopts();
config.emit_features(&["useithreads"]);
config.emit_all_perlapi_versions(10);
}
See PerlConfig for the full API.
libperl-config
Build-time helper for crates that link against libperl. Reads the
local Perl installation's Config.pm (via perl -V:...) and turns
the answers into cargo: directives + cfg(...) flags.
Used by libperl-sys and libperl-rs build scripts.
Usage
// build.rs
use libperl_config::PerlConfig;
fn main() {
let config = PerlConfig::default();
config.emit_cargo_ldopts(); // link flags from $Config{ldopts}
config.emit_features(&["useithreads"]); // cfg(perl_useithreads) if set
config.emit_all_perlapi_versions(10); // cfg(perlapi_ver26)..ver42
}
The dependent crate's source can then write things like:
#[cfg(perl_useithreads)]
fn foo(my_perl: *mut PerlInterpreter) { ... }
#[cfg(not(perl_useithreads))]
fn foo() { ... }
License
GPL-1.0-or-later OR Artistic-1.0-Perl. Same terms as Perl 5 itself.
Dependencies
~2.7–4MB
~67K SLoC