Skip to content

Commit 49d9cfd

Browse files
authored
Fix invalid architectures. (#6480)
* Fix invalid architectures.
1 parent 6867272 commit 49d9cfd

File tree

7 files changed

+43
-68
lines changed

7 files changed

+43
-68
lines changed

Extension/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# C/C++ for Visual Studio Code Change Log
22

3+
## Version 1.1.1: November 9, 2020
4+
### Bug Fixes
5+
* Fix cpptools binaries sometimes not getting installed on Windows. [#6453](https://github.com/microsoft/vscode-cpptools/issues/6453)
6+
37
## Version 1.1.0: November 5, 2020
48
### New Features
59
* Add language server support for Windows ARM64 (no debugging yet). [#5583](https://github.com/microsoft/vscode-cpptools/issues/5583)

Extension/package.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cpptools",
33
"displayName": "C/C++",
44
"description": "C/C++ IntelliSense, debugging, and code browsing.",
5-
"version": "1.1.0-master",
5+
"version": "1.1.1-master",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",
@@ -2419,7 +2419,7 @@
24192419
"linux"
24202420
],
24212421
"architectures": [
2422-
"x86_64"
2422+
"x64"
24232423
],
24242424
"binaries": [
24252425
"./bin/cpptools",
@@ -2476,10 +2476,8 @@
24762476
"win32"
24772477
],
24782478
"architectures": [
2479-
"x86_64",
2480-
"x86",
2481-
"i686",
2482-
"i386"
2479+
"x64",
2480+
"x86"
24832481
],
24842482
"binaries": [
24852483
"./bin/cpptools.exe",
@@ -2509,7 +2507,7 @@
25092507
"linux"
25102508
],
25112509
"architectures": [
2512-
"x86_64"
2510+
"x64"
25132511
],
25142512
"binaries": [
25152513
"./LLVM/bin/clang-format"
@@ -2583,7 +2581,7 @@
25832581
"linux"
25842582
],
25852583
"architectures": [
2586-
"x86_64"
2584+
"x64"
25872585
],
25882586
"binaries": [
25892587
"./debugAdapters/mono.linux-x86_64"
@@ -2665,10 +2663,8 @@
26652663
"win32"
26662664
],
26672665
"architectures": [
2668-
"x86_64",
2669-
"x86",
2670-
"i686",
2671-
"i386"
2666+
"x64",
2667+
"x86"
26722668
],
26732669
"binaries": [
26742670
"./debugAdapters/vsdbg/bin/vsdbg.exe"

Extension/src/LanguageServer/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ function realActivation(): void {
332332

333333
PlatformInformation.GetPlatformInformation().then(info => {
334334
// Skip Insiders processing for 32-bit Linux.
335-
if (info.platform !== "linux" || info.architecture === "x86_64" || info.architecture === "arm" || info.architecture === "arm64") {
335+
if (info.platform !== "linux" || info.architecture === "x64" || info.architecture === "arm" || info.architecture === "arm64") {
336336
// Skip Insiders processing for unsupported VS Code versions.
337337
const vscodeVersion: PackageVersion = new PackageVersion(vscode.version);
338338
const abTestSettings: ABTestSettings = getABTestSettings();

Extension/src/githubAPI.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,15 @@ export function vsixNameForPlatform(info: PlatformInformation): string {
116116
switch (platformInfo.platform) {
117117
case 'win32':
118118
switch (platformInfo.architecture) {
119-
case 'x86_64': return 'cpptools-win32.vsix'; // TODO: Change to cpptools-win64?
120-
case 'x86':
121-
case 'i386':
122-
case 'i686': return 'cpptools-win32.vsix';
119+
case 'x64': return 'cpptools-win32.vsix'; // TODO: Change to cpptools-win64?
120+
case 'x86': return 'cpptools-win32.vsix';
123121
case 'arm64': return 'cpptools-win-arm64.vsix';
124122
default: throw new Error(`Unexpected Windows architecture: ${platformInfo.architecture}`);
125123
}
126124
case 'darwin': return 'cpptools-osx.vsix';
127125
default: {
128126
switch (platformInfo.architecture) {
129-
case 'x86_64': return 'cpptools-linux.vsix';
127+
case 'x64': return 'cpptools-linux.vsix';
130128
case 'arm': return 'cpptools-linux-armhf.vsix';
131129
case 'arm64': return 'cpptools-linux-aarch64.vsix';
132130
default: throw new Error(`Unexpected Linux architecture: ${platformInfo.architecture}`);

Extension/src/main.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ const disposables: vscode.Disposable[] = [];
3535

3636
export async function activate(context: vscode.ExtensionContext): Promise<CppToolsApi & CppToolsExtension> {
3737
let errMsg: string = "";
38-
if (process.arch !== 'x64' && (process.platform !== 'win32' || (process.arch !== 'ia32' && process.arch !== 'arm64')) && (process.platform !== 'linux' || (process.arch !== 'x64' && process.arch !== 'arm' && process.arch !== 'arm64' && process.arch !== 'aarch64'))) {
39-
errMsg = localize("architecture.not.supported", "Architecture {0} is not supported. ", String(process.arch));
38+
const arch: string = os.arch();
39+
if (arch !== 'x64' && (process.platform !== 'win32' || (arch !== 'ia32' && arch !== 'arm64')) && (process.platform !== 'linux' || (arch !== 'x64' && arch !== 'arm' && arch !== 'arm64'))) {
40+
errMsg = localize("architecture.not.supported", "Architecture {0} is not supported. ", String(arch));
4041
} else if (process.platform === 'linux' && fs.existsSync('/etc/alpine-release')) {
4142
errMsg = localize("apline.containers.not.supported", "Alpine containers are not supported.");
4243
}
@@ -372,7 +373,8 @@ function sendTelemetry(info: PlatformInformation): boolean {
372373
util.setProgress(util.getProgressInstallSuccess());
373374
}
374375

375-
installBlob.telemetryProperties['osArchitecture'] = info.architecture ?? "";
376+
installBlob.telemetryProperties['osArchitecture'] = os.arch();
377+
installBlob.telemetryProperties['infoArchitecture'] = info.architecture;
376378

377379
Telemetry.logDebuggerEvent("acquisition", installBlob.telemetryProperties);
378380

Extension/src/packageManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ export function VersionsMatch(pkg: IPackage, info: PlatformInformation): boolean
491491
}
492492

493493
export function ArchitecturesMatch(value: IPackage, info: PlatformInformation): boolean {
494-
return !value.architectures || (info.architecture !== undefined && value.architectures.indexOf(info.architecture) !== -1);
494+
return !value.architectures || (value.architectures.indexOf(info.architecture) !== -1);
495495
}
496496

497497
export function PlatformsMatch(value: IPackage, info: PlatformInformation): boolean {

Extension/src/platform.ts

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* ------------------------------------------------------------------------------------------ */
55

66
import * as os from 'os';
7-
import * as util from './common';
87
import { LinuxDistribution } from './linuxDistribution';
98
import * as plist from 'plist';
109
import * as fs from 'fs';
@@ -24,77 +23,53 @@ export function GetOSName(processPlatform: string | undefined): string | undefin
2423
}
2524

2625
export class PlatformInformation {
27-
constructor(public platform: string, public architecture?: string, public distribution?: LinuxDistribution, public version?: string) { }
26+
constructor(public platform: string, public architecture: string, public distribution?: LinuxDistribution, public version?: string) { }
2827

2928
public static GetPlatformInformation(): Promise<PlatformInformation> {
3029
const platform: string = os.platform();
31-
let architecturePromise: Promise<string | undefined>;
30+
const architecture: string = PlatformInformation.GetArchitecture();
3231
let distributionPromise: Promise<LinuxDistribution | undefined> = Promise.resolve<LinuxDistribution | undefined>(undefined);
3332
let versionPromise: Promise<string | undefined> = Promise.resolve<string | undefined>(undefined);
3433

3534
switch (platform) {
3635
case "win32":
37-
architecturePromise = PlatformInformation.GetWindowsArchitecture();
3836
break;
3937

4038
case "linux":
41-
architecturePromise = PlatformInformation.GetUnixArchitecture();
4239
distributionPromise = LinuxDistribution.GetDistroInformation();
4340
break;
4441

4542
case "darwin":
46-
architecturePromise = PlatformInformation.GetUnixArchitecture();
4743
versionPromise = PlatformInformation.GetDarwinVersion();
4844
break;
4945

5046
default:
5147
throw new Error(localize("unknown.os.platform", "Unknown OS platform"));
5248
}
5349

54-
return Promise.all([architecturePromise, distributionPromise, versionPromise])
55-
.then(([arch, distro, version]) =>
56-
new PlatformInformation(platform, arch, distro, version)
50+
return Promise.all([distributionPromise, versionPromise])
51+
.then(([distro, version]) =>
52+
new PlatformInformation(platform, architecture, distro, version)
5753
);
5854
}
5955

60-
public static GetUnknownArchitecture(): string { return "Unknown"; }
61-
62-
private static GetWindowsArchitecture(): Promise<string> {
63-
return util.execChildProcess('wmic os get osarchitecture', util.extensionPath)
64-
.then((architecture) => {
65-
if (architecture) {
66-
const archArray: string[] = architecture.split(os.EOL);
67-
if (archArray.length >= 2) {
68-
const arch: string = archArray[1].trim();
69-
70-
// Note: This string can be localized. So, we'll just check to see if it contains 32 or 64.
71-
if (arch.indexOf('64') >= 0) {
72-
if (arch.indexOf('ARM') >= 0) {
73-
return "arm64";
74-
}
75-
return "x86_64";
76-
} else if (arch.indexOf('32') >= 0) {
77-
return "x86";
78-
}
79-
}
80-
}
81-
return PlatformInformation.GetUnknownArchitecture();
82-
}).catch((error) => PlatformInformation.GetUnknownArchitecture());
83-
}
84-
85-
private static GetUnixArchitecture(): Promise<string | undefined> {
86-
return util.execChildProcess('uname -m', util.packageJson.extensionFolderPath)
87-
.then((architecture) => {
88-
if (architecture) {
89-
if (architecture.startsWith('arm64') || architecture.startsWith('aarch64')) {
90-
return 'arm64';
91-
} else if (architecture.startsWith('armv')) {
92-
return 'arm';
93-
}
94-
return architecture.trim();
56+
public static GetArchitecture(): string {
57+
const arch: string = os.arch();
58+
switch (arch) {
59+
case "x64":
60+
case "arm64":
61+
case "arm":
62+
return arch;
63+
case "x32":
64+
case "ia32":
65+
return "x86";
66+
default:
67+
if (os.platform() === "win32") {
68+
return "x86";
69+
} else {
70+
return "x64";
9571
}
96-
return undefined;
97-
});
72+
}
9873
}
9974

10075
private static GetDarwinVersion(): Promise<string> {

0 commit comments

Comments
 (0)