-
Notifications
You must be signed in to change notification settings - Fork 7
/
application_linker.rs
47 lines (43 loc) · 1.36 KB
/
application_linker.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::{command_runner, file_path_converter::FilePathConverter};
use std::{error::Error, sync::Arc};
pub struct ApplicationLinker {
file_path_converter: Arc<FilePathConverter>,
}
impl ApplicationLinker {
pub fn new(file_path_converter: Arc<FilePathConverter>) -> Self {
Self {
file_path_converter,
}
}
}
impl app::infra::ApplicationLinker for ApplicationLinker {
fn link(
&self,
object_files: &[app::infra::FilePath],
archive_files: &[app::infra::FilePath],
application_file: &app::infra::FilePath,
) -> Result<(), Box<dyn Error>> {
command_runner::run(
std::process::Command::new("clang")
.arg("-Werror")
.arg("-o")
.arg(
self.file_path_converter
.convert_to_os_path(application_file),
)
.args(
object_files
.iter()
.map(|file| self.file_path_converter.convert_to_os_path(file)),
)
.args(
archive_files
.iter()
.map(|file| self.file_path_converter.convert_to_os_path(file)),
)
.arg("-ldl")
.arg("-lpthread"),
)?;
Ok(())
}
}