Skip to content

Commit

Permalink
Merge pull request #11 from genya0407/feature/3.2.0-2
Browse files Browse the repository at this point in the history
Added mruby_3_2_0 feature
  • Loading branch information
genya0407 authored Dec 31, 2023
2 parents bce6fe4 + 93d6d3d commit 553214a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 9 additions & 6 deletions minutus-mruby-build-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<PathBuf>,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -164,6 +162,11 @@ fn run_command(current_dir: &Path, cmd: &[&str]) -> Result<String> {
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)
)))
}
}
2 changes: 1 addition & 1 deletion minutus-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions minutus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
4 changes: 2 additions & 2 deletions minutus/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_{}",
Expand Down

0 comments on commit 553214a

Please sign in to comment.