summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/build.rs b/build.rs
index 1852601..e86db58 100644
--- a/build.rs
+++ b/build.rs
@@ -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");
}