no message

This commit is contained in:
2024-10-09 22:21:57 +03:00
parent 54c80c516b
commit 6252af944e
699 changed files with 2634 additions and 1997 deletions

View File

@@ -0,0 +1,193 @@
package _VisualDVM.GlobalData.Compiler;
import Common.Utils.CommonUtils;
import _VisualDVM.Current;
import Common.Database.Objects.iDBObject;
import _VisualDVM.Validators.DVMHelpParser;
import _VisualDVM.GlobalData.CompilerEnvironment.CompilerEnvironmentsSet;
import _VisualDVM.GlobalData.CompilerOption.CompilerOptionsSet;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.LanguageName;
import com.sun.org.glassfish.gmbal.Description;
public class Compiler extends iDBObject {
public int machine_id = -1;
public String description = "";
public CompilerType type = CompilerType.dvm;
public String home_path = ""; //домашняя папка. нужна для двм компиляторов, в теории и для остальных может сгодиться, например для установки окружения ifort под виндой
public String call_command = ""; //непосредственно вызов компилятора.
public String version_command = "";//команда запроса версии компилятора.
public String help_command = "";// команда запроса help
public String version = "?";
public String revision = "?";
//-
@Description("IGNORE")
public boolean helpLoaded = false;
@Description("IGNORE")
public String helpText = "";
//-
@Description("IGNORE")
public boolean versionLoaded = false;
@Description("IGNORE")
public String versionText = "";
//-
public CompilerOptionsSet options = new CompilerOptionsSet();
public CompilerEnvironmentsSet environments = new CompilerEnvironmentsSet();
//-
public Compiler() {
}
public Compiler(Machine machine,
String description_in,
CompilerType type_in,
String call_command_in,
String version_command_in,
String help_command_in
) {
machine_id = machine.id;
description = description_in;
type = type_in;
call_command = call_command_in;
version_command = version_command_in;
help_command = help_command_in;
}
public void ResetHelp() {
helpLoaded = false;
helpText = "";
options.clear();
environments.clear();
}
public void ResetVersion() {
versionLoaded = false;
versionText = "";
}
public void ParseHelp() {
switch (type) {
case dvm:
DVMHelpParser.ReadOptions(this);
break;
default:
break;
}
}
public void ParseVersion() {
switch (type) {
case dvm:
String [] lines = versionText.split("\n");
if (lines.length>=3) {
String[] data = lines[2].split(" ");
if (data.length >= 4)
version = data[3].replace(",", "");
if (data.length >= 7) revision = data[6].replace(",", "");
}
break;
default:
break;
}
}
@Override
public boolean isVisible() {
return Current.HasMachine() && Current.getMachine().id == machine_id;
}
//todo понять как извлекать версию чтобы выдавать нормальную инфу.
@Override
public String toString() {
return call_command;
}
public String getStyleOptions(DBProjectFile program) {
String res = "";
switch (type) {
case gnu:
switch (program.languageName) {
case fortran:
switch (program.style) {
case free:
res = "-ffree-form";
break;
case extended:
res = "-ffixed-line-length-132";
break;
case fixed:
res = "-ffixed-form";
break;
case none:
break;
}
break;
}
break;
case dvm:
switch (program.languageName) {
case fortran:
switch (program.style) {
case fixed:
case extended:
res = "-FI";
break;
case free:
res = "-f90";
break;
case none:
break;
}
break;
}
break;
case intel:
switch (program.languageName) {
case fortran:
switch (program.style) {
case fixed:
case extended:
res = "-fixed";
break;
case free:
res = "-free";
break;
case none:
break;
}
break;
}
break;
}
return res;
}
//todo как то извлекать/заполнять версии компилятора?
public String getDescription() {
return description;
}
public String getSpecialLinkCommand(LanguageName languageName) {
switch (type) {
case dvm:
switch (languageName) {
case fortran:
return "flink";
case c:
return "clink";
}
break;
}
return "";
}
public String getSpecialCompilationCommand(LanguageName languageName) {
switch (type) {
case dvm:
switch (languageName) {
case fortran:
return "f";
case c:
return "c";
}
break;
}
return "";
}
public String getHelpCommand() {
return CommonUtils.DQuotes(call_command) + " " + help_command;
}
public String getVersionCommand() {
return CommonUtils.DQuotes(call_command) + " " + version_command;
}
public String getVersionInfo(){
return "v="+version+" r="+revision;
}
}

View File

