0xMiden / 0xMiden/protocol

Building a package from the Rust project for Mockchain-based tests

未關閉
#2,611 10 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
132
分支
167
平均合併
1 天 23 小時
30 天內合併 PR
110

描述

As mentioned in https://github.com/0xMiden/compiler/issues/981#issuecomment-3949988737 and to complement the DX features added in https://github.com/0xMiden/protocol/pull/2502 we need to provide a user with a way to build the package.

I suggest implementing it as a function but I'm open to other ideas:
```rust
pub(super) fn compile_rust_package(project_path: &str, release: bool) -> Arc {
let mode_flag = if release { "--release" } else { "--dev" };
let output = std::process::Command::new("miden")
.arg("build")
// Midenup's "miden build" command inherits all of cargo miden's flags.
.current_dir(project_path)
.env("MIDENUP_MANIFEST_URI", format!("file://{project_path}/channel-manifest.json"))
.arg(mode_flag)
.output()
// TODO: Add the cargo install command once `midenup` is published
// in crates.io.
.expect("failed to execute `miden build`. Is midenup installed?.
If not, follow the installation instructions in: https://github.com/0xMiden/midenup");

if !output.status.success() {
panic!("miden build failed:\n{}", String::from_utf8_lossy(&output.stderr))
}

// Read the .masp artifact from the project's target directory
let masp_path = std::path::Path::new(project_path)
.join("target/miden/release")
.read_dir()
.expect("failed to read target/miden/release")
.filter_map(|e| e.ok())
.find(|e| e.path().extension().is_some_and(|ext| ext == "masp"))
.map(|entry| entry.path())
.expect("no .masp file found in target/miden/release");

let masp_bytes = std::fs::read(&masp_path).expect("failed to read .masp artifact");
Arc::new(Package::read_from_bytes(&masp_bytes).expect("failed to parse .masp package"))
}
```
@PhilippGackstatter What do you think?

@lima-limon-inc

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。