Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Abort on compilation error

parent 3acf4b3c
Pipeline #110318 failed with stages
in 45 seconds
...@@ -134,39 +134,42 @@ public class EMADLGenerator { ...@@ -134,39 +134,42 @@ public class EMADLGenerator {
} }
public void executeCommands() throws IOException { public void executeCommands() throws IOException {
File tempScript = createTempScript();
File tempScript = createTempScript(); try {
ProcessBuilder pb = new ProcessBuilder("bash", tempScript.toString());
try { pb.inheritIO();
ProcessBuilder pb = new ProcessBuilder("bash", tempScript.toString()); Process process = pb.start();
pb.inheritIO(); int returnCode = process.waitFor();
Process process = pb.start(); if(returnCode != 0) {
process.waitFor(); Log.error("During compilation, an error occured. See above for more details.");
}catch(Exception e){ System.exit(1);
System.out.println(e); }
} finally { }catch(Exception e){
tempScript.delete(); Log.error("During compilation, the following error occured: '" + e.toString() + "'");
} System.exit(1);
} finally {
tempScript.delete();
}
} }
public File createTempScript() throws IOException{ public File createTempScript() throws IOException{
File tempScript = File.createTempFile("script", null); File tempScript = File.createTempFile("script", null);
try{ try{
Writer streamWriter = new OutputStreamWriter(new FileOutputStream( Writer streamWriter = new OutputStreamWriter(new FileOutputStream(
tempScript)); tempScript));
PrintWriter printWriter = new PrintWriter(streamWriter); PrintWriter printWriter = new PrintWriter(streamWriter);
printWriter.println("#!/bin/bash"); printWriter.println("#!/bin/bash");
printWriter.println("cd " + getGenerationTargetPath()); printWriter.println("csssd " + getGenerationTargetPath());
printWriter.println("mkdir --parents build"); printWriter.println("mkdir --parents build");
printWriter.println("cd build"); printWriter.println("cd build");
printWriter.println("cmake .."); printWriter.println("cmake ..");
printWriter.println("make"); printWriter.println("make");
printWriter.close(); printWriter.close();
}catch(Exception e){ }catch(Exception e){
System.out.println(e); System.out.println(e);
} }
return tempScript; return tempScript;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment