use std::fs::File;
use std::process::Command;
fn main() {
println!("cargo:rerun-if-changed=<full path from cargo root to input file>");
let rust_file = File::create("<output file>").expect("failed to open parser.rs");
Command::new("re2rust")
.current_dir("<input file dir>")
.arg("<input file>")
.stdout(rust_file)
.spawn().expect("failed to execute re2rust");
}
3条答案
按热度按时间zour9fqk1#
您可以使用
build.rs
脚本。文档是here,但您的用例的要点可能类似于bqujaahr2#
你可能想创建一个
build.rs
文件,它可以做rust二进制文件能做的任何事情。4nkexdtk3#
为了完整起见,下面是一个完整的
build.rs
,用于工具仅将输出写入stdout的情况。