From 367bb3c060302fc5fa2a14440f2dbf25574d2a17 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 20 Nov 2023 15:10:59 +0200 Subject: [PATCH 01/22] chore: draft `compile` command options using clap --- Cargo.lock | 9 +++++++ Cargo.toml | 4 ++- cargo-ext/Cargo.toml | 20 +++++++++++++++ cargo-ext/src/commands.rs | 54 +++++++++++++++++++++++++++++++++++++++ cargo-ext/src/main.rs | 23 +++++++++++++++++ 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 cargo-ext/Cargo.toml create mode 100644 cargo-ext/src/commands.rs create mode 100644 cargo-ext/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 460b6ddf2..55c154483 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,6 +212,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "cargo-miden" +version = "0.1.0" +dependencies = [ + "clap 4.4.2", + "midenc-driver", + "midenc-session", +] + [[package]] name = "cc" version = "1.0.83" diff --git a/Cargo.toml b/Cargo.toml index 61e683656..0d674173f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,9 @@ members = [ "midenc-session", "tools/*", "frontend-wasm", - "tests/rust-apps/*", + "tests/rust", "tests/integration", + "cargo-ext", ] exclude = ["tests/rust-apps-wasm"] @@ -77,6 +78,7 @@ midenc-compile = { path = "midenc-compile" } midenc-driver = { path = "midenc-driver" } midenc-session = { path = "midenc-session" } miden-integration-tests = { path = "tests/integration" } +miden-cargo-extension = { path = "cargo-ext" } [profile.dev] diff --git a/cargo-ext/Cargo.toml b/cargo-ext/Cargo.toml new file mode 100644 index 000000000..8d9fe9f6a --- /dev/null +++ b/cargo-ext/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "cargo-miden" +version.workspace = true +rust-version.workspace = true +authors.workspace = true +description.workspace = true +repository.workspace = true +homepage.workspace = true +documentation.workspace = true +categories.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +midenc-driver.workspace = true +midenc-session.workspace = true +clap.workspace = true \ No newline at end of file diff --git a/cargo-ext/src/commands.rs b/cargo-ext/src/commands.rs new file mode 100644 index 000000000..733366810 --- /dev/null +++ b/cargo-ext/src/commands.rs @@ -0,0 +1,54 @@ +use std::path::PathBuf; + +use clap::Parser; +use clap::Subcommand; +use midenc_session::TargetEnv; + +#[derive(Parser, Debug)] +#[command(name = "cargo")] +#[command(bin_name = "cargo")] +pub enum CargoCli { + Miden(MidenArgs), +} + +#[derive(Parser, Debug)] +#[command(name = "miden")] +#[command(bin_name = "cargo miden")] +#[command(about = "Cargo command for developing Miden projects", long_about = None)] +pub struct MidenArgs { + #[command(subcommand)] + pub command: Commands, +} + +#[derive(Debug, Subcommand)] +pub enum Commands { + /// Invoke the compiler frontend + #[command(next_display_order(10), name = "compile", about = "Compile to MASM")] + Compile { + /// The target environment to compile for + #[arg(long = "target", value_name = "TARGET", default_value_t = TargetEnv::Base, display_order(2))] + target: TargetEnv, + + /// Tells the compiler to produce an executable Miden program from the binary target + #[arg(long = "bin-name", display_order(3))] + bin_name: String, + + /// Tells the compiler to produce a Miden library from the lib target + #[arg( + long = "lib", + conflicts_with("bin-name"), + default_value_t = false, + display_order(4) + )] + is_library: bool, + + /// Write output to `` + #[arg( + short = 'o', + value_name = "FILENAME", + id = "output-file", + display_order(6) + )] + output_file: Option, + }, +} diff --git a/cargo-ext/src/main.rs b/cargo-ext/src/main.rs new file mode 100644 index 000000000..5e954441f --- /dev/null +++ b/cargo-ext/src/main.rs @@ -0,0 +1,23 @@ +use clap::Parser; +use commands::CargoCli; +use commands::Commands; + +mod commands; + +fn main() { + let args = match CargoCli::parse() { + CargoCli::Miden(args) => args, + }; + + match args.command { + Commands::Compile { + target, + bin_name, + is_library, + output_file, + } => { + // TODO: pass unrecognized flags to the midenc + todo!("run cargo"); + } + } +} From f09a893304101ab4740a56e9893ce43b7a7f43fb Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 20 Nov 2023 15:11:26 +0200 Subject: [PATCH 02/22] test: draft `compile` command using the `midenc_driver`, add test compiling a template project --- Cargo.lock | 2 + Cargo.toml | 2 +- cargo-ext/Cargo.toml | 14 +++- .../src/{commands.rs => cli_commands.rs} | 15 +--- cargo-ext/src/compile.rs | 84 +++++++++++++++++++ cargo-ext/src/lib.rs | 2 + cargo-ext/src/main.rs | 11 +-- cargo-ext/tests/compile.rs | 22 +++++ cargo-ext/tests/data/template/Cargo.lock | 7 ++ cargo-ext/tests/data/template/Cargo.toml | 12 +++ cargo-ext/tests/data/template/src/lib.rs | 18 ++++ cargo-ext/tests/mod.rs | 2 + cargo-ext/tests/utils.rs | 11 +++ 13 files changed, 183 insertions(+), 19 deletions(-) rename cargo-ext/src/{commands.rs => cli_commands.rs} (76%) create mode 100644 cargo-ext/src/compile.rs create mode 100644 cargo-ext/src/lib.rs create mode 100644 cargo-ext/tests/compile.rs create mode 100644 cargo-ext/tests/data/template/Cargo.lock create mode 100644 cargo-ext/tests/data/template/Cargo.toml create mode 100644 cargo-ext/tests/data/template/src/lib.rs create mode 100755 cargo-ext/tests/mod.rs create mode 100644 cargo-ext/tests/utils.rs diff --git a/Cargo.lock b/Cargo.lock index 55c154483..a0b40472e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -217,8 +217,10 @@ name = "cargo-miden" version = "0.1.0" dependencies = [ "clap 4.4.2", + "miden-diagnostics", "midenc-driver", "midenc-session", + "rusty-fork", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0d674173f..a3ac46666 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ members = [ "tests/integration", "cargo-ext", ] -exclude = ["tests/rust-apps-wasm"] +exclude = ["tests/rust-apps-wasm", "cargo-ext/tests/data"] [workspace.package] version = "0.1.0" diff --git a/cargo-ext/Cargo.toml b/cargo-ext/Cargo.toml index 8d9fe9f6a..91317d6dc 100644 --- a/cargo-ext/Cargo.toml +++ b/cargo-ext/Cargo.toml @@ -13,8 +13,20 @@ license.workspace = true readme.workspace = true edition.workspace = true publish.workspace = true +autotests = false # disable autodiscovery of tests + +[[bin]] +name = "cargo-miden" + +[[test]] +name = "integration" +path = "tests/mod.rs" [dependencies] midenc-driver.workspace = true midenc-session.workspace = true -clap.workspace = true \ No newline at end of file +miden-diagnostics.workspace = true +clap.workspace = true + +[dev-dependencies] +rusty-fork = "0.3.0" \ No newline at end of file diff --git a/cargo-ext/src/commands.rs b/cargo-ext/src/cli_commands.rs similarity index 76% rename from cargo-ext/src/commands.rs rename to cargo-ext/src/cli_commands.rs index 733366810..fbd481f20 100644 --- a/cargo-ext/src/commands.rs +++ b/cargo-ext/src/cli_commands.rs @@ -29,18 +29,9 @@ pub enum Commands { #[arg(long = "target", value_name = "TARGET", default_value_t = TargetEnv::Base, display_order(2))] target: TargetEnv, - /// Tells the compiler to produce an executable Miden program from the binary target + /// Tells the compiler to produce an executable Miden program from the binary target or a library from the lib target if not specified #[arg(long = "bin-name", display_order(3))] - bin_name: String, - - /// Tells the compiler to produce a Miden library from the lib target - #[arg( - long = "lib", - conflicts_with("bin-name"), - default_value_t = false, - display_order(4) - )] - is_library: bool, + bin_name: Option, /// Write output to `` #[arg( @@ -49,6 +40,6 @@ pub enum Commands { id = "output-file", display_order(6) )] - output_file: Option, + output_file: PathBuf, }, } diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs new file mode 100644 index 000000000..4c9c6a020 --- /dev/null +++ b/cargo-ext/src/compile.rs @@ -0,0 +1,84 @@ +use core::panic; +use std::path::PathBuf; +use std::process::Command; +use std::sync::Arc; + +use miden_diagnostics::Verbosity; +use midenc_session::InputFile; +use midenc_session::OutputFile; +use midenc_session::OutputType; +use midenc_session::OutputTypeSpec; +use midenc_session::OutputTypes; +use midenc_session::ProjectType; +use midenc_session::Session; +use midenc_session::TargetEnv; + +pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf) { + let mut cargo_build_cmd = Command::new("cargo"); + cargo_build_cmd + .arg("build") + .arg("--release") + .arg("--target=wasm32-unknown-unknown"); + + let project_type = if let Some(bin_name) = bin_name { + cargo_build_cmd.arg("--bin").arg(bin_name); + ProjectType::Program + } else { + ProjectType::Library + }; + let output = cargo_build_cmd.output().expect( + format!( + "Failed to execute cargo build {}.", + cargo_build_cmd + .get_args() + .map(|arg| format!("'{}'", arg.to_str().unwrap())) + .collect::>() + .join(" ") + ) + .as_str(), + ); + if !output.status.success() { + eprintln!("{}", String::from_utf8_lossy(&output.stderr)); + panic!("Rust to Wasm compilation failed!"); + } + // TODO: parse the lib name from the Cargo.toml file + let artifact_name = "miden_lib"; + let cwd = std::env::current_dir().unwrap(); + let target_bin_file_path = cwd + .join("target") + .join("wasm32-unknown-unknown") + .join("release") + .join(artifact_name) + .with_extension("wasm"); + if !target_bin_file_path.exists() { + panic!( + "Cargo build failed, expected Wasm artifact at path: {}", + target_bin_file_path.to_str().unwrap() + ); + } + + let input = InputFile::from_path(target_bin_file_path).expect("Invalid Wasm artifact path"); + let output_file = OutputFile::Real(output_file); + let output_types = OutputTypes::new(vec![OutputTypeSpec { + output_type: OutputType::Masl, + path: Some(output_file.clone()), + }]); + let options = midenc_session::Options::new(cwd) + // .with_color(color) + .with_verbosity(Verbosity::Debug) + // .with_warnings(self.warn) + .with_output_types(output_types); + let session = Arc::new( + Session::new(target, input, None, Some(output_file), None, options, None) + // .with_arg_matches(matches) + .with_project_type(project_type), + ); + match midenc_driver::commands::compile(session.clone()) { + Ok(_) => (), + Err(e) => { + eprintln!("{}", e); + // TODO: print diagnostics + panic!("Compilation failed!"); + } + } +} diff --git a/cargo-ext/src/lib.rs b/cargo-ext/src/lib.rs new file mode 100644 index 000000000..d8ae8a565 --- /dev/null +++ b/cargo-ext/src/lib.rs @@ -0,0 +1,2 @@ +mod compile; +pub use compile::compile; diff --git a/cargo-ext/src/main.rs b/cargo-ext/src/main.rs index 5e954441f..563121cc2 100644 --- a/cargo-ext/src/main.rs +++ b/cargo-ext/src/main.rs @@ -1,8 +1,9 @@ +use cargo_miden::compile; use clap::Parser; -use commands::CargoCli; -use commands::Commands; +use cli_commands::CargoCli; +use cli_commands::Commands; -mod commands; +mod cli_commands; fn main() { let args = match CargoCli::parse() { @@ -13,11 +14,11 @@ fn main() { Commands::Compile { target, bin_name, - is_library, output_file, } => { + // TODO: ensure wasm32-unknown-unknown target is installed // TODO: pass unrecognized flags to the midenc - todo!("run cargo"); + compile(target, bin_name, output_file); } } } diff --git a/cargo-ext/tests/compile.rs b/cargo-ext/tests/compile.rs new file mode 100644 index 000000000..a4833d5a0 --- /dev/null +++ b/cargo-ext/tests/compile.rs @@ -0,0 +1,22 @@ +use crate::utils::get_test_path; +use cargo_miden::compile; +use midenc_session::TargetEnv; +use std::env; + +// rusty_fork::rusty_fork_test! { + +#[test] +fn compile_template() { + let restore_dir = env::current_dir().unwrap(); + let test_dir = get_test_path("template"); + env::set_current_dir(&test_dir).unwrap(); + let masm_path_rel = "target/miden_lib.masm"; + // dbg!(&test_dir); + compile(TargetEnv::Base, None, test_dir.join(masm_path_rel)); + env::set_current_dir(restore_dir).unwrap(); + let masm_file_path = test_dir.join(masm_path_rel); + assert!(masm_file_path.exists()); + assert!(masm_file_path.metadata().unwrap().len() > 0); +} + +// } diff --git a/cargo-ext/tests/data/template/Cargo.lock b/cargo-ext/tests/data/template/Cargo.lock new file mode 100644 index 000000000..e381c6d62 --- /dev/null +++ b/cargo-ext/tests/data/template/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "miden-lib" +version = "0.1.0" diff --git a/cargo-ext/tests/data/template/Cargo.toml b/cargo-ext/tests/data/template/Cargo.toml new file mode 100644 index 000000000..553f7b670 --- /dev/null +++ b/cargo-ext/tests/data/template/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "miden-lib" +version = "0.1.0" +edition = "2021" + +[workspace] + +[lib] +crate-type = ["cdylib"] + +[profile.release] +opt-level = "z" \ No newline at end of file diff --git a/cargo-ext/tests/data/template/src/lib.rs b/cargo-ext/tests/data/template/src/lib.rs new file mode 100644 index 000000000..0da60d0f7 --- /dev/null +++ b/cargo-ext/tests/data/template/src/lib.rs @@ -0,0 +1,18 @@ +#![no_std] + +// #[global_allocator] +// static A: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc; + +#[panic_handler] +fn my_panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +#[no_mangle] +pub fn function(n: u32) -> u32 { + let mut a = n; + while a > 3 { + a = a / 3; + } + a +} diff --git a/cargo-ext/tests/mod.rs b/cargo-ext/tests/mod.rs new file mode 100755 index 000000000..a1dea7ea0 --- /dev/null +++ b/cargo-ext/tests/mod.rs @@ -0,0 +1,2 @@ +mod compile; +mod utils; diff --git a/cargo-ext/tests/utils.rs b/cargo-ext/tests/utils.rs new file mode 100644 index 000000000..288ff3428 --- /dev/null +++ b/cargo-ext/tests/utils.rs @@ -0,0 +1,11 @@ +use std::env; +use std::path::PathBuf; + +pub(crate) fn get_test_path(test_dir_name: &str) -> PathBuf { + let mut test_dir = + PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set")); + test_dir.push("tests"); + test_dir.push("data"); + test_dir.push(test_dir_name); + test_dir +} From e70602497e1b5c07438245e5ccb96d11d119fd94 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Fri, 10 Nov 2023 12:22:12 +0200 Subject: [PATCH 03/22] test: get target dir from CARGO_TARGET_DIR env var when locating Wasm artifact --- cargo-ext/src/compile.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index 4c9c6a020..d0b27eb56 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -14,17 +14,19 @@ use midenc_session::Session; use midenc_session::TargetEnv; pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf) { + // for cargo env var see https://doc.rust-lang.org/cargo/reference/environment-variables.html let mut cargo_build_cmd = Command::new("cargo"); cargo_build_cmd .arg("build") .arg("--release") .arg("--target=wasm32-unknown-unknown"); - let project_type = if let Some(bin_name) = bin_name { - cargo_build_cmd.arg("--bin").arg(bin_name); - ProjectType::Program + let (project_type, artifact_name) = if let Some(bin_name) = bin_name { + cargo_build_cmd.arg("--bin").arg(bin_name.clone()); + (ProjectType::Program, bin_name) } else { - ProjectType::Library + // TODO: parse artifact name for lib from Cargo.toml (package.name?) + (ProjectType::Library, "miden_lib".to_string()) }; let output = cargo_build_cmd.output().expect( format!( @@ -41,15 +43,18 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf eprintln!("{}", String::from_utf8_lossy(&output.stderr)); panic!("Rust to Wasm compilation failed!"); } - // TODO: parse the lib name from the Cargo.toml file - let artifact_name = "miden_lib"; let cwd = std::env::current_dir().unwrap(); - let target_bin_file_path = cwd - .join("target") - .join("wasm32-unknown-unknown") - .join("release") - .join(artifact_name) - .with_extension("wasm"); + let target_dir = std::env::var("CARGO_TARGET_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| cwd.join("target")); + let release_folder = target_dir.join("wasm32-unknown-unknown").join("release"); + if !release_folder.exists() { + panic!( + "Cargo build failed, expected release folder at path: {}", + release_folder.to_str().unwrap() + ); + } + let target_bin_file_path = release_folder.join(artifact_name).with_extension("wasm"); if !target_bin_file_path.exists() { panic!( "Cargo build failed, expected Wasm artifact at path: {}", From 66a3d32244177f4cf14e141cceaab86f7deac533 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 21 Nov 2023 12:35:26 +0200 Subject: [PATCH 04/22] fix: emit Session artifact in CodegenStage, don't require Session.matches in ApplyRewritesStage Otherwise, ApplyRewritesStage crashes when arg matches are not provided in Session. --- Cargo.lock | 1 - cargo-ext/Cargo.toml | 3 +-- cargo-ext/src/compile.rs | 37 ++++++++++++++++------------ cargo-ext/src/main.rs | 2 +- cargo-ext/tests/compile.rs | 15 ++++++----- codegen/masm/src/masm/program.rs | 26 +++++++++++++++++++ midenc-compile/src/stages/codegen.rs | 7 +++--- midenc-compile/src/stages/mod.rs | 2 +- midenc-compile/src/stages/rewrite.rs | 15 ++++++----- 9 files changed, 68 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0b40472e..6f121aa82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,6 @@ dependencies = [ "miden-diagnostics", "midenc-driver", "midenc-session", - "rusty-fork", ] [[package]] diff --git a/cargo-ext/Cargo.toml b/cargo-ext/Cargo.toml index 91317d6dc..c0c505d5a 100644 --- a/cargo-ext/Cargo.toml +++ b/cargo-ext/Cargo.toml @@ -28,5 +28,4 @@ midenc-session.workspace = true miden-diagnostics.workspace = true clap.workspace = true -[dev-dependencies] -rusty-fork = "0.3.0" \ No newline at end of file +[dev-dependencies] \ No newline at end of file diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index d0b27eb56..7637c5da4 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -13,7 +13,7 @@ use midenc_session::ProjectType; use midenc_session::Session; use midenc_session::TargetEnv; -pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf) { +pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBuf) { // for cargo env var see https://doc.rust-lang.org/cargo/reference/environment-variables.html let mut cargo_build_cmd = Command::new("cargo"); cargo_build_cmd @@ -28,6 +28,24 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf // TODO: parse artifact name for lib from Cargo.toml (package.name?) (ProjectType::Library, "miden_lib".to_string()) }; + let cwd = std::env::current_dir().unwrap(); + let target_dir = std::env::var("CARGO_TARGET_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| cwd.join("target")); + let release_folder = target_dir.join("wasm32-unknown-unknown").join("release"); + if !release_folder.exists() { + panic!( + "Cargo build failed, expected release folder at path: {}", + release_folder.to_str().unwrap() + ); + } + let target_bin_file_path = release_folder.join(artifact_name).with_extension("wasm"); + if target_bin_file_path.exists() { + // remove existing Wasm file since cargo build might not generate a new one silently + // e.g. if crate-type = ["cdylib"] is not set in Cargo.toml + std::fs::remove_file(&target_bin_file_path).unwrap(); + } + let output = cargo_build_cmd.output().expect( format!( "Failed to execute cargo build {}.", @@ -43,18 +61,6 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf eprintln!("{}", String::from_utf8_lossy(&output.stderr)); panic!("Rust to Wasm compilation failed!"); } - let cwd = std::env::current_dir().unwrap(); - let target_dir = std::env::var("CARGO_TARGET_DIR") - .map(PathBuf::from) - .unwrap_or_else(|_| cwd.join("target")); - let release_folder = target_dir.join("wasm32-unknown-unknown").join("release"); - if !release_folder.exists() { - panic!( - "Cargo build failed, expected release folder at path: {}", - release_folder.to_str().unwrap() - ); - } - let target_bin_file_path = release_folder.join(artifact_name).with_extension("wasm"); if !target_bin_file_path.exists() { panic!( "Cargo build failed, expected Wasm artifact at path: {}", @@ -63,9 +69,9 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf } let input = InputFile::from_path(target_bin_file_path).expect("Invalid Wasm artifact path"); - let output_file = OutputFile::Real(output_file); + let output_file = OutputFile::Real(output_file.clone()); let output_types = OutputTypes::new(vec![OutputTypeSpec { - output_type: OutputType::Masl, + output_type: OutputType::Masm, path: Some(output_file.clone()), }]); let options = midenc_session::Options::new(cwd) @@ -82,7 +88,6 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: PathBuf Ok(_) => (), Err(e) => { eprintln!("{}", e); - // TODO: print diagnostics panic!("Compilation failed!"); } } diff --git a/cargo-ext/src/main.rs b/cargo-ext/src/main.rs index 563121cc2..166519984 100644 --- a/cargo-ext/src/main.rs +++ b/cargo-ext/src/main.rs @@ -18,7 +18,7 @@ fn main() { } => { // TODO: ensure wasm32-unknown-unknown target is installed // TODO: pass unrecognized flags to the midenc - compile(target, bin_name, output_file); + compile(target, bin_name, &output_file); } } } diff --git a/cargo-ext/tests/compile.rs b/cargo-ext/tests/compile.rs index a4833d5a0..7a9a5df85 100644 --- a/cargo-ext/tests/compile.rs +++ b/cargo-ext/tests/compile.rs @@ -2,8 +2,7 @@ use crate::utils::get_test_path; use cargo_miden::compile; use midenc_session::TargetEnv; use std::env; - -// rusty_fork::rusty_fork_test! { +use std::fs; #[test] fn compile_template() { @@ -12,11 +11,11 @@ fn compile_template() { env::set_current_dir(&test_dir).unwrap(); let masm_path_rel = "target/miden_lib.masm"; // dbg!(&test_dir); - compile(TargetEnv::Base, None, test_dir.join(masm_path_rel)); + let output_file = test_dir.join(masm_path_rel); + // dbg!(&output_file); + compile(TargetEnv::Base, None, &output_file); env::set_current_dir(restore_dir).unwrap(); - let masm_file_path = test_dir.join(masm_path_rel); - assert!(masm_file_path.exists()); - assert!(masm_file_path.metadata().unwrap().len() > 0); + assert!(output_file.exists()); + assert!(output_file.metadata().unwrap().len() > 0); + fs::remove_file(output_file).unwrap(); } - -// } diff --git a/codegen/masm/src/masm/program.rs b/codegen/masm/src/masm/program.rs index 15f6be516..46c28725c 100644 --- a/codegen/masm/src/masm/program.rs +++ b/codegen/masm/src/masm/program.rs @@ -294,3 +294,29 @@ impl fmt::Display for Program { Ok(()) } } +impl midenc_session::Emit for Program { + fn name(&self) -> Option { + None + } + fn output_type(&self) -> midenc_session::OutputType { + midenc_session::OutputType::Masm + } + fn write_to(&self, mut writer: W) -> std::io::Result<()> { + writer.write_fmt(format_args!("{}", self)) + } +} + +enum ModulesIter<'a> { + Open(intrusive_collections::rbtree::Iter<'a, ModuleTreeAdapter>), + Frozen(intrusive_collections::rbtree::Iter<'a, FrozenModuleTreeAdapter>), +} +impl<'a> Iterator for ModulesIter<'a> { + type Item = &'a Module; + + fn next(&mut self) -> Option { + match self { + Self::Open(ref mut iter) => iter.next(), + Self::Frozen(ref mut iter) => iter.next(), + } + } +} diff --git a/midenc-compile/src/stages/codegen.rs b/midenc-compile/src/stages/codegen.rs index 889941968..4bcacb9ed 100644 --- a/midenc-compile/src/stages/codegen.rs +++ b/midenc-compile/src/stages/codegen.rs @@ -26,15 +26,16 @@ impl Stage for CodegenStage { match input { MaybeLinked::Linked(program) => { let mut convert_to_masm = masm::ConvertHirToMasm::::default(); - Ok(convert_to_masm - .convert(program, analyses, session) - .map(Compiled::Program)?) + let program = convert_to_masm.convert(program, analyses, session)?; + session.emit(&program)?; + Ok(Compiled::Program(program)) } MaybeLinked::Unlinked(modules) => { let mut convert_to_masm = masm::ConvertHirToMasm::::default(); let mut masm_modules = Vec::with_capacity(modules.len()); for module in modules.into_iter() { let masm_module = convert_to_masm.convert(module, analyses, session)?; + session.emit(&masm_module)?; masm_modules.push(masm_module); } Ok(Compiled::Modules(masm_modules)) diff --git a/midenc-compile/src/stages/mod.rs b/midenc-compile/src/stages/mod.rs index cfbfced3c..f78e431fc 100644 --- a/midenc-compile/src/stages/mod.rs +++ b/midenc-compile/src/stages/mod.rs @@ -3,7 +3,7 @@ use crate::{CompilerError, CompilerResult}; use miden_codegen_masm as masm; use miden_frontend_wasm as wasm; use miden_hir::pass::{AnalysisManager, ConversionPass, RewritePass}; -use miden_hir::{self as hir, parser::ast, PassInfo}; +use miden_hir::{self as hir, parser::ast}; use midenc_session::Session; mod codegen; diff --git a/midenc-compile/src/stages/rewrite.rs b/midenc-compile/src/stages/rewrite.rs index 4853567ae..cfbd46c77 100644 --- a/midenc-compile/src/stages/rewrite.rs +++ b/midenc-compile/src/stages/rewrite.rs @@ -26,10 +26,12 @@ impl Stage for ApplyRewritesStage { let matches = session.matches(); for rewrite in inventory::iter::> { let flag = rewrite.name(); - if let Some(index) = matches.index_of(flag) { - let is_enabled = matches.get_flag(flag); - if is_enabled { - registered.push((index, rewrite.get())); + if matches.try_contains_id(flag).is_ok() { + if let Some(index) = matches.index_of(flag) { + let is_enabled = matches.get_flag(flag); + if is_enabled { + registered.push((index, rewrite.get())); + } } } } @@ -41,10 +43,7 @@ impl Stage for ApplyRewritesStage { // Otherwise, assume that the intent was to skip those rewrites and do not add them let mut rewrites = RewriteSet::default(); if registered.is_empty() { - let convert_to_masm_flag = as PassInfo>::FLAG; - let convert_to_masm = matches.get_flag(convert_to_masm_flag); - - if convert_to_masm { + if session.should_codegen() { rewrites.push(ModuleRewritePassAdapter::new( transforms::SplitCriticalEdges, )); From 134fce378b4e5bd19d48f3561f6dcde9da5a8671 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Fri, 10 Nov 2023 16:15:45 +0200 Subject: [PATCH 05/22] test: check target folder exists after build, not before --- cargo-ext/src/compile.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index 7637c5da4..77312eec7 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -33,12 +33,6 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu .map(PathBuf::from) .unwrap_or_else(|_| cwd.join("target")); let release_folder = target_dir.join("wasm32-unknown-unknown").join("release"); - if !release_folder.exists() { - panic!( - "Cargo build failed, expected release folder at path: {}", - release_folder.to_str().unwrap() - ); - } let target_bin_file_path = release_folder.join(artifact_name).with_extension("wasm"); if target_bin_file_path.exists() { // remove existing Wasm file since cargo build might not generate a new one silently @@ -61,6 +55,12 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu eprintln!("{}", String::from_utf8_lossy(&output.stderr)); panic!("Rust to Wasm compilation failed!"); } + if !release_folder.exists() { + panic!( + "Cargo build failed, expected release folder at path: {}", + release_folder.to_str().unwrap() + ); + } if !target_bin_file_path.exists() { panic!( "Cargo build failed, expected Wasm artifact at path: {}", From 2db01ff4f716e8430d4628213e9a4564b5d7695b Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 13 Nov 2023 11:50:51 +0200 Subject: [PATCH 06/22] chore: print the progress of the compilation --- cargo-ext/src/compile.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index 77312eec7..05ef89cb3 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -33,13 +33,16 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu .map(PathBuf::from) .unwrap_or_else(|_| cwd.join("target")); let release_folder = target_dir.join("wasm32-unknown-unknown").join("release"); - let target_bin_file_path = release_folder.join(artifact_name).with_extension("wasm"); + let target_bin_file_path = release_folder + .join(artifact_name.clone()) + .with_extension("wasm"); if target_bin_file_path.exists() { // remove existing Wasm file since cargo build might not generate a new one silently // e.g. if crate-type = ["cdylib"] is not set in Cargo.toml std::fs::remove_file(&target_bin_file_path).unwrap(); } + println!("Compiling '{artifact_name}' Rust to Wasm with cargo build ..."); let output = cargo_build_cmd.output().expect( format!( "Failed to execute cargo build {}.", @@ -67,7 +70,10 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu target_bin_file_path.to_str().unwrap() ); } - + println!( + "Compiling '{}' Wasm to Masm with midenc ...", + &output_file.as_path().to_str().unwrap() + ); let input = InputFile::from_path(target_bin_file_path).expect("Invalid Wasm artifact path"); let output_file = OutputFile::Real(output_file.clone()); let output_types = OutputTypes::new(vec![OutputTypeSpec { From 555051b504e15fac7d7132d4405ac7deb3836cc7 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 13 Nov 2023 15:45:38 +0200 Subject: [PATCH 07/22] refactor: make `cargo_ext:compile` return `anyhow::Result` --- Cargo.lock | 1 + cargo-ext/Cargo.toml | 1 + cargo-ext/src/compile.rs | 41 ++++++++++++++++++++------------------ cargo-ext/src/main.rs | 5 +++-- cargo-ext/tests/compile.rs | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f121aa82..1125636b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -216,6 +216,7 @@ dependencies = [ name = "cargo-miden" version = "0.1.0" dependencies = [ + "anyhow", "clap 4.4.2", "miden-diagnostics", "midenc-driver", diff --git a/cargo-ext/Cargo.toml b/cargo-ext/Cargo.toml index c0c505d5a..853795554 100644 --- a/cargo-ext/Cargo.toml +++ b/cargo-ext/Cargo.toml @@ -27,5 +27,6 @@ midenc-driver.workspace = true midenc-session.workspace = true miden-diagnostics.workspace = true clap.workspace = true +anyhow.workspace = true [dev-dependencies] \ No newline at end of file diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index 05ef89cb3..7c4a19cd5 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -1,8 +1,9 @@ -use core::panic; +use anyhow::bail; use std::path::PathBuf; use std::process::Command; use std::sync::Arc; +use anyhow::Context; use miden_diagnostics::Verbosity; use midenc_session::InputFile; use midenc_session::OutputFile; @@ -13,7 +14,11 @@ use midenc_session::ProjectType; use midenc_session::Session; use midenc_session::TargetEnv; -pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBuf) { +pub fn compile( + target: TargetEnv, + bin_name: Option, + output_file: &PathBuf, +) -> anyhow::Result<()> { // for cargo env var see https://doc.rust-lang.org/cargo/reference/environment-variables.html let mut cargo_build_cmd = Command::new("cargo"); cargo_build_cmd @@ -28,7 +33,7 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu // TODO: parse artifact name for lib from Cargo.toml (package.name?) (ProjectType::Library, "miden_lib".to_string()) }; - let cwd = std::env::current_dir().unwrap(); + let cwd = std::env::current_dir().context("Failed to get current working directory")?; let target_dir = std::env::var("CARGO_TARGET_DIR") .map(PathBuf::from) .unwrap_or_else(|_| cwd.join("target")); @@ -39,11 +44,16 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu if target_bin_file_path.exists() { // remove existing Wasm file since cargo build might not generate a new one silently // e.g. if crate-type = ["cdylib"] is not set in Cargo.toml - std::fs::remove_file(&target_bin_file_path).unwrap(); + std::fs::remove_file(&target_bin_file_path).with_context(|| { + format!( + "Failed to remove existing Wasm file {}", + &target_bin_file_path.to_str().unwrap() + ) + })?; } println!("Compiling '{artifact_name}' Rust to Wasm with cargo build ..."); - let output = cargo_build_cmd.output().expect( + let output = cargo_build_cmd.output().with_context(|| { format!( "Failed to execute cargo build {}.", cargo_build_cmd @@ -52,29 +62,28 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu .collect::>() .join(" ") ) - .as_str(), - ); + })?; if !output.status.success() { eprintln!("{}", String::from_utf8_lossy(&output.stderr)); - panic!("Rust to Wasm compilation failed!"); + bail!("Rust to Wasm compilation failed!"); } if !release_folder.exists() { - panic!( + bail!( "Cargo build failed, expected release folder at path: {}", release_folder.to_str().unwrap() ); } if !target_bin_file_path.exists() { - panic!( + bail!( "Cargo build failed, expected Wasm artifact at path: {}", target_bin_file_path.to_str().unwrap() ); } println!( - "Compiling '{}' Wasm to Masm with midenc ...", + "Compiling '{}' Wasm to MASM with midenc ...", &output_file.as_path().to_str().unwrap() ); - let input = InputFile::from_path(target_bin_file_path).expect("Invalid Wasm artifact path"); + let input = InputFile::from_path(target_bin_file_path).context("Invalid input file")?; let output_file = OutputFile::Real(output_file.clone()); let output_types = OutputTypes::new(vec![OutputTypeSpec { output_type: OutputType::Masm, @@ -90,11 +99,5 @@ pub fn compile(target: TargetEnv, bin_name: Option, output_file: &PathBu // .with_arg_matches(matches) .with_project_type(project_type), ); - match midenc_driver::commands::compile(session.clone()) { - Ok(_) => (), - Err(e) => { - eprintln!("{}", e); - panic!("Compilation failed!"); - } - } + midenc_driver::commands::compile(session.clone()).context("Wasm to MASM compilation failed!") } diff --git a/cargo-ext/src/main.rs b/cargo-ext/src/main.rs index 166519984..60ea6d377 100644 --- a/cargo-ext/src/main.rs +++ b/cargo-ext/src/main.rs @@ -1,3 +1,4 @@ +use anyhow::Context; use cargo_miden::compile; use clap::Parser; use cli_commands::CargoCli; @@ -5,7 +6,7 @@ use cli_commands::Commands; mod cli_commands; -fn main() { +fn main() -> anyhow::Result<()> { let args = match CargoCli::parse() { CargoCli::Miden(args) => args, }; @@ -18,7 +19,7 @@ fn main() { } => { // TODO: ensure wasm32-unknown-unknown target is installed // TODO: pass unrecognized flags to the midenc - compile(target, bin_name, &output_file); + compile(target, bin_name, &output_file).context(format!("Failed to compile {}", target)) } } } diff --git a/cargo-ext/tests/compile.rs b/cargo-ext/tests/compile.rs index 7a9a5df85..463a91dd6 100644 --- a/cargo-ext/tests/compile.rs +++ b/cargo-ext/tests/compile.rs @@ -13,7 +13,7 @@ fn compile_template() { // dbg!(&test_dir); let output_file = test_dir.join(masm_path_rel); // dbg!(&output_file); - compile(TargetEnv::Base, None, &output_file); + compile(TargetEnv::Base, None, &output_file).expect("Failed to compile"); env::set_current_dir(restore_dir).unwrap(); assert!(output_file.exists()); assert!(output_file.metadata().unwrap().len() > 0); From 5ad3645ffa41b345dc37c901171a9f3795a0a973 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 20 Nov 2023 15:12:40 +0200 Subject: [PATCH 08/22] refactor: use cargo-metadata to get Wasm artifacts --- Cargo.lock | 59 +++++++++++++ cargo-ext/Cargo.toml | 1 + cargo-ext/src/compile.rs | 102 +++++++++++++---------- cargo-ext/tests/data/template/Cargo.lock | 2 +- cargo-ext/tests/data/template/Cargo.toml | 2 +- 5 files changed, 122 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1125636b5..ba4ea7c90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,17 +212,50 @@ dependencies = [ "generic-array", ] +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + [[package]] name = "cargo-miden" version = "0.1.0" dependencies = [ "anyhow", + "cargo_metadata", "clap 4.4.2", "miden-diagnostics", "midenc-driver", "midenc-session", ] +[[package]] +name = "cargo-platform" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" version = "1.0.83" @@ -703,6 +736,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + [[package]] name = "jobserver" version = "0.1.27" @@ -1519,6 +1558,12 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + [[package]] name = "same-file" version = "1.0.6" @@ -1549,6 +1594,9 @@ name = "semver" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +dependencies = [ + "serde", +] [[package]] name = "serde" @@ -1570,6 +1618,17 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.3" diff --git a/cargo-ext/Cargo.toml b/cargo-ext/Cargo.toml index 853795554..abe7ea378 100644 --- a/cargo-ext/Cargo.toml +++ b/cargo-ext/Cargo.toml @@ -28,5 +28,6 @@ midenc-session.workspace = true miden-diagnostics.workspace = true clap.workspace = true anyhow.workspace = true +cargo_metadata = "0.18" [dev-dependencies] \ No newline at end of file diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index 7c4a19cd5..0461a726b 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -1,6 +1,8 @@ use anyhow::bail; +use cargo_metadata::Message; use std::path::PathBuf; use std::process::Command; +use std::process::Stdio; use std::sync::Arc; use anyhow::Context; @@ -25,70 +27,86 @@ pub fn compile( .arg("build") .arg("--release") .arg("--target=wasm32-unknown-unknown"); - - let (project_type, artifact_name) = if let Some(bin_name) = bin_name { + let project_type = if let Some(ref bin_name) = bin_name { cargo_build_cmd.arg("--bin").arg(bin_name.clone()); - (ProjectType::Program, bin_name) + ProjectType::Program } else { - // TODO: parse artifact name for lib from Cargo.toml (package.name?) - (ProjectType::Library, "miden_lib".to_string()) + ProjectType::Library }; - let cwd = std::env::current_dir().context("Failed to get current working directory")?; - let target_dir = std::env::var("CARGO_TARGET_DIR") - .map(PathBuf::from) - .unwrap_or_else(|_| cwd.join("target")); - let release_folder = target_dir.join("wasm32-unknown-unknown").join("release"); - let target_bin_file_path = release_folder - .join(artifact_name.clone()) - .with_extension("wasm"); - if target_bin_file_path.exists() { - // remove existing Wasm file since cargo build might not generate a new one silently - // e.g. if crate-type = ["cdylib"] is not set in Cargo.toml - std::fs::remove_file(&target_bin_file_path).with_context(|| { + println!("Compiling Wasm with cargo build ..."); + let mut child = cargo_build_cmd + .arg("--message-format=json-render-diagnostics") + .stdout(Stdio::piped()) + .spawn() + .with_context(|| { format!( - "Failed to remove existing Wasm file {}", - &target_bin_file_path.to_str().unwrap() + "Failed to execute cargo build {}.", + cargo_build_cmd + .get_args() + .map(|arg| format!("'{}'", arg.to_str().unwrap())) + .collect::>() + .join(" ") ) })?; + let reader = std::io::BufReader::new(child.stdout.take().unwrap()); + let mut wasm_artifacts = Vec::new(); + for message in cargo_metadata::Message::parse_stream(reader) { + match message.context("Failed to parse cargo metadata")? { + Message::CompilerArtifact(artifact) => { + // find the Wasm artifact in artifact.filenames + for filename in artifact.filenames { + if filename.as_str().ends_with(".wasm") { + wasm_artifacts.push(filename.into_std_path_buf()); + } + } + } + _ => (), + } } - - println!("Compiling '{artifact_name}' Rust to Wasm with cargo build ..."); - let output = cargo_build_cmd.output().with_context(|| { - format!( - "Failed to execute cargo build {}.", - cargo_build_cmd - .get_args() - .map(|arg| format!("'{}'", arg.to_str().unwrap())) - .collect::>() - .join(" ") - ) - })?; - if !output.status.success() { - eprintln!("{}", String::from_utf8_lossy(&output.stderr)); + let output = child.wait().expect("Couldn't get cargo's exit status"); + if !output.success() { bail!("Rust to Wasm compilation failed!"); } - if !release_folder.exists() { + + if wasm_artifacts.is_empty() { + match project_type { + ProjectType::Library => bail!("Cargo build failed, no Wasm artifact found. Check if crate-type = [\"cdylib\"] is set in Cargo.toml"), + ProjectType::Program => bail!("Cargo build failed, no Wasm artifact found."), + } + } + if wasm_artifacts.len() > 1 { bail!( - "Cargo build failed, expected release folder at path: {}", - release_folder.to_str().unwrap() + "Cargo build failed, multiple Wasm artifacts found: {:?}. Only one Wasm artifact is expected.", + wasm_artifacts ); } - if !target_bin_file_path.exists() { - bail!( - "Cargo build failed, expected Wasm artifact at path: {}", - target_bin_file_path.to_str().unwrap() + let wasm_file_path = wasm_artifacts[0].clone(); + match project_type { + ProjectType::Program => { + let bin_name = bin_name.unwrap(); + if !wasm_file_path.ends_with(format!("{}.wasm", bin_name)) { + bail!( + "Cargo build failed, Wasm artifact name {} does not match the expected name '{}'.", + wasm_file_path.to_str().unwrap(), + bin_name ); + } + } + ProjectType::Library => (), } + println!( - "Compiling '{}' Wasm to MASM with midenc ...", + "Compiling '{}' Wasm to {} MASM with midenc ...", + wasm_file_path.to_str().unwrap(), &output_file.as_path().to_str().unwrap() ); - let input = InputFile::from_path(target_bin_file_path).context("Invalid input file")?; + let input = InputFile::from_path(wasm_file_path).context("Invalid input file")?; let output_file = OutputFile::Real(output_file.clone()); let output_types = OutputTypes::new(vec![OutputTypeSpec { output_type: OutputType::Masm, path: Some(output_file.clone()), }]); + let cwd = std::env::current_dir().context("Failed to get current working directory")?; let options = midenc_session::Options::new(cwd) // .with_color(color) .with_verbosity(Verbosity::Debug) diff --git a/cargo-ext/tests/data/template/Cargo.lock b/cargo-ext/tests/data/template/Cargo.lock index e381c6d62..08aa217ca 100644 --- a/cargo-ext/tests/data/template/Cargo.lock +++ b/cargo-ext/tests/data/template/Cargo.lock @@ -3,5 +3,5 @@ version = 3 [[package]] -name = "miden-lib" +name = "miden-wallet-lib" version = "0.1.0" diff --git a/cargo-ext/tests/data/template/Cargo.toml b/cargo-ext/tests/data/template/Cargo.toml index 553f7b670..954ea1802 100644 --- a/cargo-ext/tests/data/template/Cargo.toml +++ b/cargo-ext/tests/data/template/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "miden-lib" +name = "miden-wallet-lib" version = "0.1.0" edition = "2021" From e108242263154052e823bad1de69ad000ac6f053 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 14 Nov 2023 10:52:09 +0200 Subject: [PATCH 09/22] chore: add README.md to cargo-ext --- cargo-ext/README.md | 50 +++++++++++++++++++++++++++++++++++++++++++ cargo-ext/src/main.rs | 2 -- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 cargo-ext/README.md diff --git a/cargo-ext/README.md b/cargo-ext/README.md new file mode 100644 index 000000000..5029c5a27 --- /dev/null +++ b/cargo-ext/README.md @@ -0,0 +1,50 @@ +# Miden Cargo Extension + +This crate provides a cargo extension that allows you to compile Rust code to Miden VM MASM. + +## Installation + +To install the extension, run: + +```bash +cargo install cargo-miden +``` + +## Requirements + +Since Rust is first compiled to Wasm, you'll need to have the `wasm32-unknown-unknown` target installed: + +```bash +rustup target add wasm32-unknown-unknown +``` + +## Usage + +### Getting help +To get help with the extension, run: + +```bash +cargo miden +``` + +Or for help with a specific command: + +```bash +cargo miden --help +``` + +### Creating a new project +To create a new Miden VM project, run: + +```bash +cargo miden new +``` + +### Compiling a project +To compile a Rust crate to Miden VM MASM, run: + +```bash +cargo miden compile -o +``` + +Without any additional arguments, this will compile the library target of the crate in the current directory. diff --git a/cargo-ext/src/main.rs b/cargo-ext/src/main.rs index 60ea6d377..b4b01ece1 100644 --- a/cargo-ext/src/main.rs +++ b/cargo-ext/src/main.rs @@ -17,8 +17,6 @@ fn main() -> anyhow::Result<()> { bin_name, output_file, } => { - // TODO: ensure wasm32-unknown-unknown target is installed - // TODO: pass unrecognized flags to the midenc compile(target, bin_name, &output_file).context(format!("Failed to compile {}", target)) } } From 58d3309a0dc786bc437fbf7b0d448ca4136dc266 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 20 Nov 2023 15:14:37 +0200 Subject: [PATCH 10/22] feat: add `new` command that generates a new Miden project from a template --- Cargo.lock | 1206 +++++++++++++++++++++++++++++++-- cargo-ext/Cargo.toml | 2 + cargo-ext/src/cli_commands.rs | 7 +- cargo-ext/src/lib.rs | 3 + cargo-ext/src/main.rs | 2 + cargo-ext/src/new_project.rs | 40 ++ 6 files changed, 1220 insertions(+), 40 deletions(-) create mode 100644 cargo-ext/src/new_project.rs diff --git a/Cargo.lock b/Cargo.lock index ba4ea7c90..5331bef8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,6 +38,20 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if", + "const-random", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.0.5" @@ -47,6 +61,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80a21b9440a626c7fc8573a9e3d3a06b75c7c97754c2949bc7857b90353ca655" +dependencies = [ + "as-slice", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -56,6 +79,21 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon 1.0.2", + "colorchoice", + "is-terminal", + "utf8parse", +] + [[package]] name = "anstream" version = "0.5.0" @@ -65,7 +103,7 @@ dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", - "anstyle-wincon", + "anstyle-wincon 2.1.0", "colorchoice", "utf8parse", ] @@ -91,7 +129,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", ] [[package]] @@ -101,7 +149,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -110,6 +158,12 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "anymap2" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" + [[package]] name = "arrayref" version = "0.3.7" @@ -122,6 +176,15 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "ascii-canvas" version = "3.0.0" @@ -212,6 +275,26 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bstr" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" +dependencies = [ + "memchr", + "regex-automata 0.4.3", + "serde", +] + +[[package]] +name = "btoi" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd6407f73a9b8b6162d8a2ef999fe6afd7cc15902ebf42c5cd296addf17e0ad" +dependencies = [ + "num-traits", +] + [[package]] name = "camino" version = "1.1.6" @@ -221,16 +304,56 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-generate" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a4798d27e0ded03c08f86f6226e65a88eb2a92b69555a282b61ed98afeae6da" +dependencies = [ + "anyhow", + "clap 4.3.24", + "console", + "dialoguer", + "env_logger 0.10.1", + "git2", + "gix-config", + "heck", + "home", + "ignore", + "indexmap 2.0.0", + "indicatif", + "liquid", + "liquid-core", + "liquid-derive", + "liquid-lib", + "log", + "names", + "paste", + "path-absolutize", + "regex", + "remove_dir_all", + "rhai", + "sanitize-filename", + "semver", + "serde", + "tempfile", + "thiserror", + "toml 0.7.6", + "walkdir", +] + [[package]] name = "cargo-miden" version = "0.1.0" dependencies = [ "anyhow", + "cargo-generate", "cargo_metadata", - "clap 4.4.2", + "clap 4.3.24", "miden-diagnostics", "midenc-driver", "midenc-session", + "path-absolutize", ] [[package]] @@ -289,21 +412,22 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.2" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" dependencies = [ "clap_builder", "clap_derive", + "once_cell", ] [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" dependencies = [ - "anstream", + "anstream 0.3.2", "anstyle", "clap_lex", "strsim 0.10.0", @@ -311,9 +435,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", @@ -362,6 +486,39 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "console" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.45.0", +] + +[[package]] +name = "const-random" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + [[package]] name = "constant_time_eq" version = "0.3.0" @@ -414,6 +571,24 @@ dependencies = [ "typenum", ] +[[package]] +name = "cvt" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ae9bf77fbf2d39ef573205d554d87e86c12f1994e9ea335b0651b9b278bcf1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "deranged" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -427,6 +602,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "dialoguer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" +dependencies = [ + "console", + "shell-words", + "tempfile", + "zeroize", +] + [[package]] name = "diff" version = "0.1.13" @@ -470,6 +657,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" +[[package]] +name = "dlmalloc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "203540e710bfadb90e5e29930baf5d10270cec1f43ab34f46f78b147b2de715a" +dependencies = [ + "libc", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "either" version = "1.9.0" @@ -485,6 +687,12 @@ dependencies = [ "log", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "env_logger" version = "0.9.3" @@ -498,6 +706,19 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -512,7 +733,7 @@ checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -545,6 +766,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "faster-hex" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239f7bfb930f820ab16a9cd95afc26f88264cf6905c960b340a615384aa3338a" +dependencies = [ + "serde", +] + [[package]] name = "fastrand" version = "2.0.0" @@ -556,7 +786,7 @@ name = "filecheck" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.4.2", + "clap 4.3.24", "lit", ] @@ -572,7 +802,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e0afc943ef18eebf6bc3335daeb8d338202093d18444a1784ea7f57fe7680f8" dependencies = [ - "ahash", + "ahash 0.7.6", "num_cpus", "parking_lot", "seize", @@ -584,6 +814,29 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_at" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982f82cc75107eef84f417ad6c53ae89bf65b561937ca4a3b3b0fd04d0aa2425" +dependencies = [ + "aligned", + "cfg-if", + "cvt", + "libc", + "nix", + "windows-sys 0.48.0", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -611,12 +864,259 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "git2" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b989d6a7ca95a362cf2cfc5ad688b3a467be1f87e480b8dad07fee8c79b0044" +dependencies = [ + "bitflags 1.3.2", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + +[[package]] +name = "gix-actor" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f8a773b5385e9d2f88bd879fb763ec1212585f6d630ebe13adb7bac93bce975" +dependencies = [ + "bstr", + "btoi", + "gix-date", + "itoa", + "thiserror", + "winnow", +] + +[[package]] +name = "gix-config" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a312d120231dc8d5a2e34928a9a2098c1d3dbad76f0660ee38d0b1a87de5271" +dependencies = [ + "bstr", + "gix-config-value", + "gix-features", + "gix-glob", + "gix-path", + "gix-ref", + "gix-sec", + "log", + "memchr", + "once_cell", + "smallvec", + "thiserror", + "unicode-bom", + "winnow", +] + +[[package]] +name = "gix-config-value" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901e184f3d4f99bf015ca13b5ccacb09e26b400f198fe2066651089e2c490680" +dependencies = [ + "bitflags 2.4.0", + "bstr", + "gix-path", + "libc", + "thiserror", +] + +[[package]] +name = "gix-date" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a825babda995d788e30d306a49dacd1e93d5f5d33d53c7682d0347cef40333c" +dependencies = [ + "bstr", + "itoa", + "thiserror", + "time", +] + +[[package]] +name = "gix-features" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f77decb545f63a52852578ef5f66ecd71017ffc1983d551d5fa2328d6d9817f" +dependencies = [ + "gix-hash", + "gix-trace", + "libc", + "sha1_smol", + "walkdir", +] + +[[package]] +name = "gix-fs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d5089f3338647776733a75a800a664ab046f56f21c515fa4722e395f877ef8" +dependencies = [ + "gix-features", +] + +[[package]] +name = "gix-glob" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c753299d14a29ca06d7adc8464c16f1786eb97bc9a44a796ad0a37f57235a494" +dependencies = [ + "bitflags 2.4.0", + "bstr", + "gix-features", + "gix-path", +] + +[[package]] +name = "gix-hash" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d4796bac3aaf0c2f8bea152ca924ae3bdc5f135caefe6431116bcd67e98eab9" +dependencies = [ + "faster-hex", + "thiserror", +] + +[[package]] +name = "gix-lock" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de4363023577b31906b476b34eefbf76931363ec574f88b5c7b6027789f1e3ce" +dependencies = [ + "gix-tempfile", + "gix-utils", + "thiserror", +] + +[[package]] +name = "gix-object" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4283b7b5e9438afe2e3183e9acd1c77e750800937bb56c06b750822d2ff6d95" +dependencies = [ + "bstr", + "btoi", + "gix-actor", + "gix-date", + "gix-features", + "gix-hash", + "gix-validate", + "itoa", + "smallvec", + "thiserror", + "winnow", +] + +[[package]] +name = "gix-path" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "764b31ac54472e796f08be376eaeea3e30800949650566620809659d39969dbd" +dependencies = [ + "bstr", + "gix-trace", + "home", + "once_cell", + "thiserror", +] + +[[package]] +name = "gix-ref" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993ce5c448a94038b8da1a8969c0facd6c1fbac509fa013344c580458f41527d" +dependencies = [ + "gix-actor", + "gix-date", + "gix-features", + "gix-fs", + "gix-hash", + "gix-lock", + "gix-object", + "gix-path", + "gix-tempfile", + "gix-validate", + "memmap2", + "thiserror", + "winnow", +] + +[[package]] +name = "gix-sec" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0debc2e70613a077c257c2bb45ab4f652a550ae1d00bdca356633ea9de88a230" +dependencies = [ + "bitflags 2.4.0", + "gix-path", + "libc", + "windows", +] + +[[package]] +name = "gix-tempfile" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea558d3daf3b1d0001052b12218c66c8f84788852791333b633d7eeb6999db1" +dependencies = [ + "gix-fs", + "libc", + "once_cell", + "parking_lot", + "tempfile", +] + +[[package]] +name = "gix-trace" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b6d623a1152c3facb79067d6e2ecdae48130030cf27d6eb21109f13bd7b836" + +[[package]] +name = "gix-utils" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b85d89dc728613e26e0ed952a19583744e7f5240fcd4aa30d6c824ffd8b52f0f" +dependencies = [ + "fastrand", +] + +[[package]] +name = "gix-validate" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05cab2b03a45b866156e052aa38619f4ece4adcb2f79978bfc249bc3b21b8c5" +dependencies = [ + "bstr", + "thiserror", +] + [[package]] name = "glob" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -650,13 +1150,22 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "human-panic" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb2df2fb4e13fa697d21d93061ebcbbd876f5ef643b48ff59cfab57a726ef140" dependencies = [ - "anstream", + "anstream 0.5.0", "anstyle", "backtrace", "os_info", @@ -672,6 +1181,33 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "ignore" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +dependencies = [ + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -690,6 +1226,29 @@ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", "hashbrown 0.14.0", + "serde", +] + +[[package]] +name = "indicatif" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", ] [[package]] @@ -715,7 +1274,7 @@ checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.2", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -760,6 +1319,16 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "kstring" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3066350882a1cd6d950d055997f379ac37fd39f81cd4d8ed186032eb3c5747" +dependencies = [ + "serde", + "static_assertions", +] + [[package]] name = "lalrpop" version = "0.20.0" @@ -806,18 +1375,115 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libgit2-sys" +version = "0.15.2+1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + [[package]] name = "libm" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libssh2-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +[[package]] +name = "liquid" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f68ae1011499ae2ef879f631891f21c78e309755f4a5e483c4a8f12e10b609" +dependencies = [ + "doc-comment", + "liquid-core", + "liquid-derive", + "liquid-lib", + "serde", +] + +[[package]] +name = "liquid-core" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e0724dfcaad5cfb7965ea0f178ca0870b8d7315178f4a7179f5696f7f04d5f" +dependencies = [ + "anymap2", + "itertools 0.10.5", + "kstring", + "liquid-derive", + "num-traits", + "pest", + "pest_derive", + "regex", + "serde", + "time", +] + +[[package]] +name = "liquid-derive" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2fb41a9bb4257a3803154bdf7e2df7d45197d1941c9b1a90ad815231630721" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "liquid-lib" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2a17e273a6fb1fb6268f7a5867ddfd0bd4683c7e19b51084f3d567fad4348c0" +dependencies = [ + "itertools 0.10.5", + "liquid-core", + "once_cell", + "percent-encoding", + "regex", + "time", + "unicode-segmentation", +] + [[package]] name = "lit" version = "1.0.4" @@ -857,12 +1523,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] -name = "memoffset" -version = "0.9.0" +name = "memmap2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" dependencies = [ - "autocfg", + "libc", +] + +[[package]] +name = "memmap2" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" +dependencies = [ + "libc", +] + +[[package]] +name = "miden-air" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fa086b50e9fc3f808e171cb69f81fe464efbc01f996df3db0e450caaf070749" +dependencies = [ + "miden-core", + "winter-air", ] [[package]] @@ -1124,7 +1809,7 @@ name = "midenc" version = "0.1.0" dependencies = [ "anyhow", - "env_logger", + "env_logger 0.9.3", "human-panic", "midenc-driver", ] @@ -1134,7 +1819,8 @@ name = "midenc-compile" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.4.2", + "bitflags 1.3.2", + "clap 4.3.24", "inventory", "log", "miden-assembly", @@ -1168,7 +1854,7 @@ dependencies = [ "anyhow", "atty", "bitflags 1.3.2", - "clap 4.4.2", + "clap 4.3.24", "inventory", "miden-diagnostics", "miden-hir-symbol", @@ -1185,12 +1871,41 @@ dependencies = [ "adler", ] +[[package]] +name = "names" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bddcd3bf5144b6392de80e04c347cd7fab2508f6df16a85fc496ecd5cec39bc" +dependencies = [ + "rand", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + +[[package]] +name = "normpath" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec60c60a693226186f5d6edf073232bfb6464ed97eb22cf3b01c1e8198fd97f5" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "num-bigint" version = "0.4.4" @@ -1253,6 +1968,21 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.32.1" @@ -1268,6 +1998,24 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_info" version = "3.7.0" @@ -1299,7 +2047,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1308,6 +2056,75 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "path-absolutize" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" +dependencies = [ + "path-dedot", +] + +[[package]] +name = "path-dedot" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" +dependencies = [ + "once_cell", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pest" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "pest_meta" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "petgraph" version = "0.6.4" @@ -1327,6 +2144,24 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "portable-atomic" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1479,8 +2314,8 @@ checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax 0.7.5", + "regex-automata 0.3.8", + "regex-syntax", ] [[package]] @@ -1494,6 +2329,12 @@ dependencies = [ "regex-syntax 0.7.5", ] +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" + [[package]] name = "regex-syntax" version = "0.7.5" @@ -1501,10 +2342,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] -name = "regex-syntax" +name = "remove_dir_all" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "23895cfadc1917fed9c6ed76a8c2903615fa3704f7493ff82b364c6540acc02b" +dependencies = [ + "aligned", + "cfg-if", + "cvt", + "fs_at", + "lazy_static", + "libc", + "normpath", + "windows-sys 0.45.0", +] + +[[package]] +name = "rhai" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2a11a646ef5d4e4a9d5cf80c7e4ecb20f9b1954292d5c5e6d6cbc8d33728ec" +dependencies = [ + "ahash 0.8.6", + "bitflags 1.3.2", + "instant", + "num-traits", + "rhai_codegen", + "smallvec", + "smartstring", +] + +[[package]] +name = "rhai_codegen" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "853977598f084a492323fe2f7896b4100a86284ee8473612de60021ea341310f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] [[package]] name = "rustc-demangle" @@ -1537,7 +2414,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1573,6 +2450,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sanitize-filename" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ed72fbaf78e6f2d41744923916966c4fbe3d7c74e3037a8ee482f1115572603" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1638,6 +2525,12 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1_smol" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" + [[package]] name = "sha2" version = "0.10.8" @@ -1659,6 +2552,12 @@ dependencies = [ "keccak", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "siphasher" version = "0.3.11" @@ -1671,6 +2570,29 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "string_cache" version = "0.8.7" @@ -1728,7 +2650,7 @@ dependencies = [ "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1780,6 +2702,47 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +dependencies = [ + "deranged", + "itoa", + "libc", + "num_threads", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -1789,6 +2752,21 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "toml" version = "0.5.11" @@ -1805,6 +2783,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -1845,18 +2824,51 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + [[package]] name = "unarray" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-bom" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" + [[package]] name = "unicode-ident" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-width" version = "0.1.10" @@ -1869,6 +2881,17 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" @@ -1884,6 +2907,12 @@ dependencies = [ "getrandom", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vec_map" version = "0.8.2" @@ -2012,13 +3041,46 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -2027,51 +3089,93 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -2157,3 +3261,29 @@ name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zerocopy" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/cargo-ext/Cargo.toml b/cargo-ext/Cargo.toml index abe7ea378..6fc2650d0 100644 --- a/cargo-ext/Cargo.toml +++ b/cargo-ext/Cargo.toml @@ -29,5 +29,7 @@ miden-diagnostics.workspace = true clap.workspace = true anyhow.workspace = true cargo_metadata = "0.18" +cargo-generate = "0.18" +path-absolutize = "3.1.1" [dev-dependencies] \ No newline at end of file diff --git a/cargo-ext/src/cli_commands.rs b/cargo-ext/src/cli_commands.rs index fbd481f20..0d3c6281e 100644 --- a/cargo-ext/src/cli_commands.rs +++ b/cargo-ext/src/cli_commands.rs @@ -22,8 +22,8 @@ pub struct MidenArgs { #[derive(Debug, Subcommand)] pub enum Commands { - /// Invoke the compiler frontend - #[command(next_display_order(10), name = "compile", about = "Compile to MASM")] + /// Compile the current project to MASM + #[command(next_display_order(10), name = "compile")] Compile { /// The target environment to compile for #[arg(long = "target", value_name = "TARGET", default_value_t = TargetEnv::Base, display_order(2))] @@ -42,4 +42,7 @@ pub enum Commands { )] output_file: PathBuf, }, + /// Scaffold a new Miden project at the given path + #[command(next_display_order(10), name = "new")] + New { path: PathBuf }, } diff --git a/cargo-ext/src/lib.rs b/cargo-ext/src/lib.rs index d8ae8a565..247841c10 100644 --- a/cargo-ext/src/lib.rs +++ b/cargo-ext/src/lib.rs @@ -1,2 +1,5 @@ mod compile; +mod new_project; + pub use compile::compile; +pub use new_project::new_project; diff --git a/cargo-ext/src/main.rs b/cargo-ext/src/main.rs index b4b01ece1..6844d7159 100644 --- a/cargo-ext/src/main.rs +++ b/cargo-ext/src/main.rs @@ -1,5 +1,6 @@ use anyhow::Context; use cargo_miden::compile; +use cargo_miden::new_project; use clap::Parser; use cli_commands::CargoCli; use cli_commands::Commands; @@ -19,5 +20,6 @@ fn main() -> anyhow::Result<()> { } => { compile(target, bin_name, &output_file).context(format!("Failed to compile {}", target)) } + Commands::New { path } => new_project(path).context("Failed to scaffold a new project"), } } diff --git a/cargo-ext/src/new_project.rs b/cargo-ext/src/new_project.rs new file mode 100644 index 000000000..2d4c13b17 --- /dev/null +++ b/cargo-ext/src/new_project.rs @@ -0,0 +1,40 @@ +use std::path::PathBuf; + +use anyhow::Context; +use cargo_generate::GenerateArgs; +use cargo_generate::TemplatePath; + +pub fn new_project(path: PathBuf) -> anyhow::Result<()> { + let name = path + .file_name() + .ok_or_else(|| { + anyhow::anyhow!("Failed to get the last segment of the provided path for the project name") + })? + .to_str() + .ok_or_else(|| { + anyhow::anyhow!("The last segment of the provided path must be valid UTF8 to generate a valid project name") + })? + .to_string(); + + let generate_args = GenerateArgs { + template_path: TemplatePath { + git: Some("https://github.com/greenhat/miden-project-template".into()), + ..Default::default() + }, + destination: path + .parent() + .map(|p| { + use path_absolutize::Absolutize; + p.absolutize().map(|p| p.to_path_buf()) + }) + .transpose() + .context("Failed to convert destination path to an absolute path")?, + name: Some(name), + force_git_init: true, + verbose: true, + ..Default::default() + }; + cargo_generate::generate(generate_args) + .context("Failed to scaffold new Miden project from the template")?; + return Ok(()); +} From 824a8eb7bb73f5892bb7ad8aba72162264ded35a Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 20 Nov 2023 15:55:56 +0200 Subject: [PATCH 11/22] fix: fix build after the rebase --- Cargo.lock | 40 +++++++++++++--------------------------- Cargo.toml | 2 +- cargo-ext/Cargo.toml | 2 +- cargo-ext/src/compile.rs | 2 +- 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5331bef8f..4b985baf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -351,7 +351,7 @@ dependencies = [ "cargo_metadata", "clap 4.3.24", "miden-diagnostics", - "midenc-driver", + "midenc-compile", "midenc-session", "path-absolutize", ] @@ -657,15 +657,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" -[[package]] -name = "dlmalloc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203540e710bfadb90e5e29930baf5d10270cec1f43ab34f46f78b147b2de715a" -dependencies = [ - "libc", -] - [[package]] name = "doc-comment" version = "0.3.3" @@ -1532,22 +1523,12 @@ dependencies = [ ] [[package]] -name = "memmap2" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" -dependencies = [ - "libc", -] - -[[package]] -name = "miden-air" -version = "0.7.0" +name = "memoffset" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fa086b50e9fc3f808e171cb69f81fe464efbc01f996df3db0e450caaf070749" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ - "miden-core", - "winter-air", + "autocfg", ] [[package]] @@ -1819,7 +1800,6 @@ name = "midenc-compile" version = "0.1.0" dependencies = [ "anyhow", - "bitflags 1.3.2", "clap 4.3.24", "inventory", "log", @@ -1839,7 +1819,7 @@ name = "midenc-driver" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.4.2", + "clap 4.3.24", "miden-diagnostics", "miden-hir", "midenc-compile", @@ -2315,7 +2295,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata 0.3.8", - "regex-syntax", + "regex-syntax 0.7.5", ] [[package]] @@ -2341,6 +2321,12 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + [[package]] name = "remove_dir_all" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index a3ac46666..b0d827ad0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ members = [ "midenc-session", "tools/*", "frontend-wasm", - "tests/rust", + "tests/rust-apps/*", "tests/integration", "cargo-ext", ] diff --git a/cargo-ext/Cargo.toml b/cargo-ext/Cargo.toml index 6fc2650d0..9a45fee22 100644 --- a/cargo-ext/Cargo.toml +++ b/cargo-ext/Cargo.toml @@ -23,7 +23,7 @@ name = "integration" path = "tests/mod.rs" [dependencies] -midenc-driver.workspace = true +midenc-compile.workspace = true midenc-session.workspace = true miden-diagnostics.workspace = true clap.workspace = true diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index 0461a726b..e218eefe3 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -117,5 +117,5 @@ pub fn compile( // .with_arg_matches(matches) .with_project_type(project_type), ); - midenc_driver::commands::compile(session.clone()).context("Wasm to MASM compilation failed!") + midenc_compile::compile(session.clone()).context("Wasm to MASM compilation failed!") } From 62adf34dda92f15d508558397971328bb68ba5c6 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 21 Nov 2023 12:30:03 +0200 Subject: [PATCH 12/22] fix: switch to https://github.com/0xPolygonMiden/rust-templates --- cargo-ext/src/new_project.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cargo-ext/src/new_project.rs b/cargo-ext/src/new_project.rs index 2d4c13b17..f5b55fb4f 100644 --- a/cargo-ext/src/new_project.rs +++ b/cargo-ext/src/new_project.rs @@ -18,7 +18,8 @@ pub fn new_project(path: PathBuf) -> anyhow::Result<()> { let generate_args = GenerateArgs { template_path: TemplatePath { - git: Some("https://github.com/greenhat/miden-project-template".into()), + git: Some("https://github.com/0xPolygonMiden/rust-templates".into()), + auto_path: Some("library".into()), ..Default::default() }, destination: path From af32c7104afa94e0751ac3f2e1ba509c925aca0a Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 21 Nov 2023 12:41:59 +0200 Subject: [PATCH 13/22] fix build after rebase --- codegen/masm/src/masm/program.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/codegen/masm/src/masm/program.rs b/codegen/masm/src/masm/program.rs index 46c28725c..4bee58080 100644 --- a/codegen/masm/src/masm/program.rs +++ b/codegen/masm/src/masm/program.rs @@ -305,18 +305,3 @@ impl midenc_session::Emit for Program { writer.write_fmt(format_args!("{}", self)) } } - -enum ModulesIter<'a> { - Open(intrusive_collections::rbtree::Iter<'a, ModuleTreeAdapter>), - Frozen(intrusive_collections::rbtree::Iter<'a, FrozenModuleTreeAdapter>), -} -impl<'a> Iterator for ModulesIter<'a> { - type Item = &'a Module; - - fn next(&mut self) -> Option { - match self { - Self::Open(ref mut iter) => iter.next(), - Self::Frozen(ref mut iter) => iter.next(), - } - } -} From 5a8a6edeb3fc86cd7e400c32fe94a74a6c7574b6 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 21 Nov 2023 16:27:14 +0200 Subject: [PATCH 14/22] refactor: switch from emiting MASM in CodegenStage, and switch to output folder in cargo extension Add WasmTranslationConfig::module_name_fallback to use if Wasm module doesn't specify a name in the custom section. In `Session::emit` if the path is a directory, emit to a file in that directory named after a compiled item(module) name. --- cargo-ext/src/cli_commands.rs | 10 ++++----- cargo-ext/src/compile.rs | 30 +++++++++++++++++++------- cargo-ext/src/main.rs | 7 +++--- cargo-ext/tests/compile.rs | 16 +++++++------- codegen/masm/src/masm/program.rs | 11 ---------- frontend-wasm/src/config.rs | 5 ++++- frontend-wasm/src/module_env.rs | 4 ++-- frontend-wasm/src/module_translator.rs | 9 ++++++-- midenc-compile/src/stages/codegen.rs | 2 -- midenc-compile/src/stages/parse.rs | 17 +++++++++++---- midenc-session/src/lib.rs | 10 ++++++--- 11 files changed, 71 insertions(+), 50 deletions(-) diff --git a/cargo-ext/src/cli_commands.rs b/cargo-ext/src/cli_commands.rs index 0d3c6281e..56c772004 100644 --- a/cargo-ext/src/cli_commands.rs +++ b/cargo-ext/src/cli_commands.rs @@ -33,14 +33,14 @@ pub enum Commands { #[arg(long = "bin-name", display_order(3))] bin_name: Option, - /// Write output to `` + /// Output directory for the compiled MASM file(s) #[arg( - short = 'o', - value_name = "FILENAME", - id = "output-file", + long = "out-dir", + value_name = "FOLDER", + id = "output-folder", display_order(6) )] - output_file: PathBuf, + output_folder: PathBuf, }, /// Scaffold a new Miden project at the given path #[command(next_display_order(10), name = "new")] diff --git a/cargo-ext/src/compile.rs b/cargo-ext/src/compile.rs index e218eefe3..2d820b2e5 100644 --- a/cargo-ext/src/compile.rs +++ b/cargo-ext/src/compile.rs @@ -19,7 +19,7 @@ use midenc_session::TargetEnv; pub fn compile( target: TargetEnv, bin_name: Option, - output_file: &PathBuf, + output_folder: &PathBuf, ) -> anyhow::Result<()> { // for cargo env var see https://doc.rust-lang.org/cargo/reference/environment-variables.html let mut cargo_build_cmd = Command::new("cargo"); @@ -95,16 +95,23 @@ pub fn compile( ProjectType::Library => (), } + if !output_folder.exists() { + bail!( + "Output folder '{}' does not exist.", + output_folder.to_str().unwrap() + ); + } + println!( - "Compiling '{}' Wasm to {} MASM with midenc ...", + "Compiling '{}' Wasm to '{}' directory with midenc ...", wasm_file_path.to_str().unwrap(), - &output_file.as_path().to_str().unwrap() + &output_folder.as_path().to_str().unwrap() ); let input = InputFile::from_path(wasm_file_path).context("Invalid input file")?; - let output_file = OutputFile::Real(output_file.clone()); + let output_file_folder = OutputFile::Real(output_folder.clone()); let output_types = OutputTypes::new(vec![OutputTypeSpec { output_type: OutputType::Masm, - path: Some(output_file.clone()), + path: Some(output_file_folder.clone()), }]); let cwd = std::env::current_dir().context("Failed to get current working directory")?; let options = midenc_session::Options::new(cwd) @@ -113,9 +120,16 @@ pub fn compile( // .with_warnings(self.warn) .with_output_types(output_types); let session = Arc::new( - Session::new(target, input, None, Some(output_file), None, options, None) - // .with_arg_matches(matches) - .with_project_type(project_type), + Session::new( + target, + input, + Some(output_folder.clone()), + None, + None, + options, + None, + ) + .with_project_type(project_type), ); midenc_compile::compile(session.clone()).context("Wasm to MASM compilation failed!") } diff --git a/cargo-ext/src/main.rs b/cargo-ext/src/main.rs index 6844d7159..6a82d4646 100644 --- a/cargo-ext/src/main.rs +++ b/cargo-ext/src/main.rs @@ -16,10 +16,9 @@ fn main() -> anyhow::Result<()> { Commands::Compile { target, bin_name, - output_file, - } => { - compile(target, bin_name, &output_file).context(format!("Failed to compile {}", target)) - } + output_folder, + } => compile(target, bin_name, &output_folder) + .context(format!("Failed to compile {}", target)), Commands::New { path } => new_project(path).context("Failed to scaffold a new project"), } } diff --git a/cargo-ext/tests/compile.rs b/cargo-ext/tests/compile.rs index 463a91dd6..5879f11f3 100644 --- a/cargo-ext/tests/compile.rs +++ b/cargo-ext/tests/compile.rs @@ -8,14 +8,14 @@ use std::fs; fn compile_template() { let restore_dir = env::current_dir().unwrap(); let test_dir = get_test_path("template"); - env::set_current_dir(&test_dir).unwrap(); - let masm_path_rel = "target/miden_lib.masm"; // dbg!(&test_dir); - let output_file = test_dir.join(masm_path_rel); - // dbg!(&output_file); - compile(TargetEnv::Base, None, &output_file).expect("Failed to compile"); + env::set_current_dir(&test_dir).unwrap(); + let masm_path_rel = "target"; + let output_folder = test_dir.join(masm_path_rel); + compile(TargetEnv::Base, None, &output_folder).expect("Failed to compile"); env::set_current_dir(restore_dir).unwrap(); - assert!(output_file.exists()); - assert!(output_file.metadata().unwrap().len() > 0); - fs::remove_file(output_file).unwrap(); + let expected_masm_path = output_folder.join("miden_wallet_lib.masm"); + assert!(expected_masm_path.exists()); + assert!(expected_masm_path.metadata().unwrap().len() > 0); + fs::remove_file(expected_masm_path).unwrap(); } diff --git a/codegen/masm/src/masm/program.rs b/codegen/masm/src/masm/program.rs index 4bee58080..15f6be516 100644 --- a/codegen/masm/src/masm/program.rs +++ b/codegen/masm/src/masm/program.rs @@ -294,14 +294,3 @@ impl fmt::Display for Program { Ok(()) } } -impl midenc_session::Emit for Program { - fn name(&self) -> Option { - None - } - fn output_type(&self) -> midenc_session::OutputType { - midenc_session::OutputType::Masm - } - fn write_to(&self, mut writer: W) -> std::io::Result<()> { - writer.write_fmt(format_args!("{}", self)) - } -} diff --git a/frontend-wasm/src/config.rs b/frontend-wasm/src/config.rs index b28a657ad..17a10f3da 100644 --- a/frontend-wasm/src/config.rs +++ b/frontend-wasm/src/config.rs @@ -1,3 +1,6 @@ /// Configuration for the WASM translation. #[derive(Debug, Default)] -pub struct WasmTranslationConfig {} +pub struct WasmTranslationConfig { + /// The module name to use if Wasm module doesn't have one. + pub module_name_fallback: Option, +} diff --git a/frontend-wasm/src/module_env.rs b/frontend-wasm/src/module_env.rs index a71ee38d4..c7b0d142d 100644 --- a/frontend-wasm/src/module_env.rs +++ b/frontend-wasm/src/module_env.rs @@ -113,9 +113,9 @@ pub struct ModuleEnvironment<'a> { impl<'a> ModuleEnvironment<'a> { /// Creates a new `ModuleEnvironment` instance. - pub fn new() -> Self { + pub fn new(name: String) -> Self { Self { - info: ModuleInfo::new(Ident::with_empty_span(Symbol::intern("noname"))), + info: ModuleInfo::new(Ident::with_empty_span(Symbol::intern(name))), trans: FuncTranslator::new(), function_bodies: PrimaryMap::new(), data_segments: PrimaryMap::new(), diff --git a/frontend-wasm/src/module_translator.rs b/frontend-wasm/src/module_translator.rs index b9458f7f5..9fb8581e4 100644 --- a/frontend-wasm/src/module_translator.rs +++ b/frontend-wasm/src/module_translator.rs @@ -32,10 +32,15 @@ struct WasmTranslationResult { /// Translate a sequence of bytes forming a valid Wasm binary into Miden IR fn translate_module_inner( wasm: &[u8], - _config: &WasmTranslationConfig, + config: &WasmTranslationConfig, diagnostics: &DiagnosticsHandler, ) -> WasmResult { - let mut module_env = ModuleEnvironment::new(); + let mut module_env = ModuleEnvironment::new( + config + .module_name_fallback + .clone() + .unwrap_or("noname".to_owned()), + ); let env = &mut module_env; let wasm_features = WasmFeatures::default(); let mut validator = Validator::new_with_features(wasm_features); diff --git a/midenc-compile/src/stages/codegen.rs b/midenc-compile/src/stages/codegen.rs index 4bcacb9ed..6bf66052f 100644 --- a/midenc-compile/src/stages/codegen.rs +++ b/midenc-compile/src/stages/codegen.rs @@ -27,7 +27,6 @@ impl Stage for CodegenStage { MaybeLinked::Linked(program) => { let mut convert_to_masm = masm::ConvertHirToMasm::::default(); let program = convert_to_masm.convert(program, analyses, session)?; - session.emit(&program)?; Ok(Compiled::Program(program)) } MaybeLinked::Unlinked(modules) => { @@ -35,7 +34,6 @@ impl Stage for CodegenStage { let mut masm_modules = Vec::with_capacity(modules.len()); for module in modules.into_iter() { let masm_module = convert_to_masm.convert(module, analyses, session)?; - session.emit(&masm_module)?; masm_modules.push(masm_module); } Ok(Compiled::Modules(masm_modules)) diff --git a/midenc-compile/src/stages/parse.rs b/midenc-compile/src/stages/parse.rs index 169759c6e..826c169b8 100644 --- a/midenc-compile/src/stages/parse.rs +++ b/midenc-compile/src/stages/parse.rs @@ -1,5 +1,6 @@ use midenc_session::InputFile; use std::path::Path; +use wasm::WasmTranslationConfig; use super::*; @@ -37,7 +38,11 @@ impl Stage for ParseStage { }, InputType::Stdin { ref input, .. } => match file_type { FileType::Hir => self.parse_ast_from_bytes(&input, &session), - FileType::Wasm => self.parse_hir_from_wasm_bytes(&input, &session), + FileType::Wasm => self.parse_hir_from_wasm_bytes( + &input, + &session, + &WasmTranslationConfig::default(), + ), unsupported => unreachable!("unsupported file type: {unsupported}"), }, } @@ -80,16 +85,20 @@ impl ParseStage { let mut file = std::fs::File::open(path)?; let mut bytes = Vec::with_capacity(1024); file.read_to_end(&mut bytes)?; - self.parse_hir_from_wasm_bytes(&bytes, session) + let file_name = path.file_name().unwrap().to_str().unwrap().to_owned(); + let config = wasm::WasmTranslationConfig { + module_name_fallback: Some(file_name), + }; + self.parse_hir_from_wasm_bytes(&bytes, session, &config) } fn parse_hir_from_wasm_bytes( &self, bytes: &[u8], session: &Session, + config: &WasmTranslationConfig, ) -> CompilerResult { - let config = wasm::WasmTranslationConfig::default(); - let module = wasm::translate_module(bytes, &config, &session.diagnostics)?; + let module = wasm::translate_module(bytes, config, &session.diagnostics)?; Ok(ParseOutput::Hir(Box::new(module))) } diff --git a/midenc-session/src/lib.rs b/midenc-session/src/lib.rs index 2a681898d..21078f707 100644 --- a/midenc-session/src/lib.rs +++ b/midenc-session/src/lib.rs @@ -285,13 +285,17 @@ impl Session { if self.should_emit(output_type) { match self.output_files.path(output_type) { OutputFile::Real(path) => { - let path = if let Some(name) = item.name() { - path.with_file_name(name.as_str()) + let file_path = if path.is_dir() { + let item_name = item + .name() + .map(|s| s.to_string()) + .unwrap_or("noname".to_string()); + path.join(item_name.as_str()) .with_extension(output_type.extension()) } else { path }; - item.write_to_file(&path)?; + item.write_to_file(&file_path)?; } OutputFile::Stdout => { item.write_to_stdout()?; From 91a8b3c9c2dab70d66a810ba6516f1083a4ca8c7 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 21 Nov 2023 17:08:32 +0200 Subject: [PATCH 15/22] test: in cargo extension test create output folder if not exist --- cargo-ext/tests/compile.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cargo-ext/tests/compile.rs b/cargo-ext/tests/compile.rs index 5879f11f3..631913000 100644 --- a/cargo-ext/tests/compile.rs +++ b/cargo-ext/tests/compile.rs @@ -12,6 +12,9 @@ fn compile_template() { env::set_current_dir(&test_dir).unwrap(); let masm_path_rel = "target"; let output_folder = test_dir.join(masm_path_rel); + if !output_folder.exists() { + fs::create_dir_all(&output_folder).unwrap(); + } compile(TargetEnv::Base, None, &output_folder).expect("Failed to compile"); env::set_current_dir(restore_dir).unwrap(); let expected_masm_path = output_folder.join("miden_wallet_lib.masm"); From 29ffb838588f1720ce49863d920d31c029be5706 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 5 Dec 2023 12:09:41 +0200 Subject: [PATCH 16/22] refactor: move cargo-ext to tools/cargo-miden --- Cargo.toml | 1 - {cargo-ext => tools/cargo-miden}/Cargo.toml | 0 {cargo-ext => tools/cargo-miden}/README.md | 0 {cargo-ext => tools/cargo-miden}/src/cli_commands.rs | 0 {cargo-ext => tools/cargo-miden}/src/compile.rs | 0 {cargo-ext => tools/cargo-miden}/src/lib.rs | 0 {cargo-ext => tools/cargo-miden}/src/main.rs | 0 {cargo-ext => tools/cargo-miden}/src/new_project.rs | 0 {cargo-ext => tools/cargo-miden}/tests/compile.rs | 0 {cargo-ext => tools/cargo-miden}/tests/data/template/Cargo.lock | 0 {cargo-ext => tools/cargo-miden}/tests/data/template/Cargo.toml | 0 {cargo-ext => tools/cargo-miden}/tests/data/template/src/lib.rs | 0 {cargo-ext => tools/cargo-miden}/tests/mod.rs | 0 {cargo-ext => tools/cargo-miden}/tests/utils.rs | 0 14 files changed, 1 deletion(-) rename {cargo-ext => tools/cargo-miden}/Cargo.toml (100%) rename {cargo-ext => tools/cargo-miden}/README.md (100%) rename {cargo-ext => tools/cargo-miden}/src/cli_commands.rs (100%) rename {cargo-ext => tools/cargo-miden}/src/compile.rs (100%) rename {cargo-ext => tools/cargo-miden}/src/lib.rs (100%) rename {cargo-ext => tools/cargo-miden}/src/main.rs (100%) rename {cargo-ext => tools/cargo-miden}/src/new_project.rs (100%) rename {cargo-ext => tools/cargo-miden}/tests/compile.rs (100%) rename {cargo-ext => tools/cargo-miden}/tests/data/template/Cargo.lock (100%) rename {cargo-ext => tools/cargo-miden}/tests/data/template/Cargo.toml (100%) rename {cargo-ext => tools/cargo-miden}/tests/data/template/src/lib.rs (100%) rename {cargo-ext => tools/cargo-miden}/tests/mod.rs (100%) rename {cargo-ext => tools/cargo-miden}/tests/utils.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index b0d827ad0..21ac6daa9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ members = [ "frontend-wasm", "tests/rust-apps/*", "tests/integration", - "cargo-ext", ] exclude = ["tests/rust-apps-wasm", "cargo-ext/tests/data"] diff --git a/cargo-ext/Cargo.toml b/tools/cargo-miden/Cargo.toml similarity index 100% rename from cargo-ext/Cargo.toml rename to tools/cargo-miden/Cargo.toml diff --git a/cargo-ext/README.md b/tools/cargo-miden/README.md similarity index 100% rename from cargo-ext/README.md rename to tools/cargo-miden/README.md diff --git a/cargo-ext/src/cli_commands.rs b/tools/cargo-miden/src/cli_commands.rs similarity index 100% rename from cargo-ext/src/cli_commands.rs rename to tools/cargo-miden/src/cli_commands.rs diff --git a/cargo-ext/src/compile.rs b/tools/cargo-miden/src/compile.rs similarity index 100% rename from cargo-ext/src/compile.rs rename to tools/cargo-miden/src/compile.rs diff --git a/cargo-ext/src/lib.rs b/tools/cargo-miden/src/lib.rs similarity index 100% rename from cargo-ext/src/lib.rs rename to tools/cargo-miden/src/lib.rs diff --git a/cargo-ext/src/main.rs b/tools/cargo-miden/src/main.rs similarity index 100% rename from cargo-ext/src/main.rs rename to tools/cargo-miden/src/main.rs diff --git a/cargo-ext/src/new_project.rs b/tools/cargo-miden/src/new_project.rs similarity index 100% rename from cargo-ext/src/new_project.rs rename to tools/cargo-miden/src/new_project.rs diff --git a/cargo-ext/tests/compile.rs b/tools/cargo-miden/tests/compile.rs similarity index 100% rename from cargo-ext/tests/compile.rs rename to tools/cargo-miden/tests/compile.rs diff --git a/cargo-ext/tests/data/template/Cargo.lock b/tools/cargo-miden/tests/data/template/Cargo.lock similarity index 100% rename from cargo-ext/tests/data/template/Cargo.lock rename to tools/cargo-miden/tests/data/template/Cargo.lock diff --git a/cargo-ext/tests/data/template/Cargo.toml b/tools/cargo-miden/tests/data/template/Cargo.toml similarity index 100% rename from cargo-ext/tests/data/template/Cargo.toml rename to tools/cargo-miden/tests/data/template/Cargo.toml diff --git a/cargo-ext/tests/data/template/src/lib.rs b/tools/cargo-miden/tests/data/template/src/lib.rs similarity index 100% rename from cargo-ext/tests/data/template/src/lib.rs rename to tools/cargo-miden/tests/data/template/src/lib.rs diff --git a/cargo-ext/tests/mod.rs b/tools/cargo-miden/tests/mod.rs similarity index 100% rename from cargo-ext/tests/mod.rs rename to tools/cargo-miden/tests/mod.rs diff --git a/cargo-ext/tests/utils.rs b/tools/cargo-miden/tests/utils.rs similarity index 100% rename from cargo-ext/tests/utils.rs rename to tools/cargo-miden/tests/utils.rs From 426096c4cf3ddf01becde092374bb5fa9b282326 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 5 Dec 2023 12:10:42 +0200 Subject: [PATCH 17/22] chore: remove miden-cargo-extension from workspace deps --- Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 21ac6daa9..fd61f8636 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,8 +77,6 @@ midenc-compile = { path = "midenc-compile" } midenc-driver = { path = "midenc-driver" } midenc-session = { path = "midenc-session" } miden-integration-tests = { path = "tests/integration" } -miden-cargo-extension = { path = "cargo-ext" } - [profile.dev] lto = false From 5f0892f94d3cce40f0479744ec4487dc36c2b898 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 5 Dec 2023 12:31:11 +0200 Subject: [PATCH 18/22] remove `next_display_order` option in `Command` --- tools/cargo-miden/src/cli_commands.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/cargo-miden/src/cli_commands.rs b/tools/cargo-miden/src/cli_commands.rs index 56c772004..3cf7f204c 100644 --- a/tools/cargo-miden/src/cli_commands.rs +++ b/tools/cargo-miden/src/cli_commands.rs @@ -23,10 +23,10 @@ pub struct MidenArgs { #[derive(Debug, Subcommand)] pub enum Commands { /// Compile the current project to MASM - #[command(next_display_order(10), name = "compile")] + #[command(name = "compile")] Compile { /// The target environment to compile for - #[arg(long = "target", value_name = "TARGET", default_value_t = TargetEnv::Base, display_order(2))] + #[arg(long = "target", value_name = "TARGET", default_value_t = TargetEnv::Base)] target: TargetEnv, /// Tells the compiler to produce an executable Miden program from the binary target or a library from the lib target if not specified @@ -43,6 +43,6 @@ pub enum Commands { output_folder: PathBuf, }, /// Scaffold a new Miden project at the given path - #[command(next_display_order(10), name = "new")] + #[command(name = "new")] New { path: PathBuf }, } From a69711b1406608db2cb18e4b7ed1b8cfc8dd28c6 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 5 Dec 2023 15:46:23 +0200 Subject: [PATCH 19/22] fix: rename `compile` cargo extension command to `build`; imports cleanup; --- tools/cargo-miden/src/cli_commands.rs | 4 ++-- tools/cargo-miden/src/compile.rs | 14 ++++---------- tools/cargo-miden/src/main.rs | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tools/cargo-miden/src/cli_commands.rs b/tools/cargo-miden/src/cli_commands.rs index 3cf7f204c..ef8deb341 100644 --- a/tools/cargo-miden/src/cli_commands.rs +++ b/tools/cargo-miden/src/cli_commands.rs @@ -23,8 +23,8 @@ pub struct MidenArgs { #[derive(Debug, Subcommand)] pub enum Commands { /// Compile the current project to MASM - #[command(name = "compile")] - Compile { + #[command(name = "build")] + Build { /// The target environment to compile for #[arg(long = "target", value_name = "TARGET", default_value_t = TargetEnv::Base)] target: TargetEnv, diff --git a/tools/cargo-miden/src/compile.rs b/tools/cargo-miden/src/compile.rs index 2d820b2e5..589cb7245 100644 --- a/tools/cargo-miden/src/compile.rs +++ b/tools/cargo-miden/src/compile.rs @@ -1,20 +1,14 @@ use anyhow::bail; use cargo_metadata::Message; -use std::path::PathBuf; use std::process::Command; -use std::process::Stdio; use std::sync::Arc; +use std::{path::PathBuf, process::Stdio}; use anyhow::Context; use miden_diagnostics::Verbosity; -use midenc_session::InputFile; -use midenc_session::OutputFile; -use midenc_session::OutputType; -use midenc_session::OutputTypeSpec; -use midenc_session::OutputTypes; -use midenc_session::ProjectType; -use midenc_session::Session; -use midenc_session::TargetEnv; +use midenc_session::{ + InputFile, OutputFile, OutputType, OutputTypeSpec, OutputTypes, ProjectType, Session, TargetEnv, +}; pub fn compile( target: TargetEnv, diff --git a/tools/cargo-miden/src/main.rs b/tools/cargo-miden/src/main.rs index 6a82d4646..971252d4a 100644 --- a/tools/cargo-miden/src/main.rs +++ b/tools/cargo-miden/src/main.rs @@ -13,7 +13,7 @@ fn main() -> anyhow::Result<()> { }; match args.command { - Commands::Compile { + Commands::Build { target, bin_name, output_folder, From 253d491f2e5249dd21423a918ab386a93d04de71 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Tue, 5 Dec 2023 16:02:04 +0200 Subject: [PATCH 20/22] refactor: remove `path-absolutize` dependency --- Cargo.lock | 1 - tools/cargo-miden/Cargo.toml | 1 - tools/cargo-miden/src/new_project.rs | 5 +---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b985baf5..8c6c695e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,7 +353,6 @@ dependencies = [ "miden-diagnostics", "midenc-compile", "midenc-session", - "path-absolutize", ] [[package]] diff --git a/tools/cargo-miden/Cargo.toml b/tools/cargo-miden/Cargo.toml index 9a45fee22..8c6197534 100644 --- a/tools/cargo-miden/Cargo.toml +++ b/tools/cargo-miden/Cargo.toml @@ -30,6 +30,5 @@ clap.workspace = true anyhow.workspace = true cargo_metadata = "0.18" cargo-generate = "0.18" -path-absolutize = "3.1.1" [dev-dependencies] \ No newline at end of file diff --git a/tools/cargo-miden/src/new_project.rs b/tools/cargo-miden/src/new_project.rs index f5b55fb4f..3e3e4268b 100644 --- a/tools/cargo-miden/src/new_project.rs +++ b/tools/cargo-miden/src/new_project.rs @@ -24,10 +24,7 @@ pub fn new_project(path: PathBuf) -> anyhow::Result<()> { }, destination: path .parent() - .map(|p| { - use path_absolutize::Absolutize; - p.absolutize().map(|p| p.to_path_buf()) - }) + .map(|p| p.canonicalize().map(|p| p.to_path_buf())) .transpose() .context("Failed to convert destination path to an absolute path")?, name: Some(name), From 6e563ef7b14c177dd410e4c90b8e3182873c85a5 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Thu, 7 Dec 2023 15:44:14 +0200 Subject: [PATCH 21/22] feat: revamp cargo-miden to pass the unrecognized options to cargo, and pick up the artifacts from the cargo build to compile the MASM. Similar to the way cargo-component does it. Keep in mind that this cargo extension is planned to be the cargo-component replacement when it comes to building/publishing/etc the Wasm/Miden components. This should explain some implementation details. The overaching idea is to introduce specific to Miden subcommands (e.g. `new`) and pass the rest of the subcommands to cargo where its (e.g. `build`). --- Cargo.lock | 2820 ++++++++++++++++- tools/cargo-miden/Cargo.toml | 7 + tools/cargo-miden/README.md | 12 +- tools/cargo-miden/src/build.rs | 64 + tools/cargo-miden/src/cli_commands.rs | 48 - tools/cargo-miden/src/compile.rs | 129 - tools/cargo-miden/src/config.rs | 809 +++++ tools/cargo-miden/src/lib.rs | 128 +- tools/cargo-miden/src/main.rs | 44 +- tools/cargo-miden/src/new_project.rs | 56 +- tools/cargo-miden/src/run_cargo_command.rs | 127 + tools/cargo-miden/src/target.rs | 58 + tools/cargo-miden/tests/build.rs | 42 + tools/cargo-miden/tests/compile.rs | 24 - .../tests/data/template/Cargo.lock | 7 - .../tests/data/template/Cargo.toml | 12 - .../tests/data/template/src/lib.rs | 18 - tools/cargo-miden/tests/mod.rs | 2 +- 18 files changed, 3943 insertions(+), 464 deletions(-) create mode 100644 tools/cargo-miden/src/build.rs delete mode 100644 tools/cargo-miden/src/cli_commands.rs delete mode 100644 tools/cargo-miden/src/compile.rs create mode 100644 tools/cargo-miden/src/config.rs create mode 100644 tools/cargo-miden/src/run_cargo_command.rs create mode 100644 tools/cargo-miden/src/target.rs create mode 100644 tools/cargo-miden/tests/build.rs delete mode 100644 tools/cargo-miden/tests/compile.rs delete mode 100644 tools/cargo-miden/tests/data/template/Cargo.lock delete mode 100644 tools/cargo-miden/tests/data/template/Cargo.toml delete mode 100644 tools/cargo-miden/tests/data/template/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 8c6c695e5..c493808e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,18 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "opaque-debug", +] + [[package]] name = "ahash" version = "0.7.6" @@ -70,6 +82,21 @@ dependencies = [ "as-slice", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -81,29 +108,28 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", - "anstyle-wincon 1.0.2", + "anstyle-wincon 2.1.0", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", - "anstyle-wincon 2.1.0", + "anstyle-wincon 3.0.2", "colorchoice", "utf8parse", ] @@ -134,9 +160,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -144,12 +170,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -194,6 +220,183 @@ dependencies = [ "term", ] +[[package]] +name = "async-broadcast" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" +dependencies = [ + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +dependencies = [ + "async-lock 3.2.0", + "async-task", + "concurrent-queue", + "fastrand 2.0.0", + "futures-lite 2.1.0", + "slab", +] + +[[package]] +name = "async-fs" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "blocking", + "futures-lite 1.13.0", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" +dependencies = [ + "async-lock 3.2.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.1.0", + "parking", + "polling 3.3.1", + "rustix 0.38.26", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +dependencies = [ + "event-listener 4.0.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" +dependencies = [ + "async-io 1.13.0", + "async-lock 2.8.0", + "async-signal", + "blocking", + "cfg-if", + "event-listener 3.1.0", + "futures-lite 1.13.0", + "rustix 0.38.26", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-recursion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "async-signal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +dependencies = [ + "async-io 2.2.1", + "async-lock 2.8.0", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 0.38.26", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-task" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" + +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "atty" version = "0.2.14" @@ -205,6 +408,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "auth-git2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41e7771d4ab6635cbd685ce8db215b29c78a468098126de77c57f3b2e6eb3757" +dependencies = [ + "dirs", + "git2", + "terminal-prompt", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -226,6 +440,36 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + [[package]] name = "bit-set" version = "0.5.3" @@ -275,6 +519,38 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-modes" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" +dependencies = [ + "block-padding", + "cipher", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel", + "async-lock 3.2.0", + "async-task", + "fastrand 2.0.0", + "futures-io", + "futures-lite 2.1.0", + "piper", + "tracing", +] + [[package]] name = "bstr" version = "1.8.0" @@ -282,7 +558,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" dependencies = [ "memchr", - "regex-automata 0.4.3", + "regex-automata", "serde", ] @@ -295,6 +571,24 @@ dependencies = [ "num-traits", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + [[package]] name = "camino" version = "1.1.6" @@ -304,23 +598,91 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-component" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8abe1e8a19a9d5c26ff5bb99bf9325f161d6e0ba196fe6cebbd8a50260ca346" +dependencies = [ + "anyhow", + "bytes", + "cargo-component-core", + "cargo_metadata", + "clap 4.4.11", + "futures", + "heck", + "indexmap 2.1.0", + "libc", + "log", + "p256", + "parse_arg", + "pretty_env_logger", + "rand_core", + "rpassword", + "semver", + "serde", + "serde_json", + "tokio", + "tokio-util", + "toml_edit 0.21.0", + "url", + "warg-client", + "warg-crypto", + "warg-protocol", + "wasm-metadata", + "wit-bindgen-core", + "wit-bindgen-rust", + "wit-component", + "wit-parser", +] + +[[package]] +name = "cargo-component-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93484e75d9d9bb99d53bdd56873501f5ddb3be72f6b15db6359b9372646757f1" +dependencies = [ + "anyhow", + "clap 4.4.11", + "futures", + "indexmap 2.1.0", + "keyring", + "libc", + "log", + "owo-colors", + "semver", + "serde", + "tokio", + "toml_edit 0.21.0", + "unicode-width", + "url", + "warg-client", + "warg-crypto", + "warg-protocol", + "windows-sys 0.52.0", + "wit-component", + "wit-parser", +] + [[package]] name = "cargo-generate" -version = "0.18.4" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a4798d27e0ded03c08f86f6226e65a88eb2a92b69555a282b61ed98afeae6da" +checksum = "8a2885ae054e000b117515ab33e91c10eca90c2788a7baec1b97ada1f1f51e57" dependencies = [ "anyhow", - "clap 4.3.24", + "auth-git2", + "clap 4.4.11", "console", "dialoguer", "env_logger 0.10.1", + "fs-err", "git2", "gix-config", "heck", "home", "ignore", - "indexmap 2.0.0", + "indexmap 2.1.0", "indicatif", "liquid", "liquid-core", @@ -338,7 +700,7 @@ dependencies = [ "serde", "tempfile", "thiserror", - "toml 0.7.6", + "toml 0.8.8", "walkdir", ] @@ -347,12 +709,19 @@ name = "cargo-miden" version = "0.1.0" dependencies = [ "anyhow", + "cargo-component", + "cargo-component-core", "cargo-generate", "cargo_metadata", - "clap 4.3.24", + "clap 4.4.11", + "env_logger 0.9.3", + "log", "miden-diagnostics", "midenc-compile", "midenc-session", + "parse_arg", + "path-absolutize", + "semver", ] [[package]] @@ -394,6 +763,28 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.48.5", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + [[package]] name = "clap" version = "2.34.0" @@ -411,22 +802,21 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.24" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.24" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ - "anstream 0.3.2", + "anstream 0.6.4", "anstyle", "clap_lex", "strsim 0.10.0", @@ -434,9 +824,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -446,9 +836,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "codespan" @@ -485,6 +875,15 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "concurrent-queue" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.7" @@ -498,6 +897,12 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + [[package]] name = "const-random" version = "0.1.17" @@ -530,6 +935,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" version = "0.2.9" @@ -554,6 +975,15 @@ version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f333fa641a9ad2bff0b107767dcb972c18c2bfab7969805a1d7e42449ccb0408" +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -561,17 +991,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] -name = "crypto-common" -version = "0.1.6" +name = "crypto-bigint" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "typenum", + "rand_core", + "subtle", + "zeroize", ] [[package]] -name = "cvt" +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cvt" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2ae9bf77fbf2d39ef573205d554d87e86c12f1994e9ea335b0651b9b278bcf1" @@ -579,6 +1021,52 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 2.0.31", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.9" @@ -586,6 +1074,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" dependencies = [ "powerfmt", + "serde", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -603,13 +1103,14 @@ dependencies = [ [[package]] name = "dialoguer" -version = "0.10.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" dependencies = [ "console", "shell-words", "tempfile", + "thiserror", "zeroize", ] @@ -626,7 +1127,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", ] [[package]] @@ -639,6 +1151,18 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -662,12 +1186,46 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + [[package]] name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "pem-rfc7468", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "ena" version = "0.14.2" @@ -683,6 +1241,36 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enumflags2" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + [[package]] name = "env_logger" version = "0.9.3" @@ -717,23 +1305,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] @@ -746,6 +1323,44 @@ dependencies = [ "version_check", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", + "pin-project-lite", +] + [[package]] name = "expect-test" version = "1.4.1" @@ -765,18 +1380,37 @@ dependencies = [ "serde", ] +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + [[package]] name = "fastrand" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + [[package]] name = "filecheck" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.3.24", + "clap 4.4.11", "lit", ] @@ -804,6 +1438,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.0" @@ -813,6 +1462,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] + [[package]] name = "fs_at" version = "0.1.10" @@ -827,6 +1485,123 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +dependencies = [ + "fastrand 2.0.0", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" + +[[package]] +name = "futures-util" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -835,6 +1610,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -856,11 +1632,11 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "git2" -version = "0.17.2" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b989d6a7ca95a362cf2cfc5ad688b3a467be1f87e480b8dad07fee8c79b0044" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "libc", "libgit2-sys", "log", @@ -871,9 +1647,9 @@ dependencies = [ [[package]] name = "gix-actor" -version = "0.25.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f8a773b5385e9d2f88bd879fb763ec1212585f6d630ebe13adb7bac93bce975" +checksum = "948a5f9e43559d16faf583694f1c742eb401ce24ce8e6f2238caedea7486433c" dependencies = [ "bstr", "btoi", @@ -885,9 +1661,9 @@ dependencies = [ [[package]] name = "gix-config" -version = "0.28.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a312d120231dc8d5a2e34928a9a2098c1d3dbad76f0660ee38d0b1a87de5271" +checksum = "5cae98c6b4c66c09379bc35274b172587d6b0ac369a416c39128ad8c6454f9bb" dependencies = [ "bstr", "gix-config-value", @@ -896,7 +1672,6 @@ dependencies = [ "gix-path", "gix-ref", "gix-sec", - "log", "memchr", "once_cell", "smallvec", @@ -907,9 +1682,9 @@ dependencies = [ [[package]] name = "gix-config-value" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901e184f3d4f99bf015ca13b5ccacb09e26b400f198fe2066651089e2c490680" +checksum = "ea7505b97f4d8e7933e29735a568ba2f86d8de466669d9f0e8321384f9972f47" dependencies = [ "bitflags 2.4.0", "bstr", @@ -920,9 +1695,9 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a825babda995d788e30d306a49dacd1e93d5f5d33d53c7682d0347cef40333c" +checksum = "fc7df669639582dc7c02737642f76890b03b5544e141caba68a7d6b4eb551e0d" dependencies = [ "bstr", "itoa", @@ -932,31 +1707,32 @@ dependencies = [ [[package]] name = "gix-features" -version = "0.33.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f77decb545f63a52852578ef5f66ecd71017ffc1983d551d5fa2328d6d9817f" +checksum = "51f4365ba17c4f218d7fd9ec102b8d2d3cb0ca200a835e81151ace7778aec827" dependencies = [ "gix-hash", "gix-trace", "libc", + "prodash", "sha1_smol", "walkdir", ] [[package]] name = "gix-fs" -version = "0.5.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d5089f3338647776733a75a800a664ab046f56f21c515fa4722e395f877ef8" +checksum = "8cd171c0cae97cd0dc57e7b4601cb1ebf596450e263ef3c02be9107272c877bd" dependencies = [ "gix-features", ] [[package]] name = "gix-glob" -version = "0.11.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c753299d14a29ca06d7adc8464c16f1786eb97bc9a44a796ad0a37f57235a494" +checksum = "8fac08925dbc14d414bd02eb45ffb4cecd912d1fce3883f867bd0103c192d3e4" dependencies = [ "bitflags 2.4.0", "bstr", @@ -966,9 +1742,9 @@ dependencies = [ [[package]] name = "gix-hash" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d4796bac3aaf0c2f8bea152ca924ae3bdc5f135caefe6431116bcd67e98eab9" +checksum = "1884c7b41ea0875217c1be9ce91322f90bde433e91d374d0e1276073a51ccc60" dependencies = [ "faster-hex", "thiserror", @@ -976,9 +1752,9 @@ dependencies = [ [[package]] name = "gix-lock" -version = "8.0.0" +version = "11.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de4363023577b31906b476b34eefbf76931363ec574f88b5c7b6027789f1e3ce" +checksum = "f4feb1dcd304fe384ddc22edba9dd56a42b0800032de6537728cea2f033a4f37" dependencies = [ "gix-tempfile", "gix-utils", @@ -987,9 +1763,9 @@ dependencies = [ [[package]] name = "gix-object" -version = "0.35.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4283b7b5e9438afe2e3183e9acd1c77e750800937bb56c06b750822d2ff6d95" +checksum = "740f2a44267f58770a1cb3a3d01d14e67b089c7136c48d4bddbb3cfd2bf86a51" dependencies = [ "bstr", "btoi", @@ -1006,9 +1782,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "764b31ac54472e796f08be376eaeea3e30800949650566620809659d39969dbd" +checksum = "6a1d370115171e3ae03c5c6d4f7d096f2981a40ddccb98dfd704c773530ba73b" dependencies = [ "bstr", "gix-trace", @@ -1019,9 +1795,9 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.35.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993ce5c448a94038b8da1a8969c0facd6c1fbac509fa013344c580458f41527d" +checksum = "0ec2f6d07ac88d2fb8007ee3fa3e801856fb9d82e7366ec0ca332eb2c9d74a52" dependencies = [ "gix-actor", "gix-date", @@ -1040,9 +1816,9 @@ dependencies = [ [[package]] name = "gix-sec" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0debc2e70613a077c257c2bb45ab4f652a550ae1d00bdca356633ea9de88a230" +checksum = "92b9542ac025a8c02ed5d17b3fc031a111a384e859d0be3532ec4d58c40a0f28" dependencies = [ "bitflags 2.4.0", "gix-path", @@ -1052,9 +1828,9 @@ dependencies = [ [[package]] name = "gix-tempfile" -version = "8.0.0" +version = "11.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea558d3daf3b1d0001052b12218c66c8f84788852791333b633d7eeb6999db1" +checksum = "05cc2205cf10d99f70b96e04e16c55d4c7cf33efc151df1f793e29fd12a931f8" dependencies = [ "gix-fs", "libc", @@ -1075,7 +1851,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b85d89dc728613e26e0ed952a19583744e7f5240fcd4aa30d6c824ffd8b52f0f" dependencies = [ - "fastrand", + "fastrand 2.0.0", ] [[package]] @@ -1107,6 +1883,36 @@ dependencies = [ "regex", ] +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1115,15 +1921,18 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "hermit-abi" @@ -1141,14 +1950,72 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] -name = "home" -version = "0.5.5" +name = "hex" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys 0.48.0", +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "http" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", ] +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + [[package]] name = "human-panic" version = "1.2.0" @@ -1171,6 +2038,78 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.4.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.4.0" @@ -1206,16 +2145,17 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", + "serde", ] [[package]] name = "indexmap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "serde", ] @@ -1247,7 +2187,7 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b694dc9f70c3bda874626d2aed13b780f137aab435f4e9814121955cf706122e" dependencies = [ - "memoffset", + "memoffset 0.9.0", ] [[package]] @@ -1256,6 +2196,23 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1be380c410bf0595e94992a648ea89db4dd3f3354ba54af206fd2a68cf5ac8e" +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.2", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + [[package]] name = "is-terminal" version = "0.4.9" @@ -1263,7 +2220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.2", - "rustix", + "rustix 0.38.26", "windows-sys 0.48.0", ] @@ -1300,6 +2257,15 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "keccak" version = "0.1.4" @@ -1309,6 +2275,20 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keyring" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec6488afbd1d8202dbd6e2dd38c0753d8c0adba9ac9985fc6f732a0d551f75e1" +dependencies = [ + "byteorder", + "lazy_static", + "linux-keyutils", + "secret-service", + "security-framework", + "winapi", +] + [[package]] name = "kstring" version = "2.0.0" @@ -1361,15 +2341,15 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libgit2-sys" -version = "0.15.2+1.6.4" +version = "0.16.1+1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" dependencies = [ "cc", "libc", @@ -1411,11 +2391,27 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linux-keyutils" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f27bb67f6dd1d0bb5ab582868e4f65052e58da6401188a08f0da09cf512b84b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "liquid" @@ -1506,6 +2502,38 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "logos" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-codegen" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc487311295e0002e452025d6b580b77bb17286de87b57138f3b5db711cded68" +dependencies = [ + "beef", + "fnv", + "proc-macro2", + "quote", + "regex-syntax 0.6.29", + "syn 2.0.31", +] + +[[package]] +name = "logos-derive" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbfc0d229f1f42d790440136d941afd806bc9e949e2bcb8faa813b0f00d1267e" +dependencies = [ + "logos-codegen", +] + [[package]] name = "memchr" version = "2.6.3" @@ -1521,6 +2549,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -1799,7 +2836,7 @@ name = "midenc-compile" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.3.24", + "clap 4.4.11", "inventory", "log", "miden-assembly", @@ -1818,7 +2855,7 @@ name = "midenc-driver" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.3.24", + "clap 4.4.11", "miden-diagnostics", "miden-hir", "midenc-compile", @@ -1833,7 +2870,7 @@ dependencies = [ "anyhow", "atty", "bitflags 1.3.2", - "clap 4.3.24", + "clap 4.4.11", "inventory", "miden-diagnostics", "miden-hir-symbol", @@ -1841,6 +2878,35 @@ dependencies = [ "thiserror", ] +[[package]] +name = "miette" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +dependencies = [ + "miette-derive", + "once_cell", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1850,6 +2916,23 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "names" version = "0.14.0" @@ -1859,6 +2942,24 @@ dependencies = [ "rand", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -1874,6 +2975,7 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", + "memoffset 0.7.1", ] [[package]] @@ -1885,6 +2987,20 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "num" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.4" @@ -1896,6 +3012,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-complex" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +dependencies = [ + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1906,6 +3031,29 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -1977,6 +3125,38 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" +dependencies = [ + "bitflags 2.4.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + [[package]] name = "openssl-probe" version = "0.1.5" @@ -1985,9 +3165,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.95" +version = "0.9.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" dependencies = [ "cc", "libc", @@ -1995,6 +3175,22 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + [[package]] name = "os_info" version = "3.7.0" @@ -2007,12 +3203,36 @@ dependencies = [ ] [[package]] -name = "parking_lot" -version = "0.12.1" +name = "owo-colors" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", "parking_lot_core", ] @@ -2029,6 +3249,12 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "parse_arg" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14248cc8eced350e20122a291613de29e4fa129ba2731818c4cdbb44fccd3e55" + [[package]] name = "paste" version = "1.0.14" @@ -2053,6 +3279,58 @@ dependencies = [ "once_cell", ] +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] +name = "pbjson" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048f9ac93c1eab514f9470c4bc8d97ca2a0a236b84f45cc19d69a59fc11467f6" +dependencies = [ + "base64 0.13.1", + "serde", +] + +[[package]] +name = "pbjson-build" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdbb7b706f2afc610f3853550cdbbf6372fd324824a087806bd4480ea4996e24" +dependencies = [ + "heck", + "itertools 0.10.5", + "prost", + "prost-types", +] + +[[package]] +name = "pbjson-types" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a88c8d87f99a4ac14325e7a4c24af190fca261956e3b82dd7ed67e77e6c7043" +dependencies = [ + "bytes", + "chrono", + "pbjson", + "pbjson-build", + "prost", + "prost-build", + "serde", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -2111,7 +3389,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.1.0", ] [[package]] @@ -2123,12 +3401,75 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.0", + "futures-io", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.26", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "portable-atomic" version = "1.5.1" @@ -2163,6 +3504,35 @@ dependencies = [ "yansi", ] +[[package]] +name = "pretty_env_logger" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" +dependencies = [ + "env_logger 0.10.1", + "log", +] + +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -2170,7 +3540,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.14", ] [[package]] @@ -2182,6 +3552,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prodash" +version = "26.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794b5bf8e2d19b53dcdcec3e4bba628e20f5b6062503ba89281fa7037dd7bbcf" + [[package]] name = "proptest" version = "1.4.0" @@ -2202,6 +3578,100 @@ dependencies = [ "unarray", ] +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools 0.10.5", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 1.0.109", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "prost-reflect" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b823de344848e011658ac981009100818b322421676740546f8b52ed5249428" +dependencies = [ + "logos", + "miette", + "once_cell", + "prost", + "prost-types", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost", +] + +[[package]] +name = "protox" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06a5aacd1f6147ceac5e3896e0c766187dc6a9645f3b93ec821fabbaf821b887" +dependencies = [ + "bytes", + "miette", + "prost", + "prost-reflect", + "prost-types", + "protox-parse", + "thiserror", +] + +[[package]] +name = "protox-parse" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30fc6d0af2dec2c39da31eb02cc78cbc05b843b04f30ad78ccc6e8a342ec5518" +dependencies = [ + "logos", + "miette", + "prost-types", + "thiserror", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -2287,32 +3757,32 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.5" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.8", - "regex-syntax 0.7.5", + "regex-automata", + "regex-syntax 0.8.2", ] [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] -name = "regex-automata" -version = "0.4.3" +name = "regex-syntax" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" @@ -2342,16 +3812,67 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "reqwest" +version = "0.11.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +dependencies = [ + "base64 0.21.5", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "winreg", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "rhai" -version = "1.15.1" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2a11a646ef5d4e4a9d5cf80c7e4ecb20f9b1954292d5c5e6d6cbc8d33728ec" +checksum = "e3625f343d89990133d013e39c46e350915178cf94f1bec9f49b0cbef98a3e3c" dependencies = [ "ahash 0.8.6", - "bitflags 1.3.2", + "bitflags 2.4.0", "instant", "num-traits", + "once_cell", "rhai_codegen", "smallvec", "smartstring", @@ -2368,6 +3889,27 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "rpassword" +version = "7.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80472be3c897911d0137b2d2b9055faf6eeac5b14e324073d83bc17b191d7e3f" +dependencies = [ + "libc", + "rtoolbox", + "windows-sys 0.48.0", +] + +[[package]] +name = "rtoolbox" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c247d24e63230cdb56463ae328478bd5eac8b8faa8c69461a77e8e323afac90e" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2391,17 +3933,31 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.11" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ - "bitflags 2.4.0", + "bitflags 1.3.2", "errno", + "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.8", "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -2445,6 +4001,15 @@ dependencies = [ "regex", ] +[[package]] +name = "schannel" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -2452,62 +4017,190 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "seize" -version = "0.2.5" +name = "sec1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e5739de653b129b0a59da381599cf17caf24bc586f6a797c52d3d6147c5b85a" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "num_cpus", - "once_cell", + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", ] [[package]] -name = "semver" -version = "1.0.18" +name = "secrecy" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" dependencies = [ - "serde", + "zeroize", ] [[package]] -name = "serde" -version = "1.0.188" +name = "secret-service" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "5da1a5ad4d28c03536f82f77d9f36603f5e37d8869ac98f0a750d5b5686d8d95" dependencies = [ - "serde_derive", + "aes", + "block-modes", + "futures-util", + "generic-array", + "hkdf", + "num", + "once_cell", + "rand", + "serde", + "sha2", + "zbus", ] [[package]] -name = "serde_derive" -version = "1.0.188" +name = "security-framework" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.31", + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", ] [[package]] -name = "serde_json" -version = "1.0.108" +name = "security-framework-sys" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ - "itoa", - "ryu", + "core-foundation-sys", + "libc", +] + +[[package]] +name = "seize" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e5739de653b129b0a59da381599cf17caf24bc586f6a797c52d3d6147c5b85a" +dependencies = [ + "num_cpus", + "once_cell", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ + "base64 0.21.5", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.1.0", "serde", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", ] [[package]] @@ -2543,12 +4236,40 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + [[package]] name = "siphasher" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.11.0" @@ -2566,6 +4287,45 @@ dependencies = [ "version_check", ] +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "spdx" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b19b32ed6d899ab23174302ff105c1577e45a06b08d4fe0a9dd13ce804bbbf71" +dependencies = [ + "smallvec", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -2603,6 +4363,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -2625,6 +4391,27 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.8.0" @@ -2632,9 +4419,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", - "fastrand", + "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix", + "rustix 0.38.26", "windows-sys 0.48.0", ] @@ -2658,6 +4445,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal-prompt" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572818b3472910acbd5dff46a3413715c18e934b071ab2ba464a7b2c2af16376" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -2752,6 +4549,60 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.5.5", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.11" @@ -2768,18 +4619,30 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ - "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.14", +] + +[[package]] +name = "toml" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +dependencies = [ + "indexmap 2.1.0", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.21.0", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -2790,13 +4653,69 @@ version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", "winnow", ] +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + [[package]] name = "typed-arena" version = "2.0.2" @@ -2815,6 +4734,16 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +[[package]] +name = "uds_windows" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi", +] + [[package]] name = "unarray" version = "0.1.4" @@ -2856,9 +4785,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -2875,6 +4804,7 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -2919,22 +4849,227 @@ dependencies = [ "libc", ] +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", ] [[package]] -name = "wasi" +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "warg-api" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6155f45f54e013e7e4016ed728d132e5b5e4da6a9ab688edfa0a19a3d6fe87f6" +dependencies = [ + "itertools 0.11.0", + "serde", + "serde_with", + "thiserror", + "warg-crypto", + "warg-protocol", +] + +[[package]] +name = "warg-client" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "807a117360b22b04a5e89adf980d48f0076fc28c6d971bf3a868cce29b76a29a" +dependencies = [ + "anyhow", + "async-trait", + "bytes", + "clap 4.4.11", + "dirs", + "futures-util", + "itertools 0.11.0", + "libc", + "normpath", + "once_cell", + "pathdiff", + "reqwest", + "serde", + "serde_json", + "tempfile", + "thiserror", + "tokio", + "tokio-util", + "tracing", + "url", + "walkdir", + "warg-api", + "warg-crypto", + "warg-protocol", + "warg-transparency", + "windows-sys 0.48.0", +] + +[[package]] +name = "warg-crypto" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3421fa178ce468087d2c51b53ae4ab6d435e4e41bb6fee2c2b25bd555df9f6c3" +dependencies = [ + "anyhow", + "base64 0.21.5", + "digest", + "hex", + "leb128", + "once_cell", + "p256", + "rand_core", + "secrecy", + "serde", + "sha2", + "signature", + "thiserror", +] + +[[package]] +name = "warg-protobuf" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78a6adafed625d8d254d34ee0c9836c2f9e6bd5a799b489ffc31c2c572554234" +dependencies = [ + "anyhow", + "pbjson", + "pbjson-build", + "pbjson-types", + "prost", + "prost-build", + "prost-types", + "protox", + "regex", + "serde", + "warg-crypto", +] + +[[package]] +name = "warg-protocol" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e47b7e7a8a9f9895268b68e7cf29ca1d3129faa9f9bcbc973ff5e92884a014" +dependencies = [ + "anyhow", + "base64 0.21.5", + "hex", + "indexmap 2.1.0", + "pbjson-types", + "prost", + "prost-types", + "semver", + "serde", + "serde_with", + "thiserror", + "warg-crypto", + "warg-protobuf", + "warg-transparency", + "wasmparser 0.108.0", +] + +[[package]] +name = "warg-transparency" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cd84da2c4f298556706e75a8f19df3e2c844be2ce9e959b07904fb66c333cc" +dependencies = [ + "anyhow", + "prost", + "thiserror", + "warg-crypto", + "warg-protobuf", +] + +[[package]] +name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.31", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.31", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" + [[package]] name = "wasm-encoder" version = "0.31.1" @@ -2944,6 +5079,44 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-encoder" +version = "0.38.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-metadata" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d835d67708f6374937c550ad8dd1d17c616ae009e3f00d7a0ac9f7825e78c36a" +dependencies = [ + "anyhow", + "indexmap 2.1.0", + "serde", + "serde_derive", + "serde_json", + "spdx", + "wasm-encoder 0.38.1", + "wasmparser 0.118.1", +] + +[[package]] +name = "wasm-streams" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmparser" version = "0.107.0" @@ -2954,13 +5127,33 @@ dependencies = [ "semver", ] +[[package]] +name = "wasmparser" +version = "0.108.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c956109dcb41436a39391139d9b6e2d0a5e0b158e1293ef352ec977e5e36c5" +dependencies = [ + "indexmap 2.1.0", + "semver", +] + [[package]] name = "wasmparser" version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad71036aada3f6b09251546e97e4f4f176dd6b41cf6fa55e7e0f65e86aec319a" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", + "semver", +] + +[[package]] +name = "wasmparser" +version = "0.118.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" +dependencies = [ + "indexmap 2.1.0", "semver", ] @@ -2983,7 +5176,7 @@ dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder", + "wasm-encoder 0.31.1", ] [[package]] @@ -2995,6 +5188,28 @@ dependencies = [ "wast", ] +[[package]] +name = "web-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.26", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3035,6 +5250,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -3053,6 +5277,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -3083,6 +5316,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -3095,6 +5343,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -3107,6 +5361,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -3119,6 +5379,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -3131,6 +5397,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -3143,6 +5415,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -3155,6 +5433,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -3167,6 +5451,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" version = "0.5.15" @@ -3176,6 +5466,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "winter-air" version = "0.7.1" @@ -3241,12 +5541,148 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e914055793322b3efa7ea6acd5116edf65aebcb704a09b1c4d1308c82509992" +[[package]] +name = "wit-bindgen-core" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dfc34e539edf78da2efed167549962a4d26000db04694408285f52d90703fee" +dependencies = [ + "anyhow", + "wit-component", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e898ad170a2796e9ecc495ce52cc2518dc35364ec042a4e108dd3c454e2a24c6" +dependencies = [ + "anyhow", + "heck", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-component" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a35a2a9992898c9d27f1664001860595a4bc99d32dd3599d547412e17d7e2" +dependencies = [ + "anyhow", + "bitflags 2.4.0", + "indexmap 2.1.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder 0.38.1", + "wasm-metadata", + "wasmparser 0.118.1", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15df6b7b28ce94b8be39d8df5cb21a08a4f3b9f33b631aedb4aa5776f785ead3" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.1.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "xdg-home" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +dependencies = [ + "nix", + "winapi", +] + [[package]] name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zbus" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +dependencies = [ + "async-broadcast", + "async-executor", + "async-fs", + "async-io 1.13.0", + "async-lock 2.8.0", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "byteorder", + "derivative", + "enumflags2", + "event-listener 2.5.3", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix", + "once_cell", + "ordered-stream", + "rand", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tracing", + "uds_windows", + "winapi", + "xdg-home", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + [[package]] name = "zerocopy" version = "0.7.26" @@ -3269,6 +5705,44 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + +[[package]] +name = "zvariant" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] diff --git a/tools/cargo-miden/Cargo.toml b/tools/cargo-miden/Cargo.toml index 8c6197534..2f49bf45f 100644 --- a/tools/cargo-miden/Cargo.toml +++ b/tools/cargo-miden/Cargo.toml @@ -26,9 +26,16 @@ path = "tests/mod.rs" midenc-compile.workspace = true midenc-session.workspace = true miden-diagnostics.workspace = true +env_logger.workspace = true +log.workspace = true clap.workspace = true anyhow.workspace = true +cargo-component = "0.5" +cargo-component-core = "0.5" cargo_metadata = "0.18" cargo-generate = "0.18" +semver = "1.0.20" +parse_arg = "0.1.4" +path-absolutize = "3.1.1" [dev-dependencies] \ No newline at end of file diff --git a/tools/cargo-miden/README.md b/tools/cargo-miden/README.md index 5029c5a27..3d0f6961d 100644 --- a/tools/cargo-miden/README.md +++ b/tools/cargo-miden/README.md @@ -10,14 +10,6 @@ To install the extension, run: cargo install cargo-miden ``` -## Requirements - -Since Rust is first compiled to Wasm, you'll need to have the `wasm32-unknown-unknown` target installed: - -```bash -rustup target add wasm32-unknown-unknown -``` - ## Usage ### Getting help @@ -44,7 +36,7 @@ cargo miden new To compile a Rust crate to Miden VM MASM, run: ```bash -cargo miden compile -o +cargo miden build ``` -Without any additional arguments, this will compile the library target of the crate in the current directory. +Without any additional arguments, this will compile the library target in the target directory in the `miden` folder. diff --git a/tools/cargo-miden/src/build.rs b/tools/cargo-miden/src/build.rs new file mode 100644 index 000000000..e072f787c --- /dev/null +++ b/tools/cargo-miden/src/build.rs @@ -0,0 +1,64 @@ +use std::{ + path::{Path, PathBuf}, + sync::Arc, +}; + +use anyhow::{bail, Context}; +use miden_diagnostics::Verbosity; +use midenc_session::{ + InputFile, OutputFile, OutputType, OutputTypeSpec, OutputTypes, ProjectType, Session, TargetEnv, +}; + +pub fn build_masm( + wasm_file_path: &Path, + output_folder: &Path, + is_bin: bool, +) -> anyhow::Result { + let project_type = if is_bin { + ProjectType::Program + } else { + ProjectType::Library + }; + + if !output_folder.exists() { + bail!( + "MASM output folder '{}' does not exist.", + output_folder.to_str().unwrap() + ); + } + log::debug!( + "Compiling '{}' Wasm to '{}' directory with midenc ...", + wasm_file_path.to_str().unwrap(), + &output_folder.to_str().unwrap() + ); + let input = InputFile::from_path(wasm_file_path).context("Invalid input file")?; + let output_file_folder = OutputFile::Real(output_folder.to_path_buf()); + let output_type = OutputType::Masm; + let output_types = OutputTypes::new(vec![OutputTypeSpec { + output_type, + path: Some(output_file_folder.clone()), + }]); + let cwd = std::env::current_dir().context("Failed to get current working directory")?; + let options = midenc_session::Options::new(cwd) + // .with_color(color) + .with_verbosity(Verbosity::Debug) + // .with_warnings(self.warn) + .with_output_types(output_types); + let target = TargetEnv::default(); + let session = Arc::new( + Session::new( + target, + input, + Some(output_folder.to_path_buf()), + None, + None, + options, + None, + ) + .with_project_type(project_type), + ); + midenc_compile::compile(session.clone()).context("Wasm to MASM compilation failed!")?; + let mut output_path = output_folder.join(wasm_file_path.file_stem().unwrap()); + output_path.set_extension(output_type.extension()); + Ok(output_path) +} diff --git a/tools/cargo-miden/src/cli_commands.rs b/tools/cargo-miden/src/cli_commands.rs deleted file mode 100644 index ef8deb341..000000000 --- a/tools/cargo-miden/src/cli_commands.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::path::PathBuf; - -use clap::Parser; -use clap::Subcommand; -use midenc_session::TargetEnv; - -#[derive(Parser, Debug)] -#[command(name = "cargo")] -#[command(bin_name = "cargo")] -pub enum CargoCli { - Miden(MidenArgs), -} - -#[derive(Parser, Debug)] -#[command(name = "miden")] -#[command(bin_name = "cargo miden")] -#[command(about = "Cargo command for developing Miden projects", long_about = None)] -pub struct MidenArgs { - #[command(subcommand)] - pub command: Commands, -} - -#[derive(Debug, Subcommand)] -pub enum Commands { - /// Compile the current project to MASM - #[command(name = "build")] - Build { - /// The target environment to compile for - #[arg(long = "target", value_name = "TARGET", default_value_t = TargetEnv::Base)] - target: TargetEnv, - - /// Tells the compiler to produce an executable Miden program from the binary target or a library from the lib target if not specified - #[arg(long = "bin-name", display_order(3))] - bin_name: Option, - - /// Output directory for the compiled MASM file(s) - #[arg( - long = "out-dir", - value_name = "FOLDER", - id = "output-folder", - display_order(6) - )] - output_folder: PathBuf, - }, - /// Scaffold a new Miden project at the given path - #[command(name = "new")] - New { path: PathBuf }, -} diff --git a/tools/cargo-miden/src/compile.rs b/tools/cargo-miden/src/compile.rs deleted file mode 100644 index 589cb7245..000000000 --- a/tools/cargo-miden/src/compile.rs +++ /dev/null @@ -1,129 +0,0 @@ -use anyhow::bail; -use cargo_metadata::Message; -use std::process::Command; -use std::sync::Arc; -use std::{path::PathBuf, process::Stdio}; - -use anyhow::Context; -use miden_diagnostics::Verbosity; -use midenc_session::{ - InputFile, OutputFile, OutputType, OutputTypeSpec, OutputTypes, ProjectType, Session, TargetEnv, -}; - -pub fn compile( - target: TargetEnv, - bin_name: Option, - output_folder: &PathBuf, -) -> anyhow::Result<()> { - // for cargo env var see https://doc.rust-lang.org/cargo/reference/environment-variables.html - let mut cargo_build_cmd = Command::new("cargo"); - cargo_build_cmd - .arg("build") - .arg("--release") - .arg("--target=wasm32-unknown-unknown"); - let project_type = if let Some(ref bin_name) = bin_name { - cargo_build_cmd.arg("--bin").arg(bin_name.clone()); - ProjectType::Program - } else { - ProjectType::Library - }; - println!("Compiling Wasm with cargo build ..."); - let mut child = cargo_build_cmd - .arg("--message-format=json-render-diagnostics") - .stdout(Stdio::piped()) - .spawn() - .with_context(|| { - format!( - "Failed to execute cargo build {}.", - cargo_build_cmd - .get_args() - .map(|arg| format!("'{}'", arg.to_str().unwrap())) - .collect::>() - .join(" ") - ) - })?; - let reader = std::io::BufReader::new(child.stdout.take().unwrap()); - let mut wasm_artifacts = Vec::new(); - for message in cargo_metadata::Message::parse_stream(reader) { - match message.context("Failed to parse cargo metadata")? { - Message::CompilerArtifact(artifact) => { - // find the Wasm artifact in artifact.filenames - for filename in artifact.filenames { - if filename.as_str().ends_with(".wasm") { - wasm_artifacts.push(filename.into_std_path_buf()); - } - } - } - _ => (), - } - } - let output = child.wait().expect("Couldn't get cargo's exit status"); - if !output.success() { - bail!("Rust to Wasm compilation failed!"); - } - - if wasm_artifacts.is_empty() { - match project_type { - ProjectType::Library => bail!("Cargo build failed, no Wasm artifact found. Check if crate-type = [\"cdylib\"] is set in Cargo.toml"), - ProjectType::Program => bail!("Cargo build failed, no Wasm artifact found."), - } - } - if wasm_artifacts.len() > 1 { - bail!( - "Cargo build failed, multiple Wasm artifacts found: {:?}. Only one Wasm artifact is expected.", - wasm_artifacts - ); - } - let wasm_file_path = wasm_artifacts[0].clone(); - match project_type { - ProjectType::Program => { - let bin_name = bin_name.unwrap(); - if !wasm_file_path.ends_with(format!("{}.wasm", bin_name)) { - bail!( - "Cargo build failed, Wasm artifact name {} does not match the expected name '{}'.", - wasm_file_path.to_str().unwrap(), - bin_name - ); - } - } - ProjectType::Library => (), - } - - if !output_folder.exists() { - bail!( - "Output folder '{}' does not exist.", - output_folder.to_str().unwrap() - ); - } - - println!( - "Compiling '{}' Wasm to '{}' directory with midenc ...", - wasm_file_path.to_str().unwrap(), - &output_folder.as_path().to_str().unwrap() - ); - let input = InputFile::from_path(wasm_file_path).context("Invalid input file")?; - let output_file_folder = OutputFile::Real(output_folder.clone()); - let output_types = OutputTypes::new(vec![OutputTypeSpec { - output_type: OutputType::Masm, - path: Some(output_file_folder.clone()), - }]); - let cwd = std::env::current_dir().context("Failed to get current working directory")?; - let options = midenc_session::Options::new(cwd) - // .with_color(color) - .with_verbosity(Verbosity::Debug) - // .with_warnings(self.warn) - .with_output_types(output_types); - let session = Arc::new( - Session::new( - target, - input, - Some(output_folder.clone()), - None, - None, - options, - None, - ) - .with_project_type(project_type), - ); - midenc_compile::compile(session.clone()).context("Wasm to MASM compilation failed!") -} diff --git a/tools/cargo-miden/src/config.rs b/tools/cargo-miden/src/config.rs new file mode 100644 index 000000000..22eb9d2ee --- /dev/null +++ b/tools/cargo-miden/src/config.rs @@ -0,0 +1,809 @@ +//! Module for cargo-miden configuration. +//! +//! This implements an argument parser because `clap` is not +//! designed for parsing unknown or unsupported arguments. +//! +//! See https://github.com/clap-rs/clap/issues/1404 for some +//! discussion around this issue. +//! +//! To properly "wrap" `cargo` commands, we need to be able to +//! detect certain arguments, but not error out if the arguments +//! are otherwise unknown as they will be passed to `cargo` directly. +//! +//! This will allow `cargo-miden` to be used as a drop-in +//! replacement for `cargo` without having to be fully aware of +//! the many subcommands and options that `cargo` supports. +//! +//! What is detected here is the minimal subset of the arguments +//! that `cargo` supports which are necessary for `cargo-miden` +//! to function. + +use anyhow::{anyhow, bail, Context, Result}; +use cargo_component_core::terminal::{Color, Terminal}; +use parse_arg::{iter_short, match_arg}; +use semver::Version; +use std::fmt; +use std::str::FromStr; +use std::{collections::BTreeMap, fmt::Display, path::PathBuf}; + +/// Represents a cargo package specifier. +/// +/// See `cargo help pkgid` for more information. +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct CargoPackageSpec { + /// The name of the package, e.g. `foo`. + pub name: String, + /// The version of the package, if specified. + pub version: Option, +} + +impl CargoPackageSpec { + /// Creates a new package specifier from a string. + pub fn new(spec: impl Into) -> Result { + let spec = spec.into(); + + // Bail out if the package specifier contains a URL. + if spec.contains("://") { + bail!("URL package specifier `{spec}` is not supported"); + } + + Ok(match spec.split_once('@') { + Some((name, version)) => Self { + name: name.to_string(), + version: Some( + version + .parse() + .with_context(|| format!("invalid package specified `{spec}`"))?, + ), + }, + None => Self { + name: spec, + version: None, + }, + }) + } +} + +impl FromStr for CargoPackageSpec { + type Err = anyhow::Error; + + fn from_str(s: &str) -> Result { + Self::new(s) + } +} + +impl fmt::Display for CargoPackageSpec { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{name}", name = self.name)?; + if let Some(version) = &self.version { + write!(f, "@{version}")?; + } + + Ok(()) + } +} + +#[derive(Debug, Clone)] +enum Arg { + Flag { + name: &'static str, + short: Option, + value: bool, + }, + Single { + name: &'static str, + value_name: &'static str, + short: Option, + value: Option, + }, + Multiple { + name: &'static str, + value_name: &'static str, + short: Option, + values: Vec, + }, + Counting { + name: &'static str, + short: Option, + value: usize, + }, +} + +impl Arg { + fn name(&self) -> &'static str { + match self { + Self::Flag { name, .. } + | Self::Single { name, .. } + | Self::Multiple { name, .. } + | Self::Counting { name, .. } => name, + } + } + + fn short(&self) -> Option { + match self { + Self::Flag { short, .. } + | Self::Single { short, .. } + | Self::Multiple { short, .. } + | Self::Counting { short, .. } => *short, + } + } + + fn expects_value(&self) -> bool { + matches!(self, Self::Single { .. } | Self::Multiple { .. }) + } + + fn set_value(&mut self, v: String) -> Result<()> { + match self { + Self::Single { value, .. } => { + if value.is_some() { + bail!("the argument '{self}' cannot be used multiple times"); + } + + *value = Some(v); + Ok(()) + } + Self::Multiple { values, .. } => { + values.push(v); + Ok(()) + } + _ => unreachable!(), + } + } + + fn set_present(&mut self) -> Result<()> { + match self { + Self::Flag { value, .. } => { + if *value { + bail!("the argument '{self}' cannot be used multiple times"); + } + + *value = true; + Ok(()) + } + Self::Counting { value, .. } => { + *value += 1; + Ok(()) + } + _ => unreachable!(), + } + } + + fn take_single(&mut self) -> Option { + match self { + Self::Single { value, .. } => value.take(), + _ => None, + } + } + + fn take_multiple(&mut self) -> Vec { + match self { + Self::Multiple { values, .. } => std::mem::take(values), + _ => Vec::new(), + } + } + + fn count(&self) -> usize { + match self { + Arg::Flag { value, .. } => *value as usize, + Arg::Single { value, .. } => value.is_some() as usize, + Arg::Multiple { values, .. } => values.len(), + Arg::Counting { value, .. } => *value, + } + } + + #[cfg(test)] + fn reset(&mut self) { + match self { + Arg::Flag { value, .. } => *value = false, + Arg::Single { value, .. } => *value = None, + Arg::Multiple { values, .. } => values.clear(), + Arg::Counting { value, .. } => *value = 0, + } + } +} + +impl Display for Arg { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{name}", name = self.name())?; + match self { + Self::Single { value_name, .. } | Self::Multiple { value_name, .. } => { + write!(f, " <{value_name}>") + } + _ => Ok(()), + } + } +} + +#[derive(Default, Debug, Clone)] +struct Args { + args: Vec, + long: BTreeMap<&'static str, usize>, + short: BTreeMap, +} + +impl Args { + fn flag(self, name: &'static str, short: Option) -> Self { + self.insert(Arg::Flag { + name, + short, + value: false, + }) + } + + fn single(self, name: &'static str, value_name: &'static str, short: Option) -> Self { + self.insert(Arg::Single { + name, + value_name, + short, + value: None, + }) + } + + fn multiple(self, name: &'static str, value_name: &'static str, short: Option) -> Self { + self.insert(Arg::Multiple { + name, + value_name, + short, + values: Vec::new(), + }) + } + + fn counting(self, name: &'static str, short: Option) -> Self { + self.insert(Arg::Counting { + name, + short, + value: 0, + }) + } + + fn get(&mut self, name: &str) -> Option<&Arg> { + self.long.get(name).copied().map(|i| &self.args[i]) + } + + fn get_mut(&mut self, name: &str) -> Option<&mut Arg> { + self.long.get(name).copied().map(|i| &mut self.args[i]) + } + + fn get_short_mut(&mut self, short: char) -> Option<&mut Arg> { + self.short.get(&short).copied().map(|i| &mut self.args[i]) + } + + fn insert(mut self, arg: Arg) -> Self { + let name = arg.name(); + let short = arg.short(); + + let index = self.args.len(); + self.args.push(arg); + + let prev = self.long.insert(name, index); + assert!(prev.is_none(), "duplicate argument `{name}` provided"); + + if let Some(short) = short { + let prev = self.short.insert(short, index); + assert!(prev.is_none(), "duplicate argument `-{short}` provided"); + } + + self + } + + /// Parses an argument as an option. + /// + /// Returns `Ok(true)` if the argument is an option. + /// + /// Returns `Ok(false)` if the argument is not an option. + fn parse(&mut self, arg: &str, iter: &mut impl Iterator) -> Result { + // Handle short options + if let Some(mut short) = iter_short(arg) { + while let Some(c) = short.next() { + if let Some(option) = self.get_short_mut(c) { + if option.expects_value() { + let value: String = short.parse_remaining(iter).map_err(|_| { + anyhow!("a value is required for '{option}' but none was supplied") + })?; + + // Strip a leading `=` out of the value if present + option + .set_value(value.strip_prefix('=').map(Into::into).unwrap_or(value))?; + return Ok(true); + } + + option.set_present()?; + } + } + + // The argument is an option + return Ok(true); + } + + // Handle long options + if arg.starts_with("--") { + if let Some(option) = self.get_mut(arg.split_once('=').map(|(n, _)| n).unwrap_or(arg)) { + if option.expects_value() { + if let Some(v) = match_arg(option.name(), &arg, iter) { + option.set_value(v.map_err(|_| { + anyhow!("a value is required for '{option}' but none was supplied") + })?)?; + } + } else if option.name() == arg { + option.set_present()?; + } + } + + // The argument is an option + return Ok(true); + } + + // Not an option + Ok(false) + } +} + +/// Represents known cargo arguments. +/// +/// This is a subset of the arguments that cargo supports that +/// are necessary for cargo-miden to function. +#[derive(Default, Debug, Clone, Eq, PartialEq)] +pub struct CargoArguments { + /// The --color argument. + pub color: Option, + /// The (count of) --verbose argument. + pub verbose: usize, + /// The --quiet argument. + pub quiet: bool, + /// The --target argument. + pub targets: Vec, + /// The --manifest-path argument. + pub manifest_path: Option, + /// The --frozen argument. + pub frozen: bool, + /// The --locked argument. + pub locked: bool, + /// The --release argument. + pub release: bool, + /// The --offline argument. + pub offline: bool, + /// The --workspace argument. + pub workspace: bool, + /// The --package argument. + pub packages: Vec, +} + +impl CargoArguments { + /// Determines if network access is allowed based on the configuration. + pub fn network_allowed(&self) -> bool { + !self.frozen && !self.offline + } + + /// Determines if an update to the lock file is allowed based on the configuration. + pub fn lock_update_allowed(&self) -> bool { + !self.frozen && !self.locked + } + + /// Parses the arguments from the environment. + pub fn parse() -> Result { + Self::parse_from(std::env::args().skip(1)) + } + + /// Parses the arguments from an iterator. + pub fn parse_from(iter: impl Iterator) -> Result + where + T: Into, + { + let mut args = Args::default() + .single("--color", "WHEN", Some('c')) + .single("--manifest-path", "PATH", None) + .multiple("--package", "SPEC", Some('p')) + .multiple("--target", "TRIPLE", None) + .flag("--release", Some('r')) + .flag("--frozen", None) + .flag("--locked", None) + .flag("--offline", None) + .flag("--all", None) + .flag("--workspace", None) + .counting("--verbose", Some('v')) + .flag("--quiet", Some('q')); + + let mut iter = iter.map(Into::into).peekable(); + + // Skip the first argument if it is `miden` + if let Some(arg) = iter.peek() { + if arg == "miden" { + iter.next().unwrap(); + } + } + + while let Some(arg) = iter.next() { + // Break out of processing at the first `--` + if arg == "--" { + break; + } + + // Parse options + if args.parse(&arg, &mut iter)? { + continue; + } + } + + Ok(Self { + color: args + .get_mut("--color") + .unwrap() + .take_single() + .map(|v| v.parse()) + .transpose()?, + verbose: args.get("--verbose").unwrap().count(), + quiet: args.get("--quiet").unwrap().count() > 0, + manifest_path: args + .get_mut("--manifest-path") + .unwrap() + .take_single() + .map(PathBuf::from), + targets: args.get_mut("--target").unwrap().take_multiple(), + frozen: args.get("--frozen").unwrap().count() > 0, + locked: args.get("--locked").unwrap().count() > 0, + offline: args.get("--offline").unwrap().count() > 0, + release: args.get("--release").unwrap().count() > 0, + workspace: args.get("--workspace").unwrap().count() > 0 + || args.get("--all").unwrap().count() > 0, + packages: args + .get_mut("--package") + .unwrap() + .take_multiple() + .into_iter() + .map(CargoPackageSpec::new) + .collect::>()?, + }) + } +} + +/// Configuration information for cargo-miden. +/// +/// This is used to configure the behavior of cargo-miden. +#[derive(Debug)] +pub struct Config { + /// The terminal to use. + terminal: Terminal, +} + +impl Config { + /// Create a new `Config` with the given terminal. + pub fn new(terminal: Terminal) -> Result { + Ok(Self { terminal }) + } + + /// Gets a reference to the terminal for writing messages. + pub fn terminal(&self) -> &Terminal { + &self.terminal + } +} + +#[cfg(test)] +mod test { + use super::*; + use std::iter::empty; + + #[test] + fn it_parses_flags() { + let mut args = Args::default().flag("--flag", Some('f')); + + // Test not the flag + args.parse("--not-flag", &mut empty::()).unwrap(); + let arg = args.get("--flag").unwrap(); + assert_eq!(arg.count(), 0); + + // Test the flag + args.parse("--flag", &mut empty::()).unwrap(); + assert_eq!( + args.parse("--flag", &mut empty::()) + .unwrap_err() + .to_string(), + "the argument '--flag' cannot be used multiple times" + ); + let arg = args.get_mut("--flag").unwrap(); + assert_eq!(arg.count(), 1); + arg.reset(); + + // Test not the short flag + args.parse("-rxd", &mut empty::()).unwrap(); + let arg = args.get("--flag").unwrap(); + assert_eq!(arg.count(), 0); + + // Test the short flag + args.parse("-rfx", &mut empty::()).unwrap(); + assert_eq!( + args.parse("-fxz", &mut empty::()) + .unwrap_err() + .to_string(), + "the argument '--flag' cannot be used multiple times" + ); + let arg = args.get("--flag").unwrap(); + assert_eq!(arg.count(), 1); + + // Test it prints correctly + assert_eq!(arg.to_string(), "--flag") + } + + #[test] + fn it_parses_single_values() { + let mut args = Args::default().single("--option", "VALUE", Some('o')); + + // Test not the option + args.parse("--not-option", &mut empty::()).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), None); + + // Test missing value + assert_eq!( + args.parse("--option", &mut empty::()) + .unwrap_err() + .to_string(), + "a value is required for '--option ' but none was supplied" + ); + + // Test the option with equals + args.parse("--option=value", &mut empty::()) + .unwrap(); + assert_eq!( + args.parse("--option=value", &mut empty::()) + .unwrap_err() + .to_string(), + "the argument '--option ' cannot be used multiple times" + ); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), Some("value".to_string())); + arg.reset(); + + // Test the option with space + let mut iter = ["value".to_string()].into_iter(); + args.parse("--option", &mut iter).unwrap(); + assert!(iter.next().is_none()); + let mut iter = ["value".to_string()].into_iter(); + assert_eq!( + args.parse("--option", &mut iter).unwrap_err().to_string(), + "the argument '--option ' cannot be used multiple times" + ); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), Some("value".to_string())); + arg.reset(); + + // Test not the short option + args.parse("-xyz", &mut empty::()).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), None); + + assert_eq!( + args.parse("-fo", &mut empty::()) + .unwrap_err() + .to_string(), + "a value is required for '--option ' but none was supplied" + ); + + // Test the short option without equals + args.parse("-xofoo", &mut empty::()).unwrap(); + assert_eq!( + args.parse("-zyobar", &mut iter).unwrap_err().to_string(), + "the argument '--option ' cannot be used multiple times" + ); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), Some(String::from("foo"))); + + // Test the short option with equals + args.parse("-xo=foo", &mut empty::()).unwrap(); + assert_eq!( + args.parse("-zyo=bar", &mut iter).unwrap_err().to_string(), + "the argument '--option ' cannot be used multiple times" + ); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), Some(String::from("foo"))); + + // Test the short option with space + let mut iter = ["value".to_string()].into_iter(); + args.parse("-xo", &mut iter).unwrap(); + let mut iter = ["value".to_string()].into_iter(); + assert_eq!( + args.parse("-zyo", &mut iter).unwrap_err().to_string(), + "the argument '--option ' cannot be used multiple times" + ); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), Some(String::from("value"))); + + // Test it prints correctly + assert_eq!(arg.to_string(), "--option ") + } + + #[test] + fn it_parses_multiple_values() { + let mut args = Args::default().multiple("--option", "VALUE", Some('o')); + + // Test not the option + args.parse("--not-option", &mut empty::()).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_multiple(), Vec::::new()); + + // Test missing value + assert_eq!( + args.parse("--option", &mut empty::()) + .unwrap_err() + .to_string(), + "a value is required for '--option ' but none was supplied" + ); + + // Test the option with equals + args.parse("--option=foo", &mut empty::()).unwrap(); + args.parse("--option=bar", &mut empty::()).unwrap(); + args.parse("--option=baz", &mut empty::()).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!( + arg.take_multiple(), + vec!["foo".to_string(), "bar".to_string(), "baz".to_string(),] + ); + arg.reset(); + + // Test the option with space + let mut iter = ["foo".to_string()].into_iter(); + args.parse("--option", &mut iter).unwrap(); + assert!(iter.next().is_none()); + let mut iter = ["bar".to_string()].into_iter(); + args.parse("--option", &mut iter).unwrap(); + assert!(iter.next().is_none()); + let mut iter = ["baz".to_string()].into_iter(); + args.parse("--option", &mut iter).unwrap(); + assert!(iter.next().is_none()); + let arg = args.get_mut("--option").unwrap(); + assert_eq!( + arg.take_multiple(), + vec!["foo".to_string(), "bar".to_string(), "baz".to_string(),] + ); + arg.reset(); + + // Test not the short option + args.parse("-xyz", &mut empty::()).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!(arg.take_single(), None); + + // Test missing shot option value + assert_eq!( + args.parse("-fo", &mut empty::()) + .unwrap_err() + .to_string(), + "a value is required for '--option ' but none was supplied" + ); + + // Test the short option without equals + args.parse("-xofoo", &mut empty::()).unwrap(); + args.parse("-yobar", &mut empty::()).unwrap(); + args.parse("-zobaz", &mut empty::()).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!( + arg.take_multiple(), + vec!["foo".to_string(), "bar".to_string(), "baz".to_string(),] + ); + + // Test the short option with equals + args.parse("-xo=foo", &mut empty::()).unwrap(); + args.parse("-yo=bar", &mut empty::()).unwrap(); + args.parse("-zo=baz", &mut empty::()).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!( + arg.take_multiple(), + vec!["foo".to_string(), "bar".to_string(), "baz".to_string(),] + ); + + // Test the short option with space + let mut iter = ["foo".to_string()].into_iter(); + args.parse("-xo", &mut iter).unwrap(); + let mut iter = ["bar".to_string()].into_iter(); + args.parse("-yo", &mut iter).unwrap(); + let mut iter = ["baz".to_string()].into_iter(); + args.parse("-zo", &mut iter).unwrap(); + let arg = args.get_mut("--option").unwrap(); + assert_eq!( + arg.take_multiple(), + vec!["foo".to_string(), "bar".to_string(), "baz".to_string(),] + ); + + // Test it prints correctly + assert_eq!(arg.to_string(), "--option ") + } + + #[test] + fn it_parses_counting_flag() { + let mut args = Args::default().counting("--flag", Some('f')); + + // Test not the the flag + args.parse("--not-flag", &mut empty::()).unwrap(); + let arg = args.get("--flag").unwrap(); + assert_eq!(arg.count(), 0); + + // Test the flag + args.parse("--flag", &mut empty::()).unwrap(); + args.parse("--flag", &mut empty::()).unwrap(); + args.parse("--flag", &mut empty::()).unwrap(); + let arg = args.get_mut("--flag").unwrap(); + assert_eq!(arg.count(), 3); + arg.reset(); + + // Test the short flag + args.parse("-xfzf", &mut empty::()).unwrap(); + args.parse("-pfft", &mut empty::()).unwrap(); + args.parse("-abcd", &mut empty::()).unwrap(); + let arg = args.get_mut("--flag").unwrap(); + assert_eq!(arg.count(), 4); + + // Test it prints correctly + assert_eq!(arg.to_string(), "--flag") + } + + #[test] + fn it_parses_cargo_arguments() { + let args: CargoArguments = + CargoArguments::parse_from(["miden", "build", "--workspace"].into_iter()).unwrap(); + assert_eq!( + args, + CargoArguments { + color: None, + verbose: 0, + quiet: false, + targets: Vec::new(), + manifest_path: None, + release: false, + frozen: false, + locked: false, + offline: false, + workspace: true, + packages: Vec::new(), + } + ); + + let args = CargoArguments::parse_from( + [ + "miden", + "publish", + "-vvv", + "--color=auto", + "--manifest-path", + "Cargo.toml", + "--release", + "--package", + "package1", + "-p=package2@1.1.1", + "--target=foo", + "--target", + "bar", + "--quiet", + "--frozen", + "--locked", + "--offline", + "--all", + "--not-an-option", + ] + .into_iter(), + ) + .unwrap(); + assert_eq!( + args, + CargoArguments { + color: Some(Color::Auto), + verbose: 3, + quiet: true, + targets: vec!["foo".to_string(), "bar".to_string()], + manifest_path: Some("Cargo.toml".into()), + release: true, + frozen: true, + locked: true, + offline: true, + workspace: true, + packages: vec![ + CargoPackageSpec { + name: "package1".to_string(), + version: None + }, + CargoPackageSpec { + name: "package2".to_string(), + version: Some(Version::parse("1.1.1").unwrap()) + } + ], + } + ); + } +} diff --git a/tools/cargo-miden/src/lib.rs b/tools/cargo-miden/src/lib.rs index 247841c10..856c36f85 100644 --- a/tools/cargo-miden/src/lib.rs +++ b/tools/cargo-miden/src/lib.rs @@ -1,5 +1,127 @@ -mod compile; +use std::path::PathBuf; + +use crate::run_cargo_command::run_cargo_command; +use anyhow::bail; +use cargo_component::load_metadata; +use cargo_component_core::terminal::Terminal; +use clap::{CommandFactory, Parser}; +use config::CargoArguments; +use new_project::NewCommand; + +mod build; +pub mod config; mod new_project; +mod run_cargo_command; +mod target; + +fn version() -> &'static str { + option_env!("CARGO_VERSION_INFO").unwrap_or(env!("CARGO_PKG_VERSION")) +} + +/// The list of commands that are built-in to `cargo-miden`. +const BUILTIN_COMMANDS: &[&str] = &[ + "miden", // for indirection via `cargo miden` + "new", +]; + +const AFTER_HELP: &str = "Unrecognized subcommands will be passed to cargo verbatim + and the artifacts will be processed afterwards (e.g. `build` command compiles MASM). + \n\ + See `cargo help` for more information on available cargo commands."; + +/// Cargo integration for Miden +#[derive(Parser)] +#[clap( + bin_name = "cargo", + version, + propagate_version = true, + arg_required_else_help = true, + after_help = AFTER_HELP +)] +#[command(version = version())] +enum CargoMiden { + /// Cargo integration for Miden + #[clap(subcommand, hide = true, after_help = AFTER_HELP)] + Miden(Command), // indirection via `cargo miden` + #[clap(flatten)] + Command(Command), +} + +#[derive(Parser)] +enum Command { + New(NewCommand), +} + +fn detect_subcommand(args: I) -> Option +where + I: IntoIterator, + T: Into + Clone, +{ + let mut iter = args.into_iter().map(Into::into).skip(1).peekable(); + + // Skip the first argument if it is `miden` (i.e. `cargo miden`) + if let Some(arg) = iter.peek() { + if arg == "miden" { + iter.next().unwrap(); + } + } + + for arg in iter { + // Break out of processing at the first `--` + if arg == "--" { + break; + } + + if !arg.starts_with('-') { + return Some(arg); + } + } + + None +} + +pub fn run(args: T, terminal: &Terminal) -> anyhow::Result> +where + T: Iterator, +{ + let args = args.collect::>(); + let subcommand = detect_subcommand(args.clone().into_iter()); + + let outputs = match subcommand.as_deref() { + // Check for built-in command or no command (shows help) + Some(cmd) if BUILTIN_COMMANDS.contains(&cmd) => { + match CargoMiden::parse_from(args.clone()) { + CargoMiden::Miden(cmd) | CargoMiden::Command(cmd) => match cmd { + Command::New(cmd) => vec![cmd.exec()?], + }, + } + } + + // If no subcommand was detected, + None => { + // Attempt to parse the supported CLI (expected to fail) + CargoMiden::parse_from(args); + + // If somehow the CLI parsed correctly despite no subcommand, + // print the help instead + CargoMiden::command().print_long_help()?; + Vec::new() + } + + _ => { + // Not a built-in command, run the cargo command + let cargo_args = CargoArguments::parse_from(args.clone().into_iter())?; + let metadata = load_metadata(&terminal, cargo_args.manifest_path.as_deref(), false)?; + if metadata.packages.is_empty() { + bail!( + "manifest `{path}` contains no package or the workspace has no members", + path = metadata.workspace_root.join("Cargo.toml") + ); + } -pub use compile::compile; -pub use new_project::new_project; + let spawn_args: Vec<_> = args.into_iter().skip(1).collect(); + run_cargo_command(&metadata, subcommand.as_deref(), &cargo_args, &spawn_args)? + } + }; + Ok(outputs) +} diff --git a/tools/cargo-miden/src/main.rs b/tools/cargo-miden/src/main.rs index 971252d4a..df62bf60a 100644 --- a/tools/cargo-miden/src/main.rs +++ b/tools/cargo-miden/src/main.rs @@ -1,24 +1,30 @@ -use anyhow::Context; -use cargo_miden::compile; -use cargo_miden::new_project; -use clap::Parser; -use cli_commands::CargoCli; -use cli_commands::Commands; - -mod cli_commands; +use cargo_component_core::terminal::{Terminal, Verbosity}; +use cargo_miden::{config::CargoArguments, run}; fn main() -> anyhow::Result<()> { - let args = match CargoCli::parse() { - CargoCli::Miden(args) => args, - }; + // Initialize logger + let mut builder = env_logger::Builder::from_env("CARGO_MIDEN_TRACE"); + builder.format_indent(Some(2)); + builder.format_timestamp(None); + builder.init(); + + let cargo_args = CargoArguments::parse_from(std::env::args())?; + let terminal = Terminal::new( + if cargo_args.quiet { + Verbosity::Quiet + } else { + match cargo_args.verbose { + 0 => Verbosity::Normal, + _ => Verbosity::Verbose, + } + }, + cargo_args.color.unwrap_or_default(), + ); - match args.command { - Commands::Build { - target, - bin_name, - output_folder, - } => compile(target, bin_name, &output_folder) - .context(format!("Failed to compile {}", target)), - Commands::New { path } => new_project(path).context("Failed to scaffold a new project"), + if let Err(e) = run(std::env::args(), &terminal) { + terminal.error(format!("{e:?}"))?; + std::process::exit(1); } + + Ok(()) } diff --git a/tools/cargo-miden/src/new_project.rs b/tools/cargo-miden/src/new_project.rs index 3e3e4268b..7419364a3 100644 --- a/tools/cargo-miden/src/new_project.rs +++ b/tools/cargo-miden/src/new_project.rs @@ -3,9 +3,20 @@ use std::path::PathBuf; use anyhow::Context; use cargo_generate::GenerateArgs; use cargo_generate::TemplatePath; +use clap::Args; -pub fn new_project(path: PathBuf) -> anyhow::Result<()> { - let name = path +/// Create a new Miden project at +#[derive(Args)] +#[clap(disable_version_flag = true)] +pub struct NewCommand { + /// The path for the generated package. + #[clap(value_name = "path")] + pub path: PathBuf, +} + +impl NewCommand { + pub fn exec(self) -> anyhow::Result { + let name = self.path .file_name() .ok_or_else(|| { anyhow::anyhow!("Failed to get the last segment of the provided path for the project name") @@ -16,23 +27,28 @@ pub fn new_project(path: PathBuf) -> anyhow::Result<()> { })? .to_string(); - let generate_args = GenerateArgs { - template_path: TemplatePath { - git: Some("https://github.com/0xPolygonMiden/rust-templates".into()), - auto_path: Some("library".into()), + let generate_args = GenerateArgs { + template_path: TemplatePath { + git: Some("https://github.com/0xPolygonMiden/rust-templates".into()), + auto_path: Some("library".into()), + ..Default::default() + }, + destination: self + .path + .parent() + .map(|p| { + use path_absolutize::Absolutize; + p.absolutize().map(|p| p.to_path_buf()) + }) + .transpose() + .context("Failed to convert destination path to an absolute path")?, + name: Some(name), + force_git_init: true, + verbose: true, ..Default::default() - }, - destination: path - .parent() - .map(|p| p.canonicalize().map(|p| p.to_path_buf())) - .transpose() - .context("Failed to convert destination path to an absolute path")?, - name: Some(name), - force_git_init: true, - verbose: true, - ..Default::default() - }; - cargo_generate::generate(generate_args) - .context("Failed to scaffold new Miden project from the template")?; - return Ok(()); + }; + cargo_generate::generate(generate_args) + .context("Failed to scaffold new Miden project from the template")?; + return Ok(self.path); + } } diff --git a/tools/cargo-miden/src/run_cargo_command.rs b/tools/cargo-miden/src/run_cargo_command.rs new file mode 100644 index 000000000..f62276a60 --- /dev/null +++ b/tools/cargo-miden/src/run_cargo_command.rs @@ -0,0 +1,127 @@ +use anyhow::bail; +use cargo_metadata::Metadata; +use std::path::PathBuf; +use std::process::Command; + +use crate::build::build_masm; +use crate::config::CargoArguments; +use crate::target::{install_wasm32_wasi, WASM32_WASI_TARGET}; + +fn is_wasm_target(target: &str) -> bool { + target == WASM32_WASI_TARGET +} + +/// Runs the cargo command as specified in the configuration. +/// +/// Returns any relevant output artifacts. +pub fn run_cargo_command( + metadata: &Metadata, + subcommand: Option<&str>, + cargo_args: &CargoArguments, + spawn_args: &[String], +) -> anyhow::Result> { + let cargo = std::env::var("CARGO") + .map(PathBuf::from) + .ok() + .unwrap_or_else(|| PathBuf::from("cargo")); + + let mut args = spawn_args.iter().peekable(); + if let Some(arg) = args.peek() { + if *arg == "miden" { + args.next().unwrap(); + } + } + + // Spawn the actual cargo command + log::debug!( + "spawning cargo `{cargo}` with arguments `{args:?}`", + cargo = cargo.display(), + args = args.clone().collect::>(), + ); + + let mut cmd = Command::new(&cargo); + cmd.args(args); + + let is_build = matches!(subcommand, Some("b") | Some("build")); + + // Handle the target for build commands + if is_build { + install_wasm32_wasi()?; + + // Add an implicit wasm32-wasi target if there isn't a wasm target present + if !cargo_args.targets.iter().any(|t| is_wasm_target(t)) { + cmd.arg("--target").arg(WASM32_WASI_TARGET); + } + } + + match cmd.status() { + Ok(status) => { + if !status.success() { + bail!("cargo failed with exit code {}", status.code().unwrap_or(1)); + } + } + Err(e) => { + bail!("failed to spawn `{cargo}`: {e}", cargo = cargo.display()); + } + } + let mut outputs = Vec::new(); + if is_build { + log::debug!("searching for WebAssembly modules to compile to MASM"); + let targets = cargo_args + .targets + .iter() + .map(String::as_str) + .filter(|t| is_wasm_target(t)) + .chain(cargo_args.targets.is_empty().then_some(WASM32_WASI_TARGET)); + + for target in targets { + let out_dir = metadata + .target_directory + .join(target) + .join(if cargo_args.release { + "release" + } else { + "debug" + }); + + let miden_out_dir = + metadata + .target_directory + .join("miden") + .join(if cargo_args.release { + "release" + } else { + "debug" + }); + if !miden_out_dir.exists() { + std::fs::create_dir_all(&miden_out_dir)?; + } + + for package in &metadata.packages { + let is_bin = package.targets.iter().any(|t| t.is_bin()); + + // First try for .wasm + let path = out_dir.join(&package.name).with_extension("wasm"); + if path.exists() { + let output = + build_masm(path.as_std_path(), miden_out_dir.as_std_path(), is_bin)?; + outputs.push(output); + } else { + let path = out_dir + .join(package.name.replace('-', "_")) + .with_extension("wasm"); + if path.exists() { + let output = + build_masm(path.as_std_path(), miden_out_dir.as_std_path(), is_bin)?; + outputs.push(output); + } else { + log::debug!("no output found for package `{name}`", name = package.name); + bail!("Cargo build failed, no Wasm artifact found"); + } + } + } + } + } + + Ok(outputs) +} diff --git a/tools/cargo-miden/src/target.rs b/tools/cargo-miden/src/target.rs new file mode 100644 index 000000000..653979969 --- /dev/null +++ b/tools/cargo-miden/src/target.rs @@ -0,0 +1,58 @@ +use anyhow::{bail, Result}; +use std::{ + env, + path::PathBuf, + process::{Command, Stdio}, +}; + +pub const WASM32_WASI_TARGET: &str = "wasm32-wasi"; + +pub fn install_wasm32_wasi() -> Result<()> { + log::info!("Installing {WASM32_WASI_TARGET} target"); + let sysroot = get_sysroot()?; + if sysroot.join("lib/rustlib/wasm32-wasi").exists() { + return Ok(()); + } + + if env::var_os("RUSTUP_TOOLCHAIN").is_none() { + bail!( + "failed to find the `wasm32-wasi` target \ + and `rustup` is not available. If you're using rustup \ + make sure that it's correctly installed; if not, make sure to \ + install the `wasm32-wasi` target before using this command" + ); + } + + let output = Command::new("rustup") + .arg("target") + .arg("add") + .arg(WASM32_WASI_TARGET) + .stderr(Stdio::inherit()) + .stdout(Stdio::inherit()) + .output()?; + + if !output.status.success() { + bail!("failed to install the `wasm32-wasi` target"); + } + + Ok(()) +} + +fn get_sysroot() -> Result { + let output = Command::new("rustc") + .arg("--print") + .arg("sysroot") + .output()?; + + if !output.status.success() { + bail!( + "failed to execute `rustc --print sysroot`, \ + command exited with error: {output}", + output = String::from_utf8_lossy(&output.stderr) + ); + } + + let sysroot = PathBuf::from(String::from_utf8(output.stdout)?.trim()); + + Ok(sysroot) +} diff --git a/tools/cargo-miden/tests/build.rs b/tools/cargo-miden/tests/build.rs new file mode 100644 index 000000000..b68be32d8 --- /dev/null +++ b/tools/cargo-miden/tests/build.rs @@ -0,0 +1,42 @@ +use cargo_component_core::terminal; +use cargo_miden::run; +use std::env; +use std::fs; + +// NOTE: This test sets the current working directory so don't run it in parallel with tests +// that depend on the current directory + +#[test] +fn build_new_project_from_template() { + let restore_dir = env::current_dir().unwrap(); + let temp_dir = env::temp_dir(); + env::set_current_dir(&temp_dir).unwrap(); + let project_name = "test-proj"; + let expected_new_project_dir = &temp_dir.join(project_name); + if expected_new_project_dir.exists() { + fs::remove_dir_all(expected_new_project_dir).unwrap(); + } + let args = ["cargo", "miden", "new", project_name] + .into_iter() + .map(|s| s.to_string()); + let terminal = terminal::Terminal::new(terminal::Verbosity::Verbose, terminal::Color::Auto); + let outputs = run(args, &terminal).expect("Failed to create new project"); + let new_project_path = outputs.first().unwrap().canonicalize().unwrap(); + dbg!(&new_project_path); + assert!(new_project_path.exists()); + assert_eq!( + new_project_path, + expected_new_project_dir.canonicalize().unwrap() + ); + env::set_current_dir(&new_project_path).unwrap(); + let args = ["cargo", "miden", "build", "--release"] + .iter() + .map(|s| s.to_string()); + let outputs = run(args, &terminal).expect("Failed to compile"); + let expected_masm_path = outputs.first().unwrap(); + dbg!(&expected_masm_path); + assert!(expected_masm_path.exists()); + assert!(expected_masm_path.metadata().unwrap().len() > 0); + env::set_current_dir(restore_dir).unwrap(); + fs::remove_dir_all(new_project_path).unwrap(); +} diff --git a/tools/cargo-miden/tests/compile.rs b/tools/cargo-miden/tests/compile.rs deleted file mode 100644 index 631913000..000000000 --- a/tools/cargo-miden/tests/compile.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::utils::get_test_path; -use cargo_miden::compile; -use midenc_session::TargetEnv; -use std::env; -use std::fs; - -#[test] -fn compile_template() { - let restore_dir = env::current_dir().unwrap(); - let test_dir = get_test_path("template"); - // dbg!(&test_dir); - env::set_current_dir(&test_dir).unwrap(); - let masm_path_rel = "target"; - let output_folder = test_dir.join(masm_path_rel); - if !output_folder.exists() { - fs::create_dir_all(&output_folder).unwrap(); - } - compile(TargetEnv::Base, None, &output_folder).expect("Failed to compile"); - env::set_current_dir(restore_dir).unwrap(); - let expected_masm_path = output_folder.join("miden_wallet_lib.masm"); - assert!(expected_masm_path.exists()); - assert!(expected_masm_path.metadata().unwrap().len() > 0); - fs::remove_file(expected_masm_path).unwrap(); -} diff --git a/tools/cargo-miden/tests/data/template/Cargo.lock b/tools/cargo-miden/tests/data/template/Cargo.lock deleted file mode 100644 index 08aa217ca..000000000 --- a/tools/cargo-miden/tests/data/template/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "miden-wallet-lib" -version = "0.1.0" diff --git a/tools/cargo-miden/tests/data/template/Cargo.toml b/tools/cargo-miden/tests/data/template/Cargo.toml deleted file mode 100644 index 954ea1802..000000000 --- a/tools/cargo-miden/tests/data/template/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "miden-wallet-lib" -version = "0.1.0" -edition = "2021" - -[workspace] - -[lib] -crate-type = ["cdylib"] - -[profile.release] -opt-level = "z" \ No newline at end of file diff --git a/tools/cargo-miden/tests/data/template/src/lib.rs b/tools/cargo-miden/tests/data/template/src/lib.rs deleted file mode 100644 index 0da60d0f7..000000000 --- a/tools/cargo-miden/tests/data/template/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![no_std] - -// #[global_allocator] -// static A: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc; - -#[panic_handler] -fn my_panic(_info: &core::panic::PanicInfo) -> ! { - loop {} -} - -#[no_mangle] -pub fn function(n: u32) -> u32 { - let mut a = n; - while a > 3 { - a = a / 3; - } - a -} diff --git a/tools/cargo-miden/tests/mod.rs b/tools/cargo-miden/tests/mod.rs index a1dea7ea0..3a146708a 100755 --- a/tools/cargo-miden/tests/mod.rs +++ b/tools/cargo-miden/tests/mod.rs @@ -1,2 +1,2 @@ -mod compile; +mod build; mod utils; From 769d983508dfaad11920dcf2f1e277b1b87ba46e Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Thu, 7 Dec 2023 18:04:03 +0200 Subject: [PATCH 22/22] refactor: make `WasmTranslationConfig::module_name_fallback` non-optional --- frontend-wasm/src/config.rs | 12 ++++++++++-- frontend-wasm/src/module_translator.rs | 7 +------ midenc-compile/src/stages/parse.rs | 8 +++++--- tools/cargo-miden/tests/utils.rs | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/frontend-wasm/src/config.rs b/frontend-wasm/src/config.rs index 17a10f3da..a35697bd8 100644 --- a/frontend-wasm/src/config.rs +++ b/frontend-wasm/src/config.rs @@ -1,6 +1,14 @@ /// Configuration for the WASM translation. -#[derive(Debug, Default)] +#[derive(Debug)] pub struct WasmTranslationConfig { /// The module name to use if Wasm module doesn't have one. - pub module_name_fallback: Option, + pub module_name_fallback: String, +} + +impl Default for WasmTranslationConfig { + fn default() -> Self { + Self { + module_name_fallback: "noname".to_string(), + } + } } diff --git a/frontend-wasm/src/module_translator.rs b/frontend-wasm/src/module_translator.rs index 9fb8581e4..626e1a7e5 100644 --- a/frontend-wasm/src/module_translator.rs +++ b/frontend-wasm/src/module_translator.rs @@ -35,12 +35,7 @@ fn translate_module_inner( config: &WasmTranslationConfig, diagnostics: &DiagnosticsHandler, ) -> WasmResult { - let mut module_env = ModuleEnvironment::new( - config - .module_name_fallback - .clone() - .unwrap_or("noname".to_owned()), - ); + let mut module_env = ModuleEnvironment::new(config.module_name_fallback.clone()); let env = &mut module_env; let wasm_features = WasmFeatures::default(); let mut validator = Validator::new_with_features(wasm_features); diff --git a/midenc-compile/src/stages/parse.rs b/midenc-compile/src/stages/parse.rs index 826c169b8..8fa43aa7c 100644 --- a/midenc-compile/src/stages/parse.rs +++ b/midenc-compile/src/stages/parse.rs @@ -36,12 +36,14 @@ impl Stage for ParseStage { FileType::Wasm => self.parse_hir_from_wasm_file(path.as_ref(), &session), unsupported => unreachable!("unsupported file type: {unsupported}"), }, - InputType::Stdin { ref input, .. } => match file_type { + InputType::Stdin { name, ref input } => match file_type { FileType::Hir => self.parse_ast_from_bytes(&input, &session), FileType::Wasm => self.parse_hir_from_wasm_bytes( &input, &session, - &WasmTranslationConfig::default(), + &WasmTranslationConfig { + module_name_fallback: name.to_string().clone(), + }, ), unsupported => unreachable!("unsupported file type: {unsupported}"), }, @@ -87,7 +89,7 @@ impl ParseStage { file.read_to_end(&mut bytes)?; let file_name = path.file_name().unwrap().to_str().unwrap().to_owned(); let config = wasm::WasmTranslationConfig { - module_name_fallback: Some(file_name), + module_name_fallback: file_name, }; self.parse_hir_from_wasm_bytes(&bytes, session, &config) } diff --git a/tools/cargo-miden/tests/utils.rs b/tools/cargo-miden/tests/utils.rs index 288ff3428..de17a8abd 100644 --- a/tools/cargo-miden/tests/utils.rs +++ b/tools/cargo-miden/tests/utils.rs @@ -1,6 +1,7 @@ use std::env; use std::path::PathBuf; +#[allow(dead_code)] pub(crate) fn get_test_path(test_dir_name: &str) -> PathBuf { let mut test_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"));