@@ -0,0 +1,9 @@
package _VisualDVM.GlobalData.Compiler;
public enum CompilerType {
Undefined,
//----------------------
dvm,
mpi,
gnu,
intel
}

View File

@@ -0,0 +1,159 @@
package _VisualDVM.GlobalData.Compiler;
import Common.Utils.CommonUtils;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.DataSetControlForm;
import _VisualDVM.Visual.UI;
import Common.Visual.Windows.Dialog.DBObjectDialog;
import _VisualDVM.Utils;
import _VisualDVM.Validators.PathValidator;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import _VisualDVM.GlobalData.Compiler.UI.CompilerFields;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import java.util.LinkedHashMap;
public class CompilersDBTable extends iDBTable<Compiler> {
public CompilersDBTable() {
super(Compiler.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(Makefile.class, new FKBehaviour(FKDataBehaviour.DROP, FKCurrentObjectBehaviuor.PASSIVE));
res.put(Module.class, new FKBehaviour(FKDataBehaviour.DROP, FKCurrentObjectBehaviuor.PASSIVE));
res.put(RunConfiguration.class, new FKBehaviour(FKDataBehaviour.DROP, FKCurrentObjectBehaviuor.PASSIVE));
return res;
}
@Override
public DBObjectDialog<Compiler, CompilerFields> getDialog() {
return new DBObjectDialog<Compiler, CompilerFields>(CompilerFields.class) {
@Override
public void validateFields() {
//<editor-fold desc="расположение">
String home = fields.tfHome.getText();
if (!home.isEmpty()) {
if (home.startsWith("/")) {
if (CommonUtils.ContainsCyrillic(home))
Log.Writeln("Расположение компилятора не может содержать кириллицу");
else {
new PathValidator(home, "Расположение компилятора", Log).Validate();
}
} else
Log.Writeln("Расположение компилятора может быть либо пустой строкой, либо путём к файлу");
}
//</editor-fold>
//<editor-fold desc="команда вызова">
String call_command = fields.tfCallCommand.getText();
if (call_command.isEmpty())
Log.Writeln("Команда вызова компилятора не может быть пустой");
else if (CommonUtils.ContainsCyrillic(call_command))
Log.Writeln("Команда вызова компилятора не может содержать кириллицу");
else {
switch (call_command.charAt(0)) {
case ' ':
Log.Writeln("Команда вызова компилятора не может начинаться с пробела.");
break;
case '/':
if (call_command.endsWith("/"))
Log.Writeln("Каталог не может быть указан в качестве команды.");
else
new PathValidator(call_command, "Команда вызова компилятора", Log).Validate();
break;
default:
//это команда.
//самое опасное место. теоретически тут можно ввести любую команду ОС, в том числе rm -rf
if (call_command.contains(" "))
Log.Writeln("Прямая команда вызова не может содержать пробелы");
if (!call_command.contains("+")&& CommonUtils.ContainsForbiddenName(call_command))
Log.Writeln("Прямая команда вызова содержит запрещённые символы");
else {
if (Utils.isLinuxSystemCommand(call_command))
Log.Writeln(CommonUtils.DQuotes(call_command) + " является системной командой Linux");
}
break;
}
}
//</editor-fold>
}
@Override
public void fillFields() {
fields.tfDescription.setText(Result.description);
fields.tfCallCommand.setText(Result.call_command);
fields.tfHelpCommand.setText(Result.help_command);
fields.tfVersionCommand.setText(Result.version_command);
fields.tfHome.setText(Result.home_path);
CommonUI.TrySelect(fields.cbCompilerType, Result.type);
fields.events_on = true;
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.description = fields.tfDescription.getText();
Result.call_command = fields.tfCallCommand.getText();
Result.help_command = fields.tfHelpCommand.getText();
Result.version_command = fields.tfVersionCommand.getText();
Result.home_path = fields.tfHome.getText();
Result.type = (CompilerType) fields.cbCompilerType.getSelectedItem();
}
@Override
public int getDefaultHeight() {
return 300;
}
};
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getMainWindow().getTestingWindow().ShowCurrentCompiler();
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{"описание", "команда вызова", "версия", "ревизия"};
}
@Override
public Object getFieldAt(Compiler object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.description;
case 2:
return object.call_command;
case 3:
return object.version;
case 4:
return object.revision;
}
return null;
}
@Override
public Current CurrentName() {
return Current.Compiler;
}
}

View File

