Skip to content

Commit c1806bc

Browse files
Updating dependencies and compiling to wait forever with logs
1 parent 3ece141 commit c1806bc

File tree

2 files changed

+118
-69
lines changed

2 files changed

+118
-69
lines changed

Src/runcpp2/CompilingLinking.cpp

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ namespace
216216
std::unordered_map<std::string, std::vector<std::string>> substitutionMap;
217217
substitutionMap = substitutionMapTemplate;
218218
std::vector<std::future<bool>> actions;
219+
std::vector<bool> finished;
219220

220221
//Cache logs for worker threads
221222
ssLOG_ENABLE_CACHE_OUTPUT_FOR_NEW_THREADS();
@@ -235,6 +236,7 @@ namespace
235236
ssLOG_ERROR("Failed to get relative path for " << currentSource);
236237
ssLOG_ERROR("Failed with error: " << e.message());
237238
actions.emplace_back(std::async(std::launch::deferred, []{return false;}));
239+
finished.emplace_back(false);
238240
continue;
239241
}
240242

@@ -260,6 +262,7 @@ namespace
260262
ssLOG_ERROR("profile " << profile.Name << " missing extension for " <<
261263
"object link file");
262264
actions.emplace_back(std::async(std::launch::deferred, []{return false;}));
265+
finished.emplace_back(false);
263266
continue;
264267
}
265268

@@ -273,6 +276,7 @@ namespace
273276
{
274277
ssLOG_ERROR("Failed to substitute \"" << currentPath << "\"");
275278
actions.emplace_back(std::async(std::launch::deferred, []{return false;}));
279+
finished.emplace_back(false);
276280
continue;
277281
}
278282

@@ -283,6 +287,7 @@ namespace
283287
ssLOG_ERROR("Failed to create directory structure for " << currentPath);
284288
ssLOG_ERROR("Failed with error: " << e.message());
285289
actions.emplace_back(std::async(std::launch::deferred, []{return false;}));
290+
finished.emplace_back(false);
286291
continue;
287292
}
288293

@@ -434,44 +439,58 @@ namespace
434439
}
435440
)
436441
); //actions.emplace_back
442+
finished.emplace_back(false);
437443

438444
//Evaluate the compile results for each batch for compilations
439445
if(actions.size() >= maxThreads || i == sourceFiles.size() - 1)
440446
{
441-
std::chrono::system_clock::time_point deadline =
442-
std::chrono::system_clock::now() + std::chrono::seconds(60);
443-
for(int j = 0; j < actions.size(); ++j)
447+
bool needsWaiting = false;
448+
do
444449
{
445-
if(!actions.at(j).valid())
450+
needsWaiting = false;
451+
std::chrono::system_clock::time_point deadline =
452+
std::chrono::system_clock::now() + std::chrono::seconds(60);
453+
for(int j = 0; j < actions.size(); ++j)
446454
{
447-
ssLOG_ERROR("Failed to construct actions for compiling");
448-
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
449-
return false;
450-
}
451-
452-
std::future_status actionStatus = actions.at(j).wait_until(deadline);
453-
bool result = false;
454-
455-
if( actionStatus == std::future_status::deferred ||
456-
actionStatus == std::future_status::ready)
457-
{
458-
result = actions.at(j).get();
459-
}
460-
else
461-
{
462-
ssLOG_ERROR("Compiling timeout");
463-
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
464-
failedAny = true;
465-
}
466-
467-
if(!result)
468-
{
469-
ssLOG_ERROR("Compiling Failed");
470-
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
471-
failedAny = true;
455+
if(finished.at(j))
456+
continue;
457+
458+
if(!actions.at(j).valid())
459+
{
460+
ssLOG_ERROR("Failed to construct actions for compiling");
461+
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
462+
return false;
463+
}
464+
465+
std::future_status actionStatus = actions.at(j).wait_until(deadline);
466+
bool result = false;
467+
468+
if( actionStatus == std::future_status::deferred ||
469+
actionStatus == std::future_status::ready)
470+
{
471+
result = actions.at(j).get();
472+
finished.at(j) = true;
473+
474+
if(!result)
475+
{
476+
ssLOG_ERROR("Compiling Failed");
477+
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
478+
failedAny = true;
479+
}
480+
}
481+
else
482+
{
483+
ssLOG_WARNING("Manual interrupt might be needed");
484+
ssLOG_WARNING("Waited 30 seconds, compiling still going...");
485+
needsWaiting = true;
486+
result = true;
487+
}
472488
}
473489
}
490+
while(needsWaiting);
491+
474492
actions.clear();
493+
finished.clear();
475494
}
476495
}
477496

Src/runcpp2/DependenciesHelper.cpp

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ bool runcpp2::SetupDependenciesIfNeeded(const runcpp2::Data::Profile& profile,
551551
return false;
552552

553553
std::vector<std::future<bool>> actions;
554+
std::vector<bool> finished;
554555

555556
//Cache logs for worker threads
556557
ssLOG_ENABLE_CACHE_OUTPUT_FOR_NEW_THREADS();
@@ -590,38 +591,52 @@ bool runcpp2::SetupDependenciesIfNeeded(const runcpp2::Data::Profile& profile,
590591
)
591592
);
592593

