run_make_support/external_deps/c_cxx_compiler/
gcc.rs
1use std::path::Path;
2
3use crate::command::Command;
4
5#[track_caller]
9pub fn gcc() -> Gcc {
10 Gcc::new()
11}
12
13#[derive(Debug)]
15#[must_use]
16pub struct Gcc {
17 cmd: Command,
18}
19
20crate::macros::impl_common_helpers!(Gcc);
21
22impl Gcc {
23 #[track_caller]
28 pub fn new() -> Self {
29 let cmd = Command::new("gcc");
30 Self { cmd }
31 }
32
33 pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
35 self.cmd.arg(path.as_ref());
36 self
37 }
38
39 pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
42 self.cmd.arg("-L");
43 self.cmd.arg(path.as_ref());
44 self
45 }
46
47 pub fn out_exe(&mut self, name: &str) -> &mut Self {
49 self.cmd.arg("-o");
50 self.cmd.arg(name);
51 self
52 }
53
54 pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
56 self.cmd.arg("-o");
57 self.cmd.arg(path.as_ref());
58 self
59 }
60
61 pub fn optimize(&mut self) -> &mut Self {
63 self.cmd.arg("-O3");
64 self
65 }
66}