2023-09-17 22:13:42 +03:00
|
|
|
|
package GlobalData.Tasks.Supervisor.Remote;
|
2024-03-27 00:28:04 +03:00
|
|
|
|
import Common.UI.UI;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import Common.Utils.Utils;
|
|
|
|
|
|
import GlobalData.Makefile.Makefile;
|
|
|
|
|
|
import GlobalData.RemoteFile.RemoteFile;
|
|
|
|
|
|
import GlobalData.Tasks.CompilationTask.CompilationTask;
|
|
|
|
|
|
import GlobalData.Tasks.TaskState;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
public class RemoteCompilationSupervisor extends RemoteTaskSupervisor<CompilationTask> {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void PrepareWorkspace() throws Exception {
|
|
|
|
|
|
//0. если нет папки с его именем создаем.
|
2024-01-08 20:37:16 +03:00
|
|
|
|
pass.user.connection.MKDIR(getRemoteProject());
|
|
|
|
|
|
pass.user.connection.SynchronizeProjectSubDirsR(project, project.Home, getRemoteProject(), false);
|
|
|
|
|
|
pass.user.connection.tryRM(getBinary());
|
2023-09-17 22:13:42 +03:00
|
|
|
|
if (!task.binary_name.isEmpty()) {
|
|
|
|
|
|
RemoteFile old_binary = new RemoteFile(getRemoteProject().full_name, task.binary_name);
|
2024-01-08 20:37:16 +03:00
|
|
|
|
pass.user.connection.tryRM(old_binary);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
//отправить мейкфайл.
|
|
|
|
|
|
Makefile makefile = task.getMakefile();
|
|
|
|
|
|
File makefile_text = Utils.CreateTempFile("makefile", makefile.Generate(project));
|
2024-01-08 20:37:16 +03:00
|
|
|
|
pass.user.connection.putSingleFile(makefile_text, new RemoteFile(getRemoteProject().full_name, "Makefile"));
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//очистить все что связано с gcov
|
|
|
|
|
|
//файлы gcda, gcno, gcov
|
2024-01-08 20:37:16 +03:00
|
|
|
|
pass.user.connection.deleteFilesByExtensions(getRemoteProject(), "gcda", "gcno", "gcov");
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//очистить служебные файлы.
|
|
|
|
|
|
super.PrepareWorkspace();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void StartTask() throws Exception {
|
2024-04-09 15:23:35 +03:00
|
|
|
|
task.PID = pass.user.connection.startProcess(getRemoteProject(), getStartCommand());
|
2024-01-08 20:37:16 +03:00
|
|
|
|
System.out.println("PID="+Utils.Brackets(task.PID));
|
2023-09-17 22:13:42 +03:00
|
|
|
|
task.state = TaskState.Running;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void ValidateTaskResults() throws Exception {
|
2024-01-08 20:37:16 +03:00
|
|
|
|
if (pass.user.connection.Exists(getBinary())) {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
RemoteFile renamed_binary = new RemoteFile(getRemoteProject().full_name, Utils.getDateName("spf_" + getBinary().name));
|
2024-01-08 20:37:16 +03:00
|
|
|
|
pass.user.connection.sftpChannel.rename(getBinary().full_name, renamed_binary.full_name);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
task.binary_name = renamed_binary.name;
|
|
|
|
|
|
task.state = TaskState.Done;
|
|
|
|
|
|
} else task.state = TaskState.DoneWithErrors;
|
|
|
|
|
|
task.AnalyzeResultsTexts(project);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|