File: build.rs

package info (click to toggle)
rust-isahc 1.7.2%2Bds-20
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,044 kB
  • sloc: perl: 258; python: 148; makefile: 24; sh: 1
file content (18 lines) | stat: -rw-r--r-- 576 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::{env, error::Error};

fn main() -> Result<(), Box<dyn Error>> {
    println!("cargo:rustc-env=ISAHC_FEATURES={}", get_feature_string());

    Ok(())
}

/// Generate a "feature string" for the crate features currently enabled.
fn get_feature_string() -> String {
    env::vars()
        .filter(|(name, _)| name.starts_with("CARGO_FEATURE_"))
        .filter(|(_, value)| value == "1")
        .map(|(name, _)| name.trim_start_matches("CARGO_FEATURE_").to_lowercase())
        .map(|name| name.replace('_', "-"))
        .collect::<Vec<String>>()
        .join(",")
}