-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee4d26a
commit ebcd33a
Showing
10 changed files
with
1,672 additions
and
1,843 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,45 @@ | ||
[package] | ||
name = "cxx2flow" | ||
version = "0.6.1" | ||
edition = "2018" | ||
authors = ["mgt <[email protected]>"] | ||
description = "Convert your C/C++ code to control flow chart" | ||
license = "MIT" | ||
repository = "https://github.com/Enter-tainer/cxx2flow" | ||
include = ["src/**/*", "LICENSE", "README.md", "build.rs"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[[bin]] | ||
name = "cxx2flow" | ||
path = "src/main.rs" | ||
|
||
[lib] | ||
name = "cxx2flow" | ||
path = "src/lib.rs" | ||
crate-type = ["lib"] | ||
|
||
[dependencies] | ||
thiserror = "1.0" | ||
clap = { version = "4.4.7", features = ["derive", "wrap_help"] } | ||
log = "0.4.20" | ||
tree-sitter = "0.20.9" | ||
tree-sitter-cpp = "0.20.0" | ||
petgraph = "0.6.4" | ||
itertools = "0.10.5" | ||
hash-chain = "0.3.2" | ||
once_cell = "1.18.0" | ||
miette = { version = "5.10.0", features = ["fancy"] } | ||
enum_dispatch = "0.3.12" | ||
colored = "2.0.4" | ||
[build-dependencies] | ||
vergen = "7.4.4" | ||
[profile.release] | ||
lto = "fat" | ||
[package] | ||
name = "cxx2flow" | ||
version = "0.6.1" | ||
edition = "2021" | ||
authors = ["mgt <[email protected]>"] | ||
description = "Convert your C/C++ code to control flow chart" | ||
license = "MIT" | ||
repository = "https://github.com/Enter-tainer/cxx2flow" | ||
include = ["src/**/*", "LICENSE", "README.md", "build.rs"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[[bin]] | ||
name = "cxx2flow" | ||
path = "src/main.rs" | ||
|
||
[lib] | ||
name = "cxx2flow" | ||
path = "src/lib.rs" | ||
crate-type = ["lib"] | ||
|
||
[dependencies] | ||
thiserror = "1.0" | ||
clap = { version = "4.5.6", features = ["derive", "wrap_help"] } | ||
log = "0.4.21" | ||
tree-sitter = "0.22.6" | ||
tree-sitter-cpp = "0.22.2" | ||
petgraph = "0.6.5" | ||
itertools = "0.13.0" | ||
hash-chain = "0.3.2" | ||
once_cell = "1.19.0" | ||
miette = { version = "7.2.0", features = ["fancy"] } | ||
enum_dispatch = "0.3.13" | ||
colored = "2.1.0" | ||
[build-dependencies] | ||
anyhow = "1.0" | ||
vergen = { version = "8.3.1", features = [ | ||
"build", | ||
"cargo", | ||
"git", | ||
"git2", | ||
"rustc", | ||
] } | ||
[profile.release] | ||
lto = "fat" |
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
use vergen::{vergen, Config, SemverKind}; | ||
|
||
fn main() { | ||
let mut config = Config::default(); | ||
// Change the SEMVER output to the lightweight variant | ||
*config.git_mut().semver_kind_mut() = SemverKind::Lightweight; | ||
// Add a `-dirty` flag to the SEMVER output | ||
*config.git_mut().semver_dirty_mut() = Some("-dirty"); | ||
// Generate the instructions | ||
if let Err(e) = vergen(config) { | ||
eprintln!("error occurred while generating instructions: {:?}", e); | ||
let mut config = Config::default(); | ||
*config.git_mut().enabled_mut() = false; | ||
vergen(config).unwrap(); | ||
} | ||
} | ||
use anyhow::Result; | ||
use vergen::EmitBuilder; | ||
|
||
fn main() -> Result<()> { | ||
// Emit the instructions | ||
EmitBuilder::builder() | ||
.all_cargo() | ||
.build_timestamp() | ||
.git_sha(false) | ||
.git_describe(true, true, None) | ||
.all_rustc() | ||
.emit()?; | ||
Ok(()) | ||
} |
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 |
---|---|---|
@@ -1,81 +1,82 @@ | ||
use clap::Parser; | ||
use once_cell::sync::Lazy; | ||
|
||
static LONG_VERSION: Lazy<String> = Lazy::new(|| { | ||
format!( | ||
" | ||
Build Timestamp: {} | ||
Build Version: {} | ||
Commit SHA: {:?} | ||
Commit Date: {:?} | ||
Commit Branch: {:?} | ||
Cargo Target Triple: {} | ||
Cargo Profile: {} | ||
", | ||
env!("VERGEN_BUILD_TIMESTAMP"), | ||
env!("VERGEN_BUILD_SEMVER"), | ||
option_env!("VERGEN_GIT_SHA"), | ||
option_env!("VERGEN_GIT_COMMIT_TIMESTAMP"), | ||
option_env!("VERGEN_GIT_BRANCH"), | ||
env!("VERGEN_CARGO_TARGET_TRIPLE"), | ||
env!("VERGEN_CARGO_PROFILE") | ||
) | ||
}); | ||
#[derive(Parser, Debug)] | ||
#[clap(about, version, long_version(LONG_VERSION.as_str()) ,author, after_help("Note that you need to manually compile the dot file using graphviz to get SVG or PNG files. | ||
EXAMPLES: | ||
cat main.cpp | cxx2flow | dot -Tsvg -o test.svg | ||
cxx2flow test.cpp | dot -Tpng -o test.png | ||
cxx2flow main.cpp my_custom_func | dot -Tsvg -o test.svg | ||
Please give me star if this application helps you! | ||
如果这个应用有帮助到你,请给我点一个 star! | ||
https://github.com/Enter-tainer/cxx2flow | ||
"))] | ||
pub struct Args { | ||
#[clap( | ||
short, | ||
long, | ||
help( | ||
"Sets the output file. | ||
If not specified, result will be directed to stdout. | ||
e.g. graph.dot" | ||
) | ||
)] | ||
pub output: Option<String>, | ||
|
||
#[clap( | ||
short, | ||
long, | ||
help( | ||
"Sets the style of the flow chart. | ||
If specified, output flow chart will have curly connection line." | ||
) | ||
)] | ||
pub curly: bool, | ||
|
||
#[clap(long, help("Use C preprocessor."))] | ||
pub cpp: bool, | ||
|
||
#[clap(short, long, help("Use tikz backend."))] | ||
pub tikz: bool, | ||
|
||
#[clap(short, long, help("Use d2 backend."))] | ||
pub d2: bool, | ||
|
||
#[clap(long, help("Dump AST(For debug purpose only)."))] | ||
pub dump_ast: bool, | ||
|
||
#[clap(help( | ||
"Sets the path of the input file. e.g. test.cpp | ||
If not specified, cxx2flow will read from stdin." | ||
))] | ||
pub input: Option<String>, | ||
|
||
#[clap( | ||
default_value("main"), | ||
help("The function you want to convert. e.g. main") | ||
)] | ||
pub function: String, | ||
} | ||
use clap::Parser; | ||
use once_cell::sync::Lazy; | ||
|
||
static NONE: &str = "None"; | ||
static LONG_VERSION: Lazy<String> = Lazy::new(|| { | ||
format!( | ||
" | ||
Version: {} | ||
Build Timestamp: {} | ||
Build Git Describe: {} | ||
Commit SHA: {} | ||
Commit Date: {} | ||
Commit Branch: {} | ||
Cargo Target Triple: {} | ||
", | ||
env!("CARGO_PKG_VERSION"), | ||
env!("VERGEN_BUILD_TIMESTAMP"), | ||
env!("VERGEN_GIT_DESCRIBE"), | ||
option_env!("VERGEN_GIT_SHA").unwrap_or(NONE), | ||
option_env!("VERGEN_GIT_COMMIT_TIMESTAMP").unwrap_or(NONE), | ||
option_env!("VERGEN_GIT_BRANCH").unwrap_or(NONE), | ||
env!("VERGEN_CARGO_TARGET_TRIPLE"), | ||
) | ||
}); | ||
#[derive(Parser, Debug)] | ||
#[clap(about, version, long_version(LONG_VERSION.as_str()) ,author, after_help("Note that you need to manually compile the dot file using graphviz to get SVG or PNG files. | ||
EXAMPLES: | ||
cat main.cpp | cxx2flow | dot -Tsvg -o test.svg | ||
cxx2flow test.cpp | dot -Tpng -o test.png | ||
cxx2flow main.cpp my_custom_func | dot -Tsvg -o test.svg | ||
Please give me star if this application helps you! | ||
如果这个应用有帮助到你,请给我点一个 star! | ||
https://github.com/Enter-tainer/cxx2flow | ||
"))] | ||
pub struct Args { | ||
#[clap( | ||
short, | ||
long, | ||
help( | ||
"Sets the output file. | ||
If not specified, result will be directed to stdout. | ||
e.g. graph.dot" | ||
) | ||
)] | ||
pub output: Option<String>, | ||
|
||
#[clap( | ||
short, | ||
long, | ||
help( | ||
"Sets the style of the flow chart. | ||
If specified, output flow chart will have curly connection line." | ||
) | ||
)] | ||
pub curly: bool, | ||
|
||
#[clap(long, help("Use C preprocessor."))] | ||
pub cpp: bool, | ||
|
||
#[clap(short, long, help("Use tikz backend."))] | ||
pub tikz: bool, | ||
|
||
#[clap(short, long, help("Use d2 backend."))] | ||
pub d2: bool, | ||
|
||
#[clap(long, help("Dump AST(For debug purpose only)."))] | ||
pub dump_ast: bool, | ||
|
||
#[clap(help( | ||
"Sets the path of the input file. e.g. test.cpp | ||
If not specified, cxx2flow will read from stdin." | ||
))] | ||
pub input: Option<String>, | ||
|
||
#[clap( | ||
default_value("main"), | ||
help("The function you want to convert. e.g. main") | ||
)] | ||
pub function: String, | ||
} |
Oops, something went wrong.