From 5aafea22888b69661160b94eadfc0ab076876440 Mon Sep 17 00:00:00 2001 From: ynqa Date: Wed, 20 Mar 2024 16:06:36 +0900 Subject: [PATCH 1/2] check whether autoconf/automake are installed and building goes failed if they are not installed --- j9-sys/build.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/j9-sys/build.rs b/j9-sys/build.rs index d29e349..40a2e5d 100644 --- a/j9-sys/build.rs +++ b/j9-sys/build.rs @@ -4,9 +4,33 @@ extern crate bindgen; use std::{ env, fs, path::{Path, PathBuf}, + process::Command, }; +fn check_installed(name: &str) -> anyhow::Result<()> { + let check = Command::new(name) + .arg("--version") + .output(); + + match check { + Ok(output) => { + if !output.status.success() { + return Err(anyhow::anyhow!("{} is required, but it's not installed or not in PATH.", name)); + } + }, + Err(_) => { + return Err(anyhow::anyhow!("{} is required, but it's not installed or not in PATH.", name)); + } + } + + Ok(()) +} + fn main() -> anyhow::Result<()> { + // Check if autoconf is installed + check_installed("autoconf")?; + check_installed("automake")?; + let out_dir = env::var("OUT_DIR").map(PathBuf::from)?; let src_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("jq"); let build_dir = out_dir.join("jq_build"); From 8aabb46993a2761ae711a167d6c075b4cbc1fbf8 Mon Sep 17 00:00:00 2001 From: ynqa Date: Wed, 20 Mar 2024 16:10:34 +0900 Subject: [PATCH 2/2] fmt --- j9-sys/build.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/j9-sys/build.rs b/j9-sys/build.rs index 40a2e5d..8bb2879 100644 --- a/j9-sys/build.rs +++ b/j9-sys/build.rs @@ -8,18 +8,22 @@ use std::{ }; fn check_installed(name: &str) -> anyhow::Result<()> { - let check = Command::new(name) - .arg("--version") - .output(); + let check = Command::new(name).arg("--version").output(); match check { Ok(output) => { if !output.status.success() { - return Err(anyhow::anyhow!("{} is required, but it's not installed or not in PATH.", name)); + return Err(anyhow::anyhow!( + "{} is required, but it's not installed or not in PATH.", + name + )); } - }, + } Err(_) => { - return Err(anyhow::anyhow!("{} is required, but it's not installed or not in PATH.", name)); + return Err(anyhow::anyhow!( + "{} is required, but it's not installed or not in PATH.", + name + )); } }