проверка версии модулей в стадии - создание рабочих папок пакета. Если версия не найдена, или меньше актуальной, модули будут пересобраны.

This commit is contained in:
2023-12-24 01:36:52 +03:00
parent 43d7c4da8b
commit 9e571d33a8
7 changed files with 146 additions and 132 deletions

View File

@@ -231,9 +231,62 @@ public class UserConnection {
sftpChannel.rm(file.full_name);
}
//--
writeToFile("cd " + Utils.DQuotes(directory.full_name)+"\n"+ String.join("\n", commands), script_file);
writeToFile("cd " + Utils.DQuotes(directory.full_name) + "\n" + String.join("\n", commands), script_file);
//--
ShellCommand(script_file.full_name + " 1>" + Utils.DQuotes(out.full_name) + " 2>" + Utils.DQuotes(err.full_name));
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 "";
}
}