0xMiden / 0xMiden/protocol

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

Abierto
#2,611 10 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
132
Forks
167
Merge medio
1 d 23 h
PR fusionados (30 d)
110

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.