arduino/arduino-pro-ide#31: Include clangd for linux with 'bin' and 'lib' folders

This commit is contained in:
Miro Spönemann
2020-01-10 11:02:23 +01:00
parent b8fdb03433
commit bef9185c6c
5 changed files with 79 additions and 25 deletions

View File

@@ -64,7 +64,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
bindBackendService(SketchesServicePath, SketchesService);
});
bind(ConnectionContainerModule).toConstantValue(sketchesServiceConnectionModule);
// Config service
bind(ConfigServiceImpl).toSelf().inSingletonScope();
bind(ConfigService).toService(ConfigServiceImpl);
@@ -161,8 +161,14 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
// Set up cpp extension
if (!process.env.CPP_CLANGD_COMMAND) {
const executable = os.platform() === 'win32' ? 'clangd.exe' : 'clangd';
const clangdCommand = join(__dirname, '..', '..', 'build', executable);
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;
}

View File

@@ -24,8 +24,8 @@ export class ArduinoLanguageServerContribution extends BaseLanguageServerContrib
}
async start(clientConnection: IConnection, options: LanguageServerStartOptions): Promise<void> {
const clangd = await this.resolveExecutable('clangd');
const languageServer = await this.resolveExecutable('arduino-language-server');
const clangd = await this.resolveExecutable('clangd');
const cli = await this.resolveExecutable('arduino-cli');
// Add '-log' argument to enable logging to files
const args: string[] = ['-clangd', clangd, '-cli', cli];
@@ -47,7 +47,11 @@ export class ArduinoLanguageServerContribution extends BaseLanguageServerContrib
protected resolveExecutable(name: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
const path = `${process.env.PATH}${delimiter}${join(__dirname, '..', '..', '..', 'build')}`;
const segments = ['..', '..', '..', 'build'];
if (name === 'clangd' && os.platform() !== 'win32') {
segments.push('bin');
}
const path = `${process.env.PATH}${delimiter}${join(__dirname, ...segments)}`;
const suffix = os.platform() === 'win32' ? '.exe' : '';
which(name + suffix, { path }, (err, execPath) => {
if (err) {