How to call a batch builder script on a Rust cargo build script?
The project rust-onig requires to compile the oniguruma C project. This is originated from the question error: failed to run custom build command for `onig_sys v61.1.0` which attempts to build oniguruma
on windows. Afterwards was noticed on windows within Visual Studio 2015, we need to call the make_win32.bat
, instead of cmake
to build the oniguruma
C project.
However I have no idea how to do the cargo
builder to call the make_win32.bat
build script. Based on build-script, I edited the default builder build.rs which is attempting to use cmake
instead of make_win32.bat
:
extern crate pkg_config;
extern crate cmake;
// use std::env;
// fn compile_with_cmake() {
// use cmake::Config;
// let static_link = env::var("CARGO_FEATURE_STATIC_ONIG").is_ok();
// // Builds the project in the directory located in `oniguruma`, installing it
// // into $OUT_DIR
// let mut c = Config::new("oniguruma");
// let dst = if static_link {
// c.define("BUILD_SHARED_LIBS", "OFF")
// } else {
// c.define("CMAKE_MACOSX_RPATH", "NO")
// }
// .build();
// let link_type = if static_link {
// "static"
// } else {
// "dylib"
// };
// println!("cargo:rustc-link-search=native={}",
// dst.join("build").display());
// println!("cargo:rustc-link-lib={}=onig", link_type);
// }
pub fn main() {
println!("Opening MAIN!!!!!!!!\n\n\n\n");
use std::process::Command;
let status = Command::new("D:\\User\\Downloads\\rust-onig\\onig_sys\\oniguruma\\make_win32.bat").status().unwrap_or_else(|e|
{
panic!("failed to execute process: {}", e)
});
println!("process exited with: {}", status);
println!("process exited with: {}", status);
println!("process exited with: {}", status);
println!("process exited with: {}", status);
println!("process exited with: {}", status);
// if let Ok(_) = pkg_config::find_library("oniguruma") {
// return;
// }
// compile_with_cmake();
}
But my builder script is not called, as the message process exited with
is never showed:
D:\Downloads\rust-onig>cargo build
Compiling onig_sys v61.1.0 (file:///D:/User/Downloads/rust-onig/onig_sys)
Compiling onig v1.2.0 (file:///D:/User/Downloads/rust-onig)
warning: unused import: `c_ulong`, #[warn(unused_imports)] on by default
--> src\names.rs:6:27
|
6 | use libc::{c_int, c_uint, c_ulong, c_void, c_uchar};
| ^^^^^^^
Finished dev [unoptimized + debuginfo] target(s) in 11.31 secs
D:\Downloads\rust-onig>
What is displayed, when do we attempt to used the cmake
builder can be viewed on the question This is originated from the question error: failed to run custom build command for `onig_sys v61.1.0`
The problem there is cmake
is generating several Visual Studio
projects, which purely do not know how to build oniguruma
. The only solution able to effectively build it is the make_win32.bat
which already comes within oniguruma
. Moreover, we need to use the make_win32.bat
instead of let cmake
generating Visual Studio
.