diff --git a/midenc-compile/src/compiler.rs b/midenc-compile/src/compiler.rs index 9ee41b72e..221b5d9e4 100644 --- a/midenc-compile/src/compiler.rs +++ b/midenc-compile/src/compiler.rs @@ -163,6 +163,11 @@ pub struct Compiler { long = "link-library", short = 'l', value_name = "[KIND=]NAME", + value_delimiter = ',', + default_value_ifs([ + ("target", "base", "std"), + ("target", "rollup", "std,base"), + ]), next_line_help(true), help_heading = "Linker" )] diff --git a/midenc-session/src/libs.rs b/midenc-session/src/libs.rs index 27c6745d0..b47b67117 100644 --- a/midenc-session/src/libs.rs +++ b/midenc-session/src/libs.rs @@ -28,7 +28,7 @@ impl FromStr for LibraryKind { fn from_str(s: &str) -> Result { match s { - "mast" => Ok(Self::Mast), + "mast" | "masl" => Ok(Self::Mast), "masm" => Ok(Self::Masm), _ => Err(()), } @@ -60,8 +60,15 @@ impl LinkLibrary { } // Handle libraries shipped with the compiler, or via Miden crates - if self.name == "std" { - return Ok(StdLibrary::default().into()); + match self.name.as_ref() { + "std" => return Ok(StdLibrary::default().into()), + "base" => { + // TODO(pauls): Handle properly once we have miden-base-sys + return Err(Report::msg(format!( + "invalid link library 'base': miden-base-sys is unimplemented" + ))); + } + _ => (), } // Search for library among specified search paths @@ -160,7 +167,7 @@ impl clap::builder::TypedValueParser for LinkLibraryParser { Some(Box::new( [ PossibleValue::new("masm").help("A Miden Assembly project directory"), - PossibleValue::new("mast").help("A compiled MAST library file"), + PossibleValue::new("masl").help("A compiled MAST library file"), ] .into_iter(), )) diff --git a/tests/integration/src/compiler_test.rs b/tests/integration/src/compiler_test.rs index eefb5c02c..495b577ec 100644 --- a/tests/integration/src/compiler_test.rs +++ b/tests/integration/src/compiler_test.rs @@ -1202,7 +1202,7 @@ fn dummy_session(flags: &[&str]) -> Rc { } /// Create a default session for testing -pub fn default_session(inputs: I, extra_flags: &[S]) -> Rc +pub fn default_session(inputs: I, argv: &[S]) -> Rc where I: IntoIterator, S: AsRef, @@ -1214,8 +1214,7 @@ where reporting::set_panic_hook(); } - let mut argv = vec!["-l", "std"]; - argv.extend(extra_flags.iter().map(|flag| flag.as_ref())); + let argv = argv.into_iter().map(|arg| arg.as_ref()); let session = midenc_compile::Compiler::new_session(inputs, None, argv) // Ensure MASM outputs are generated .with_output_type(OutputType::Masm, None); diff --git a/tools/cargo-miden/src/build.rs b/tools/cargo-miden/src/build.rs index 2c356f62b..0d4047652 100644 --- a/tools/cargo-miden/src/build.rs +++ b/tools/cargo-miden/src/build.rs @@ -39,8 +39,6 @@ pub fn build_masm( output_file.as_os_str(), project_type.as_ref(), "--verbose".as_ref(), - "-l".as_ref(), - "std".as_ref(), ]; let session = Rc::new(Compiler::new_session([input], None, args)); midenc_compile::compile(session.clone())?;