From b543993869c231a54c00936a88568240ae096173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Mon, 10 Oct 2022 13:04:09 +0200 Subject: [PATCH] Fix Erlang compiler & convert it to typescript (#4124) --- etc/config/erlang.defaults.properties | 2 +- lib/compilers/{erlang.js => erlang.ts} | 68 ++++++++++---------------- 2 files changed, 26 insertions(+), 44 deletions(-) rename lib/compilers/{erlang.js => erlang.ts} (52%) diff --git a/etc/config/erlang.defaults.properties b/etc/config/erlang.defaults.properties index b6fb121ad72..9370da7289f 100644 --- a/etc/config/erlang.defaults.properties +++ b/etc/config/erlang.defaults.properties @@ -1,7 +1,7 @@ # Default settings for Erlang compilers=&erlang compilerType=erlang -versionFlag= +versionFlag=-noshell -eval io:fwrite("~s~n", [erlang:system_info(otp_release)]), halt(). objdumper= instructionSet=beam diff --git a/lib/compilers/erlang.js b/lib/compilers/erlang.ts similarity index 52% rename from lib/compilers/erlang.js rename to lib/compilers/erlang.ts index bef2dfbe9e9..0aea71a8224 100644 --- a/lib/compilers/erlang.js +++ b/lib/compilers/erlang.ts @@ -24,8 +24,8 @@ import path from 'path'; +import {ParseFilters} from '../../types/features/filters.interfaces'; import {BaseCompiler} from '../base-compiler'; -import {logger} from '../logger'; import {ErlangParser} from './argument-parsers'; @@ -34,8 +34,7 @@ export class ErlangCompiler extends BaseCompiler { return 'erlang'; } - /* eslint-disable no-unused-vars */ - optionsForFilter(filters, outputFilename) { + override optionsForFilter(filters: ParseFilters, outputFilename: string): string[] { return [ '-noshell', '-eval', @@ -47,52 +46,35 @@ export class ErlangCompiler extends BaseCompiler { 'halt().', ]; } - /* eslint-enable no-unused-vars */ - async runCompiler(compiler, options, inputFilename, execOptions) { - if (!execOptions) { - execOptions = this.getDefaultExecOptions(); - } - - if (!execOptions.customCwd) { - execOptions.customCwd = path.dirname(inputFilename); - } - - const result = await this.exec(compiler, options.concat(['-input', inputFilename]), execOptions); - result.inputFilename = inputFilename; - const transformedInput = result.filenameTransform(inputFilename); - this.parseCompilationOutput(result, transformedInput); - return result; - } - - getVersion() { - logger.info(`Gathering ${this.compiler.id} version information on ${this.compiler.exe}...`); - if (this.compiler.explicitVersion) { - logger.debug(`${this.compiler.id} has forced version output: ${this.compiler.explicitVersion}`); - return {stdout: [this.compiler.explicitVersion], stderr: [], code: 0}; - } - const execOptions = this.getDefaultExecOptions(); - const versionCmd = this.compilerProps(`compiler.${this.compiler.id}.runtime`); - execOptions.timeoutMs = 0; // No timeout for --version. A sort of workaround for slow EFS/NFS on the prod site - execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([]); - - try { - return this.execCompilerCached( - versionCmd, - ['-noshell', '-eval', 'io:fwrite("~s~n", [erlang:system_info(otp_release)]), halt().'], - execOptions, - ); - } catch (err) { - logger.error(`Unable to get version for compiler '${this.compiler.exe}' - ${err}`); - return null; - } + override orderArguments( + options: string[], + inputFilename: string, + libIncludes: string[], + libOptions: string[], + libPaths: string[], + libLinks: string[], + userOptions: string[], + staticLibLinks: string[], + ): string[] { + options.push('-input', inputFilename); + return super.orderArguments( + options, + inputFilename, + libIncludes, + libOptions, + libPaths, + libLinks, + userOptions, + staticLibLinks, + ); } - getOutputFilename(dirPath, outputFilebase) { + override getOutputFilename(dirPath: string, outputFilebase: string): string { return path.join(dirPath, `${outputFilebase}.S`); } - getArgumentParser() { + override getArgumentParser() { return ErlangParser; } }