(args: GenerateArgs)
| 83 | } |
| 84 | |
| 85 | fn generate(args: GenerateArgs) -> Result<()> { |
| 86 | let base_diff_config = diff::DiffObjConfig { |
| 87 | function_reloc_diffs: diff::FunctionRelocDiffs::None, |
| 88 | combine_data_sections: true, |
| 89 | combine_text_sections: true, |
| 90 | ppc_calculate_pool_relocations: false, |
| 91 | ..Default::default() |
| 92 | }; |
| 93 | |
| 94 | let output_format = OutputFormat::from_option(args.format.as_deref())?; |
| 95 | let project_dir = args.project.as_deref().unwrap_or_else(|| Utf8PlatformPath::new(".")); |
| 96 | info!("Loading project {}", project_dir); |
| 97 | |
| 98 | let project = match objdiff_core::config::try_project_config(project_dir.as_ref()) { |
| 99 | Some((Ok(config), _)) => config, |
| 100 | Some((Err(err), _)) => bail!("Failed to load project configuration: {}", err), |
| 101 | None => bail!("No project configuration found"), |
| 102 | }; |
| 103 | let target_obj_dir = |
| 104 | project.target_dir.as_ref().map(|p| project_dir.join(p.with_platform_encoding())); |
| 105 | let base_obj_dir = |
| 106 | project.base_dir.as_ref().map(|p| project_dir.join(p.with_platform_encoding())); |
| 107 | let project_units = project.units.as_deref().unwrap_or_default(); |
| 108 | let objects = project_units |
| 109 | .iter() |
| 110 | .enumerate() |
| 111 | .map(|(idx, o)| { |
| 112 | ( |
| 113 | ObjectConfig::new( |
| 114 | o, |
| 115 | project_dir, |
| 116 | target_obj_dir.as_deref(), |
| 117 | base_obj_dir.as_deref(), |
| 118 | ), |
| 119 | idx, |
| 120 | ) |
| 121 | }) |
| 122 | .collect::<Vec<_>>(); |
| 123 | info!( |
| 124 | "Generating report for {} units (using {} threads)", |
| 125 | objects.len(), |
| 126 | if args.deduplicate { 1 } else { rayon::current_num_threads() } |
| 127 | ); |
| 128 | |
| 129 | let start = Instant::now(); |
| 130 | let mut units = vec![]; |
| 131 | let mut existing_functions: HashSet<String> = HashSet::new(); |
| 132 | if args.deduplicate { |
| 133 | // If deduplicating, we need to run single-threaded |
| 134 | for (object, unit_idx) in &objects { |
| 135 | let diff_config = build_unit_diff_config( |
| 136 | &base_diff_config, |
| 137 | project.options.as_ref(), |
| 138 | project_units.get(*unit_idx).and_then(ProjectObject::options), |
| 139 | &args.config, |
| 140 | )?; |
| 141 | if let Some(unit) = report_object(object, &diff_config, Some(&mut existing_functions))? |
| 142 | { |
no test coverage detected