Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/Compile.java

93 lines
3.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package Visual_DVM_2021.Passes.All;
import Common.CurrentAnchestor;
import Common.Utils.CommonUtils;
import Common_old.Current;
import Common_old.UI.UI;
import Common_old.Utils.Utils;
import GlobalData.GlobalDatabase;
import GlobalData.Tasks.CompilationTask.CompilationTask;
import GlobalData.Tasks.TaskState;
import GlobalData.User.UserState;
import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Pass_2021;
public class Compile extends Pass_2021<db_project_info> {
Pass_2021 subpass = null;
CompilationTask compilationTask = null;
@Override
protected PassCode_2021 necessary() {
return Current.getProject().languageName.equals(LanguageName.fortran) ? PassCode_2021.SPF_ParseFilesWithOrder : null;
}
@Override
public String getIconPath() {
return "/icons/Start.png";
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) {
if (CurrentAnchestor.Check(Log, Current.Project, Current.Machine, Current.User, Current.Makefile)) {
target = Current.getProject();
subpass = null;
compilationTask = null;
if (Current.getUser().state != UserState.ready_to_work)
Log.Writeln_("Пользователь " + CommonUtils.Brackets(Current.getUser().login) +
" не проинициализирован\ерейдите на вкладку 'Настройки компиляции и запуска',\n" +
" и выполните команду 'Инициализация пользователя'\n");
Current.getMakefile().Validate(Log);
return Log.isEmpty();
}
return false;
}
@Override
protected void performPreparation() throws Exception {
compilationTask = new CompilationTask();
compilationTask.machine_id = Current.getMachine().id;
compilationTask.user_id = Current.getUser().id;
compilationTask.makefile_id = Current.getMakefile().id;
compilationTask.project_path = target.Home.getAbsolutePath();
compilationTask.project_description = target.description;
//------------------------------------------
compilationTask.CompleteSummary(target.compilation_maxtime);
compilationTask.state = TaskState.Inactive;
CommonUtils.db.Insert(compilationTask);
Utils.forceDeleteWithCheck(compilationTask.getLocalWorkspace());
}
@Override
protected void showPreparation() throws Exception {
((GlobalDatabase)CommonUtils.db).compilationTasks.ShowUI(compilationTask.getPK());
}
@Override
protected void body() throws Exception {
switch (Current.getMachine().type) {
case Local:
if (CommonUtils.isWindows) {
subpass = passes.get(PassCode_2021.WindowsLocalCompilation);
} else
subpass = passes.get(PassCode_2021.LinuxLocalCompilation);
break;
case Undefined:
case MVS_cluster:
throw new PassException("Компиляция не реализована для типа машины " + CommonUtils.DQuotes(Current.getMachine().type));
default:
subpass = passes.get(PassCode_2021.RemoteCompilation);
break;
}
subpass.Do(Current.getCompilationTask(), Current.getProject());
}
@Override
protected boolean validate() {
return (subpass != null) && subpass.isDone();
}
@Override
protected void showFinish() throws Exception {
((GlobalDatabase)CommonUtils.db).compilationTasks.ShowUI(compilationTask.getPK());
UI.getDebugWindow().ShowLastCompilationTask();
}
}