@@ -0,0 +1,13 @@
package _VisualDVM.GlobalData.Compiler;
import Common.Visual.Menus.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class CompilersMenuBar extends DataMenuBar {
public CompilersMenuBar() {
super("компиляторы",
PassCode_2021.AddCompiler,
PassCode_2021.EditCompiler,
PassCode_2021.DeleteCompiler,
PassCode_2021.ShowCompilerVersion,
PassCode_2021.ShowCompilerHelp);
}
}

View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.GlobalData.Compiler.UI.CompilerFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="87831" class="javax.swing.JTextField" binding="tfHome" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<vspacer id="44b33">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="627cc" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="расположение"/>
</properties>
</component>
<component id="48916" class="javax.swing.JButton" binding="bBrowse">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<icon value="icons/LastOpened.png"/>
<text value=""/>
</properties>
</component>
<component id="d58a0" class="javax.swing.JTextField" binding="tfCallCommand" custom-create="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="f3f87" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="команда вызова"/>
</properties>
</component>
<component id="87234" class="javax.swing.JTextField" binding="tfDescription" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="d1e8b" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="описание"/>
</properties>
</component>
<component id="ac56f" class="javax.swing.JTextField" binding="tfVersionCommand" custom-create="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="34097" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="запрос версии"/>
</properties>
</component>
<component id="b2235" class="javax.swing.JTextField" binding="tfHelpCommand" custom-create="true">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="8982d" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="запрос help"/>
</properties>
</component>
<component id="19a71" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="тип"/>
</properties>
</component>
<component id="673a2" class="javax.swing.JComboBox" binding="cbCompilerType" custom-create="true">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<toolTipText value="выберите тип компилятора"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,93 @@
package _VisualDVM.GlobalData.Compiler.UI;
import Common.Visual.CommonUI;
import _VisualDVM.Current;
import Common.Visual.TextField.StyledTextField;
import Common.Visual.Windows.Dialog.DialogFields;
import Common.Visual.Windows.Dialog.VDirectoryChooser;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.Machine.MachineType;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.io.File;
import java.util.Objects;
public class CompilerFields implements DialogFields {
public JPanel content;
public JTextField tfHome;
public JButton bBrowse;
public JTextField tfDescription;
public JTextField tfCallCommand;
public JTextField tfVersionCommand;
public JTextField tfHelpCommand;
public JComboBox<CompilerType> cbCompilerType;
public boolean events_on = false;
VDirectoryChooser directoryChooser = new VDirectoryChooser("Выбор домашней папки dvm системы");
public CompilerFields() {
bBrowse.addActionListener(e -> {
CompilerType type = (CompilerType) cbCompilerType.getSelectedItem();
if (type == CompilerType.dvm) {
String dst = null;
if (Current.getMachine().type.equals(MachineType.Local)) {
File file = directoryChooser.ShowDialog();
if (file != null)
dst = file.getAbsolutePath();
} else {
if (Pass_2021.passes.get(PassCode_2021.SelectRemoteFile).Do(true))
dst = Current.getRemoteFile().full_name;
}
if (dst != null)
tfHome.setText(dst);
} else
CommonUI.Info("Назначение домашней папки поддерживается только для dvm системы.");
});
tfHome.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void removeUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void changedUpdate(DocumentEvent e) {
}
}
);
cbCompilerType.addActionListener(e -> {
if (Objects.requireNonNull(cbCompilerType.getSelectedItem()) == CompilerType.dvm) {
tfVersionCommand.setText("ver");
tfHelpCommand.setText("help");
} else {
tfVersionCommand.setText("--version");
tfHelpCommand.setText("--help");
}
});
}
public void TryRestoreCallCommand() {
if (events_on && (cbCompilerType.getSelectedItem() != null) && cbCompilerType.getSelectedItem().equals(CompilerType.dvm))
tfCallCommand.setText(tfHome.getText() +
(tfHome.getText().endsWith("/") ? "" : "/") +
"bin/dvm_drv");
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfDescription = new StyledTextField();
tfHome = new StyledTextField();
tfCallCommand = new StyledTextField();
tfVersionCommand = new StyledTextField();
tfHelpCommand = new StyledTextField();
cbCompilerType = new JComboBox<>();
cbCompilerType.addItem(CompilerType.dvm);
cbCompilerType.addItem(CompilerType.intel);
cbCompilerType.addItem(CompilerType.gnu);
}
@Override
public Component getContent() {
return content;
}
}