1
- use std:: path:: PathBuf ;
2
-
3
1
#[ derive( Clone ) ]
4
2
pub struct CompilationCommandBuilder {
5
3
compiler : String ,
@@ -9,7 +7,6 @@ pub struct CompilationCommandBuilder {
9
7
optimization : String ,
10
8
include_paths : Vec < String > ,
11
9
project_root : Option < String > ,
12
- output : String ,
13
10
linker : Option < String > ,
14
11
extra_flags : Vec < String > ,
15
12
}
@@ -24,7 +21,6 @@ impl CompilationCommandBuilder {
24
21
optimization : "2" . to_string ( ) ,
25
22
include_paths : Vec :: new ( ) ,
26
23
project_root : None ,
27
- output : String :: new ( ) ,
28
24
linker : None ,
29
25
extra_flags : Vec :: new ( ) ,
30
26
}
@@ -91,10 +87,10 @@ impl CompilationCommandBuilder {
91
87
#[ allow( clippy:: large_enum_variant) ]
92
88
pub enum CompilationCommand {
93
89
Simple ( std:: process:: Command ) ,
90
+ #[ allow( unused) ]
94
91
CustomLinker {
95
92
cmd : std:: process:: Command ,
96
93
linker : std:: process:: Command ,
97
- cleanup : PathBuf ,
98
94
} ,
99
95
}
100
96
@@ -112,12 +108,9 @@ impl CompilationCommand {
112
108
CompilationCommand :: CustomLinker {
113
109
mut cmd,
114
110
mut linker,
115
- cleanup,
116
111
} => {
117
112
let output = cmd. output ( ) ?;
118
113
119
- linker. current_dir ( "c_programs" ) ;
120
-
121
114
if log:: log_enabled!( log:: Level :: Trace ) {
122
115
linker. stdout ( std:: process:: Stdio :: inherit ( ) ) ;
123
116
linker. stderr ( std:: process:: Stdio :: inherit ( ) ) ;
@@ -129,9 +122,9 @@ impl CompilationCommand {
129
122
linker. get_program( ) ,
130
123
) ;
131
124
}
132
- if cleanup. exists ( ) {
133
- std:: fs:: remove_file ( cleanup) ?;
134
- }
125
+ // if cleanup.exists() {
126
+ // std::fs::remove_file(cleanup)?;
127
+ // }
135
128
136
129
Ok ( output)
137
130
}
@@ -141,8 +134,8 @@ impl CompilationCommand {
141
134
142
135
impl CompilationCommandBuilder {
143
136
pub fn into_command ( self ) -> CompilationCommand {
144
- let project_root = self . project_root . unwrap_or_default ( ) ;
145
- let project_root_str = project_root. as_str ( ) ;
137
+ // let project_root = self.project_root.unwrap_or_default();
138
+ // let project_root_str = project_root.as_str();
146
139
147
140
let mut cmd = std:: process:: Command :: new ( self . compiler ) ;
148
141
@@ -159,28 +152,27 @@ impl CompilationCommandBuilder {
159
152
cmd. arg ( format ! ( "--target={target}" ) ) ;
160
153
}
161
154
162
- if let ( Some ( linker ) , Some ( cxx_toolchain_dir) ) = ( & self . linker , & self . cxx_toolchain_dir ) {
155
+ if let ( Some ( _linker ) , Some ( cxx_toolchain_dir) ) = ( & self . linker , & self . cxx_toolchain_dir ) {
163
156
cmd. arg ( "-c" ) ;
164
157
cmd. args (
165
158
self . include_paths
166
159
. iter ( )
167
160
. map ( |path| "--include-directory=" . to_string ( ) + cxx_toolchain_dir + path) ,
168
161
) ;
169
162
170
- let output = "dummy_value" ;
171
- let mut linker_cmd = std:: process:: Command :: new ( linker) ;
172
- linker_cmd. arg ( format ! ( "{project_root_str}/{output}" ) ) ;
163
+ // let linker_cmd = std::process::Command::new(linker);
164
+ // linker_cmd.arg(format!("{project_root_str}/{output}"));
173
165
174
- linker_cmd . arg ( "-o" ) ;
175
- linker_cmd . arg ( format ! ( "{project_root_str}/{}" , self . output ) ) ;
166
+ // let remove_path = PathBuf::new( );
167
+ // PathBuf::from (format!("{project_root_str}/{output}" ));
176
168
177
- let remove_path = PathBuf :: from ( format ! ( "{project_root_str}/{output}" ) ) ;
169
+ // CompilationCommand::CustomLinker {
170
+ // cmd,
171
+ // linker: linker_cmd,
172
+ // // cleanup: remove_path,
173
+ // }
178
174
179
- CompilationCommand :: CustomLinker {
180
- cmd,
181
- linker : linker_cmd,
182
- cleanup : remove_path,
183
- }
175
+ CompilationCommand :: Simple ( cmd)
184
176
} else {
185
177
CompilationCommand :: Simple ( cmd)
186
178
}
0 commit comments