Skip to content

Commit

Permalink
Merge pull request #4 from smoothdeveloper/buildrs-prettyplease-on-lo…
Browse files Browse the repository at this point in the history
…w-reaper-rs

rea-rs-low: update to Cargo.toml and build.rs in order to pretty print the generated reaper.rs
  • Loading branch information
Levitanus authored Mar 31, 2024
2 parents ffc4728 + 315586e commit f102ded
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion low/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ generate = ["generate-stage-one", "generate-stage-two"]
generate-stage-one = ["generate-stage-two", "bindgen"]

# Stage 2 can run separately.
generate-stage-two = ["quote", "syn", "proc-macro2", "phf"]
generate-stage-two = ["quote", "prettyplease", "syn", "proc-macro2", "phf"]

[dependencies]
c_str_macro = "1.0.2"
Expand All @@ -55,4 +55,5 @@ cc = "1.0.65"
phf = {version = "0.8", features = ["macros"], optional = true}
proc-macro2 = {version = "1.0.8", optional = true}
quote = {version = "1.0.2", optional = true}
prettyplease = {version="0.1.25", optional = true}
syn = {version = "1.0.14", features = ["full"], optional = true}
8 changes: 6 additions & 2 deletions low/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,12 @@ mod codegen {
/// Generates the `reaper.rs` file from the previously generated
/// `bindings.rs`
fn generate_reaper(file: &syn::File) {
let fn_ptrs = parse_fn_ptrs(file, "reaper_functions");
let result = generate_reaper_token_stream(&fn_ptrs);
let result = {
let fn_ptrs = parse_fn_ptrs(file, "reaper_functions");
let result = generate_reaper_token_stream(&fn_ptrs);
let syntax_tree = syn::parse_file(result.to_string().as_str()).unwrap();
prettyplease::unparse(&syntax_tree)
};
std::fs::write("src/reaper.rs", result.to_string())
.expect("Unable to write file");
}
Expand Down

0 comments on commit f102ded

Please sign in to comment.