Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
Patch mspec sources in build.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
lopopolo committed Jul 5, 2019
1 parent 3a5deb5 commit 8e1a91b
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions spec-runner/build.rs
@@ -0,0 +1,58 @@
use fs_extra::dir::{self, CopyOptions};
use std::env;
use std::path::PathBuf;
use std::process::Command;

/// vendored mruby version
const MRUBY_REVISION: &str = "1685c45";

/// Path helpers
struct Build;

impl Build {
fn root() -> String {
env::var("CARGO_MANIFEST_DIR").unwrap()
}

fn mspec_vendored_dir() -> String {
format!("{}/spec/mspec", &Build::root(),)
}

fn mspec_source_dir() -> String {
format!("{}/mspec", env::var("OUT_DIR").unwrap())
}

fn patch(patch: &str) -> String {
format!("{}/spec/{}", Build::root(), patch)
}
}

fn main() {
let opts = CopyOptions::new();
let _ = dir::remove(Build::mspec_source_dir());
dir::copy(
Build::mspec_vendored_dir(),
env::var("OUT_DIR").unwrap(),
&opts,
)
.unwrap();
for patch in vec![
"0001-Add-mruby-engine-detection-to-mspec-platform-guard.patch",
"0002-Add-fallback-for-Fixnum-size.patch",
"0003-Short-circuit-in-mspec-helpers-tmp.patch",
"0004-Call-Kernel-require-instead-of-Kernel-load.patch",
"0005-Remove-reference-to-SystemExit.patch",
"0006-Use-explicit-call-to-to_int.patch",
] {
if !Command::new("bash")
.arg("-c")
.arg(format!("patch -p1 < '{}'", Build::patch(patch)))
.current_dir(Build::mspec_source_dir())
.status()
.unwrap()
.success()
{
panic!("Failed to patch mspec sources with {}", patch);
}
}
}

0 comments on commit 8e1a91b

Please sign in to comment.