| 242 | } |
| 243 | |
| 244 | void ExecCompiler() { |
| 245 | int exitcode; |
| 246 | Int inputs; |
| 247 | StrArr *args = new StrArr(1); |
| 248 | switch (inputs = CInput->len() + CCInput->len()) { |
| 249 | case 0: |
| 250 | if (mode == COMP) |
| 251 | Error("no input files");; |
| 252 | break; |
| 253 | case 1: |
| 254 | break; |
| 255 | default: |
| 256 | Error("too many C/C++ input files"); |
| 257 | break; |
| 258 | } |
| 259 | switch (mode) { |
| 260 | case CPP: |
| 261 | PassThroughCompiler(); |
| 262 | break; |
| 263 | case COMP: |
| 264 | args->add(S("-c"))->add(CompArgs); |
| 265 | break; |
| 266 | case LINK: |
| 267 | args->add(LinkArgs); |
| 268 | break; |
| 269 | } |
| 270 | if (inputs) { |
| 271 | Str *cppOutput = RunCPP(); |
| 272 | const char *lang = CInput->len() == 1 ? "c" : "c++"; |
| 273 | args->add(S("-x"))->add(S(lang))->add(S("-")); |
| 274 | if (debug) { |
| 275 | printf("%s: %s %s\n", |
| 276 | mode == COMP ? "Compiler" : "Linker", |
| 277 | Compiler->c_str(), |
| 278 | StrJoin(args, " ")->c_str()); |
| 279 | if (debug >= 2) |
| 280 | Print(cppOutput); |
| 281 | fflush(stdout); |
| 282 | } |
| 283 | int success = WriteProcess(Compiler, args, cppOutput); |
| 284 | if (!success) |
| 285 | exit(1); |
| 286 | } else { |
| 287 | TestOutputExecutable(); |
| 288 | PassThroughCompiler(); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | INIT(Args, { |
| 293 | GCVar(Language); |
no test coverage detected