diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 712197b085..adc66eed2a 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -534,6 +534,20 @@ export function checkInstallLockFile(): Promise { return checkFileExists(getInstallLockPath()); } +/** Get the platform that the installed binaries belong to.*/ +export function getInstalledBinaryPlatform(): string | undefined { + // the LLVM/bin folder is utilized to identify the platform + let installedPlatform: string = ""; + if (checkFileExistsSync(path.join(extensionPath, "LLVM/bin/clang-format.exe"))) { + installedPlatform = "win32"; + } else if (checkFileExistsSync(path.join(extensionPath, "LLVM/bin/clang-format.darwin"))) { + installedPlatform = "darwin"; + } else if (checkFileExistsSync(path.join(extensionPath, "LLVM/bin/clang-format"))) { + installedPlatform = "linux"; + } + return installedPlatform; +} + /** Reads the content of a text file */ export function readFileText(filePath: string, encoding: string = "utf8"): Promise { return new Promise((resolve, reject) => { diff --git a/Extension/src/githubAPI.ts b/Extension/src/githubAPI.ts index 048ff33b09..5ebe4f113f 100644 --- a/Extension/src/githubAPI.ts +++ b/Extension/src/githubAPI.ts @@ -12,7 +12,7 @@ import * as vscode from 'vscode'; import * as telemetry from './telemetry'; const testingInsidersVsixInstall: boolean = false; // Change this to true to enable testing of the Insiders vsix installation. - +export const releaseDownloadUrl: string = "https://github.com/microsoft/vscode-cpptools/releases"; /** * The object representation of a Build Asset. Each Asset corresponds to information about a release file on GitHub. */ @@ -96,7 +96,7 @@ function isArrayOfBuilds(input: any): input is Build[] { * @param info Information about the user's operating system. * @return VSIX filename for the extension's releases matched to the user's platform. */ -function vsixNameForPlatform(info: PlatformInformation): string { +export function vsixNameForPlatform(info: PlatformInformation): string { const vsixName: string | undefined = function(platformInfo): string | undefined { switch (platformInfo.platform) { case 'win32': return 'cpptools-win32.vsix'; diff --git a/Extension/src/main.ts b/Extension/src/main.ts index d5aab4c5ea..a085276d27 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -17,12 +17,13 @@ import { PersistentState } from './LanguageServer/persistentState'; import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools'; import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands'; -import { PlatformInformation } from './platform'; +import { PlatformInformation, GetOSName } from './platform'; import { PackageManager, PackageManagerError, IPackage, VersionsMatch, ArchitecturesMatch, PlatformsMatch } from './packageManager'; import { getInstallationInformation, InstallationInformation, setInstallationStage, setInstallationType, InstallationType } from './installationInformation'; import { Logger, getOutputChannelLogger, showOutputChannel } from './logger'; import { CppTools1, NullCppTools } from './cppTools1'; import { CppSettings } from './LanguageServer/settings'; +import { vsixNameForPlatform, releaseDownloadUrl } from './githubAPI'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -49,6 +50,20 @@ export async function activate(context: vscode.ExtensionContext): Promise { + if (selection === downloadLink) { + vscode.env.openExternal(vscode.Uri.parse(releaseDownloadUrl)); + } + }); + } + // Register a protocol handler to serve localized versions of the schema for c_cpp_properties.json class SchemaProvider implements vscode.TextDocumentContentProvider { public async provideTextDocumentContent(uri: vscode.Uri): Promise { @@ -317,7 +332,7 @@ function handleError(error: any): void { outputChannelLogger.appendLine(localize('failed.at.stage', "Failed at stage: {0}", installationInformation.stage)); outputChannelLogger.appendLine(errorMessage); outputChannelLogger.appendLine(""); - outputChannelLogger.appendLine(localize('failed.at.stage2', 'If you work in an offline environment or repeatedly see this error, try downloading a version of the extension with all the dependencies pre-included from https://github.com/Microsoft/vscode-cpptools/releases, then use the "Install from VSIX" command in VS Code to install it.')); + outputChannelLogger.appendLine(localize('failed.at.stage2', 'If you work in an offline environment or repeatedly see this error, try downloading a version of the extension with all the dependencies pre-included from {0}, then use the "Install from VSIX" command in VS Code to install it.', releaseDownloadUrl)); showOutputChannel(); } diff --git a/Extension/src/platform.ts b/Extension/src/platform.ts index 1f48c270ee..4e777c1e0e 100644 --- a/Extension/src/platform.ts +++ b/Extension/src/platform.ts @@ -14,6 +14,15 @@ import * as nls from 'vscode-nls'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); +export function GetOSName(processPlatform: string | undefined): string | undefined { + switch (processPlatform) { + case "win32": return "Windows"; + case "darwin": return "MacOS"; + case "linux": return "Linux"; + default: return undefined; + } +} + export class PlatformInformation { constructor(public platform: string, public architecture?: string, public distribution?: LinuxDistribution, public version?: string) { }