Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
add DONT_RUSTFMT flag to disable using rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekkMA authored and david-allison committed May 6, 2021
1 parent 6b2410e commit 2296461
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions rslib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,18 @@ fn main() -> std::io::Result<()> {
.service_generator(service_generator())
.compile_protos(&["../proto/backend.proto", "../proto/sqlite.proto"], &["../proto"])
.unwrap();
// rustfmt the protobuf code
let rustfmt = Command::new("rustfmt")
.arg(Path::new("src/backend_proto.rs"))
.status()
.unwrap();
assert!(rustfmt.success(), "rustfmt backend_proto.rs failed");

// if DONT_RUSTFMT is not present, then perform rustfmt
if let Err(e) = std::env::var("DONT_RUSTFMT") {
assert_eq!(e, std::env::VarError::NotPresent);
println!("Using rustfmt to format src/backend_proto.rs");
// rustfmt the protobuf code
let rustfmt = Command::new("rustfmt")
.arg(Path::new("src/backend_proto.rs"))
.status()
.unwrap();
assert!(rustfmt.success(), "rustfmt backend_proto.rs failed");
}

// write the other language ftl files
let mut ftl_lang_dirs = vec!["./ftl/anki-core-i18n/core".to_string()];
Expand Down

0 comments on commit 2296461

Please sign in to comment.