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

Commit9b2c568

Browse files
authored
Add cleanUnusedBinaries stage (microsoft#5153)
Our offline installer will include two versions of lldb../debugAdapters/lldb is lldb-mi 3.8 and is used for High-Sierra and older./debugAdapters/lldb-mi is lldb-mi 10.x and is used for Mojave andhigher.
1 parent5986aee commit9b2c568

File tree

2 files changed

+64
-36
lines changed

2 files changed

+64
-36
lines changed

‎Extension/src/main.ts‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as nls from 'vscode-nls';
1616
import{CppToolsApi,CppToolsExtension}from'vscode-cpptools';
1717
import{getTemporaryCommandRegistrarInstance,initializeTemporaryCommandRegistrar}from'./commands';
1818
import{PlatformInformation}from'./platform';
19-
import{PackageManager,PackageManagerError,IPackage}from'./packageManager';
19+
import{PackageManager,PackageManagerError,IPackage,VersionsMatch,ArchitecturesMatch,PlatformsMatch}from'./packageManager';
2020
import{getInstallationInformation,InstallationInformation,setInstallationStage,setInstallationType,InstallationType}from'./installationInformation';
2121
import{Logger,getOutputChannelLogger,showOutputChannel}from'./logger';
2222
import{CppTools1,NullCppTools}from'./cppTools1';
@@ -103,6 +103,9 @@ async function offlineInstallation(): Promise<void> {
103103
setInstallationType(InstallationType.Offline);
104104
constinfo:PlatformInformation=awaitPlatformInformation.GetPlatformInformation();
105105

106+
setInstallationStage('cleanUpUnusedBinaries');
107+
awaitcleanUpUnusedBinaries(info);
108+
106109
setInstallationStage('makeBinariesExecutable');
107110
awaitmakeBinariesExecutable();
108111

@@ -168,19 +171,44 @@ function makeBinariesExecutable(): Promise<void> {
168171
returnutil.allowExecution(util.getDebugAdaptersPath("OpenDebugAD7"));
169172
}
170173

174+
functionpackageMatchesPlatform(pkg:IPackage,info:PlatformInformation):boolean{
175+
returnPlatformsMatch(pkg,info)&&
176+
(pkg.architectures===undefined||ArchitecturesMatch(pkg,info))&&
177+
VersionsMatch(pkg,info);
178+
}
179+
171180
functionmakeOfflineBinariesExecutable(info:PlatformInformation):Promise<void>{
172181
letpromises:Thenable<void>[]=[];
173182
letpackages:IPackage[]=util.packageJson["runtimeDependencies"];
174183
packages.forEach(p=>{
175184
if(p.binaries&&p.binaries.length>0&&
176-
p.platforms.findIndex(plat=>plat===info.platform)!==-1&&
177-
(p.architectures===undefined||p.architectures.findIndex(arch=>arch===info.architecture)!==-1)){
185+
packageMatchesPlatform(p,info)){
178186
p.binaries.forEach(binary=>promises.push(util.allowExecution(util.getExtensionFilePath(binary))));
179187
}
180188
});
181189
returnPromise.all(promises).then(()=>{});
182190
}
183191

192+
functioncleanUpUnusedBinaries(info:PlatformInformation):Promise<void>{
193+
letpromises:Thenable<void>[]=[];
194+
letpackages:IPackage[]=util.packageJson["runtimeDependencies"];
195+
constlogger:Logger=getOutputChannelLogger();
196+
197+
packages.forEach(p=>{
198+
if(p.binaries&&p.binaries.length>0&&
199+
!packageMatchesPlatform(p,info)){
200+
p.binaries.forEach(binary=>{
201+
constpath:string=util.getExtensionFilePath(binary);
202+
if(fs.existsSync(path)){
203+
logger.appendLine(`deleting:${path}`);
204+
promises.push(util.deleteFile(path));
205+
}
206+
});
207+
}
208+
});
209+
returnPromise.all(promises).then(()=>{});
210+
}
211+
184212
functionremoveUnnecessaryFile():Promise<void>{
185213
if(os.platform()!=='win32'){
186214
letsourcePath:string=util.getDebugAdaptersPath("bin/OpenDebugAD7.exe.config");

‎Extension/src/packageManager.ts‎

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -153,43 +153,13 @@ export class PackageManager {
153153
returnthis.GetPackageList()
154154
.then((list)=>
155155
list.filter((value,index,array)=>
156-
this.ArchitecturesMatch(value)&&
157-
this.PlatformsMatch(value)&&
158-
this.VersionsMatch(value)
156+
ArchitecturesMatch(value,this.platformInfo)&&
157+
PlatformsMatch(value,this.platformInfo)&&
158+
VersionsMatch(value,this.platformInfo)
159159
)
160160
);
161161
}
162162

163-
privateArchitecturesMatch(value:IPackage):boolean{
164-
return!value.architectures||(this.platformInfo.architecture!==undefined&&value.architectures.indexOf(this.platformInfo.architecture)!==-1);
165-
}
166-
167-
privatePlatformsMatch(value:IPackage):boolean{
168-
return!value.platforms||value.platforms.indexOf(this.platformInfo.platform)!==-1;
169-
}
170-
171-
privateVersionsMatch(value:IPackage):boolean{
172-
if(value.versionRegex){
173-
// If we have a versionRegex but did not get a platformVersion
174-
if(!this.platformInfo.version){
175-
// If we are expecting to match the versionRegex, return false since there was no version found.
176-
//
177-
// If we are expecting to not match the versionRegex, return true since we are expecting to
178-
// not match the version string, the only match would be if versionRegex was not set.
179-
return!value.matchVersion;
180-
}
181-
constregex:RegExp=newRegExp(value.versionRegex);
182-
183-
return(value.matchVersion ?
184-
regex.test(this.platformInfo.version) :
185-
!regex.test(this.platformInfo.version)
186-
);
187-
}
188-
189-
// No versionRegex provided.
190-
returntrue;
191-
}
192-
193163
privateasyncDownloadPackage(pkg:IPackage,progressCount:string,progress:vscode.Progress<{message?:string;increment?:number}>):Promise<void>{
194164
this.AppendChannel(localize("downloading.package","Downloading package '{0}' ",pkg.description));
195165

@@ -467,3 +437,33 @@ export class PackageManager {
467437
}
468438
}
469439
}
440+
441+
exportfunctionVersionsMatch(pkg:IPackage,info:PlatformInformation):boolean{
442+
if(pkg.versionRegex){
443+
// If we have a versionRegex but did not get a platformVersion
444+
if(!info.version){
445+
// If we are expecting to match the versionRegex, return false since there was no version found.
446+
//
447+
// If we are expecting to not match the versionRegex, return true since we are expecting to
448+
// not match the version string, the only match would be if versionRegex was not set.
449+
return!pkg.matchVersion;
450+
}
451+
constregex:RegExp=newRegExp(pkg.versionRegex);
452+
453+
return(pkg.matchVersion ?
454+
regex.test(info.version) :
455+
!regex.test(info.version)
456+
);
457+
}
458+
459+
// No versionRegex provided.
460+
returntrue;
461+
}
462+
463+
exportfunctionArchitecturesMatch(value:IPackage,info:PlatformInformation):boolean{
464+
return!value.architectures||(info.architecture!==undefined&&value.architectures.indexOf(info.architecture)!==-1);
465+
}
466+
467+
exportfunctionPlatformsMatch(value:IPackage,info:PlatformInformation):boolean{
468+
return!value.platforms||value.platforms.indexOf(info.platform)!==-1;
469+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp