rust_builder: fix workspace binary discovery and add cargo test/check/clean/fmt support #3
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_lib_rhai#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
1. Workspace binary discovery fails with
all_bins()rust_builder_from(workspace_root).release().all_bins().copy_to_hero_bin().build()fails with "Artifact not found" even though cargo build succeeds (exit code 0).Root cause:
parse_cargo_toml()inhero_lib/crates/code/src/rust_builder/cargo.rs(lines 206-212) only parses explicit[[bin]]sections from the workspace rootCargo.toml. In a workspace, the root has no[[bin]]entries — those are in member crate Cargo.toml files. Sometadata.binariesis empty, andfind_artifacts()returns empty.Workaround: Use
.bin("specific_name")per binary instead of.all_bins(). This bypasses metadata lookup and searches for the named file directly intarget/release/.Fix needed in
parse_cargo_toml():Cargo.tomlfiles for[[bin]]entriessrc/main.rs→ package name,src/bin/*.rs→ file name)Files:
hero_lib/crates/code/src/rust_builder/cargo.rs—parse_cargo_toml()functionhero_lib/crates/code/src/rust_builder/mod.rs—find_artifacts()at line 455-4602. Missing cargo operations in rust_builder
Currently
rust_builderonly supportscargo build. For Rhai-based build automation (replacing Makefiles), we need native support for:build()cargo buildtest()cargo test --workspacecheck()cargo check --workspaceclean()cargo cleanfmt()cargo fmt --allfmt_check()cargo fmt --all --checkclippy()cargo clippy --workspacedoc()cargo doc --no-depsThese could be additional methods on the builder, e.g.:
Or a more general approach:
Context
This is needed for the Rhai-as-Makefile paradigm (hero_proc issue #29). Currently
test.rhaiandclean.rhaifall back toexecute("cargo test/clean")shell commands because native Rhai functions don't exist.Acceptance Criteria
rust_builder_from(workspace).all_bins().build()correctly discovers binaries from workspace membersrust_builder_from(path).test()runs cargo test and returns resultrust_builder_from(path).check()runs cargo checkrust_builder_from(path).clean()runs cargo cleanrust_builder_from(path).fmt()and.fmt_check()run cargo fmtrust_builder_from(path).clippy()runs cargo clippy