Skip to content

Commit 1dc14d9

Browse files
Make output_files a vector inside Session::new()
Signed-off-by: Tomas Fabrizio Orsi <[email protected]>
1 parent d7ab568 commit 1dc14d9

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

midenc-session/src/lib.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Session {
119119
pub fn new<I>(
120120
inputs: I,
121121
output_dir: Option<PathBuf>,
122-
output_file: Option<OutputFile>,
122+
output_files: Option<Vec<OutputFile>>,
123123
target_dir: PathBuf,
124124
options: Options,
125125
emitter: Option<Arc<dyn Emitter>>,
@@ -130,13 +130,13 @@ impl Session {
130130
{
131131
let inputs = inputs.into_iter().collect::<Vec<_>>();
132132

133-
Self::make(inputs, output_dir, output_file, target_dir, options, emitter, source_manager)
133+
Self::make(inputs, output_dir, output_files, target_dir, options, emitter, source_manager)
134134
}
135135

136136
fn make(
137137
inputs: Vec<InputFile>,
138138
output_dir: Option<PathBuf>,
139-
output_file: Option<OutputFile>,
139+
output_files: Option<Vec<OutputFile>>,
140140
target_dir: PathBuf,
141141
options: Options,
142142
emitter: Option<Arc<dyn Emitter>>,
@@ -156,9 +156,21 @@ impl Session {
156156
.unwrap_or("<unset>".to_string())
157157
);
158158
log::debug!(
159-
target: "driver",
160-
" | output_file = {}",
161-
output_file.as_ref().map(|of| of.to_string()).unwrap_or("<unset>".to_string())
159+
target: "driver",
160+
" | output_files = {}",
161+
output_files.as_ref()
162+
.map(|output_files| {
163+
output_files
164+
.iter()
165+
.map(|of| of.to_string())
166+
.reduce(|mut acc, e| {
167+
acc.push_str(", ");
168+
acc.push_str(e.as_str());
169+
acc
170+
})
171+
.unwrap_or("<unset>".to_string())
172+
})
173+
.unwrap_or("<unset>".to_string())
162174
);
163175
log::debug!(target: "driver", " | target_dir = {}", target_dir.display());
164176
}
@@ -168,6 +180,11 @@ impl Session {
168180
emitter.unwrap_or_else(|| options.default_emitter()),
169181
));
170182

183+
let output_file: Option<OutputFile> = if let Some(output_files) = output_files {
184+
output_files.into_iter().filter(|of| of.parent().is_some()).reduce(|acc, _| acc)
185+
} else {
186+
None
187+
};
171188
let output_dir = output_dir
172189
.as_deref()
173190
.or_else(|| output_file.as_ref().and_then(|of| of.parent()))

0 commit comments

Comments
 (0)