summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-06-19 11:12:04 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-06-19 11:25:17 +0100
commit162cc051e68adc29519114315bf40e9aec15c14d (patch)
tree3452a6c4d3f343ec1fa6811e5d53f64f1e6cd510 /src
parent2d1e97a133302172d77e63802c63ba4786d788cd (diff)
downloadsubplot-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 'src')
-rw-r--r--src/graphmarkup.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/graphmarkup.rs b/src/graphmarkup.rs
index 78ffe89..f5637dc 100644
--- a/src/graphmarkup.rs
+++ b/src/graphmarkup.rs
@@ -29,6 +29,13 @@ pub struct MarkupOpts {
env = "SUBPLOT_PLANTUML_JAR_PATH"
)]
plantuml_jar_path: Option<PathBuf>,
+ #[structopt(
+ long = "java",
+ help = "Path to Java executable (note, effectively overrides JAVA_HOME if set to an absolute path)",
+ name = "JAVA_PATH",
+ env = "SUBPLOT_JAVA_PATH"
+ )]
+ java_path: Option<PathBuf>,
}
impl MarkupOpts {
@@ -40,13 +47,17 @@ impl MarkupOpts {
if let Some(plantuml_path) = &self.plantuml_jar_path {
*PLANTUML_JAR_PATH.lock().unwrap() = plantuml_path.clone();
}
+ if let Some(java_path) = &self.java_path {
+ *JAVA_PATH.lock().unwrap() = java_path.clone();
+ }
}
}
lazy_static! {
- static ref DOT_PATH: Mutex<PathBuf> = Mutex::new("dot".into());
+ static ref DOT_PATH: Mutex<PathBuf> = Mutex::new(env!("BUILTIN_DOT_PATH").into());
static ref PLANTUML_JAR_PATH: Mutex<PathBuf> =
- Mutex::new("/usr/share/plantuml/plantuml.jar".into());
+ Mutex::new(env!("BUILTIN_PLANTUML_JAR_PATH").into());
+ static ref JAVA_PATH: Mutex<PathBuf> = Mutex::new(env!("BUILTIN_JAVA_PATH").into());
}
/// A code block with markup for a graph.
@@ -181,7 +192,7 @@ impl PlantumlMarkup {
impl GraphMarkup for PlantumlMarkup {
fn as_svg(&self) -> Result<Vec<u8>> {
- let mut cmd = Command::new("java");
+ let mut cmd = Command::new(JAVA_PATH.lock().unwrap().clone());
cmd.arg("-Djava.awt.headless=true")
.arg("-jar")
.arg(PLANTUML_JAR_PATH.lock().unwrap().clone())