0xMiden / 0xMiden/protocol

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

Đang mở
#2,611 10 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
132
Fork
167
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
110

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.