feat(build): expose Cargo build artifact output#139
Merged
Conversation
328c87d to
272e9da
Compare
272e9da to
2422bcc
Compare
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.
问题
下游调用
ostool::build::cargo_build后只能知道构建成功,无法直接拿到 Cargo JSON 输出中解析出的可执行产物路径。需要使用该路径的调用方只能自行按target/<target>/<profile>/<bin>规则拼接,容易和 Cargo 实际选择的 bin、profile、target-dir 或后续构建逻辑产生偏差。修改
ostool::build::CargoBuildOutput,暴露:elf_path():Cargo 解析出的可执行 ELF 路径。cargo_artifact_dir():该可执行产物所在目录。ostool::build::cargo_build_with_output(...) -> anyhow::Result<CargoBuildOutput>,复用现有 Cargo build pipeline,在完成 runtime artifact 状态更新和 post-build commands 后返回构建产物信息。cargo_build(...) -> anyhow::Result<()>,改为调用新函数后丢弃返回值,避免破坏现有调用方。设计说明
该接口不改变现有
cargo_build的返回类型,降低兼容性影响;同时输出值从内部CargoBuildOutcome/ResolvedCargoArtifact转换而来,保证下游拿到的路径和 ostool 当前选择、记录的 Cargo artifact 保持一致。验证
cargo fmtcargo test