From 258b1e903efa5767823d6b1b7f91a798497b1105 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Tue, 15 Dec 2020 11:02:31 +0100 Subject: [PATCH] GH-393: Do not use `clangd` from the `$PATH`. Closes: arduino/arduino-pro-ide#393 Signed-off-by: Akos Kitta --- .../src/node/arduino-ide-backend-module.ts | 18 ------------------ arduino-ide-extension/src/node/exec-util.ts | 7 ++++++- .../src/node/executable-service-impl.ts | 2 +- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/arduino-ide-extension/src/node/arduino-ide-backend-module.ts b/arduino-ide-extension/src/node/arduino-ide-backend-module.ts index aca34379..1f7657e8 100644 --- a/arduino-ide-extension/src/node/arduino-ide-backend-module.ts +++ b/arduino-ide-extension/src/node/arduino-ide-backend-module.ts @@ -1,6 +1,3 @@ -import * as fs from 'fs'; -import * as os from 'os'; -import { join } from 'path'; import { ContainerModule } from 'inversify'; import { ArduinoDaemonImpl } from './arduino-daemon-impl'; import { ILogger } from '@theia/core/lib/common/logger'; @@ -128,21 +125,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { }); })); - // Set up cpp extension - if (!process.env.CPP_CLANGD_COMMAND) { - const segments = ['..', '..', 'build']; - if (os.platform() === 'win32') { - segments.push('clangd.exe'); - } else { - segments.push('bin'); - segments.push('clangd'); - } - const clangdCommand = join(__dirname, ...segments); - if (fs.existsSync(clangdCommand)) { - process.env.CPP_CLANGD_COMMAND = clangdCommand; - } - } - // File-system extension for mapping paths to URIs bind(NodeFileSystemExt).toSelf().inSingletonScope(); bind(FileSystemExt).toService(NodeFileSystemExt); diff --git a/arduino-ide-extension/src/node/exec-util.ts b/arduino-ide-extension/src/node/exec-util.ts index 2c718530..8402e9c1 100644 --- a/arduino-ide-extension/src/node/exec-util.ts +++ b/arduino-ide-extension/src/node/exec-util.ts @@ -4,7 +4,12 @@ import * as semver from 'semver'; import { join } from 'path'; import { spawn } from 'child_process'; -export async function getExecPath(commandName: string, onError: (error: Error) => void = (error) => console.log(error), versionArg?: string, inBinDir?: boolean): Promise { +export async function getExecPath( + commandName: string, + onError: (error: Error) => void = (error) => console.log(error), + versionArg?: string | undefined, + inBinDir?: boolean): Promise { + const execName = `${commandName}${os.platform() === 'win32' ? '.exe' : ''}`; const relativePath = ['..', '..', 'build']; if (inBinDir) { diff --git a/arduino-ide-extension/src/node/executable-service-impl.ts b/arduino-ide-extension/src/node/executable-service-impl.ts index c72bc324..e54b583e 100644 --- a/arduino-ide-extension/src/node/executable-service-impl.ts +++ b/arduino-ide-extension/src/node/executable-service-impl.ts @@ -14,7 +14,7 @@ export class ExecutableServiceImpl implements ExecutableService { async list(): Promise<{ clangdUri: string, cliUri: string, lsUri: string }> { const [ls, clangd, cli] = await Promise.all([ getExecPath('arduino-language-server', this.onError.bind(this)), - getExecPath('clangd', this.onError.bind(this), '--version', os.platform() !== 'win32'), + getExecPath('clangd', this.onError.bind(this), undefined, os.platform() !== 'win32'), getExecPath('arduino-cli', this.onError.bind(this)) ]); return {