Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rea-rs-low: update to Cargo.toml and build.rs in order to pretty print the generated reaper.rs #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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