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

Combine all Rust code-examples into one binary #4767

Merged
merged 15 commits into from
Jan 10, 2024

Conversation

emilk
Copy link
Member

@emilk emilk commented Jan 10, 2024

What

This reduces the number of binaries in our workspace from 99 to 55.

We do this by joining all docs/code-examples into one binary, with a little help from some build.rs codegen.
This will any compiler error messages to the wrong file though, so it is not a perfect solution by any means.

I also decided to put all the code examples in their own folder (docs/code-examples/all), with the control structures (Cargo.toml, CMakeLists, …) in the parent folder (docs/code-examples). If you have a better idea for a name than "all" I'm all ears.

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@emilk emilk added 🧑‍💻 dev experience developer experience (excluding CI) 🚜 refactor Change the code, not the functionality exclude from changelog PRs with this won't show up in CHANGELOG.md labels Jan 10, 2024
@jprochazk
Copy link
Member

The docs/code-examples path is also hardcoded in landing

@Wumpf Wumpf self-requested a review January 10, 2024 11:31
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

docs/code-examples/build.rs Outdated Show resolved Hide resolved
- **Python**: `python <example_name>.py`, e.g. `python point3d_random.py`.
- **Rust**: `cargo r -p code_examples --bin <example_name`, e.g. `cargo r -p code_examples --bin point3d_random`.
- **Rust**: `cargo run -p code_examples -- <example_name`, e.g. `cargo run -p code_examples -- point3d_random`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

come to think it's a bit strange that they have different names in all languages!

  • cpp: doc examples
  • python: example name
  • rust: code examples

can we unify this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll save that for a follow-up PR

@emilk emilk merged commit 2a41e5f into main Jan 10, 2024
43 checks passed
@emilk emilk deleted the emilk/one-rust-example-binary branch January 10, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI) exclude from changelog PRs with this won't show up in CHANGELOG.md 🚜 refactor Change the code, not the functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants