-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codegen: format Python before writing to file (#2694)
Formatting each Python file individually solves two problems: * python files changing back and forth while codegen is being run * modfiied timestamps being updated unnecessarily It is also more functional and clean overall --- I also introduced a simple way to run the codegen: `cargo codegen`. It completely ignores the source hashes though, so beware of that. It has some nice features though:: * It supports logging (`build.rs` swallows all output) * It supports `--profile` to get a flamegraph of the build ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2694) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/2694) - [Docs preview](https://rerun.io/preview/pr%3Aemilk%2Fcodegen-cleanup/docs) - [Examples preview](https://rerun.io/preview/pr%3Aemilk%2Fcodegen-cleanup/examples)
- Loading branch information
Showing
125 changed files
with
458 additions
and
337 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
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 |
---|---|---|
|
@@ -63,4 +63,3 @@ re_types_builder.workspace = true | |
|
||
# External | ||
rayon.workspace = true | ||
xshell = "0.2" |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# This is a sha256 hash for all direct and indirect dependencies of this crate's build script. | ||
# It can be safely removed at anytime to force the build script to run again. | ||
# Check out build.rs to see how it's computed. | ||
114ba22844997f4dc1a9fc81ad83419d80cf124c412777c44e1b9b71b3e50510 | ||
d5ccdc80e148c8058d3885418f9c701fbae4a5fbb92defb9bd625ad27ed97a25 |
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,51 @@ | ||
//! Helper binary for running the codegen manually. Useful during development! | ||
const DEFINITIONS_DIR_PATH: &str = "crates/re_types/definitions"; | ||
const ENTRYPOINT_PATH: &str = "crates/re_types/definitions/rerun/archetypes.fbs"; | ||
const CPP_OUTPUT_DIR_PATH: &str = "rerun_cpp/src"; | ||
const RUST_OUTPUT_DIR_PATH: &str = "crates/re_types/."; | ||
const PYTHON_OUTPUT_DIR_PATH: &str = "rerun_py/rerun_sdk/rerun/_rerun2"; | ||
|
||
fn main() { | ||
re_log::setup_native_logging(); | ||
|
||
let mut profiler = re_tracing::Profiler::default(); | ||
|
||
for arg in std::env::args().skip(1) { | ||
match arg.as_str() { | ||
"--help" => { | ||
println!("Usage: [--help] [--profile]"); | ||
return; | ||
} | ||
"--profile" => profiler.start(), | ||
_ => { | ||
eprintln!("Unknown argument: {arg:?}"); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
re_log::info!("Running codegen…"); | ||
let (objects, arrow_registry) = | ||
re_types_builder::generate_lang_agnostic(DEFINITIONS_DIR_PATH, ENTRYPOINT_PATH); | ||
|
||
re_tracing::profile_scope!("Language-specific code-gen"); | ||
join3( | ||
|| re_types_builder::generate_cpp_code(CPP_OUTPUT_DIR_PATH, &objects, &arrow_registry), | ||
|| re_types_builder::generate_rust_code(RUST_OUTPUT_DIR_PATH, &objects, &arrow_registry), | ||
|| { | ||
re_types_builder::generate_python_code( | ||
PYTHON_OUTPUT_DIR_PATH, | ||
&objects, | ||
&arrow_registry, | ||
); | ||
}, | ||
); | ||
|
||
re_log::info!("Done."); | ||
} | ||
|
||
// Do 3 things in parallel | ||
fn join3(a: impl FnOnce() + Send, b: impl FnOnce() + Send, c: impl FnOnce() + Send) { | ||
rayon::join(a, || rayon::join(b, c)); | ||
} |
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
Oops, something went wrong.
fcad6c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.25
.batch_points_arrow/encode_log_msg
90881
ns/iter (± 136
)48628
ns/iter (± 95
)1.87
This comment was automatically generated by workflow using github-action-benchmark.