Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4216aa4

Browse files
Elaheh RashediElaheh Rashedibobbrow
authored
check offline/insiders VSIX (microsoft#5341)
* check offline/insiders VSIX* draft* add offline url, modify warning message* check offline/insiders VSIX* draft* add offline url, modify warning message* modify warning message* fix reviewers comments* changing the approach to determine the platform* fixing the integration test* testingCo-authored-by: Elaheh Rashedi <elrashed@microsoft.com>Co-authored-by: Bob Brown <bobbrow@users.noreply.github.com>
1 parent118bed1 commit4216aa4

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

‎Extension/src/common.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,20 @@ export function checkInstallLockFile(): Promise<boolean> {
534534
returncheckFileExists(getInstallLockPath());
535535
}
536536

537+
/** Get the platform that the installed binaries belong to.*/
538+
exportfunctiongetInstalledBinaryPlatform():string|undefined{
539+
// the LLVM/bin folder is utilized to identify the platform
540+
letinstalledPlatform:string="";
541+
if(checkFileExistsSync(path.join(extensionPath,"LLVM/bin/clang-format.exe"))){
542+
installedPlatform="win32";
543+
}elseif(checkFileExistsSync(path.join(extensionPath,"LLVM/bin/clang-format.darwin"))){
544+
installedPlatform="darwin";
545+
}elseif(checkFileExistsSync(path.join(extensionPath,"LLVM/bin/clang-format"))){
546+
installedPlatform="linux";
547+
}
548+
returninstalledPlatform;
549+
}
550+
537551
/** Reads the content of a text file */
538552
exportfunctionreadFileText(filePath:string,encoding:string="utf8"):Promise<string>{
539553
returnnewPromise<string>((resolve,reject)=>{

‎Extension/src/githubAPI.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as vscode from 'vscode';
1212
import*astelemetryfrom'./telemetry';
1313

1414
consttestingInsidersVsixInstall:boolean=false;// Change this to true to enable testing of the Insiders vsix installation.
15-
15+
exportconstreleaseDownloadUrl:string="https://github.com/microsoft/vscode-cpptools/releases";
1616
/**
1717
* The object representation of a Build Asset. Each Asset corresponds to information about a release file on GitHub.
1818
*/
@@ -96,7 +96,7 @@ function isArrayOfBuilds(input: any): input is Build[] {
9696
*@param info Information about the user's operating system.
9797
*@return VSIX filename for the extension's releases matched to the user's platform.
9898
*/
99-
functionvsixNameForPlatform(info:PlatformInformation):string{
99+
exportfunctionvsixNameForPlatform(info:PlatformInformation):string{
100100
constvsixName:string|undefined=function(platformInfo):string|undefined{
101101
switch(platformInfo.platform){
102102
case'win32':return'cpptools-win32.vsix';

‎Extension/src/main.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ import { PersistentState } from './LanguageServer/persistentState';
1717

1818
import{CppToolsApi,CppToolsExtension}from'vscode-cpptools';
1919
import{getTemporaryCommandRegistrarInstance,initializeTemporaryCommandRegistrar}from'./commands';
20-
import{PlatformInformation}from'./platform';
20+
import{PlatformInformation,GetOSName}from'./platform';
2121
import{PackageManager,PackageManagerError,IPackage,VersionsMatch,ArchitecturesMatch,PlatformsMatch}from'./packageManager';
2222
import{getInstallationInformation,InstallationInformation,setInstallationStage,setInstallationType,InstallationType}from'./installationInformation';
2323
import{Logger,getOutputChannelLogger,showOutputChannel}from'./logger';
2424
import{CppTools1,NullCppTools}from'./cppTools1';
2525
import{CppSettings}from'./LanguageServer/settings';
26+
import{vsixNameForPlatform,releaseDownloadUrl}from'./githubAPI';
2627

2728
nls.config({messageFormat:nls.MessageFormat.bundle,bundleFormat:nls.BundleFormat.standalone})();
2829
constlocalize:nls.LocalizeFunc=nls.loadMessageBundle();
@@ -49,6 +50,20 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
4950
Telemetry.activate();
5051
util.setProgress(0);
5152

53+
// check if the correct offline/insiders vsix is installed on the correct platform
54+
letinstalledPlatform:string|undefined=util.getInstalledBinaryPlatform();
55+
if(!installedPlatform||(process.platform!==installedPlatform)){
56+
constplatformInfo:PlatformInformation=awaitPlatformInformation.GetPlatformInformation();
57+
constvsixName:string=vsixNameForPlatform(platformInfo);
58+
errMsg=localize("native.binaries.not.supported","This {0} version of the extension is incompatible with your OS. Please download and install the \"{1}\" version of the extension.",GetOSName(installedPlatform),vsixName);
59+
constdownloadLink:string=localize("download.button","Go to Download Page");
60+
vscode.window.showErrorMessage(errMsg,downloadLink).then(async(selection)=>{
61+
if(selection===downloadLink){
62+
vscode.env.openExternal(vscode.Uri.parse(releaseDownloadUrl));
63+
}
64+
});
65+
}
66+
5267
// Register a protocol handler to serve localized versions of the schema for c_cpp_properties.json
5368
classSchemaProviderimplementsvscode.TextDocumentContentProvider{
5469
publicasyncprovideTextDocumentContent(uri:vscode.Uri):Promise<string>{
@@ -317,7 +332,7 @@ function handleError(error: any): void {
317332
outputChannelLogger.appendLine(localize('failed.at.stage',"Failed at stage: {0}",installationInformation.stage));
318333
outputChannelLogger.appendLine(errorMessage);
319334
outputChannelLogger.appendLine("");
320-
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 fromhttps://github.com/Microsoft/vscode-cpptools/releases, then use the "Install from VSIX" command in VS Code to install it.'));
335+
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));
321336
showOutputChannel();
322337
}
323338

‎Extension/src/platform.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ import * as nls from 'vscode-nls';
1414
nls.config({messageFormat:nls.MessageFormat.bundle,bundleFormat:nls.BundleFormat.standalone})();
1515
constlocalize:nls.LocalizeFunc=nls.loadMessageBundle();
1616

17+
exportfunctionGetOSName(processPlatform:string|undefined):string|undefined{
18+
switch(processPlatform){
19+
case"win32":return"Windows";
20+
case"darwin":return"MacOS";
21+
case"linux":return"Linux";
22+
default:returnundefined;
23+
}
24+
}
25+
1726
exportclassPlatformInformation{
1827
constructor(publicplatform:string,publicarchitecture?:string,publicdistribution?:LinuxDistribution,publicversion?:string){}
1928

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp