@@ -468,11 +468,6 @@ void updateCompatibilityVersionInfo(clang::tooling::UnifiedPath OutRoot,
468
468
const std::string CmakeHelpFile =
469
469
appendPath (OutRoot.getCanonicalPath ().str (), " dpct.cmake" );
470
470
std::ifstream InFile (CmakeHelpFile);
471
- if (!InFile) {
472
- std::string ErrMsg = " Failed to open file: " + CmakeHelpFile;
473
- ShowStatus (MigrationErrorReadWriteCMakeHelperFile, std::move (ErrMsg));
474
- dpctExit (MigrationErrorReadWriteCMakeHelperFile);
475
- }
476
471
477
472
const std::string VersionStr = Major + " ." + Minor;
478
473
const int CompatibilityValue = std::stoi (Major) * 10 + std::stoi (Minor);
@@ -516,24 +511,14 @@ void updateCompatibilityVersionInfo(clang::tooling::UnifiedPath OutRoot,
516
511
OutFile.close ();
517
512
}
518
513
519
- static void loadMainSrcFileInfo (clang::tooling::UnifiedPath OutRoot ) {
520
- std::string YamlFilePath = appendPath (OutRoot .getCanonicalPath (). str (),
521
- DpctGlobalInfo::getYamlFileName ()) ;
514
+ static void loadMainSrcFileInfo (clang::tooling::UnifiedPath YamlFilePath ) {
515
+ if (! llvm::sys::fs::exists (YamlFilePath .getCanonicalPath ()))
516
+ return ;
522
517
auto PreTU = std::make_shared<clang::tooling::TranslationUnitReplacements>();
523
- if (llvm::sys::fs::exists (YamlFilePath)) {
524
- if (loadFromYaml (YamlFilePath, *PreTU) != 0 ) {
525
- llvm::errs () << getLoadYamlFailWarning (YamlFilePath);
526
- }
527
-
528
- if (MigrateBuildScriptOnly && !DpctGlobalInfo::migratePythonScripts () ||
529
- DpctGlobalInfo::migrateCMakeScripts ()) {
530
- std::string Major = PreTU->SDKVersionMajor ;
531
- std::string Minor = PreTU->SDKVersionMinor ;
532
- if (!Major.empty () && !Minor.empty ()) {
533
- updateCompatibilityVersionInfo (OutRoot, Major, Minor);
534
- }
535
- }
518
+ if (loadFromYaml (YamlFilePath, *PreTU) != 0 ) {
519
+ llvm::errs () << getLoadYamlFailWarning ();
536
520
}
521
+ DpctGlobalInfo::setMainSourceYamlTUR (PreTU);
537
522
538
523
for (auto &Entry : PreTU->MainSourceFilesDigest ) {
539
524
if (Entry.HasCUDASyntax )
@@ -635,6 +620,12 @@ void showReportHeader() {
635
620
}
636
621
637
622
void checkIncMigrationOrExit () {
623
+ auto PreTU = DpctGlobalInfo::getMainSourceYamlTUR ();
624
+ if (!PreTU) {
625
+ PreTU = std::make_shared<clang::tooling::TranslationUnitReplacements>();
626
+ DpctGlobalInfo::setMainSourceYamlTUR (PreTU);
627
+ return ;
628
+ }
638
629
if (!MigrateBuildScriptOnly &&
639
630
clang::dpct::DpctGlobalInfo::isIncMigration ()) {
640
631
std::string Msg;
@@ -679,7 +670,6 @@ int migrateBuildScripts(const clang::tooling::UnifiedPath &InRoot,
679
670
}
680
671
681
672
void doBuildScriptMigration () {
682
- loadMainSrcFileInfo (OutRootPath);
683
673
collectBuildScripts (InRootPath, OutRootPath);
684
674
migrateBuildScripts (InRootPath, OutRootPath);
685
675
}
@@ -817,6 +807,9 @@ int runDPCT(int argc, const char **argv) {
817
807
std::string OutRootPathCUDACodepin = " " ;
818
808
CudaIncludePath = CudaInclude;
819
809
SDKPath = SDKPathOpt;
810
+
811
+ loadMainSrcFileInfo (OutRootPath.getCanonicalPath () + " /MainSourceFiles.yaml" );
812
+
820
813
std::transform (
821
814
RuleFile.begin (), RuleFile.end (),
822
815
std::back_insert_iterator<std::vector<clang::tooling::UnifiedPath>>(
@@ -1343,19 +1336,6 @@ int runDPCT(int argc, const char **argv) {
1343
1336
UseDPCPPExtensions.getNumOccurrences ());
1344
1337
setValueToOptMap (clang::dpct::OPTION_NoDRYPattern, NoDRYPattern.getValue (),
1345
1338
NoDRYPattern.getNumOccurrences ());
1346
- setValueToOptMap (clang::dpct::OPTION_CompilationsDir, CompilationsDir,
1347
- OptParser->isPSpecified ());
1348
- #ifdef _WIN32
1349
- if (!VcxprojFilePath.getPath ().empty ()) {
1350
- setValueToOptMap (clang::dpct::OPTION_VcxprojFile,
1351
- VcxprojFilePath.getCanonicalPath ().str (),
1352
- OptParser->isVcxprojfileSpecified ());
1353
- } else {
1354
- setValueToOptMap (clang::dpct::OPTION_VcxprojFile,
1355
- VcxprojFilePath.getPath ().str (),
1356
- OptParser->isVcxprojfileSpecified ());
1357
- }
1358
- #endif
1359
1339
setValueToOptMap (clang::dpct::OPTION_ProcessAll, ProcessAll.getValue (),
1360
1340
ProcessAll.getNumOccurrences ());
1361
1341
setValueToOptMap (clang::dpct::OPTION_SyclNamedLambda, SyclNamedLambda.getValue (),
@@ -1395,11 +1375,17 @@ int runDPCT(int argc, const char **argv) {
1395
1375
parseFormatStyle ();
1396
1376
}
1397
1377
// OC_Action: only migrate Build scripts.
1378
+ if (MigrateBuildScriptOnly && !DpctGlobalInfo::migratePythonScripts () ||
1379
+ DpctGlobalInfo::migrateCMakeScripts ()) {
1380
+ std::string Major = DpctGlobalInfo::getMainSourceYamlTUR ()->SDKVersionMajor ;
1381
+ std::string Minor = DpctGlobalInfo::getMainSourceYamlTUR ()->SDKVersionMinor ;
1382
+ if (!Major.empty () && !Minor.empty ()) {
1383
+ updateCompatibilityVersionInfo (OutRoot, Major, Minor);
1384
+ }
1385
+ }
1398
1386
if (MigrateBuildScriptOnly) {
1399
- loadMainSrcFileInfo (OutRootPath);
1400
1387
collectBuildScriptsSpecified (OptParser, InRootPath, OutRootPath);
1401
1388
migrateBuildScripts (InRootPath, OutRootPath);
1402
-
1403
1389
ShowStatus (MigrationBuildScriptCompleted);
1404
1390
dpctExit (MigrationSucceeded, false );
1405
1391
}
0 commit comments