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
.
I called it within -vv
, as commented by user1034749, it outputted correctly and ran the make_win32.bat
file.
I just have to put inside the make_win32.bat
the command cd D:\rust-onig\src
because the batch file was being ran on some folder elsewhere.
D:\rust-onig>cargo build -vv
Fresh libc v0.2.21
Fresh pkg-config v0.3.9
Fresh lazy_static v0.2.4
Fresh bitflags v0.7.0
Compiling onig_sys v61.3.0 (file:///D:/User/Downloads/rust-onig/onig_sys)
Running `D:\rust-onig\target\debug\build\onig_sys-a911e1c40e7ed561\build-script-build`
Opening MAIN!!!!!!!!
D:\rust-onig\onig_sys>cd /d D:\rust-onig\onig_sys\oniguruma\src
D:\rust-onig\onig_sys\oniguruma\src>copy config.h.win32 config.h
1 file(s) copied.
D:\rust-onig\onig_sys\oniguruma\src>nmake -f Makefile.windows
Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
Copyright (C) Microsoft Corporation. All rights reserved.
process exited with: exit code: 0
process exited with: exit code: 0
process exited with: exit code: 0
process exited with: exit code: 0
process exited with: exit code: 0
Running `rustc --crate-name onig_sys onig_sys\src\lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg "feature=\"static_onig\"" -C metadata=071c5dad786f940b -C extra-filename=-071c5dad786f940b --out-dir D:\rust-onig\target\debug\deps -L dependency=D:\rust-onig\target\debug\deps --extern libc=D:\rust-onig\target\debug\deps\liblibc-5dc7b85e748840b4.rlib`
Compiling onig v1.2.2 (file:///D:/User/Downloads/rust-onig)
Running `rustc --crate-name onig src\lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=9cad49cfdc2b5108 -C extra-filename=-9cad49cfdc2b5108 --out-dir D:\rust-onig\target\debug\deps -L dependency=D:\rust-onig\target\debug\deps --extern libc=D:\rust-onig\target\debug\deps\liblibc-5dc7b85e748840b4.rlib --extern lazy_static=D:\rust-onig\target\debug\deps\liblazy_static-82c2efae9a7bf732.rlib --extern onig_sys=D:\rust-onig\target\debug\deps\libonig_sys-071c5dad786f940b.rlib --extern bitflags=D:\rust-onig\target\debug\deps\libbitflags-65ddff5d2b91509e.rlib`
Finished dev [unoptimized + debuginfo] target(s) in 8.92 secs
The rust-onig developer had added built-in supported to call nmake
directly instead of using a batch
file: https://stackoverflow.com/a/42875974/4934640