flycatcherc_link/lib.rs
1use std::process::Command;
2
3/// Options to configure the parser with.
4pub struct LinkerOptions {
5
6 /// The path of the executable that the linker will generate.
7 pub output_path: Option<String>,
8
9}
10
11/// Links a list of file paths with the chosen linker, which defaults to the GCC linker.
12/// Returns whether or not the linking process was successful.
13pub fn link(files: Vec<String>, options: LinkerOptions) -> bool {
14 let mut args = files;
15
16 if let Some(path) = options.output_path {
17 args.push("-o".into());
18 args.push(path);
19 }
20
21 let res = Command::new("gcc")
22 .args(&args[..])
23 .spawn()
24 .unwrap()
25 .wait()
26 .unwrap();
27
28 res.success()
29}