594+
finished.emplace_back(false);
595+
593596
//Evaluate the setup results for each batch
594597
if(actions.size() >= maxThreads || i == availableDependencies.size() - 1)
595598
{
596-
std::chrono::system_clock::time_point deadline =
597-
std::chrono::system_clock::now() + std::chrono::seconds(60);
598-
for(int j = 0; j < actions.size(); ++j)
599+
bool needsWaiting = false;
600+
do
599601
{
600-
if(!actions.at(j).valid())
601-
{
602-
ssLOG_ERROR("Failed to construct actions for setup");
603-
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
604-
return false;
605-
}
606-
607-
std::future_status actionStatus = actions.at(j).wait_until(deadline);
608-
if(actionStatus == std::future_status::ready)
602+
std::chrono::system_clock::time_point deadline =
603+
std::chrono::system_clock::now() + std::chrono::seconds(30);
604+
needsWaiting = false;
605+
for(int j = 0; j < actions.size(); ++j)
609606
{
610-
if(!actions.at(j).get())
607+
if(finished.at(j))
608+
continue;
609+
610+
if(!actions.at(j).valid())
611611
{
612-
ssLOG_ERROR("Setup failed for dependencies");
612+
ssLOG_ERROR("Failed to construct actions for setup");
613613
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
614614
return false;
615615
}
616-
}
617-
else
618-
{
619-
ssLOG_ERROR("Dependencies setup timeout");
620-
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
621-
return false;
616+
617+
std::future_status actionStatus = actions.at(j).wait_until(deadline);
618+
if(actionStatus == std::future_status::ready)
619+
{
620+
if(!actions.at(j).get())
621+
{
622+
ssLOG_ERROR("Setup failed for dependencies");
623+
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
624+
return false;
625+
}
626+
finished.at(j) = true;
627+
}
628+
else
629+
{
630+
ssLOG_WARNING("Manual interrupt might be needed");
631+
ssLOG_WARNING("Waited 30 seconds, dependencies setup still going...");
632+
needsWaiting = true;
633+
}
622634
}
623635
}
636+
while(needsWaiting);
637+
624638
actions.clear();
639+
finished.clear();
625640
}
626641
}
627642

@@ -642,6 +657,7 @@ bool runcpp2::BuildDependencies(const runcpp2::Data::Profile& profile,
642657
return true;
643658

644659
std::vector<std::future<bool>> actions;
660+
std::vector<bool> finished;
645661

646662
//Cache logs for worker threads
647663
ssLOG_ENABLE_CACHE_OUTPUT_FOR_NEW_THREADS();
@@ -674,38 +690,52 @@ bool runcpp2::BuildDependencies(const runcpp2::Data::Profile& profile,
674690
)
675691
);
676692

693+
finished.emplace_back(false);
694+
677695
//Evaluate the setup results for each batch
678696
if(actions.size() >= maxThreads || i == availableDependencies.size() - 1)
679697
{
680-
std::chrono::system_clock::time_point deadline =
681-
std::chrono::system_clock::now() + std::chrono::seconds(60);
682-
for(int j = 0; j < actions.size(); ++j)
698+
bool needsWaiting = false;
699+
do
683700
{
684-
if(!actions.at(j).valid())
685-
{
686-
ssLOG_ERROR("Failed to construct actions for building dependencies");
687-
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
688-
return false;
689-
}
690-
691-
std::future_status actionStatus = actions.at(j).wait_until(deadline);
692-
if(actionStatus == std::future_status::ready)
701+
std::chrono::system_clock::time_point deadline =
702+
std::chrono::system_clock::now() + std::chrono::seconds(30);
703+
needsWaiting = false;
704+
for(int j = 0; j < actions.size(); ++j)
693705
{
694-
if(!actions.at(j).get())
706+
if(finished.at(j))
707+
continue;
708+
709+
if(!actions.at(j).valid())
695710
{
696-
ssLOG_ERROR("Build failed for dependencies");
711+
ssLOG_ERROR("Failed to construct actions for building dependencies");
697712
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
698713
return false;
699714
}
700-
}
701-
else
702-
{
703-
ssLOG_ERROR("Dependencies build timeout");
704-
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
705-
return false;
715+
716+
std::future_status actionStatus = actions.at(j).wait_until(deadline);
717+
if(actionStatus == std::future_status::ready)
718+
{
719+
if(!actions.at(j).get())
720+
{
721+
ssLOG_ERROR("Build failed for dependencies");
722+
ssLOG_OUTPUT_ALL_CACHE_GROUPED();
723+
return false;
724+
}
725+
finished.at(j) = true;
726+
}
727+
else
728+
{
729+
ssLOG_WARNING("Manual interrupt might be needed");
730+
ssLOG_WARNING("Waited 30 seconds, dependencies build still going...");
731+
needsWaiting = true;
732+
}
706733
}
707734
}
735+
while(needsWaiting);
736+
708737
actions.clear();
738+
finished.clear();
709739
}
710740
}
711741

0 commit comments

Comments
 (0)