forked from imgui-rs/imgui-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request imgui-rs#464 from thomcc/better-xtask
Improvements to our `xtask`s
- Loading branch information
Showing
5 changed files
with
149 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ publish = false | |
|
||
[dependencies] | ||
anyhow = "1" | ||
pico-args = "0.3" | ||
smoljson = "0.1" | ||
xshell = "0.1" | ||
xflags = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//! xflags is a bit jank still, but pretty nice compared to pico_args, and | ||
//! compiles a billion times faster than clap/structopt. | ||
//! | ||
//! When you modify stuff in the args_parser block, you'll get compile errors. | ||
//! to fix these: | ||
//! 1. run `env XFLAGS_DUMP= cargo build` in the shell. | ||
//! 2. this will error, but should spit out a block of code delimited by | ||
//! "generated start" and "generated end" comments. (if not, you probably | ||
//! have an error message about your usage of the macro, fix and retry) | ||
//! 3. Copy the generated code, and replace the bottom of this file with it. | ||
//! | ||
//! Also, rust-analyzer says this file has a "unresolved macro call". I don't | ||
//! know why, just ignore it — it goes away if you close this file. | ||
#![allow(dead_code)] | ||
|
||
xflags::args_parser! { | ||
/// Run custom build command. | ||
cmd xtask { | ||
optional -v, --verbose | ||
|
||
default cmd help { | ||
/// Print help information. | ||
optional -h, --help | ||
} | ||
/// Run lints the way we'd run it in CI | ||
cmd lint {} | ||
/// Run tests the way we'd run them in CI | ||
cmd test {} | ||
|
||
/// produce bindings using bindgen (must have bindgen installed) | ||
cmd bindgen { | ||
optional --cimgui-path cimgui_path: String | ||
optional --output-path output_path: String | ||
optional --wasm-import-name wasm_import_name: String | ||
} | ||
} | ||
} | ||
|
||
// generated start | ||
// The following code is generated by `xflags` macro. | ||
// Run `env XFLAGS_DUMP= cargo build` to regenerate. | ||
#[derive(Debug)] | ||
pub struct Xtask { | ||
pub verbose: bool, | ||
pub subcommand: XtaskCmd, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum XtaskCmd { | ||
Help(Help), | ||
Lint(Lint), | ||
Test(Test), | ||
Bindgen(Bindgen), | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Help { | ||
pub help: bool, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Lint {} | ||
|
||
#[derive(Debug)] | ||
pub struct Test {} | ||
|
||
#[derive(Debug)] | ||
pub struct Bindgen { | ||
pub cimgui_path: Option<String>, | ||
pub output_path: Option<String>, | ||
pub wasm_import_name: Option<String>, | ||
} | ||
|
||
impl Xtask { | ||
pub const HELP: &'static str = Self::_HELP; | ||
|
||
pub fn from_env() -> xflags::Result<Self> { | ||
let mut p = xflags::rt::Parser::new_from_env(); | ||
Self::_parse(&mut p) | ||
} | ||
|
||
pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> { | ||
let mut p = xflags::rt::Parser::new(args); | ||
Self::_parse(&mut p) | ||
} | ||
} | ||
// generated end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters