Skip to content

Commit 0e01bdb

Browse files
committed
Build: Automatically rebuild makefiles on "No rule to make target" error
1 parent 144fadd commit 0e01bdb

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

Tools/SC-build/Build.inl

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,37 @@ SC::Result SC::Build::Action::Internal::executeInternal(StringView workspaceName
12181218
}
12191219
else
12201220
{
1221-
SC_TRY(process.exec({arguments, numArgs}));
1222-
SC_TRY_MSG(process.getExitStatus() == 0, "Compile returned error");
1221+
String stdError;
1222+
SC_TRY(process.exec({arguments, numArgs}, {}, {}, stdError));
1223+
if (not stdError.isEmpty())
1224+
{
1225+
globalConsole->printError(stdError.view());
1226+
globalConsole->flushStdErr();
1227+
}
1228+
if (process.getExitStatus() == 0)
1229+
{
1230+
return Result(true);
1231+
}
1232+
else if (StringView(stdError.view()).startsWith("make: *** No rule to make target"))
1233+
{
1234+
globalConsole->print("Compile failed. Cleaning the project and trying again...\n");
1235+
globalConsole->flush();
1236+
arguments[1] = "clean";
1237+
Process cleanProcess;
1238+
SC_TRY(cleanProcess.exec({arguments, numArgs}));
1239+
if (cleanProcess.getExitStatus() == 0)
1240+
{
1241+
arguments[1] = targetName.view();
1242+
Process retryProcess;
1243+
SC_TRY(retryProcess.exec({arguments, numArgs}));
1244+
if (retryProcess.getExitStatus() == 0)
1245+
{
1246+
return Result(true);
1247+
}
1248+
}
1249+
return Result::Error("Compile returned error");
1250+
}
1251+
return Result::Error("Compile returned error");
12231252
}
12241253
}
12251254
break;

0 commit comments

Comments
 (0)