Skip to content

Commit

Permalink
re_types' hash now takes doc-examples into account
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jul 3, 2023
1 parent b3b76ea commit 53af477
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions crates/re_types/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use re_build_tools::{

const SOURCE_HASH_PATH: &str = "./source_hash.txt";
const DEFINITIONS_DIR_PATH: &str = "./definitions";
const DOC_EXAMPLES_DIR_PATH: &str = "../../docs/code-examples";
const RUST_OUTPUT_DIR_PATH: &str = ".";
const PYTHON_OUTPUT_DIR_PATH: &str = "../../rerun_py/rerun_sdk/rerun/_rerun2";

Expand All @@ -31,22 +32,28 @@ fn main() {
}

rerun_if_changed_or_doesnt_exist(SOURCE_HASH_PATH);
for path in iter_dir(DEFINITIONS_DIR_PATH, Some(&[".fbs"])) {
for path in iter_dir(DEFINITIONS_DIR_PATH, Some(&["fbs"])) {
rerun_if_changed(&path);
}

// NOTE: We need to hash both the flatbuffers definitions as well as the source code of the
// code generator itself!
let cur_hash = read_versioning_hash(SOURCE_HASH_PATH);
let re_types_builder_hash = compute_crate_hash("re_types_builder");
let definitions_hash = compute_dir_hash(DEFINITIONS_DIR_PATH, Some(&[".fbs"]));
let new_hash = compute_strings_hash(&[&re_types_builder_hash, &definitions_hash]);
let definitions_hash = compute_dir_hash(DEFINITIONS_DIR_PATH, Some(&["fbs"]));
let doc_examples_hash = compute_dir_hash(DOC_EXAMPLES_DIR_PATH, Some(&["rs", "py"]));
let new_hash = compute_strings_hash(&[
&re_types_builder_hash,
&definitions_hash,
&doc_examples_hash,
]);

// Leave these be please, very useful when debugging.
eprintln!("re_types_builder_hash: {re_types_builder_hash:?}");
eprintln!("cur_hash: {cur_hash:?}");
eprintln!("definitions_hash: {definitions_hash:?}");
eprintln!("doc_examples_hash: {doc_examples_hash:?}");
eprintln!("new_hash: {new_hash:?}");
eprintln!("cur_hash: {cur_hash:?}");

if let Some(cur_hash) = cur_hash {
if cur_hash == new_hash {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt
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.
4c5bee5e1a2c796b6bf5e92f5406327ab4f2d75a2bcaa7b015070f3423f300de
6a8ebfd641e56b4ca0cff54429440baa51977ff7bad373b2c9570810f06eb262

0 comments on commit 53af477

Please sign in to comment.