Перенос.

This commit is contained in:
2023-09-17 22:13:42 +03:00
parent dd2e0ca7e0
commit 629d8b8477
1239 changed files with 61161 additions and 1 deletions

View File

@@ -0,0 +1,110 @@
package GlobalData.Tasks.CompilationTask;
import Common.Current;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Makefile.Makefile;
import GlobalData.Module.Module;
import GlobalData.Tasks.RunTask.RunTask;
import GlobalData.Tasks.Task;
import ProjectData.Files.DBProjectFile;
import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import com.sun.org.glassfish.gmbal.Description;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.LinkedHashMap;
public class CompilationTask extends Task {
public int makefile_id = Utils.Nan;
public String binary_name = ""; //исполняемый файл.
//---------------------------------------------------
@Description("DEFAULT ''")
public String linkerDescription = "";
@Description("DEFAULT ''")
public String linkFlags = "";
//для отображения.
//-------------------
@Description("DEFAULT ''")
public String fortranCompilerDescription = "";
@Description("DEFAULT ''")
public String fortranFlags = "";
//-------------------
@Description("DEFAULT ''")
public String cCompilerDescription = "";
@Description("DEFAULT ''")
public String cFlags = "";
//------------------
@Description("DEFAULT ''")
public String cppCompilerDescription = "";
@Description("DEFAULT ''")
public String cppFlags = "";
//---------------------------------------------------
public void CompleteSummary(int maxtime_in) throws Exception {
maxtime = maxtime_in;
Makefile makefile = getMakefile();
LinkedHashMap<LanguageName, Module> modules = makefile.getModules();
linkerDescription = makefile.getCompilerDescription();
linkFlags = makefile.flags;
for (Module module : modules.values()) {
switch (module.language) {
case fortran:
fortranCompilerDescription = module.getCompilerDescription();
fortranFlags = module.flags;
break;
case c:
cCompilerDescription = module.getCompilerDescription();
cFlags = module.flags;
break;
case cpp:
cppCompilerDescription = module.getCompilerDescription();
cppFlags = module.flags;
break;
}
}
Global.db.Update(this);
}
//---------------------------------------------------
@Override
public File getHome() {
return Global.CompilationTasksDirectory;
}
@Override
public boolean isVisible() {
return
Current.CheckID(Current.Machine, machine_id) &&
Current.CheckID(Current.User, user_id) &&
Current.HasProject() &&
belongsToProject(Current.getProject());
}
public Makefile getMakefile() {
return Global.db.getById(Makefile.class, makefile_id);
}
@Override
public String getFullCommand() {
return "make -j -f Makefile";
}
public LinkedHashMap<Integer, RunTask> getRunTasks() {
LinkedHashMap<Integer, RunTask> res = new LinkedHashMap<>();
//так не получится. не правильно назвал ключевое поле. F...
// return Global.db.getMapByFKi(this, RunTask.class);
for (RunTask runTask : Global.db.runTasks.Data.values()) {
if (runTask.compilation_task_id == id)
res.put(runTask.id, runTask);
}
return res;
}
@Override
public void AnalyzeResultsTexts(db_project_info project) throws Exception {
String output = getOutput();
String errors = getErrors();
for (DBProjectFile file : project.db.files.Data.values()) {
if (!file.last_assembly_name.isEmpty()) {
String replacement = file.last_assembly_name + " " + Utils.RBrackets(file.name);
output = output.replace(file.last_assembly_name, replacement);
errors = errors.replace(file.last_assembly_name, replacement);
}
}
FileUtils.writeStringToFile(getOutputFile(), output);
FileUtils.writeStringToFile(getErrorsFile(), errors);
}
}

View File

@@ -0,0 +1,120 @@
package GlobalData.Tasks.CompilationTask;
import Common.Current;
import Common.Database.*;
import Common.UI.DataSetControlForm;
import Common.UI.Menus.TableMenu;
import Common.UI.UI;
import GlobalData.Tasks.RunTask.RunTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import java.util.LinkedHashMap;
import static Common.UI.Tables.TableRenderers.RendererDate;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class CompilationTasksDBTable extends iDBTable<CompilationTask> {
public CompilationTasksDBTable() {
super(CompilationTask.class);
}
@Override
public String getSingleDescription() {
return "задача на компиляцию";
}
@Override
public String getPluralDescription() {
return "задачи на компиляцию";
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(RunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(12).setRenderer(RendererDate);
columns.get(13).setRenderer(RendererStatusEnum);
}
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getMainWindow().getTestingWindow().DropRunTasksComparison();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getMainWindow().getTestingWindow().DropRunTasksComparison();
}
@Override
public void CreateControl() {
super.CreateControl();
TableMenu dataTableMenu = new TableMenu(control);
dataTableMenu.add(Pass_2021.passes.get(PassCode_2021.DeleteSelectedCompilationTasks).createMenuItem());
control.setComponentPopupMenu(dataTableMenu);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"сборка",
"",
//
"Fortran",
"",
//
"С",
"",
//
"С++",
"",
"Лимит(c)",
"Время(c)",
"Дата",
"Статус"
};
}
@Override
public Object getFieldAt(CompilationTask object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.linkerDescription;
case 3:
return object.linkFlags;
case 4:
return object.fortranCompilerDescription;
case 5:
return object.fortranFlags;
case 6:
return object.cCompilerDescription;
case 7:
return object.cFlags;
case 8:
return object.cppCompilerDescription;
case 9:
return object.cppFlags;
case 10:
return object.maxtime;
case 11:
return object.Time;
case 12:
return object.getEndDate();
case 13:
return object.state;
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.CompilationTask;
}
}