MCPcopy Index your code
hub / github.com/compiler-explorer/compiler-explorer / initialise

Method initialise

lib/base-compiler.ts:4111–4180  ·  view source on GitHub ↗
(
        mtime: Date,
        clientOptions: ClientOptionsType,
        isPrediscovered = false,
    )

Source from the content-addressed store, hash-verified

4109 }
4110
4111 async initialise(
4112 mtime: Date,
4113 clientOptions: ClientOptionsType,
4114 isPrediscovered = false,
4115 ): Promise<BaseCompiler | null> {
4116 this.mtime = mtime;
4117
4118 if (this.buildenvsetup) {
4119 await this.buildenvsetup.initialise(
4120 async (compiler: string, args: string[], options: ExecutionOptionsWithEnv) => {
4121 return this.execCompilerCached(compiler, args, options);
4122 },
4123 );
4124 }
4125
4126 if (this.getRemote()) return this;
4127
4128 const compiler = this.compiler.exe;
4129 let version = this.compiler.version || '';
4130 if (!isPrediscovered) {
4131 const versionRe = new RegExp(this.compiler.versionRe || '.*', 'i');
4132 const result = await this.getVersion();
4133 if (!result) return null;
4134 if (result.code !== 0) {
4135 logger.warn(`Compiler '${compiler}' - non-zero result ${result.code}`);
4136 }
4137 const fullVersion = result.stdout + result.stderr;
4138 _.each(utils.splitLines(fullVersion), line => {
4139 if (version) return null;
4140 const match = line.match(versionRe);
4141 if (match) version = match[0];
4142 });
4143 if (!version) {
4144 logger.error(`Unable to find compiler version for '${compiler}' with re ${versionRe}:`, result);
4145 return null;
4146 }
4147 logger.debug(`${compiler} is version '${version}'`);
4148 this.compiler.version = version;
4149 this.compiler.fullVersion = fullVersion;
4150 this.compiler.supportsCfg = this.isCfgCompiler();
4151 // all C/C++ compilers support -E
4152 this.compiler.supportsPpView = this.compiler.lang === 'c' || this.compiler.lang === 'c++';
4153 this.compiler.supportsAstView = this.couldSupportASTDump(version);
4154 }
4155
4156 try {
4157 this.cmakeBaseEnv = await this.getCmakeBaseEnv();
4158 } catch (e) {
4159 logger.error(e);
4160 }
4161
4162 this.initialiseLibraries(clientOptions);
4163
4164 if (isPrediscovered) {
4165 logger.debug(`${compiler} ${version} is ready`);
4166 if (this.compiler.cachedPossibleArguments) {
4167 this.possibleArguments.populateOptions(this.compiler.cachedPossibleArguments);
4168 delete this.compiler.cachedPossibleArguments;

Callers 1

startFunction · 0.45

Calls 14

execCompilerCachedMethod · 0.95
getRemoteMethod · 0.95
getVersionMethod · 0.95
isCfgCompilerMethod · 0.95
couldSupportASTDumpMethod · 0.95
getCmakeBaseEnvMethod · 0.95
initialiseLibrariesMethod · 0.95
splitLinesMethod · 0.80
matchMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected