MCPcopy Create free account
hub / github.com/badvision/jace / invokeAcme

Method invokeAcme

src/main/java/jace/assembly/AcmeCompiler.java:103–132  ·  view source on GitHub ↗
(File sourceFile, File workingDirectory)

Source from the content-addressed store, hash-verified

101 }
102
103 private void invokeAcme(File sourceFile, File workingDirectory) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IOException {
104 String oldPath = System.getProperty("user.dir");
105 File tempFile = null;
106 redirectSystemOutput();
107 try {
108 tempFile = File.createTempFile(sourceFile.getName(), "bin", sourceFile.getParentFile());
109 tempFile.deleteOnExit();
110 System.setProperty("user.dir", workingDirectory.getAbsolutePath());
111 AcmeCrossAssembler acme = new AcmeCrossAssembler();
112 String[] params = {"--outfile", normalizeWindowsPath(tempFile.getAbsolutePath()), "-f", "cbm", "--maxerrors","16",normalizeWindowsPath(sourceFile.getAbsolutePath())};
113 int status = acme.run("Acme", params);
114 successful = status == 0;
115 if (successful) {
116 compiledAsset = ByteBuffer.wrap(Files.readAllBytes(tempFile.toPath()));
117 }
118 tempFile.delete();
119 } finally {
120 restoreSystemOutput();
121 System.setProperty("user.dir", oldPath);
122 if (tempFile != null && tempFile.exists()) {
123 tempFile.delete();
124 }
125 }
126 rawOutput.add("Error output:");
127 extractOutput(baosErr.toString());
128 rawOutput.add("");
129 rawOutput.add("------------------------------");
130 rawOutput.add("Standard output:");
131 extractOutput(baosOut.toString());
132 }
133
134 public void extractOutput(String output) throws NumberFormatException {
135 for (String line : output.split("\\n")) {

Callers 1

compileMethod · 0.95

Calls 8

redirectSystemOutputMethod · 0.95
normalizeWindowsPathMethod · 0.95
restoreSystemOutputMethod · 0.95
extractOutputMethod · 0.95
addMethod · 0.80
getNameMethod · 0.65
runMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected