diff options
author | Patrick Quist <partouf@gmail.com> | 2022-12-13 03:11:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-12 20:11:05 -0600 |
commit | 9de0b70af362a8618edd8369d5498be51f862f06 (patch) | |
tree | 8f47ef354fd7d7f804ced3f97a7b54cec4fb7b4e | |
parent | 00b3a8ab23e19d6e5e728aee4c252637fedcb18d (diff) | |
download | compiler-explorer-gh-5322.tar.gz compiler-explorer-gh-5322.zip |
min effort ts conv dropintool (#4412)gh-5322
-rw-r--r-- | lib/tooling/_all.ts (renamed from lib/tooling/_all.js) | 0 | ||||
-rw-r--r-- | lib/tooling/compiler-dropin-tool.ts (renamed from lib/tooling/compiler-dropin-tool.js) | 30 | ||||
-rw-r--r-- | lib/tooling/index.ts (renamed from lib/tooling/index.js) | 0 |
3 files changed, 19 insertions, 11 deletions
diff --git a/lib/tooling/_all.js b/lib/tooling/_all.ts index 074516bd9..074516bd9 100644 --- a/lib/tooling/_all.js +++ b/lib/tooling/_all.ts diff --git a/lib/tooling/compiler-dropin-tool.js b/lib/tooling/compiler-dropin-tool.ts index 31a52b1a1..658117c17 100644 --- a/lib/tooling/compiler-dropin-tool.js +++ b/lib/tooling/compiler-dropin-tool.ts @@ -24,10 +24,12 @@ import _ from 'underscore'; +import {Library} from '../../types/libraries/libraries.interfaces'; import {getToolchainPath} from '../toolchain-utils'; import * as utils from '../utils'; import {BaseTool} from './base-tool'; +import {ToolResult} from './base-tool.interface'; export class CompilerDropinTool extends BaseTool { static get key() { @@ -40,19 +42,19 @@ export class CompilerDropinTool extends BaseTool { this.addOptionsToToolArgs = false; } - getToolchainPath(compilationInfo) { + getToolchainPath(compilationInfo): string | false { return getToolchainPath(compilationInfo.compiler.exe, compilationInfo.compiler.options); } - getOrderedArguments(compilationInfo, includeflags, libOptions, args, sourcefile) { + getOrderedArguments(compilationInfo, includeflags, libOptions, args, sourcefile): string[] | false { // order should be: // 1) options from the compiler config (compilationInfo.compiler.options) // 2) includes from the libraries (includeflags) // 3) options from the tool config (this.tool.options) // 4) options manually specified in the compiler tab (options) // 5) flags from the clang-tidy tab - let compileFlags = []; - let argsToFilterOut = new Set([sourcefile, '-stdlib=libc++']); + let compileFlags: string[] = []; + const argsToFilterOut = new Set([sourcefile, '-stdlib=libc++']); const toolchainPath = this.getToolchainPath(compilationInfo); @@ -62,8 +64,8 @@ export class CompilerDropinTool extends BaseTool { if (toolchainPath) { // note: needs toolchain argument twice as the first time its sometimes ignored - compileFlags = compileFlags.concat('--gcc-toolchain=' + toolchainPath); - compileFlags = compileFlags.concat('--gcc-toolchain=' + toolchainPath); + compileFlags = compileFlags.concat(['--gcc-toolchain=' + toolchainPath]); + compileFlags = compileFlags.concat(['--gcc-toolchain=' + toolchainPath]); compilerOptions = _.filter(compilerOptions, option => { return !(option.indexOf('--gcc-toolchain=') === 0 || option.indexOf('--gxx-name=') === 0); @@ -85,7 +87,7 @@ export class CompilerDropinTool extends BaseTool { args ? args : []; compileFlags = compileFlags.concat(args); - compileFlags = _.map(compileFlags, option => { + const pathFilteredFlags: (string | false)[] = _.map(compileFlags, option => { if (option && option.length > 1) { if (option[0] === '/') { return false; @@ -95,14 +97,20 @@ export class CompilerDropinTool extends BaseTool { return option; }); - return _.filter(compileFlags); + return _.filter(pathFilteredFlags) as string[]; } - async runTool(compilationInfo, inputFilepath, args, stdin, supportedLibraries) { + override async runTool( + compilationInfo: Record<any, any>, + inputFilepath?: string, + args?: string[], + stdin?: string, + supportedLibraries?: Record<string, Library>, + ): Promise<ToolResult> { const sourcefile = inputFilepath; - const includeflags = this.getIncludeArguments(compilationInfo.libraries, supportedLibraries); - const libOptions = this.getLibraryOptions(compilationInfo.libraries, supportedLibraries); + const includeflags = this.getIncludeArguments(compilationInfo.libraries, supportedLibraries || {}); + const libOptions = this.getLibraryOptions(compilationInfo.libraries, supportedLibraries || {}); const compileFlags = this.getOrderedArguments(compilationInfo, includeflags, libOptions, args, sourcefile); if (!compileFlags) { diff --git a/lib/tooling/index.js b/lib/tooling/index.ts index ca6790811..ca6790811 100644 --- a/lib/tooling/index.js +++ b/lib/tooling/index.ts |