Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/Compile.java
2024-10-09 23:37:58 +03:00

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.Current_;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import _VisualDVM.Visual.UI;
import _VisualDVM.Utils;
import _VisualDVM.GlobalData.GlobalDatabase;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import _VisualDVM.GlobalData.Tasks.TaskState;
import _VisualDVM.GlobalData.User.UserState;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.ProjectData.Project.db_project_info;
import Visual_DVM_2021.Passes.PassCode;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Pass;
public class Compile extends Pass<db_project_info> {
Pass subpass = null;
CompilationTask compilationTask = null;
@Override
protected PassCode necessary() {
return Current.getProject().languageName.equals(LanguageName.fortran) ? PassCode.SPF_ParseFilesWithOrder : null;
}
@Override
public String getIconPath() {
return "/icons/Start.png";
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) {
if (Current_.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.WindowsLocalCompilation);
} else
subpass = passes.get(PassCode.LinuxLocalCompilation);
break;
case Undefined:
case MVS_cluster:
throw new PassException("Компиляция не реализована для типа машины " + CommonUtils.DQuotes(Current.getMachine().type));
default:
subpass = passes.get(PassCode.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();
}
}