diff --git a/Cargo.lock b/Cargo.lock index 7ac9da92c0e..631ba7540b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2199,6 +2199,7 @@ name = "noirc_driver" version = "0.2.0" dependencies = [ "acvm 0.5.0", + "clap 4.1.4", "fm", "hex", "noirc_abi", diff --git a/Cargo.toml b/Cargo.toml index b033ac35b44..8f3d7e85493 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ noirc_frontend = { path = "crates/noirc_frontend" } noir_wasm = { path = "crates/wasm" } cfg-if = "1.0.0" +clap = { version = "4.1.4", features = ["derive"]} codespan = "0.9.5" codespan-reporting = "0.9.5" chumsky = { git = "https://github.com/jfecher/chumsky", rev = "ad9d312" } diff --git a/crates/nargo/Cargo.toml b/crates/nargo/Cargo.toml index 75098029e74..6b69bffc628 100644 --- a/crates/nargo/Cargo.toml +++ b/crates/nargo/Cargo.toml @@ -13,6 +13,7 @@ rustc_version = "0.4.0" build-data = "0.1.3" [dependencies] +clap.workspace = true dirs.workspace = true url.workspace = true iter-extended.workspace = true @@ -26,17 +27,17 @@ hex.workspace = true toml.workspace = true serde.workspace = true thiserror.workspace = true -clap = { version = "4.1.4", features = ["derive"]} const_format = "0.2.30" serde_json = "1.0" termcolor = "1.1.2" tempdir = "0.3.7" +color-eyre = "0.6.2" + # Backends aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "74b4d8d8b118e4477880c04149e5e9d93d388384" } aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "74b4d8d8b118e4477880c04149e5e9d93d388384" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "144378edad821bfaa52bf2cacca8ecc87514a4fc" } -color-eyre = "0.6.2" [features] default = ["plonk_bn254"] diff --git a/crates/nargo/src/cli/check_cmd.rs b/crates/nargo/src/cli/check_cmd.rs index 8fd4573ef22..2dc1fc7ff21 100644 --- a/crates/nargo/src/cli/check_cmd.rs +++ b/crates/nargo/src/cli/check_cmd.rs @@ -3,6 +3,7 @@ use acvm::ProofSystemCompiler; use clap::Args; use iter_extended::btree_map; use noirc_abi::{AbiParameter, AbiType, MAIN_RETURN_NAME}; +use noirc_driver::CompileOptions; use std::{ collections::BTreeMap, path::{Path, PathBuf}, @@ -15,24 +16,23 @@ use crate::constants::{PROVER_INPUT_FILE, VERIFIER_INPUT_FILE}; /// Checks the constraint system for errors #[derive(Debug, Clone, Args)] pub(crate) struct CheckCommand { - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliError> { - check_from_path(config.program_dir, args.allow_warnings)?; + check_from_path(config.program_dir, &args.compile_options)?; println!("Constraint system successfully built!"); Ok(()) } -// This is exposed so that we can run the examples and verify that they pass -fn check_from_path>(p: P, allow_warnings: bool) -> Result<(), CliError> { + +fn check_from_path>(p: P, compile_options: &CompileOptions) -> Result<(), CliError> { let backend = crate::backends::ConcreteBackend; let mut driver = Resolver::resolve_root_config(p.as_ref(), backend.np_language())?; add_std_lib(&mut driver); - if driver.check_crate(allow_warnings).is_err() { + if driver.check_crate(compile_options).is_err() { std::process::exit(1); } @@ -90,6 +90,8 @@ fn build_placeholder_input_map( #[cfg(test)] mod tests { + use noirc_driver::CompileOptions; + const TEST_DATA_DIR: &str = "tests/target_tests_data"; #[test] @@ -97,11 +99,12 @@ mod tests { let mut pass_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); pass_dir.push(&format!("{TEST_DATA_DIR}/pass")); + let config = CompileOptions::default(); let paths = std::fs::read_dir(pass_dir).unwrap(); for path in paths.flatten() { let path = path.path(); assert!( - super::check_from_path(path.clone(), false).is_ok(), + super::check_from_path(path.clone(), &config).is_ok(), "path: {}", path.display() ); @@ -114,11 +117,12 @@ mod tests { let mut fail_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); fail_dir.push(&format!("{TEST_DATA_DIR}/fail")); + let config = CompileOptions::default(); let paths = std::fs::read_dir(fail_dir).unwrap(); for path in paths.flatten() { let path = path.path(); assert!( - super::check_from_path(path.clone(), false).is_err(), + super::check_from_path(path.clone(), &config).is_err(), "path: {}", path.display() ); @@ -130,10 +134,17 @@ mod tests { let mut pass_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); pass_dir.push(&format!("{TEST_DATA_DIR}/pass_dev_mode")); + let mut config = CompileOptions::default(); + config.allow_warnings = true; + let paths = std::fs::read_dir(pass_dir).unwrap(); for path in paths.flatten() { let path = path.path(); - assert!(super::check_from_path(path.clone(), true).is_ok(), "path: {}", path.display()); + assert!( + super::check_from_path(path.clone(), &config).is_ok(), + "path: {}", + path.display() + ); } } } diff --git a/crates/nargo/src/cli/compile_cmd.rs b/crates/nargo/src/cli/compile_cmd.rs index 068451af451..f8be06beb5f 100644 --- a/crates/nargo/src/cli/compile_cmd.rs +++ b/crates/nargo/src/cli/compile_cmd.rs @@ -1,5 +1,6 @@ use acvm::acir::circuit::Circuit; use acvm::ProofSystemCompiler; +use noirc_driver::CompileOptions; use std::path::{Path, PathBuf}; use clap::Args; @@ -15,9 +16,8 @@ pub(crate) struct CompileCommand { /// The name of the ACIR file circuit_name: String, - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: CompileCommand, config: NargoConfig) -> Result<(), CliError> { @@ -28,7 +28,7 @@ pub(crate) fn run(args: CompileCommand, config: NargoConfig) -> Result<(), CliEr &args.circuit_name, config.program_dir, circuit_path, - args.allow_warnings, + &args.compile_options, )?; println!("Generated ACIR code into {}", circuit_path.display()); @@ -40,9 +40,9 @@ fn compile_and_preprocess_circuit>( circuit_name: &str, program_dir: P, circuit_dir: P, - allow_warnings: bool, + compile_options: &CompileOptions, ) -> Result { - let compiled_program = compile_circuit(program_dir, false, allow_warnings)?; + let compiled_program = compile_circuit(program_dir, compile_options)?; let circuit_path = save_program_to_file(&compiled_program, circuit_name, &circuit_dir); preprocess_with_path(circuit_name, circuit_dir, &compiled_program.circuit)?; @@ -52,14 +52,13 @@ fn compile_and_preprocess_circuit>( pub(crate) fn compile_circuit>( program_dir: P, - show_ssa: bool, - allow_warnings: bool, + compile_options: &CompileOptions, ) -> Result { let backend = crate::backends::ConcreteBackend; let mut driver = Resolver::resolve_root_config(program_dir.as_ref(), backend.np_language())?; add_std_lib(&mut driver); - driver.into_compiled_program(show_ssa, allow_warnings).map_err(|_| CliError::CompilationError) + driver.into_compiled_program(compile_options).map_err(|_| CliError::CompilationError) } fn preprocess_with_path>( diff --git a/crates/nargo/src/cli/contract_cmd.rs b/crates/nargo/src/cli/contract_cmd.rs index 175e69543b2..a8f2fb3a8b1 100644 --- a/crates/nargo/src/cli/contract_cmd.rs +++ b/crates/nargo/src/cli/contract_cmd.rs @@ -3,17 +3,17 @@ use super::NargoConfig; use crate::{cli::compile_cmd::compile_circuit, constants::CONTRACT_DIR, errors::CliError}; use acvm::SmartContract; use clap::Args; +use noirc_driver::CompileOptions; /// Generates a Solidity verifier smart contract for the program #[derive(Debug, Clone, Args)] pub(crate) struct ContractCommand { - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: ContractCommand, config: NargoConfig) -> Result<(), CliError> { - let compiled_program = compile_circuit(config.program_dir.clone(), false, args.allow_warnings)?; + let compiled_program = compile_circuit(config.program_dir.clone(), &args.compile_options)?; let backend = crate::backends::ConcreteBackend; #[allow(deprecated)] diff --git a/crates/nargo/src/cli/execute_cmd.rs b/crates/nargo/src/cli/execute_cmd.rs index 761f376d8f8..6ebc3ece62a 100644 --- a/crates/nargo/src/cli/execute_cmd.rs +++ b/crates/nargo/src/cli/execute_cmd.rs @@ -4,7 +4,7 @@ use acvm::PartialWitnessGenerator; use clap::Args; use noirc_abi::input_parser::{Format, InputValue}; use noirc_abi::{InputMap, WitnessMap}; -use noirc_driver::CompiledProgram; +use noirc_driver::{CompileOptions, CompiledProgram}; use super::fs::{inputs::read_inputs_from_file, witness::save_witness_to_dir}; use super::NargoConfig; @@ -20,18 +20,13 @@ pub(crate) struct ExecuteCommand { /// Write the execution witness to named file witness_name: Option, - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, - - /// Emit debug information for the intermediate SSA IR - #[arg(short, long)] - show_ssa: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: ExecuteCommand, config: NargoConfig) -> Result<(), CliError> { let (return_value, solved_witness) = - execute_with_path(&config.program_dir, args.show_ssa, args.allow_warnings)?; + execute_with_path(&config.program_dir, &args.compile_options)?; println!("Circuit witness successfully solved"); if let Some(return_value) = return_value { @@ -50,10 +45,9 @@ pub(crate) fn run(args: ExecuteCommand, config: NargoConfig) -> Result<(), CliEr fn execute_with_path>( program_dir: P, - show_ssa: bool, - allow_warnings: bool, + compile_options: &CompileOptions, ) -> Result<(Option, WitnessMap), CliError> { - let compiled_program = compile_circuit(&program_dir, show_ssa, allow_warnings)?; + let compiled_program = compile_circuit(&program_dir, compile_options)?; // Parse the initial witness values from Prover.toml let (inputs_map, _) = read_inputs_from_file( diff --git a/crates/nargo/src/cli/gates_cmd.rs b/crates/nargo/src/cli/gates_cmd.rs index 2d27b7704e0..71edd4101fe 100644 --- a/crates/nargo/src/cli/gates_cmd.rs +++ b/crates/nargo/src/cli/gates_cmd.rs @@ -1,5 +1,6 @@ use acvm::ProofSystemCompiler; use clap::Args; +use noirc_driver::CompileOptions; use std::path::Path; use crate::cli::compile_cmd::compile_circuit; @@ -10,25 +11,19 @@ use super::NargoConfig; /// Counts the occurrences of different gates in circuit #[derive(Debug, Clone, Args)] pub(crate) struct GatesCommand { - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, - - /// Emit debug information for the intermediate SSA IR - #[arg(short, long)] - show_ssa: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: GatesCommand, config: NargoConfig) -> Result<(), CliError> { - count_gates_with_path(config.program_dir, args.show_ssa, args.allow_warnings) + count_gates_with_path(config.program_dir, &args.compile_options) } fn count_gates_with_path>( program_dir: P, - show_ssa: bool, - allow_warnings: bool, + compile_options: &CompileOptions, ) -> Result<(), CliError> { - let compiled_program = compile_circuit(program_dir.as_ref(), show_ssa, allow_warnings)?; + let compiled_program = compile_circuit(program_dir.as_ref(), compile_options)?; let num_opcodes = compiled_program.circuit.opcodes.len(); let backend = crate::backends::ConcreteBackend; diff --git a/crates/nargo/src/cli/mod.rs b/crates/nargo/src/cli/mod.rs index 567645b52ac..5b5b2323e09 100644 --- a/crates/nargo/src/cli/mod.rs +++ b/crates/nargo/src/cli/mod.rs @@ -1,7 +1,7 @@ use clap::{Args, Parser, Subcommand}; use const_format::formatcp; use noirc_abi::InputMap; -use noirc_driver::Driver; +use noirc_driver::{CompileOptions, Driver}; use noirc_frontend::graph::{CrateName, CrateType}; use std::path::{Path, PathBuf}; @@ -80,14 +80,15 @@ pub fn prove_and_verify(proof_name: &str, prg_dir: &Path, show_ssa: bool) -> boo use tempdir::TempDir; let tmp_dir = TempDir::new("p_and_v_tests").unwrap(); + let compile_options = CompileOptions { show_ssa, allow_warnings: false, show_output: false }; + match prove_cmd::prove_with_path( Some(proof_name.to_owned()), prg_dir, &tmp_dir.into_path(), None, true, - show_ssa, - false, + &compile_options, ) { Ok(_) => true, Err(error) => { diff --git a/crates/nargo/src/cli/prove_cmd.rs b/crates/nargo/src/cli/prove_cmd.rs index 6fcac9aa692..02bad3a301d 100644 --- a/crates/nargo/src/cli/prove_cmd.rs +++ b/crates/nargo/src/cli/prove_cmd.rs @@ -3,6 +3,7 @@ use std::path::{Path, PathBuf}; use acvm::ProofSystemCompiler; use clap::Args; use noirc_abi::input_parser::Format; +use noirc_driver::CompileOptions; use super::fs::{ inputs::{read_inputs_from_file, write_inputs_to_file}, @@ -30,13 +31,8 @@ pub(crate) struct ProveCommand { #[arg(short, long)] verify: bool, - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, - - /// Emit debug information for the intermediate SSA IR - #[arg(short, long)] - show_ssa: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: ProveCommand, config: NargoConfig) -> Result<(), CliError> { @@ -58,8 +54,7 @@ pub(crate) fn run(args: ProveCommand, config: NargoConfig) -> Result<(), CliErro proof_dir, circuit_build_path, args.verify, - args.show_ssa, - args.allow_warnings, + &args.compile_options, )?; Ok(()) @@ -71,8 +66,7 @@ pub(crate) fn prove_with_path>( proof_dir: P, circuit_build_path: Option, check_proof: bool, - show_ssa: bool, - allow_warnings: bool, + compile_options: &CompileOptions, ) -> Result, CliError> { let (compiled_program, proving_key, verification_key) = match circuit_build_path { Some(circuit_build_path) => { @@ -83,11 +77,8 @@ pub(crate) fn prove_with_path>( (compiled_program, proving_key, verification_key) } None => { - let compiled_program = super::compile_cmd::compile_circuit( - program_dir.as_ref(), - show_ssa, - allow_warnings, - )?; + let compiled_program = + super::compile_cmd::compile_circuit(program_dir.as_ref(), compile_options)?; let backend = crate::backends::ConcreteBackend; let (proving_key, verification_key) = backend.preprocess(&compiled_program.circuit); diff --git a/crates/nargo/src/cli/test_cmd.rs b/crates/nargo/src/cli/test_cmd.rs index 3d0aa719691..65e997c53a8 100644 --- a/crates/nargo/src/cli/test_cmd.rs +++ b/crates/nargo/src/cli/test_cmd.rs @@ -2,7 +2,7 @@ use std::{collections::BTreeMap, io::Write, path::Path}; use acvm::{PartialWitnessGenerator, ProofSystemCompiler}; use clap::Args; -use noirc_driver::Driver; +use noirc_driver::{CompileOptions, Driver}; use noirc_frontend::node_interner::FuncId; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; @@ -16,33 +16,27 @@ pub(crate) struct TestCommand { /// If given, only tests with names containing this string will be run test_name: Option, - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, - - /// Display output of println statements during tests - #[arg(long)] - show_logs: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError> { let test_name: String = args.test_name.unwrap_or_else(|| "".to_owned()); - run_tests(&config.program_dir, &test_name, args.allow_warnings, args.show_logs) + run_tests(&config.program_dir, &test_name, &args.compile_options) } fn run_tests( program_dir: &Path, test_name: &str, - allow_warnings: bool, - show_output: bool, + compile_options: &CompileOptions, ) -> Result<(), CliError> { let backend = crate::backends::ConcreteBackend; let mut driver = Resolver::resolve_root_config(program_dir, backend.np_language())?; add_std_lib(&mut driver); - if driver.check_crate(allow_warnings).is_err() { + if driver.check_crate(compile_options).is_err() { std::process::exit(1); } @@ -58,7 +52,7 @@ fn run_tests( writeln!(writer, "Testing {test_name}...").expect("Failed to write to stdout"); writer.flush().ok(); - match run_test(test_name, test_function, &driver, allow_warnings, show_output) { + match run_test(test_name, test_function, &driver, compile_options) { Ok(_) => { writer.set_color(ColorSpec::new().set_fg(Some(Color::Green))).ok(); writeln!(writer, "ok").ok(); @@ -87,13 +81,12 @@ fn run_test( test_name: &str, main: FuncId, driver: &Driver, - allow_warnings: bool, - show_output: bool, + config: &CompileOptions, ) -> Result<(), CliError> { let backend = crate::backends::ConcreteBackend; let program = driver - .compile_no_check(false, allow_warnings, Some(main), show_output) + .compile_no_check(config, Some(main)) .map_err(|_| CliError::Generic(format!("Test '{test_name}' failed to compile")))?; let mut solved_witness = BTreeMap::new(); diff --git a/crates/nargo/src/cli/verify_cmd.rs b/crates/nargo/src/cli/verify_cmd.rs index 829f1ee61f7..66a1214da52 100644 --- a/crates/nargo/src/cli/verify_cmd.rs +++ b/crates/nargo/src/cli/verify_cmd.rs @@ -10,7 +10,7 @@ use crate::{ use acvm::ProofSystemCompiler; use clap::Args; use noirc_abi::input_parser::{Format, InputValue}; -use noirc_driver::CompiledProgram; +use noirc_driver::{CompileOptions, CompiledProgram}; use std::path::{Path, PathBuf}; /// Given a proof and a program, verify whether the proof is valid @@ -22,9 +22,8 @@ pub(crate) struct VerifyCommand { /// The name of the circuit build files (ACIR, proving and verification keys) circuit_name: Option, - /// Issue a warning for each unused variable instead of an error - #[arg(short, long)] - allow_warnings: bool, + #[clap(flatten)] + compile_options: CompileOptions, } pub(crate) fn run(args: VerifyCommand, config: NargoConfig) -> Result<(), CliError> { @@ -40,15 +39,14 @@ pub(crate) fn run(args: VerifyCommand, config: NargoConfig) -> Result<(), CliErr circuit_build_path }); - verify_with_path(config.program_dir, proof_path, circuit_build_path, false, args.allow_warnings) + verify_with_path(config.program_dir, proof_path, circuit_build_path, args.compile_options) } fn verify_with_path>( program_dir: P, proof_path: PathBuf, circuit_build_path: Option

, - show_ssa: bool, - allow_warnings: bool, + compile_options: CompileOptions, ) -> Result<(), CliError> { let (compiled_program, verification_key) = match circuit_build_path { Some(circuit_build_path) => { @@ -59,7 +57,7 @@ fn verify_with_path>( (compiled_program, verification_key) } None => { - let compiled_program = compile_circuit(program_dir.as_ref(), show_ssa, allow_warnings)?; + let compiled_program = compile_circuit(program_dir.as_ref(), &compile_options)?; let backend = crate::backends::ConcreteBackend; let (_, verification_key) = backend.preprocess(&compiled_program.circuit); diff --git a/crates/noirc_driver/Cargo.toml b/crates/noirc_driver/Cargo.toml index c0c459749f1..91e391697bb 100644 --- a/crates/noirc_driver/Cargo.toml +++ b/crates/noirc_driver/Cargo.toml @@ -7,6 +7,7 @@ edition.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap.workspace = true noirc_errors.workspace = true noirc_frontend.workspace = true noirc_evaluator.workspace = true diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index d898a0ae1c7..79620897412 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -3,6 +3,7 @@ #![warn(unreachable_pub)] use acvm::Language; +use clap::Args; use fm::FileType; use noirc_abi::FunctionSignature; use noirc_errors::{reporter, ReportedError}; @@ -22,6 +23,21 @@ pub struct Driver { language: Language, } +#[derive(Args, Clone, Debug, Default)] +pub struct CompileOptions { + /// Emit debug information for the intermediate SSA IR + #[arg(short, long)] + pub show_ssa: bool, + + /// Issue a warning for each unused variable instead of an error + #[arg(short, long)] + pub allow_warnings: bool, + + /// Display output of `println` statements during tests + #[arg(long)] + pub show_output: bool, +} + impl Driver { pub fn new(np_language: &Language) -> Self { let mut driver = Driver { context: Context::default(), language: np_language.clone() }; @@ -35,7 +51,9 @@ impl Driver { let mut driver = Driver::new(&np_language); driver.create_local_crate(root_file, CrateType::Binary); - driver.into_compiled_program(false, false).unwrap_or_else(|_| std::process::exit(1)) + driver + .into_compiled_program(&CompileOptions::default()) + .unwrap_or_else(|_| std::process::exit(1)) } /// Compiles a file and returns true if compilation was successful @@ -122,10 +140,11 @@ impl Driver { /// Run the lexing, parsing, name resolution, and type checking passes, /// returning Err(FrontendError) and printing any errors that were found. - pub fn check_crate(&mut self, allow_warnings: bool) -> Result<(), ReportedError> { + pub fn check_crate(&mut self, options: &CompileOptions) -> Result<(), ReportedError> { let mut errs = vec![]; CrateDefMap::collect_defs(LOCAL_CRATE, &mut self.context, &mut errs); - let error_count = reporter::report_all(&self.context.file_manager, &errs, allow_warnings); + let error_count = + reporter::report_all(&self.context.file_manager, &errs, options.allow_warnings); reporter::finish_report(error_count) } @@ -141,22 +160,19 @@ impl Driver { pub fn into_compiled_program( mut self, - show_ssa: bool, - allow_warnings: bool, + options: &CompileOptions, ) -> Result { - self.check_crate(allow_warnings)?; - self.compile_no_check(show_ssa, allow_warnings, None, true) + self.check_crate(options)?; + self.compile_no_check(options, None) } /// Compile the current crate. Assumes self.check_crate is called beforehand! #[allow(deprecated)] pub fn compile_no_check( &self, - show_ssa: bool, - allow_warnings: bool, + options: &CompileOptions, // Optional override to provide a different `main` function to start execution main_function: Option, - show_output: bool, ) -> Result { // Find the local crate, one should always be present let local_crate = self.context.def_map(LOCAL_CRATE).unwrap(); @@ -179,14 +195,20 @@ impl Driver { let np_language = self.language.clone(); let blackbox_supported = acvm::default_is_black_box_supported(np_language.clone()); - match create_circuit(program, np_language, blackbox_supported, show_ssa, show_output) { + match create_circuit( + program, + np_language, + blackbox_supported, + options.show_ssa, + options.show_output, + ) { Ok((circuit, abi)) => Ok(CompiledProgram { circuit, abi }), Err(err) => { // The FileId here will be the file id of the file with the main file // Errors will be shown at the call site without a stacktrace let file = err.location.map(|loc| loc.file); let files = &self.context.file_manager; - let error = reporter::report(files, &err.into(), file, allow_warnings); + let error = reporter::report(files, &err.into(), file, options.allow_warnings); reporter::finish_report(error as u32)?; Err(ReportedError) } diff --git a/crates/noirc_driver/src/main.rs b/crates/noirc_driver/src/main.rs index e7f99ced95f..98a51780854 100644 --- a/crates/noirc_driver/src/main.rs +++ b/crates/noirc_driver/src/main.rs @@ -1,4 +1,4 @@ -use noirc_driver::Driver; +use noirc_driver::{CompileOptions, Driver}; use noirc_frontend::graph::{CrateType, LOCAL_CRATE}; fn main() { const EXTERNAL_DIR: &str = "dep_b/lib.nr"; @@ -18,5 +18,6 @@ fn main() { driver.add_dep(LOCAL_CRATE, crate_id1, "coo4"); driver.add_dep(LOCAL_CRATE, crate_id2, "coo3"); - driver.into_compiled_program(false, false).ok(); + let config = CompileOptions::default(); + driver.into_compiled_program(&config).ok(); }