From a6b92c07076f5048a2686fe9d5a2ea1096b7a8ae Mon Sep 17 00:00:00 2001 From: konstin Date: Sat, 26 May 2018 12:04:58 +0200 Subject: [PATCH] Rerun the build script if any relevant env var changed --- build.rs | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/build.rs b/build.rs index bd4df266..cdf507a4 100644 --- a/build.rs +++ b/build.rs @@ -41,18 +41,18 @@ const PY3_MIN_MINOR: u8 = 5; const CFG_KEY: &'static str = "py_sys_config"; -// A list of python interpreter compile-time preprocessor defines that -// we will pick up and pass to rustc via --cfg=py_sys_config={varname}; -// this allows using them conditional cfg attributes in the .rs files, so -// -// #[cfg(py_sys_config="{varname}"] -// -// is the equivalent of #ifdef {varname} name in C. -// -// see Misc/SpecialBuilds.txt in the python source for what these mean. -// -// (hrm, this is sort of re-implementing what distutils does, except -// by passing command line args instead of referring to a python.h) +/// A list of python interpreter compile-time preprocessor defines that +/// we will pick up and pass to rustc via --cfg=py_sys_config={varname}; +/// this allows using them conditional cfg attributes in the .rs files, so +/// +/// #[cfg(py_sys_config="{varname}"] +/// +/// is the equivalent of #ifdef {varname} name in C. +/// +/// see Misc/SpecialBuilds.txt in the python source for what these mean. +/// +/// (hrm, this is sort of re-implementing what distutils does, except +/// by passing command line args instead of referring to a python.h) #[cfg(not(target_os = "windows"))] static SYSCONFIG_FLAGS: [&'static str; 7] = [ "Py_USING_UNICODE", @@ -239,11 +239,16 @@ fn get_rustc_link_lib(version: &PythonVersion, _: &str, _: bool) -> Result Result<(PythonVersion, String, Vec), String> { @@ -486,7 +491,6 @@ fn main() { // rust-cypthon/build.rs contains an example of how to unpack this data // into cfg flags that replicate the ones present in this library, so // you can use the same cfg syntax. - //let mut flags = flags; let flags: String = config_map.iter().fold("".to_owned(), |memo, (key, val)| { if is_value(key) { memo + format!("VAL_{}={},", key, val).as_ref() @@ -505,4 +509,16 @@ fn main() { "" } ); + + let env_vars = [ + "LD_LIBRARY_PATH", + "LIBRARY_PATH", + "PATH", + "PYTHON_LIB", + "PYTHON_SYS_EXECUTABLE", + ]; + + for var in env_vars.iter() { + println!("cargo:rerun-if-env-changed={}", var); + } }