()
| 15 | } |
| 16 | |
| 17 | fn main() { |
| 18 | if cfg!(feature = "python27-sys") |
| 19 | && (watched_var_os("CARGO_FEATURE_PY_LINK_MODE_DEFAULT").is_some() |
| 20 | || watched_var_os("CARGO_FEATURE_PY_LINK_MODE_UNRESOLVED_STATIC").is_some()) |
| 21 | { |
| 22 | eprintln!("Cannot use link mode control with Python 2.7"); |
| 23 | std::process::exit(1); |
| 24 | } |
| 25 | |
| 26 | // python{27,3.x}-sys/build.rs passes python interpreter compile flags via |
| 27 | // environment variable (using the 'links' mechanism in the cargo.toml). |
| 28 | let flags = match env::var(PYTHONSYS_ENV_VAR) { |
| 29 | Ok(flags) => flags, |
| 30 | Err(_) => { |
| 31 | eprintln!( |
| 32 | concat!( |
| 33 | "Environment variable {} not found - this is supposed to be ", |
| 34 | "exported from the pythonXX-sys dependency, so the build ", |
| 35 | "chain is broken" |
| 36 | ), |
| 37 | PYTHONSYS_ENV_VAR |
| 38 | ); |
| 39 | std::process::exit(1); |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | if !flags.is_empty() { |
| 44 | for f in flags.split(',') { |
| 45 | // write out flags as --cfg so that the same #cfg blocks can be used |
| 46 | // in rust-cpython as in the -sys libs |
| 47 | let key_and_val: Vec<&str> = f.split('=').collect(); |
| 48 | let key = key_and_val[0]; |
| 49 | let val = key_and_val[1]; |
| 50 | if key.starts_with("FLAG") { |
| 51 | println!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, &key[5..]) |
| 52 | } else { |
| 53 | println!("cargo:rustc-cfg={}=\"{}_{}\"", CFG_KEY, &key[4..], val); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
nothing calls this directly
no test coverage detected