Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement not supported message for arm platform and alpine containers #4027

Merged
merged 8 commits into from
Aug 8, 2019
34 changes: 33 additions & 1 deletion Extension/src/cppTools1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ------------------------------------------------------------------------------------------ */
'use strict';

import { CustomConfigurationProvider, Version, CppToolsApi } from 'vscode-cpptools';
import { CustomConfigurationProvider, Version, CppToolsApi, CppToolsExtension } from 'vscode-cpptools';
import { CppToolsTestApi, CppToolsTestHook, CppToolsTestExtension } from 'vscode-cpptools/out/testApi';
import { CppTools } from './cppTools';

Expand Down Expand Up @@ -63,3 +63,35 @@ export class CppTools1 implements CppToolsTestApi, CppToolsTestExtension {
return this.BackupApi.getTestHook();
}
}

/**
* This is an empty implementation of the API. Used when the extension is activated on
* an unsupported platform.
*/
export class NullCppTools implements CppToolsApi, CppToolsExtension {
private version: Version;

getApi(version: Version): CppToolsApi {
this.version = version;
return this;
}

getVersion(): Version {
return this.version;
}

registerCustomConfigurationProvider(provider: CustomConfigurationProvider): void {
}

notifyReady(provider: CustomConfigurationProvider): void {
}

didChangeCustomConfiguration(provider: CustomConfigurationProvider): void {
}

didChangeCustomBrowseConfiguration(provider: CustomConfigurationProvider): void {
}

dispose(): void {
}
}
13 changes: 12 additions & 1 deletion Extension/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { PackageManager, PackageManagerError, IPackage } from './packageManager'
import { PersistentState } from './LanguageServer/persistentState';
import { getInstallationInformation, InstallationInformation, setInstallationStage, setInstallationType, InstallationType } from './installationInformation';
import { Logger, getOutputChannelLogger, showOutputChannel } from './logger';
import { CppTools1 } from './cppTools1';
import { CppTools1, NullCppTools } from './cppTools1';

const releaseNotesVersion: number = 5;
const cppTools: CppTools1 = new CppTools1();
Expand All @@ -29,6 +29,17 @@ let reloadMessageShown: boolean = false;
let disposables: vscode.Disposable[] = [];

export async function activate(context: vscode.ExtensionContext): Promise<CppToolsApi & CppToolsExtension> {
let errMsg: string = "";
if (process.arch !== 'x32' && process.arch !== 'x64') {
errMsg = "Architecture " + String(process.arch) + " is not supported. ";
} else if (process.platform === 'linux' && fs.existsSync('/etc/alpine-release')) {
errMsg = "Alpine containers are not supported. ";
}
if (errMsg) {
vscode.window.showErrorMessage(errMsg);
return new NullCppTools();
}

util.setExtensionContext(context);
initializeTemporaryCommandRegistrar();
Telemetry.activate();
Expand Down