// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
/*! Build script to integrate PyOxidizer. */
use embed_resource;
fn main() {
let target_family =
std::env::var("CARGO_CFG_TARGET_FAMILY").expect("CARGO_CFG_TARGET_FAMILY not defined");
let global_allocator_jemalloc = std::env::var("CARGO_FEATURE_GLOBAL_ALLOCATOR_JEMALLOC").is_ok();
let global_allocator_mimalloc = std::env::var("CARGO_FEATURE_GLOBAL_ALLOCATOR_MIMALLOC").is_ok();
let global_allocator_snmalloc = std::env::var("CARGO_FEATURE_GLOBAL_ALLOCATOR_SNMALLOC").is_ok();
let global_allocator_count = vec![
global_allocator_jemalloc,
global_allocator_mimalloc,
global_allocator_snmalloc,
].into_iter().filter(|x| *x).count();
if global_allocator_count > 1 {
panic!("at most 1 global-allocator-* feature must be defined; got {}", global_allocator_count);
}
// Embed the XML manifest enabling long paths into the binary.
//
// This isn't needed on Windows 10 version 1607 and above, as long paths are
// enabled by default. But being explicit provides maximum compatibility.
if target_family == "windows" {
embed_resource::compile("{{{ program_name }}}-manifest.rc");
}
if let Ok(config_rs) = std::env::var("DEP_PYTHONXY_DEFAULT_PYTHON_CONFIG_RS") {
println!(
"cargo:rustc-env=PYOXIDIZER_DEFAULT_PYTHON_CONFIG_RS={}",
config_rs
);
} else {
panic!("unable to find build artifacts generated by pyembed crate");
}
}