diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-06-19 11:12:04 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-06-19 11:25:17 +0100 |
commit | 162cc051e68adc29519114315bf40e9aec15c14d (patch) | |
tree | 3452a6c4d3f343ec1fa6811e5d53f64f1e6cd510 /build.rs | |
parent | 2d1e97a133302172d77e63802c63ba4786d788cd (diff) | |
download | subplot-162cc051e68adc29519114315bf40e9aec15c14d.tar.gz |
build: Support dot/plantuml.jar paths via build environment variables
This also adds Java binary path override
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -118,6 +118,24 @@ fn write_out_resource_file<'a>(paths: impl Iterator<Item = &'a Path>) -> Result< Ok(()) } +/// Adopt an environment variable into the build. +/// +/// This entails watching `SUBPLOT_{var}` and setting build environment +/// to contain `BUILTIN_{var}` to either the env value, or `{def}` if not +/// provided. +fn adopt_env_var(var: &str, def: &str) { + println!("cargo:rerun-if-env-changed=SUBPLOT_{var}", var = var); + if let Ok(value) = std::env::var(format!("SUBPLOT_{var}", var = var)) { + println!( + "cargo:rustc-env=BUILTIN_{var}={value}", + var = var, + value = value + ); + } else { + println!("cargo:rustc-env=BUILTIN_{var}={def}", var = var, def = def); + } +} + fn main() { println!("cargo:rerun-if-env-changed=DEB_BUILD_OPTIONS"); let paths = if std::env::var("DEB_BUILD_OPTIONS").is_err() { @@ -129,4 +147,7 @@ fn main() { }; write_out_resource_file(paths.iter().map(PathBuf::as_path)) .expect("Unable to write the resource file out"); + adopt_env_var("DOT_PATH", "dot"); + adopt_env_var("PLANTUML_JAR_PATH", "/usr/share/plantuml/plantuml.jar"); + adopt_env_var("JAVA_PATH", "java"); } |