mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 07:08:04 -06:00
refactor to start execute earlier and glue it on the result near the end
This commit is contained in:
+25
-26
@@ -142,17 +142,15 @@ class BaseCompiler {
|
||||
.then(execResult => {
|
||||
execResult.stdout = utils.parseOutput(execResult.stdout);
|
||||
execResult.stderr = utils.parseOutput(execResult.stderr);
|
||||
result.execResult = execResult;
|
||||
return result;
|
||||
return execResult;
|
||||
}).catch(err => {
|
||||
// TODO: is this the best way? Perhaps failures in sandbox shouldn't reject
|
||||
// with "results", but instead should play on?
|
||||
result.execResult = {
|
||||
return {
|
||||
stdout: err.stdout ? utils.parseOutput(err.stdout) : [],
|
||||
stderr: err.stderr ? utils.parseOutput(err.stderr) : [],
|
||||
code: err.code !== undefined ? err.code : -1
|
||||
};
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -308,8 +306,7 @@ class BaseCompiler {
|
||||
return this.getOrBuildExecutable(key)
|
||||
.then(buildResult => {
|
||||
if (buildResult.code !== 0) {
|
||||
result.execResult = buildResult;
|
||||
return result;
|
||||
return buildResult;
|
||||
} else {
|
||||
return this.runExecutable(buildResult.executableFilename,
|
||||
result, executeParameters);
|
||||
@@ -345,9 +342,6 @@ class BaseCompiler {
|
||||
return cacheGet
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
if (doExecute) {
|
||||
return this.handleExecution(key, result, executeParameters);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -434,6 +428,8 @@ class BaseCompiler {
|
||||
});
|
||||
});
|
||||
|
||||
let executionPromise;
|
||||
|
||||
return compileToAsmPromise
|
||||
.then(results => {
|
||||
let optOutput;
|
||||
@@ -450,6 +446,14 @@ class BaseCompiler {
|
||||
}
|
||||
return result;
|
||||
})
|
||||
.then(result => {
|
||||
if (doExecute) {
|
||||
executionPromise = this.handleExecution(key, result, executeParameters);
|
||||
} else {
|
||||
executionPromise = Promise.resolve(false);
|
||||
}
|
||||
return result;
|
||||
})
|
||||
.then(result => {
|
||||
const outputFilebase = "output";
|
||||
const outputFilename = this.getOutputFilename(result.dirPath, outputFilebase);
|
||||
@@ -484,24 +488,19 @@ class BaseCompiler {
|
||||
return result;
|
||||
})
|
||||
.then(result => {
|
||||
if (doExecute) {
|
||||
return this.handleExecution(key, result, executeParameters)
|
||||
.then((result) => {
|
||||
if (result.okToCache) {
|
||||
return this.env.cachePut(key, result).then(() => result);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
});
|
||||
}
|
||||
return Promise.all([executionPromise]).then(([executionResult]) => {
|
||||
if (executionResult) {
|
||||
result.execResult = executionResult;
|
||||
}
|
||||
|
||||
if (result.okToCache) {
|
||||
// TODO: asynchronously do this? Is it possible to "fire and forget" the promise?
|
||||
// Do we want to do it higher up?
|
||||
return this.env.cachePut(key, result).then(() => result);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
if (result.okToCache) {
|
||||
// TODO: asynchronously do this? Is it possible to "fire and forget" the promise?
|
||||
// Do we want to do it higher up?
|
||||
return this.env.cachePut(key, result).then(() => result);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user