From 93d6d3d4be34037834c0995e86a2e6fc56592194 Mon Sep 17 00:00:00 2001 From: Yusuke Sangenya Date: Sun, 31 Dec 2023 22:08:54 +0900 Subject: [PATCH] Added mruby_3_2_0 feature --- README.md | 14 ++++++++++++-- minutus-mruby-build-utils/src/lib.rs | 15 +++++++++------ minutus-test/Cargo.toml | 2 +- minutus/Cargo.toml | 1 + minutus/build.rs | 4 ++-- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a72140a..d51f6dc 100644 --- a/README.md +++ b/README.md @@ -186,8 +186,18 @@ Rust's `bool` cast to mruby's `true` or `false`. ## Supported mruby versions -Currently, only [3.1.0](https://github.com/mruby/mruby/releases/tag/3.1.0) is supported. -You can use `mruby_master` feature, but it is not guaranteed to work. +[3.1.0](https://github.com/mruby/mruby/releases/tag/3.1.0) and +[3.2.0](https://github.com/mruby/mruby/releases/tag/3.2.0) are supported. +You can also use mruby's `master` branch, but it is not tested. + +```toml +[dependencies] +// Use 3.1.0 +minutus = { features = ["mruby_3.1.0"] } + +// Use master branch +minutus = { features = ["mruby_master"] } +``` ## Naming diff --git a/minutus-mruby-build-utils/src/lib.rs b/minutus-mruby-build-utils/src/lib.rs index 4513b52..43d364a 100644 --- a/minutus-mruby-build-utils/src/lib.rs +++ b/minutus-mruby-build-utils/src/lib.rs @@ -1,8 +1,6 @@ use anyhow::{anyhow, Result}; use std::path::{Path, PathBuf}; -const DEFAULT_MRUBY_VERSION: &'static str = "3.1.0"; - /// Helper for building and linking libmruby. pub struct MRubyManager { workdir: Option, @@ -31,7 +29,7 @@ impl MRubyManager { self } - /// Set mruby version. The default is `"3.1.0"`. + /// Set mruby version. pub fn mruby_version(mut self, mruby_version: &str) -> Self { self.mruby_version = Some(mruby_version.to_string()); self @@ -71,10 +69,10 @@ impl MRubyManager { let mruby_version = self .mruby_version .map(String::from) - .unwrap_or(DEFAULT_MRUBY_VERSION.to_string()); + .expect("mruby_version is not set."); let build_config = self .build_config - .unwrap_or(Path::new("default").to_path_buf()); // see: https://github.com/mruby/mruby/blob/3.1.0/doc/guides/compile.md#build + .unwrap_or(Path::new("default").to_path_buf()); // see: https://github.com/mruby/mruby/blob/3.2.0/doc/guides/compile.md#build if self.do_download { download_mruby(&workdir, &mruby_version); @@ -164,6 +162,11 @@ fn run_command(current_dir: &Path, cmd: &[&str]) -> Result { if output.status.success() { Ok(String::from_utf8_lossy(&output.stdout).to_string()) } else { - Err(anyhow!(format!("Executing {:?} failed", cmd))) + Err(anyhow!(format!( + "Executing {:?} failed: {}, {}", + cmd, + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ))) } } diff --git a/minutus-test/Cargo.toml b/minutus-test/Cargo.toml index 85d90e7..ec13e5f 100644 --- a/minutus-test/Cargo.toml +++ b/minutus-test/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" publish = [] [dependencies] -minutus = { path = "../minutus", features = ["link_mruby"] } +minutus = { path = "../minutus", features = ["mruby_3_2_0", "link_mruby"] } regex = "1" diff --git a/minutus/Cargo.toml b/minutus/Cargo.toml index a84be6a..1c98dc1 100644 --- a/minutus/Cargo.toml +++ b/minutus/Cargo.toml @@ -25,5 +25,6 @@ minutus-mruby-build-utils = { version = "0.3.2-alpha.1", path = "../minutus-mrub [features] mruby_3_1_0 = [] +mruby_3_2_0 = [] mruby_master = [] link_mruby = [] diff --git a/minutus/build.rs b/minutus/build.rs index 11f1e8f..7e7ccf3 100644 --- a/minutus/build.rs +++ b/minutus/build.rs @@ -93,8 +93,8 @@ fn main() -> Result<()> { } fn mruby_version() -> String { - let default = "3.1.0"; - let supported_versions = &["3.1.0", "MASTER"]; + let default = "3.2.0"; + let supported_versions = &["3.1.0", "3.2.0", "MASTER"]; for version in supported_versions.into_iter() { if env::var(format!( "CARGO_FEATURE_MRUBY_{}",