Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Add CLI option to filter by contract function name #7018

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ pub struct CompileOptions {
#[arg(long, hide = true)]
pub show_ssa_pass_name: Option<String>,

/// Only show the SSA and ACIR for the contract function with a given name.
#[arg(long, hide = true)]
pub show_contract_function_name: Option<String>,
aakoshh marked this conversation as resolved.
Show resolved Hide resolved

/// Emit the unoptimized SSA IR to file.
/// The IR will be dumped into the workspace target directory,
/// under `[compiled-package].ssa.json`.
Expand Down Expand Up @@ -442,6 +446,11 @@ pub fn compile_contract(

if options.print_acir {
for contract_function in &compiled_contract.functions {
if let Some(ref name) = options.show_contract_function_name {
if name != &contract_function.name {
continue;
}
}
println!(
"Compiled ACIR for {}::{} (unoptimized):",
compiled_contract.name, contract_function.name
Expand Down Expand Up @@ -486,7 +495,15 @@ fn compile_contract_inner(
continue;
}

let function = match compile_no_check(context, options, function_id, None, true) {
let mut options = options.clone();

if let Some(ref name_filter) = options.show_contract_function_name {
let show = name == *name_filter;
options.show_ssa &= show;
options.show_ssa_pass_name = options.show_ssa_pass_name.filter(|_| show);
};

let function = match compile_no_check(context, &options, function_id, None, true) {
Ok(function) => function,
Err(new_error) => {
errors.push(FileDiagnostic::from(new_error));
Expand Down
Loading