fix(hiroz-msgs): allow publishing to crates.io - #332
Merged
Merged
Conversation
build.rs reached outside its own crate directory to find hiroz-codegen's .msg/.srv assets, which cargo package/publish cannot bundle. Use hiroz_codegen::bundled_assets_dir instead, which resolves against hiroz-codegen's own CARGO_MANIFEST_DIR and works whether hiroz-codegen is a path or crates.io dependency. Also add the crates.io metadata hiroz/hiroz-codegen already carry, pin versions on the path dependencies cargo publish requires, and remove publish = false so hiroz-msgs can be published. Update the custom-messages doc example to use version dependencies instead of git.
|
There was a problem hiding this comment.
Pull request overview
Makes hiroz-msgs publishable by resolving bundled code-generation assets through hiroz-codegen.
Changes:
- Adds crates.io metadata and versioned dependencies.
- Updates bundled asset discovery.
- Documents crates.io dependencies for custom messages.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/hiroz-msgs/Cargo.toml |
Enables crates.io publication. |
crates/hiroz-msgs/build.rs |
Resolves assets through hiroz-codegen. |
docs/user-guide/custom-messages.md |
Updates dependency examples. |
Suppressed comments (1)
crates/hiroz-msgs/build.rs:431
bundled_assets_dir(true)resolves tohiroz-codegen/assets/humble, but this repository/package contains onlyassets/jazzy. Consequently a Humble build without a system ROS installation finds no bundled packages and never generatesgenerated.rs, whereas the previous code always used the Jazzy asset corpus. Keep selecting the Jazzy corpus here (the package list already excludes post-Humble interfaces), or add and publish a complete Humble corpus.
let assets_dir = hiroz_codegen::bundled_assets_dir(is_humble);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Passing is_humble to bundled_assets_dir resolved to assets/humble, which hiroz-codegen ships empty (only assets/jazzy is populated). A Humble build with no system ROS install would silently find zero bundled packages instead of falling back to the jazzy corpus, same as before this branch.
check-bundled-msgs runs in the pureRust devshell, which has no system ROS install, so it's the one place a broken bundled-assets fallback can't be masked by discover_ros_packages' system-install fallback the way every ROS-container job masks it. Add the missing cell: hiroz-msgs built with --features humble and no ROS sourced. Verified both directions on this commit's parent: reverting the bundled_assets_dir(false) fix and running this check fails to compile (missing generated.rs, ros_packages len: 0); restoring the fix makes it pass (ros_packages len: 11).
…comments in STE hiroz-derive is already declared in [workspace.dependencies], so use workspace = true instead of a second hardcoded version literal — one fewer place for the version pin to drift. hiroz itself can't take the same treatment: Cargo does not currently support overriding default-features on a workspace = true dependency (a known Cargo limitation), and hiroz-msgs needs default-features = false, features = ["rmw-zenoh"]. It keeps its explicit path + version form. Also rewrote this branch's own added comments in build.rs and scripts/test-pure-rust.nu to Simplified Technical English.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hiroz-msgs'sbuild.rslocated.msg/.srvcodegen assets via a sibling-directory path (manifest_dir.parent().join("hiroz-codegen/assets")), which only exists inside this workspace's checkout layout.cargo package/cargo publishonly bundle files inside a crate's own root, sohiroz-codegen/assets— a sibling directory — would never exist in the packaged tarball, andhiroz-msgscould never be published to crates.io. This PR removes that blocker.It also unblocks anyone building their own message-package crate on top of
hiroz-msgs(see themy-robot-msgsexample indocs/user-guide/custom-messages.md): crates.io refuses to publish any crate with agitdependency, andhiroz-msgswas git-only.Before and after
manifest_dir.parent().join("hiroz-codegen/assets")— sibling path, workspace-checkout-onlyhiroz_codegen::bundled_assets_dir(is_humble)— resolves viahiroz-codegen's own (published)CARGO_MANIFEST_DIRhiroz-msgs/Cargo.tomlpublish = false, no crates.io metadatahiroz/hiroz-codegen's style,hiroz/hiroz-derivepath deps pinned toversion = "0.2"docs/user-guide/custom-messages.mdexamplehiroz-msgs = { git = "https://github.com/ZettaScaleLabs/hiroz.git" }hiroz-msgs = { version = "0.2" }cargo package -p hiroz-msgs --listcargo publish -p hiroz-msgs --dry-runWhat fails without this
cargo publish -p hiroz-msgs --dry-runcannot succeed today — the packaged crate is missinghiroz-codegen/assets, so anyone building it outside the workspace checkout hits a missing-directory error at build time.Verified on a clean checkout at this commit:
cargo build -p hiroz-msgs --features core_msgsand other in-workspace feature combinations still build unchanged;cargo package -p hiroz-msgs --listshows nothing outside the crate root;cargo publish -p hiroz-msgs --dry-runpackages successfully. As a further check, downloading the already-publishedhiroz/hiroz-codegenv0.2.0 from crates.io and rebuildinghiroz-msgsstandalone against them (outside the workspace) confirmed codegen runs correctly against the crates.io-downloaded bundled assets.Breaking changes
None. The ROS 2 installation /
HIROZ_MSG_PATHfallback path inbuild.rsis unchanged; only the local-bundled-assets source changed from a sibling path to thehiroz-codegenpublic API.Known follow-up
hiroz/hiroz-derive's path dependencies inhiroz-msgs/Cargo.tomlnow carry a hardcodedversion = "0.2"(required forcargo publishto accept a path dependency). It does not derive fromversion.workspace, so it needs a manual bump alongside future workspace version bumps, or it will silently pin a stale minimum version in the published manifest while local/path builds keep working unaffected.