проверка версии модулей в стадии - создание рабочих папок пакета. Если версия не найдена, или меньше актуальной, модули будут пересобраны.
This commit is contained in:
6
.idea/workspace.xml
generated
6
.idea/workspace.xml
generated
@@ -7,6 +7,12 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Common/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Constants.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingPlanner.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/DVMTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/DVMTestingPlanner.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/RemoteInitialiseUser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/RemoteInitialiseUser.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import Visual_DVM_2021.Passes.PassCode_2021;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
public class Constants {
|
public class Constants {
|
||||||
public static final int Nan = -1;
|
public static final int Nan = -1;
|
||||||
|
public static final int planner_version = 2;
|
||||||
//SVN
|
//SVN
|
||||||
public static final String REPOSITORY_AUTHENTICATION = "--username dvmhuser --password dvmh2013 --non-interactive";
|
public static final String REPOSITORY_AUTHENTICATION = "--username dvmhuser --password dvmh2013 --non-interactive";
|
||||||
public static final String DVM_REPOSITORY = "http://svn.dvm-system.org/svn/dvmhrepo/dvm";
|
public static final String DVM_REPOSITORY = "http://svn.dvm-system.org/svn/dvmhrepo/dvm";
|
||||||
@@ -77,6 +78,28 @@ public class Constants {
|
|||||||
"killed by signal",
|
"killed by signal",
|
||||||
"bad termination"
|
"bad termination"
|
||||||
};
|
};
|
||||||
|
public static String[] resourses_names = new String[]{
|
||||||
|
//--
|
||||||
|
"Process_r.h",
|
||||||
|
"starter.cpp",
|
||||||
|
"launcher.cpp",
|
||||||
|
//--
|
||||||
|
"Array.h",
|
||||||
|
"CompilationSupervisor.h",
|
||||||
|
"CompilationTask.h",
|
||||||
|
"File.h",
|
||||||
|
"Global.h",
|
||||||
|
"planner.cpp",
|
||||||
|
"RunSupervisor.h",
|
||||||
|
"RunTask.h",
|
||||||
|
"String.h",
|
||||||
|
"Supervisor.h",
|
||||||
|
"Task.h",
|
||||||
|
"Text.h",
|
||||||
|
"Utils.h",
|
||||||
|
"version.h"
|
||||||
|
|
||||||
|
};
|
||||||
//пробный коммит. изменение комментария.++
|
//пробный коммит. изменение комментария.++
|
||||||
//кронтаб и перезагрузка
|
//кронтаб и перезагрузка
|
||||||
//https://snipp.ru/raznoe/crontab
|
//https://snipp.ru/raznoe/crontab
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
|||||||
testingPackage.state = state_in;
|
testingPackage.state = state_in;
|
||||||
testingPackage.ChangeDate = new Date().getTime();
|
testingPackage.ChangeDate = new Date().getTime();
|
||||||
ServerCommand(ServerCode.EditObject, testingPackage);
|
ServerCommand(ServerCode.EditObject, testingPackage);
|
||||||
|
switch (testingPackage.state) {
|
||||||
|
case Done:
|
||||||
|
case Aborted:
|
||||||
|
case CompilationExecution:
|
||||||
|
case RunningExecution:
|
||||||
|
EmailPackage();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void UpdatePackage() throws Exception {
|
void UpdatePackage() throws Exception {
|
||||||
testingPackage.ChangeDate = new Date().getTime();
|
testingPackage.ChangeDate = new Date().getTime();
|
||||||
@@ -107,7 +115,6 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
|||||||
break;
|
break;
|
||||||
case PackageStart:
|
case PackageStart:
|
||||||
PackageStart();
|
PackageStart();
|
||||||
EmailPackage();
|
|
||||||
testingPackage.StartDate = new Date().getTime();
|
testingPackage.StartDate = new Date().getTime();
|
||||||
UpdatePackageState(getStateAfterStart());
|
UpdatePackageState(getStateAfterStart());
|
||||||
Disconnect();
|
Disconnect();
|
||||||
@@ -134,7 +141,6 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
|||||||
if (testingPackage.state.equals(TasksPackageState.Analysis)) {
|
if (testingPackage.state.equals(TasksPackageState.Analysis)) {
|
||||||
AnalyseResults();
|
AnalyseResults();
|
||||||
UpdatePackageState(TasksPackageState.Done);
|
UpdatePackageState(TasksPackageState.Done);
|
||||||
EmailPackage();
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (Connect()) {
|
if (Connect()) {
|
||||||
@@ -143,7 +149,6 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
|||||||
Print("package " + testingPackage.id + " NEEDS TO KILL");
|
Print("package " + testingPackage.id + " NEEDS TO KILL");
|
||||||
Kill();
|
Kill();
|
||||||
UpdatePackageState(TasksPackageState.Aborted);
|
UpdatePackageState(TasksPackageState.Aborted);
|
||||||
EmailPackage();
|
|
||||||
ServerCommand(ServerCode.DeleteObjectByPK, ptk_id);
|
ServerCommand(ServerCode.DeleteObjectByPK, ptk_id);
|
||||||
} else {
|
} else {
|
||||||
Session();
|
Session();
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import GlobalData.User.User;
|
|||||||
import ProjectData.Files.ProjectFile;
|
import ProjectData.Files.ProjectFile;
|
||||||
import ProjectData.LanguageName;
|
import ProjectData.LanguageName;
|
||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
|
import TestingSystem.Common.TasksPackageState;
|
||||||
import TestingSystem.Common.TestingPlanner;
|
import TestingSystem.Common.TestingPlanner;
|
||||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||||
import TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
import TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||||
import TestingSystem.DVM.DVMTasks.DVMRunTask;
|
import TestingSystem.DVM.DVMTasks.DVMRunTask;
|
||||||
import TestingSystem.DVM.DVMTasks.DVMTask;
|
import TestingSystem.DVM.DVMTasks.DVMTask;
|
||||||
import TestingSystem.Common.TasksPackageState;
|
|
||||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||||
import files.ConnectionPass;
|
import files.ConnectionPass;
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
@@ -67,21 +67,12 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
ProjectFile projectFile = new ProjectFile(new File(file.getName()));
|
ProjectFile projectFile = new ProjectFile(new File(file.getName()));
|
||||||
if (projectFile.isNotExcludedProgram())
|
if (projectFile.isNotExcludedProgram()) res.get(projectFile.languageName).add(projectFile);
|
||||||
res.get(projectFile.languageName).add(projectFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
static void generateForLanguage(
|
static void generateForLanguage(String dvm_drv, LanguageName language, Vector<ProjectFile> language_programs, Vector<String> titles, Vector<String> objects, Vector<String> bodies, String flags) {
|
||||||
String dvm_drv,
|
|
||||||
LanguageName language,
|
|
||||||
Vector<ProjectFile> language_programs,
|
|
||||||
Vector<String> titles,
|
|
||||||
Vector<String> objects,
|
|
||||||
Vector<String> bodies,
|
|
||||||
String flags
|
|
||||||
) {
|
|
||||||
if (!language_programs.isEmpty()) {
|
if (!language_programs.isEmpty()) {
|
||||||
String LANG_ = language.toString().toUpperCase() + "_";
|
String LANG_ = language.toString().toUpperCase() + "_";
|
||||||
Vector<String> module_objects = new Vector<>();
|
Vector<String> module_objects = new Vector<>();
|
||||||
@@ -91,27 +82,10 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
//--
|
//--
|
||||||
String object = Utils.DQuotes(language + "_" + i + ".o");
|
String object = Utils.DQuotes(language + "_" + i + ".o");
|
||||||
module_objects.add(object);
|
module_objects.add(object);
|
||||||
module_body +=
|
module_body += object + ":\n" + "\t" + String.join(" ", Utils.MFVar(LANG_ + "COMMAND"), Utils.MFVar(LANG_ + "FLAGS"), program.getStyleOptions(), "-c", program.getQSourceName(), "-o", object + "\n\n");
|
||||||
object + ":\n" +
|
|
||||||
"\t" +
|
|
||||||
String.join(" ",
|
|
||||||
Utils.MFVar(LANG_ + "COMMAND"),
|
|
||||||
Utils.MFVar(LANG_ + "FLAGS"),
|
|
||||||
program.getStyleOptions(),
|
|
||||||
"-c",
|
|
||||||
program.getQSourceName(),
|
|
||||||
"-o",
|
|
||||||
object + "\n\n"
|
|
||||||
);
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
titles.add(String.join("\n",
|
titles.add(String.join("\n", LANG_ + "COMMAND=" + Utils.DQuotes(dvm_drv) + " " + language.getDVMCompile(), LANG_ + "FLAGS=" + flags, LANG_ + "OBJECTS=" + String.join(" ", module_objects), ""));
|
||||||
LANG_ + "COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
|
|
||||||
language.getDVMCompile(),
|
|
||||||
LANG_ + "FLAGS=" + flags,
|
|
||||||
LANG_ + "OBJECTS=" + String.join(" ", module_objects),
|
|
||||||
""
|
|
||||||
));
|
|
||||||
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
|
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
|
||||||
bodies.add(module_body);
|
bodies.add(module_body);
|
||||||
}
|
}
|
||||||
@@ -128,15 +102,7 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
generateForLanguage(dvm_drv, languageName, programs.get(languageName), titles, objects, bodies, flags);
|
generateForLanguage(dvm_drv, languageName, programs.get(languageName), titles, objects, bodies, flags);
|
||||||
}
|
}
|
||||||
//----->>
|
//----->>
|
||||||
return String.join("\n",
|
return String.join("\n", "LINK_COMMAND=" + Utils.DQuotes(dvm_drv) + " " + test_language.getDVMLink(), "LINK_FLAGS=" + flags + "\n", String.join("\n", titles), "all: " + binary, binary + " : " + String.join(" ", objects), "\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary, String.join(" ", bodies));
|
||||||
"LINK_COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
|
|
||||||
test_language.getDVMLink(),
|
|
||||||
"LINK_FLAGS=" + flags + "\n",
|
|
||||||
String.join("\n", titles),
|
|
||||||
"all: " + binary,
|
|
||||||
binary + " : " + String.join(" ", objects),
|
|
||||||
"\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary,
|
|
||||||
String.join(" ", bodies));
|
|
||||||
}
|
}
|
||||||
public void getTasksInfo(List<? extends DVMTask> tasks, String file_name) throws Exception {
|
public void getTasksInfo(List<? extends DVMTask> tasks, String file_name) throws Exception {
|
||||||
LinkedHashMap<Integer, DVMTask> sorted_tasks = new LinkedHashMap<>();
|
LinkedHashMap<Integer, DVMTask> sorted_tasks = new LinkedHashMap<>();
|
||||||
@@ -189,6 +155,10 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void PackageWorkspaceCreation() throws Exception {
|
protected void PackageWorkspaceCreation() throws Exception {
|
||||||
|
if (!CheckModules()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//--
|
||||||
testingPackage.readJson();
|
testingPackage.readJson();
|
||||||
//--
|
//--
|
||||||
LinkedHashMap<Integer, File> tests = getTestsFromJson();
|
LinkedHashMap<Integer, File> tests = getTestsFromJson();
|
||||||
@@ -213,16 +183,8 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
@Override
|
@Override
|
||||||
protected void PackageStart() throws Exception {
|
protected void PackageStart() throws Exception {
|
||||||
user.connection.ShellCommand("ulimit -s unlimited"); // нужно, для запуска сишной части.
|
user.connection.ShellCommand("ulimit -s unlimited"); // нужно, для запуска сишной части.
|
||||||
String plannerStartCommand =
|
///--
|
||||||
String.join(" ",
|
String plannerStartCommand = String.join(" ", "nohup", Utils.DQuotes(getPlanner()), Utils.DQuotes(user.workspace), Utils.DQuotes(packageRemoteWorkspace.full_name), Utils.DQuotes(testingPackage.kernels), Utils.DQuotes(testingPackage.drv), "&");
|
||||||
"nohup",
|
|
||||||
Utils.DQuotes(getPlanner()),
|
|
||||||
Utils.DQuotes(user.workspace),
|
|
||||||
Utils.DQuotes(packageRemoteWorkspace.full_name),
|
|
||||||
Utils.DQuotes(testingPackage.kernels),
|
|
||||||
Utils.DQuotes(testingPackage.drv),
|
|
||||||
"&"
|
|
||||||
);
|
|
||||||
user.connection.ShellCommand(plannerStartCommand);
|
user.connection.ShellCommand(plannerStartCommand);
|
||||||
RemoteFile PID = new RemoteFile(packageRemoteWorkspace, "PID");
|
RemoteFile PID = new RemoteFile(packageRemoteWorkspace, "PID");
|
||||||
RemoteFile STARTED = new RemoteFile(packageRemoteWorkspace, "STARTED");
|
RemoteFile STARTED = new RemoteFile(packageRemoteWorkspace, "STARTED");
|
||||||
@@ -236,7 +198,6 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected boolean CheckNextState() throws Exception {
|
protected boolean CheckNextState() throws Exception {
|
||||||
|
|
||||||
boolean progress_changed = false;
|
boolean progress_changed = false;
|
||||||
boolean state_changed = false;
|
boolean state_changed = false;
|
||||||
RemoteFile progress = new RemoteFile(packageRemoteWorkspace, "progress");
|
RemoteFile progress = new RemoteFile(packageRemoteWorkspace, "progress");
|
||||||
@@ -284,7 +245,6 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
}
|
}
|
||||||
//todo привязать это к настройкам, чтобы можно было включать/выключать удаление.
|
//todo привязать это к настройкам, чтобы можно было включать/выключать удаление.
|
||||||
//получили результат. теперь уничтожаем папку пакета на целевой машине.
|
//получили результат. теперь уничтожаем папку пакета на целевой машине.
|
||||||
|
|
||||||
if (user.connection.Exists(packageRemoteWorkspace)) {
|
if (user.connection.Exists(packageRemoteWorkspace)) {
|
||||||
user.connection.RMDIR(packageRemoteWorkspace.full_name);
|
user.connection.RMDIR(packageRemoteWorkspace.full_name);
|
||||||
}
|
}
|
||||||
@@ -364,10 +324,8 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
@Override
|
@Override
|
||||||
protected void InitSessionCredentials() {
|
protected void InitSessionCredentials() {
|
||||||
String machine_url = testingPackage.machine_address + ":" + testingPackage.machine_port;
|
String machine_url = testingPackage.machine_address + ":" + testingPackage.machine_port;
|
||||||
if (!machines.containsKey(machine_url))
|
if (!machines.containsKey(machine_url)) machines.put(machine_url, testingPackage.getMachine());
|
||||||
machines.put(machine_url, testingPackage.getMachine());
|
if (!users.containsKey(testingPackage.user_name)) users.put(testingPackage.user_name, testingPackage.getUser());
|
||||||
if (!users.containsKey(testingPackage.user_name))
|
|
||||||
users.put(testingPackage.user_name, testingPackage.getUser());
|
|
||||||
//-->>
|
//-->>
|
||||||
machine = machines.get(machine_url);
|
machine = machines.get(machine_url);
|
||||||
user = users.get(testingPackage.user_name);
|
user = users.get(testingPackage.user_name);
|
||||||
@@ -396,5 +354,34 @@ public class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
|||||||
user.connection = null;
|
user.connection = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--
|
//todo потом обобщить и для одиночных запусков. если понадобится.
|
||||||
|
protected boolean CheckModules() throws Exception {
|
||||||
|
RemoteFile modulesDirectory = new RemoteFile(user.workspace, "modules");
|
||||||
|
RemoteFile version = new RemoteFile(modulesDirectory, "version.h");
|
||||||
|
int current_version = Constants.Nan;
|
||||||
|
int actual_version = Constants.planner_version;
|
||||||
|
if (user.connection.Exists(version)) {
|
||||||
|
try {
|
||||||
|
current_version = Integer.parseInt(user.connection.readFromFile(version));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (current_version < actual_version) {
|
||||||
|
Print("Закачка кода модулей...");
|
||||||
|
for (String resource_name : Constants.resourses_names) {
|
||||||
|
Print(resource_name);
|
||||||
|
user.connection.putResource(modulesDirectory, resource_name);
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
Print("Сборка модулей...");
|
||||||
|
String modules_log = user.connection.compileModules(modulesDirectory);
|
||||||
|
if (!modules_log.isEmpty()) {
|
||||||
|
testingPackage.description = modules_log;
|
||||||
|
testingPackage.state = TasksPackageState.Aborted;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,4 +236,57 @@ public class UserConnection {
|
|||||||
ShellCommand(script_file.full_name + " 1>" + Utils.DQuotes(out.full_name) + " 2>" + Utils.DQuotes(err.full_name));
|
ShellCommand(script_file.full_name + " 1>" + Utils.DQuotes(out.full_name) + " 2>" + Utils.DQuotes(err.full_name));
|
||||||
return new Pair<>(out, err);
|
return new Pair<>(out, err);
|
||||||
}
|
}
|
||||||
|
public void putResource(RemoteFile dstDirectory, String resource_name) throws Exception {
|
||||||
|
File src = Utils.CreateTempResourceFile(resource_name);
|
||||||
|
RemoteFile dst = new RemoteFile(dstDirectory, resource_name);
|
||||||
|
putSingleFile(src, dst);
|
||||||
|
}
|
||||||
|
boolean compileModule(RemoteFile modulesDirectory, String module_name) throws Exception {
|
||||||
|
String flags = module_name.equals("planner") ? getAvailibleCPPStandard(modulesDirectory) : "";
|
||||||
|
String command = "g++ -O3 " + flags + " " + Utils.DQuotes(module_name + ".cpp") + " -o " + Utils.DQuotes(module_name);
|
||||||
|
RemoteFile binary = new RemoteFile(modulesDirectory, module_name);
|
||||||
|
//--
|
||||||
|
if (Exists(binary))
|
||||||
|
sftpChannel.rm(binary.full_name);
|
||||||
|
//--
|
||||||
|
performScript(modulesDirectory, command);
|
||||||
|
//--
|
||||||
|
if (Exists(binary)) {
|
||||||
|
sftpChannel.chmod(0777, binary.full_name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String getAvailibleCPPStandard(RemoteFile scriptDirectory) throws Exception {
|
||||||
|
String res = "";
|
||||||
|
String command = "g++ -v --help 2> /dev/null | sed -n '/^ *-std=\\([^<][^ ]\\+\\).*/ {s//\\1/p}' | grep c++";
|
||||||
|
System.out.println(command);
|
||||||
|
Pair<RemoteFile, RemoteFile> oe = performScript(scriptDirectory, command);
|
||||||
|
RemoteFile outFile = oe.getKey();
|
||||||
|
String out = readFromFile(outFile);
|
||||||
|
String[] data = out.split("\n");
|
||||||
|
for (String version : data) {
|
||||||
|
System.out.println(Utils.Brackets(version));
|
||||||
|
if (version.equals("c++17")) {
|
||||||
|
res = "-std=c++17";
|
||||||
|
break;
|
||||||
|
} else if (version.equals("c++11")) {
|
||||||
|
res = "-std=c++11";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
public String compileModules(RemoteFile modulesDirectory) throws Exception {
|
||||||
|
if (!compileModule(modulesDirectory, "launcher")) {
|
||||||
|
return "Не удалось собрать модуль [launcher]";
|
||||||
|
}
|
||||||
|
if (!compileModule(modulesDirectory, "starter")) {
|
||||||
|
return "Не удалось собрать модуль [starter]";
|
||||||
|
}
|
||||||
|
if (!compileModule(modulesDirectory, "planner")) {
|
||||||
|
return "Не удалось собрать модуль [planner]";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package Visual_DVM_2021.Passes.All;
|
package Visual_DVM_2021.Passes.All;
|
||||||
|
import Common.Constants;
|
||||||
import Common.Current;
|
import Common.Current;
|
||||||
import Common.Utils.Utils;
|
import Common.Utils.Utils;
|
||||||
import GlobalData.RemoteFile.RemoteFile;
|
import GlobalData.RemoteFile.RemoteFile;
|
||||||
import Visual_DVM_2021.Passes.PassException;
|
import Visual_DVM_2021.Passes.PassException;
|
||||||
import Visual_DVM_2021.Passes.SSH.ConnectionPass_2023;
|
import Visual_DVM_2021.Passes.SSH.ConnectionPass_2023;
|
||||||
import javafx.util.Pair;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
|
public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
|
||||||
RemoteFile modulesDirectory;
|
RemoteFile modulesDirectory;
|
||||||
@@ -24,43 +23,6 @@ public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
|
|||||||
user = Current.getUser();
|
user = Current.getUser();
|
||||||
super.Connect();
|
super.Connect();
|
||||||
}
|
}
|
||||||
void put_resource(String res_name, RemoteFile dst_directory) throws Exception {
|
|
||||||
user.connection.putSingleFile(Utils.CreateTempResourceFile(res_name), new RemoteFile(dst_directory, res_name));
|
|
||||||
}
|
|
||||||
void compileModule(String module_name, String flags) throws Exception{
|
|
||||||
String command = "g++ " + flags+" "+ Utils.DQuotes(module_name + ".cpp") + " -o "+ Utils.DQuotes(module_name);
|
|
||||||
ShowMessage2(command);
|
|
||||||
user.connection.performScript(modulesDirectory, command);
|
|
||||||
RemoteFile binary = new RemoteFile(modulesDirectory, module_name);
|
|
||||||
if (!user.connection.Exists(binary)){
|
|
||||||
throw new PassException("Не удалось собрать модуль "+Utils.Brackets(module_name));
|
|
||||||
}else {
|
|
||||||
user.connection.sftpChannel.chmod(0777, binary.full_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String getPlannerFlags() throws Exception{
|
|
||||||
String res = "";
|
|
||||||
String command = "g++ -v --help 2> /dev/null | sed -n '/^ *-std=\\([^<][^ ]\\+\\).*/ {s//\\1/p}' | grep c++";
|
|
||||||
System.out.println(command);
|
|
||||||
Pair<RemoteFile, RemoteFile> oe = user.connection.performScript(modulesDirectory, command);
|
|
||||||
RemoteFile outFile = oe.getKey();
|
|
||||||
String out = user.connection.readFromFile(outFile);
|
|
||||||
String [] data = out.split("\n");
|
|
||||||
for (String version: data){
|
|
||||||
System.out.println(Utils.Brackets(version));
|
|
||||||
if (version.equals("c++17")){
|
|
||||||
res = "-std=c++17";
|
|
||||||
break;
|
|
||||||
}else if (version.equals("c++11")){
|
|
||||||
res="-std=c++11";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println(Utils.Brackets(res));
|
|
||||||
if (res.isEmpty())
|
|
||||||
throw new PassException("На целевой машине отсутствуют с++17 и с++11!");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
protected void ServerAction() throws Exception {
|
protected void ServerAction() throws Exception {
|
||||||
String workspace_name = Utils.getDateName("visual_sapfor_workspace");
|
String workspace_name = Utils.getDateName("visual_sapfor_workspace");
|
||||||
@@ -75,38 +37,16 @@ public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
|
|||||||
for (RemoteFile remoteFile : subdirectories)
|
for (RemoteFile remoteFile : subdirectories)
|
||||||
user.connection.sftpChannel.mkdir(remoteFile.full_name);
|
user.connection.sftpChannel.mkdir(remoteFile.full_name);
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
String[] resourses_names = new String[]{
|
|
||||||
//--
|
|
||||||
"Process_r.h",
|
|
||||||
"starter.cpp",
|
|
||||||
"launcher.cpp",
|
|
||||||
//--
|
|
||||||
"Array.h",
|
|
||||||
"CompilationSupervisor.h",
|
|
||||||
"CompilationTask.h",
|
|
||||||
"File.h",
|
|
||||||
"Global.h",
|
|
||||||
"planner.cpp",
|
|
||||||
"RunSupervisor.h",
|
|
||||||
"RunTask.h",
|
|
||||||
"String.h",
|
|
||||||
"Supervisor.h",
|
|
||||||
"Task.h",
|
|
||||||
"Text.h",
|
|
||||||
"Utils.h"
|
|
||||||
};
|
|
||||||
ShowMessage1("Закачка кода модулей...");
|
ShowMessage1("Закачка кода модулей...");
|
||||||
for (String resource_name : resourses_names) {
|
for (String resource_name : Constants.resourses_names) {
|
||||||
ShowMessage2(resource_name);
|
ShowMessage2(resource_name);
|
||||||
File src = Utils.CreateTempResourceFile(resource_name);
|
user.connection.putResource(modulesDirectory, resource_name);
|
||||||
RemoteFile dst = new RemoteFile(modulesDirectory, resource_name);
|
|
||||||
user.connection.putSingleFile(src, dst);
|
|
||||||
}
|
}
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
ShowMessage1("Сборка модулей...");
|
ShowMessage1("Сборка модулей...");
|
||||||
compileModule("launcher","");
|
String modules_log = user.connection.compileModules(modulesDirectory);
|
||||||
compileModule("starter","");
|
if (!modules_log.isEmpty())
|
||||||
compileModule("planner", getPlannerFlags());
|
throw new PassException(modules_log);
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
RemoteFile info = new RemoteFile(target, Current.getAccount().email);
|
RemoteFile info = new RemoteFile(target, Current.getAccount().email);
|
||||||
user.connection.writeToFile("", info);
|
user.connection.writeToFile("", info);
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ public enum PassCode_2021 {
|
|||||||
case Undefined:
|
case Undefined:
|
||||||
return "?";
|
return "?";
|
||||||
case SPF_InsertPrivateFromGUI:
|
case SPF_InsertPrivateFromGUI:
|
||||||
return "Расстановка директив приватизации";
|
return "Вставка директив для нераспределяемых массивов";
|
||||||
case CreateTestFromSelectedFiles:
|
case CreateTestFromSelectedFiles:
|
||||||
return "Создать тест из выделенных файлов";
|
return "Создать тест из выделенных файлов";
|
||||||
case DownloadSapforPackage:
|
case DownloadSapforPackage:
|
||||||
|
|||||||
Reference in New Issue
Block a user