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

Make cargo codegen work irrelevant of CWD #2913

Merged
merged 1 commit into from
Aug 7, 2023
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
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions crates/re_types_builder/src/bin/build_re_types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Helper binary for running the codegen manually. Useful during development!
use camino::Utf8Path;

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/rerun";
Expand All @@ -25,17 +27,28 @@ fn main() {
}
}

let workspace_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.and_then(|p| p.parent())
.unwrap();

let definitions_dir_path = workspace_dir.join(DEFINITIONS_DIR_PATH);
let entrypoint_path = workspace_dir.join(ENTRYPOINT_PATH);
let cpp_output_dir_path = workspace_dir.join(CPP_OUTPUT_DIR_PATH);
let rust_output_dir_path = workspace_dir.join(RUST_OUTPUT_DIR_PATH);
let python_output_dir_path = workspace_dir.join(PYTHON_OUTPUT_DIR_PATH);

re_log::info!("Running codegen…");
let (objects, arrow_registry) =
re_types_builder::generate_lang_agnostic(DEFINITIONS_DIR_PATH, ENTRYPOINT_PATH);
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_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,
python_output_dir_path,
&objects,
&arrow_registry,
);
Expand Down