Skip to content

Commit 593ec69

Browse files
committed
Merge branch 'topic/vscode-user-build' into 'master'
Do not check platform compatibility with external ALS env variable Closes #1189 See merge request eng/ide/ada_language_server!1407
2 parents de91886 + 033176a commit 593ec69

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

integration/vscode/ada/src/clients.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import * as vscode from 'vscode';
21
import { existsSync } from 'fs';
2+
import * as vscode from 'vscode';
33
import {
44
Disposable,
55
ExecuteCommandRequest,
66
LanguageClient,
77
LanguageClientOptions,
88
ServerOptions,
99
} from 'vscode-languageclient/node';
10+
import { mainLogChannel } from './extension';
1011
import GnatTaskProvider from './gnatTaskProvider';
1112
import GprTaskProvider from './gprTaskProvider';
12-
import { getEvaluatedCustomEnv, logErrorAndThrow } from './helpers';
13-
import { mainLogChannel } from './extension';
13+
import { logErrorAndThrow } from './helpers';
1414

1515
export class ContextClients {
1616
public readonly gprClient: LanguageClient;
@@ -147,18 +147,6 @@ function createClient(
147147
// If the extension is launched in debug mode then the debug server options are used
148148
// Otherwise the run options are used
149149

150-
// Retrieve the user's custom environment variables if specified in their
151-
// settings/workspace: we'll then launch any child process with this custom
152-
// environment
153-
const custom_env = getEvaluatedCustomEnv();
154-
155-
if (custom_env) {
156-
for (const var_name in custom_env) {
157-
const var_value: string = custom_env[var_name];
158-
process.env[var_name] = var_value;
159-
}
160-
}
161-
162150
// Options to control the server
163151
const serverOptions: ServerOptions = {
164152
run: { command: serverExecPath, args: extra },

integration/vscode/ada/src/extension.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import { ContextClients } from './clients';
2626
import { registerCommands } from './commands';
2727
import { initializeDebugging } from './debugConfigProvider';
2828
import { initializeTestView } from './gnattest';
29-
import { assertSupportedEnvironments, getEvaluatedCustomEnv } from './helpers';
29+
import {
30+
assertSupportedEnvironments,
31+
getEvaluatedCustomEnv,
32+
setCustomEnvironment,
33+
} from './helpers';
3034

3135
const ADA_CONTEXT = 'ADA_PROJECT_CONTEXT';
3236
export let contextClients: ContextClients;
@@ -39,8 +43,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
3943
mainLogChannel = vscode.window.createOutputChannel('Ada Extension');
4044
mainLogChannel.appendLine('Starting Ada extension');
4145

42-
assertSupportedEnvironments(mainLogChannel);
43-
4446
// Log the environment that the extension (and all VS Code) will be using
4547
const customEnv = getEvaluatedCustomEnv();
4648

@@ -52,6 +54,13 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
5254
}
5355
}
5456

57+
// Set the custom environment into the current node process. This must be
58+
// done before calling assertSupportedEnvironments in order to set the ALS
59+
// environment variable if provided.
60+
setCustomEnvironment();
61+
62+
assertSupportedEnvironments(mainLogChannel);
63+
5564
// Create the Ada and GPR clients.
5665
contextClients = new ContextClients(context);
5766

integration/vscode/ada/src/helpers.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,33 @@ export function getEvaluatedCustomEnv() {
148148
return custom_env;
149149
}
150150

151+
/**
152+
* Read the environment variables specified in the vscode setting
153+
* `terminal.integrated.env.<os>` and set them in the current node process so
154+
* that they become inherited by any child processes.
155+
*/
156+
export function setCustomEnvironment() {
157+
// Retrieve the user's custom environment variables if specified in their
158+
// settings/workspace: we'll then launch any child process with this custom
159+
// environment
160+
const custom_env = getEvaluatedCustomEnv();
161+
162+
if (custom_env) {
163+
for (const var_name in custom_env) {
164+
const var_value: string = custom_env[var_name];
165+
process.env[var_name] = var_value;
166+
}
167+
}
168+
}
169+
151170
export function assertSupportedEnvironments(mainChannel: vscode.OutputChannel) {
171+
if (process.env.ALS) {
172+
// The User provided an external ALS executable. Do not perform any
173+
// platform support checks because we may be on an unsupported platform
174+
// where the User built and provided ALS.
175+
return;
176+
}
177+
152178
type Env = {
153179
arch: 'arm' | 'arm64' | 'x64';
154180
platform: 'win32' | 'linux' | 'darwin';

0 commit comments

Comments
 (0)