This commit is contained in:
2023-12-20 20:21:47 +03:00
parent 96b6d40136
commit fd34111d20
3 changed files with 22 additions and 20 deletions

View File

@@ -39,12 +39,27 @@ public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
}
}
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> res = user.connection.performScript(modulesDirectory, command);
RemoteFile out = res.getKey();
System.out.println(user.connection.readFromFile(out));
return "";
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
protected void ServerAction() throws Exception {
@@ -71,7 +86,7 @@ public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
"CompilationTask.h",
"File.h",
"Global.h",
"Planner.cpp",
"planner.cpp",
"RunSupervisor.h",
"RunTask.h",
"String.h",
@@ -91,21 +106,7 @@ public class RemoteInitialiseUser extends ConnectionPass_2023<RemoteFile> {
ShowMessage1("Сборка модулей...");
compileModule("launcher","");
compileModule("starter","");
getPlannerFlags();
//compileModule("planner", getPlannerFlags());
/*
//канал на исполнение независим, поэтому переход в папку отдельный
Command(
"cd " + Utils.DQuotes(sftpChannel.pwd()), //нужны ли тут кавычки?
"g++ " + starter_code + " -o " + starter,
"g++ " + launcher_code + " -o " + launcher,
"g++ -O3 -std=c++17 Planner.cpp -o " + planner,
"chmod 0777 " + starter,
"chmod 0777 " + launcher,
"chmod 0777 " + planner
);
*/
compileModule("planner", getPlannerFlags());
//--------------------------------------
RemoteFile info = new RemoteFile(target, Current.getAccount().email);
user.connection.writeToFile("", info);