MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / checkVsixCompatibility

Function checkVsixCompatibility

Extension/src/main.ts:249–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247}
248
249async function checkVsixCompatibility(): Promise<void> {
250 const ignoreMismatchedCompatibleVsix: PersistentState<boolean> = new PersistentState<boolean>("CPP." + util.packageJson.version + ".ignoreMismatchedCompatibleVsix", false);
251 let resetIgnoreMismatchedCompatibleVsix: boolean = true;
252
253 // Check to ensure the correct platform-specific VSIX was installed.
254 const vsixManifestPath: string = path.join(util.extensionPath, ".vsixmanifest");
255 // Skip the check if the file does not exist, such as when debugging cpptools.
256 if (await util.checkFileExists(vsixManifestPath)) {
257 const content: string = await util.readFileText(vsixManifestPath);
258 const matches: RegExpMatchArray | null = content.match(/TargetPlatform="(?<platform>[^"]*)"/);
259 if (matches && matches.length > 0 && matches.groups) {
260 const vsixTargetPlatform: string = matches.groups['platform'];
261 const platformInfo: PlatformInformation = await PlatformInformation.GetPlatformInformation();
262 let isPlatformCompatible: boolean = true;
263 let isPlatformMatching: boolean = true;
264 switch (vsixTargetPlatform) {
265 case "win32-x64":
266 isPlatformMatching = platformInfo.platform === "win32" && platformInfo.architecture === "x64";
267 // x64 binaries can also be run on arm64 Windows 11.
268 isPlatformCompatible = platformInfo.platform === "win32" && (platformInfo.architecture === "x64" || (platformInfo.architecture === "arm64" && semver.gte(os.release(), "10.0.22000")));
269 break;
270 case "win32-ia32":
271 isPlatformMatching = platformInfo.platform === "win32" && platformInfo.architecture === "x86";
272 // x86 binaries can also be run on x64 and arm64 Windows.
273 isPlatformCompatible = platformInfo.platform === "win32" && (platformInfo.architecture === "x86" || platformInfo.architecture === "x64" || platformInfo.architecture === "arm64");
274 break;
275 case "win32-arm64":
276 isPlatformMatching = platformInfo.platform === "win32" && platformInfo.architecture === "arm64";
277 isPlatformCompatible = isPlatformMatching;
278 break;
279 case "linux-x64":
280 isPlatformMatching = platformInfo.platform === "linux" && platformInfo.architecture === "x64" && platformInfo.distribution?.name !== "alpine";
281 isPlatformCompatible = isPlatformMatching;
282 break;
283 case "linux-arm64":
284 isPlatformMatching = platformInfo.platform === "linux" && platformInfo.architecture === "arm64" && platformInfo.distribution?.name !== "alpine";
285 isPlatformCompatible = isPlatformMatching;
286 break;
287 case "linux-armhf":
288 isPlatformMatching = platformInfo.platform === "linux" && platformInfo.architecture === "arm" && platformInfo.distribution?.name !== "alpine";
289 // armhf binaries can also be run on aarch64 linux.
290 isPlatformCompatible = platformInfo.platform === "linux" && (platformInfo.architecture === "arm" || platformInfo.architecture === "arm64") && platformInfo.distribution?.name !== "alpine";
291 break;
292 case "alpine-x64":
293 isPlatformMatching = platformInfo.platform === "linux" && platformInfo.architecture === "x64" && platformInfo.distribution?.name === "alpine";
294 isPlatformCompatible = isPlatformMatching;
295 break;
296 case "alpine-arm64":
297 isPlatformMatching = platformInfo.platform === "linux" && platformInfo.architecture === "arm64" && platformInfo.distribution?.name === "alpine";
298 isPlatformCompatible = isPlatformMatching;
299 break;
300 case "darwin-x64":
301 isPlatformMatching = platformInfo.platform === "darwin" && platformInfo.architecture === "x64";
302 isPlatformCompatible = isPlatformMatching;
303 break;
304 case "darwin-arm64":
305 isPlatformMatching = platformInfo.platform === "darwin" && platformInfo.architecture === "arm64";
306 // x64 binaries can also be run on arm64 macOS.

Callers 1

activateFunction · 0.85

Calls 5

getLocalizedHtmlPathFunction · 0.90
showErrorMessageMethod · 0.80
showWarningMessageMethod · 0.80
thenMethod · 0.45

Tested by

no test coverage detected