diff options
Diffstat (limited to 'lib/compilers/ada.js')
-rw-r--r-- | lib/compilers/ada.js | 67 |
1 files changed, 42 insertions, 25 deletions
diff --git a/lib/compilers/ada.js b/lib/compilers/ada.js index 51a1f77b5..1f3c58e52 100644 --- a/lib/compilers/ada.js +++ b/lib/compilers/ada.js @@ -33,32 +33,45 @@ class AdaCompiler extends BaseCompiler { this.compiler.supportsIntel = true; } + getExecutableFilename(dirPath) { + return path.join(dirPath, "example"); + } + + getOutputFilename(dirPath) { + return path.join(dirPath, "example.o"); + } + optionsForFilter(filters, outputFilename) { - let options = ['compile', - '-g', // enable debugging - '-c', // Compile only - '-S', // Generate ASM - '-fdiagnostics-color=always', - '-fverbose-asm', // Geneate verbose ASM showing variables - '-cargs', // Compiler Switches for gcc. - '-o', // Set the output executable name - outputFilename - ]; - if (this.compiler.intelAsm && filters.intel && !filters.binary) { - options = options.concat(this.compiler.intelAsm.split(" ")); + let options = []; + + if (!filters.binary) { + options.push( + 'compile', + '-g', // enable debugging + '-S', // Generate ASM + '-fdiagnostics-color=always', + '-fverbose-asm', // Geneate verbose ASM showing variables + '-c', // Compile only + '-eS', // commands are not errors + '-cargs', // Compiler Switches for gcc. + '-o', + outputFilename, + ); + + if (this.compiler.intelAsm && filters.intel) { + options = options.concat(this.compiler.intelAsm.split(" ")); + } + } else { + options.push( + 'make', + '-eS', + '-g', + 'example', + '-cargs' + ); } - return options; - } - // I have left the overloaded preProcess method in case there is a - // need to any actual pre-processing of the input. - // As Ada expects the outermost function name to match the source file name. - // The initial solution was to wrap any input in a dummy example procedure, - // this however restricts users from including standard library packages, as - // Ada mandates that 'with' clauses are placed in the context clause, - // which in the case of a single subprogram is outside of its declaration and body. - preProcess(source) { - return source; + return options; } async runCompiler(compiler, options, inputFilename, execOptions) { @@ -67,6 +80,7 @@ class AdaCompiler extends BaseCompiler { } // Set the working directory to be the temp directory that has been created execOptions.customCwd = path.dirname(inputFilename); + // As the file name is always appended to the end of the options array we need to // find where the '-cargs' flag is in options. This is to allow us to set the // output as 'output.s' and not end up with 'example.s'. If the output is left @@ -78,10 +92,13 @@ class AdaCompiler extends BaseCompiler { break; } } + const result = await this.exec(compiler, options, execOptions); result.inputFilename = inputFilename; - result.stdout = utils.parseOutput(result.stdout, inputFilename); - result.stderr = utils.parseOutput(result.stderr, inputFilename); + + const baseFilename = path.basename(inputFileName); + result.stdout = utils.parseOutput(result.stdout, baseFilename, execOptions.customCwd); + result.stderr = utils.parseOutput(result.stderr, baseFilename, execOptions.customCwd); return result; } } |