@@ -1356,6 +1356,51 @@ static void writeCompilationRecord(StringRef path, StringRef argsHash,
1356
1356
}
1357
1357
}
1358
1358
1359
+ static void writeInputJobsToFilelist (llvm::raw_fd_ostream &out, const Job *job,
1360
+ const file_types::ID infoType) {
1361
+ // FIXME: Duplicated from ToolChains.cpp.
1362
+ for (const Job *input : job->getInputs ()) {
1363
+ const CommandOutput &outputInfo = input->getOutput ();
1364
+ if (outputInfo.getPrimaryOutputType () == infoType) {
1365
+ for (auto &output : outputInfo.getPrimaryOutputFilenames ())
1366
+ out << output << " \n " ;
1367
+ } else {
1368
+ auto output = outputInfo.getAnyOutputForType (infoType);
1369
+ if (!output.empty ())
1370
+ out << output << " \n " ;
1371
+ }
1372
+ }
1373
+ }
1374
+ static void writeSourceInputActionsToFilelist (llvm::raw_fd_ostream &out,
1375
+ const Job *job,
1376
+ const ArgList &args) {
1377
+ // Ensure that -index-file-path works in conjunction with
1378
+ // -driver-use-filelists. It needs to be the only primary.
1379
+ if (Arg *A = args.getLastArg (options::OPT_index_file_path))
1380
+ out << A->getValue () << " \n " ;
1381
+ else {
1382
+ // The normal case for non-single-compile jobs.
1383
+ for (const Action *A : job->getSource ().getInputs ()) {
1384
+ // A could be a GeneratePCHJobAction
1385
+ if (!isa<InputAction>(A))
1386
+ continue ;
1387
+ const auto *IA = cast<InputAction>(A);
1388
+ out << IA->getInputArg ().getValue () << " \n " ;
1389
+ }
1390
+ }
1391
+ }
1392
+ static void writeOutputToFilelist (llvm::raw_fd_ostream &out, const Job *job,
1393
+ const file_types::ID infoType) {
1394
+ const CommandOutput &outputInfo = job->getOutput ();
1395
+ assert (outputInfo.getPrimaryOutputType () == infoType);
1396
+ for (auto &output : outputInfo.getPrimaryOutputFilenames ())
1397
+ out << output << " \n " ;
1398
+ }
1399
+ static void writeSupplementarOutputToFilelist (llvm::raw_fd_ostream &out,
1400
+ const Job *job) {
1401
+ job->getOutput ().writeOutputFileMap (out);
1402
+ }
1403
+
1359
1404
static bool writeFilelistIfNecessary (const Job *job, const ArgList &args,
1360
1405
DiagnosticEngine &diags) {
1361
1406
bool ok = true ;
@@ -1374,46 +1419,23 @@ static bool writeFilelistIfNecessary(const Job *job, const ArgList &args,
1374
1419
}
1375
1420
1376
1421
switch (filelistInfo.whichFiles ) {
1377
- case FilelistInfo::WhichFiles::Input:
1378
- // FIXME: Duplicated from ToolChains.cpp.
1379
- for (const Job *input : job->getInputs ()) {
1380
- const CommandOutput &outputInfo = input->getOutput ();
1381
- if (outputInfo.getPrimaryOutputType () == filelistInfo.type ) {
1382
- for (auto &output : outputInfo.getPrimaryOutputFilenames ())
1383
- out << output << " \n " ;
1384
- } else {
1385
- auto output = outputInfo.getAnyOutputForType (filelistInfo.type );
1386
- if (!output.empty ())
1387
- out << output << " \n " ;
1388
- }
1389
- }
1422
+ case FilelistInfo::WhichFiles::InputJobs:
1423
+ writeInputJobsToFilelist (out, job, filelistInfo.type );
1390
1424
break ;
1391
- case FilelistInfo::WhichFiles::PrimaryInputs:
1392
- // Ensure that -index-file-path works in conjunction with
1393
- // -driver-use-filelists. It needs to be the only primary.
1394
- if (Arg *A = args.getLastArg (options::OPT_index_file_path))
1395
- out << A->getValue () << " \n " ;
1396
- else {
1397
- // The normal case for non-single-compile jobs.
1398
- for (const Action *A : job->getSource ().getInputs ()) {
1399
- // A could be a GeneratePCHJobAction
1400
- if (!isa<InputAction>(A))
1401
- continue ;
1402
- const auto *IA = cast<InputAction>(A);
1403
- out << IA->getInputArg ().getValue () << " \n " ;
1404
- }
1405
- }
1425
+ case FilelistInfo::WhichFiles::SourceInputActions:
1426
+ writeSourceInputActionsToFilelist (out, job, args);
1406
1427
break ;
1407
- case FilelistInfo::WhichFiles::Output: {
1408
- const CommandOutput &outputInfo = job->getOutput ();
1409
- assert (outputInfo.getPrimaryOutputType () == filelistInfo.type );
1410
- for (auto &output : outputInfo.getPrimaryOutputFilenames ())
1411
- out << output << " \n " ;
1428
+ case FilelistInfo::WhichFiles::InputJobsAndSourceInputActions:
1429
+ writeInputJobsToFilelist (out, job, filelistInfo.type );
1430
+ writeSourceInputActionsToFilelist (out, job, args);
1412
1431
break ;
1413
- }
1414
- case FilelistInfo::WhichFiles::SupplementaryOutput:
1415
- job->getOutput ().writeOutputFileMap (out);
1432
+ case FilelistInfo::WhichFiles::Output: {
1433
+ writeOutputToFilelist (out, job, filelistInfo.type );
1416
1434
break ;
1435
+ }
1436
+ case FilelistInfo::WhichFiles::SupplementaryOutput:
1437
+ writeSupplementarOutputToFilelist (out, job);
1438
+ break ;
1417
1439
}
1418
1440
}
1419
1441
return ok;
0 commit comments