mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
xtask: Add book building
This commit is contained in:
parent
8b3aa7f346
commit
14457da4f8
2 changed files with 54 additions and 7 deletions
|
@ -71,6 +71,9 @@ pub enum CargoCommand<'a> {
|
||||||
cargoarg: &'a Option<&'a str>,
|
cargoarg: &'a Option<&'a str>,
|
||||||
features: Option<&'a str>,
|
features: Option<&'a str>,
|
||||||
},
|
},
|
||||||
|
Book {
|
||||||
|
mdbookarg: &'a Option<&'a str>,
|
||||||
|
},
|
||||||
ExampleSize {
|
ExampleSize {
|
||||||
cargoarg: &'a Option<&'a str>,
|
cargoarg: &'a Option<&'a str>,
|
||||||
example: &'a str,
|
example: &'a str,
|
||||||
|
@ -91,6 +94,24 @@ impl<'a> CargoCommand<'a> {
|
||||||
CargoCommand::Clippy { .. } => "clippy",
|
CargoCommand::Clippy { .. } => "clippy",
|
||||||
CargoCommand::Format { .. } => "fmt",
|
CargoCommand::Format { .. } => "fmt",
|
||||||
CargoCommand::Doc { .. } => "doc",
|
CargoCommand::Doc { .. } => "doc",
|
||||||
|
CargoCommand::Book { .. } => "build",
|
||||||
|
// TODO
|
||||||
|
// CargoCommand::Test { .. } => "test",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn command(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
CargoCommand::Run { .. }
|
||||||
|
| CargoCommand::Qemu { .. }
|
||||||
|
| CargoCommand::ExampleCheck { .. }
|
||||||
|
| CargoCommand::Check { .. }
|
||||||
|
| CargoCommand::ExampleBuild { .. }
|
||||||
|
| CargoCommand::Build { .. }
|
||||||
|
| CargoCommand::ExampleSize { .. }
|
||||||
|
| CargoCommand::Clippy { .. }
|
||||||
|
| CargoCommand::Format { .. }
|
||||||
|
| CargoCommand::Doc { .. } => "cargo",
|
||||||
|
CargoCommand::Book { .. } => "mdbook",
|
||||||
// TODO
|
// TODO
|
||||||
// CargoCommand::Test { .. } => "test",
|
// CargoCommand::Test { .. } => "test",
|
||||||
}
|
}
|
||||||
|
@ -230,6 +251,18 @@ impl<'a> CargoCommand<'a> {
|
||||||
}
|
}
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
|
CargoCommand::Book { mdbookarg } => {
|
||||||
|
let mut args = vec![];
|
||||||
|
|
||||||
|
args.extend_from_slice(&[self.name()]);
|
||||||
|
|
||||||
|
if let Some(arg) = mdbookarg {
|
||||||
|
args.extend_from_slice(&[arg]);
|
||||||
|
}
|
||||||
|
|
||||||
|
args.extend_from_slice(&["book/en"]);
|
||||||
|
args
|
||||||
|
}
|
||||||
CargoCommand::Format {
|
CargoCommand::Format {
|
||||||
cargoarg,
|
cargoarg,
|
||||||
package,
|
package,
|
||||||
|
@ -324,10 +357,6 @@ impl<'a> CargoCommand<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command(&self) -> &str {
|
|
||||||
"cargo"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildMode {
|
impl BuildMode {
|
||||||
|
|
|
@ -154,6 +154,9 @@ enum Commands {
|
||||||
|
|
||||||
/// Build docs
|
/// Build docs
|
||||||
Doc,
|
Doc,
|
||||||
|
|
||||||
|
/// Build books with mdbook
|
||||||
|
Book,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
|
@ -400,6 +403,10 @@ fn main() -> anyhow::Result<()> {
|
||||||
info!("Running cargo doc on backend: {backend:?}");
|
info!("Running cargo doc on backend: {backend:?}");
|
||||||
cargo_doc(&cargologlevel, backend)?;
|
cargo_doc(&cargologlevel, backend)?;
|
||||||
}
|
}
|
||||||
|
Commands::Book => {
|
||||||
|
info!("Running mdbook build");
|
||||||
|
cargo_book(&cargologlevel)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -534,6 +541,16 @@ fn cargo_doc(cargoarg: &Option<&str>, backend: Backends) -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cargo_book(cargoarg: &Option<&str>) -> anyhow::Result<()> {
|
||||||
|
command_parser(
|
||||||
|
&CargoCommand::Book {
|
||||||
|
mdbookarg: cargoarg,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn run_test(
|
fn run_test(
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
|
@ -680,13 +697,14 @@ fn command_parser(command: &CargoCommand, overwrite: bool) -> anyhow::Result<()>
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
CargoCommand::ExampleBuild { .. }
|
CargoCommand::Format { .. }
|
||||||
| CargoCommand::ExampleCheck { .. }
|
| CargoCommand::ExampleCheck { .. }
|
||||||
| CargoCommand::Build { .. }
|
| CargoCommand::ExampleBuild { .. }
|
||||||
| CargoCommand::Check { .. }
|
| CargoCommand::Check { .. }
|
||||||
|
| CargoCommand::Build { .. }
|
||||||
| CargoCommand::Clippy { .. }
|
| CargoCommand::Clippy { .. }
|
||||||
| CargoCommand::Doc { .. }
|
| CargoCommand::Doc { .. }
|
||||||
| CargoCommand::Format { .. }
|
| CargoCommand::Book { .. }
|
||||||
| CargoCommand::ExampleSize { .. } => {
|
| CargoCommand::ExampleSize { .. } => {
|
||||||
let cargo_result = run_command(command)?;
|
let cargo_result = run_command(command)?;
|
||||||
if let Some(exit_code) = cargo_result.exit_status.code() {
|
if let Some(exit_code) = cargo_result.exit_status.code() {
|
||||||
|
|
Loading…
Reference in a new issue