Add rustfmt_skip to generated files
This commit is contained in:
parent
08e62fd681
commit
32ee76f7d8
|
@ -5,5 +5,6 @@ regenerate:
|
|||
cargo run -- \
|
||||
--prefix crate::gen \
|
||||
--support-crate crate \
|
||||
--rustfmt-skip \
|
||||
-o $(CURDIR)/src/gen \
|
||||
../../../schema/schema.bin
|
||||
|
|
|
@ -22,6 +22,9 @@ struct CommandLine {
|
|||
#[structopt(long)]
|
||||
xref: Vec<String>,
|
||||
|
||||
#[structopt(long)]
|
||||
rustfmt_skip: bool,
|
||||
|
||||
input_glob: Vec<String>,
|
||||
}
|
||||
|
||||
|
@ -43,6 +46,7 @@ fn main() -> Result<(), Error> {
|
|||
if let Some(c) = args.support_crate {
|
||||
config.support_crate = c;
|
||||
}
|
||||
config.rustfmt_skip = args.rustfmt_skip;
|
||||
config.load_schemas_and_bundles(
|
||||
&expand_inputs(&args.input_glob)?,
|
||||
&expand_inputs(&args.xref)?)?;
|
||||
|
|
|
@ -104,6 +104,7 @@ pub struct CompilerConfig {
|
|||
pub support_crate: String,
|
||||
pub external_modules: Map<ModulePath, ExternalModule>,
|
||||
pub plugins: Vec<Box<dyn Plugin>>,
|
||||
pub rustfmt_skip: bool,
|
||||
}
|
||||
|
||||
pub fn load_schema_or_bundle_with_purpose(
|
||||
|
@ -189,6 +190,7 @@ impl CompilerConfig {
|
|||
Box::new(parsers::ParserPlugin),
|
||||
Box::new(unparsers::UnparserPlugin),
|
||||
],
|
||||
rustfmt_skip: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +321,11 @@ pub fn compile(config: &CompilerConfig) -> io::Result<()> {
|
|||
|
||||
lines.push(Formatter::to_string(vertical(false, seq![
|
||||
"#![allow(unused_parens)]",
|
||||
"#![allow(unused_imports)]",
|
||||
"#![allow(unused_imports)]"])));
|
||||
if config.rustfmt_skip {
|
||||
lines.push("#![cfg_attr(rustfmt, rustfmt_skip)]".to_owned());
|
||||
}
|
||||
lines.push(Formatter::to_string(vertical(false, seq![
|
||||
"",
|
||||
"use std::convert::TryFrom;",
|
||||
format!("use {}::support as _support;", &config.support_crate),
|
||||
|
@ -352,6 +358,11 @@ pub fn compile(config: &CompilerConfig) -> io::Result<()> {
|
|||
mod_rs.extend(vec!["mod.rs"]);
|
||||
let mut lines = Vec::new();
|
||||
|
||||
if config.rustfmt_skip {
|
||||
lines.push("#![cfg_attr(rustfmt, rustfmt_skip)]".to_owned());
|
||||
lines.push("".to_owned());
|
||||
}
|
||||
|
||||
for (modpath, (_, module_purpose)) in config.bundle.iter() {
|
||||
if *module_purpose != Purpose::Codegen {
|
||||
continue;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
|
||||
pub mod schema;
|
||||
|
||||
use crate::support as _support;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use crate::support as _support;
|
||||
|
|
Loading…
Reference in New Issue