Skip to content

Commit 05014a3

Browse files
Add darwin OS version change check for lldb-mi (#5197)
If the darwin version changes and is upgraded to Mojave or higher, users will need to use ./debugAdapters/lldb-mi. These changes will cleanup the old files and cause the online installation process to run again. Co-authored-by: Sean McManus <[email protected]>
1 parent 276e095 commit 05014a3

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

Extension/src/main.ts

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as Telemetry from './telemetry';
1212
import * as util from './common';
1313
import * as vscode from 'vscode';
1414
import * as nls from 'vscode-nls';
15+
import { PersistentState } from './LanguageServer/persistentState';
1516

1617
import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools';
1718
import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands';
@@ -69,17 +70,44 @@ export function deactivate(): Thenable<void> {
6970
async function processRuntimeDependencies(): Promise<void> {
7071
const installLockExists: boolean = await util.checkInstallLockFile();
7172

72-
if (installLockExists) {
73+
setInstallationStage('getPlatformInfo');
74+
const info: PlatformInformation = await PlatformInformation.GetPlatformInformation();
75+
76+
let forceOnlineInstall: boolean = false;
77+
if (info.platform === "darwin" && info.version) {
78+
const darwinVersion: PersistentState<string | undefined> = new PersistentState("Cpp.darwinVersion", info.version);
79+
80+
// macOS version has changed
81+
if (darwinVersion.Value !== info.version) {
82+
const highSierraOrLowerRegex: RegExp = new RegExp('10\\.(1[0-3]|[0-9])(\\..*)*$');
83+
const lldbMiFolderPath: string = util.getExtensionFilePath('./debugAdapters/lldb-mi');
84+
85+
// For macOS and if a user has upgraded their OS, check to see if we are on Mojave or later
86+
// and that the debugAdapters/lldb-mi folder exists. This will force a online install to get the correct binaries.
87+
if (!highSierraOrLowerRegex.test(info.version) &&
88+
!fs.existsSync(lldbMiFolderPath)) {
89+
90+
forceOnlineInstall = true;
91+
92+
setInstallationStage('cleanUpUnusedBinaries');
93+
await cleanUpUnusedBinaries(info);
94+
}
95+
}
96+
}
97+
98+
const doOfflineInstall: boolean = installLockExists && !forceOnlineInstall;
99+
100+
if (doOfflineInstall) {
73101
// Offline Scenario: Lock file exists but package.json has not had its activationEvents rewritten.
74102
if (util.packageJson.activationEvents && util.packageJson.activationEvents.length === 1) {
75103
try {
76-
await offlineInstallation();
104+
await offlineInstallation(info);
77105
} catch (error) {
78106
getOutputChannelLogger().showErrorMessage(localize('initialization.failed', 'The installation of the C/C++ extension failed. Please see the output window for more information.'));
79107
showOutputChannel();
80108

81109
// Send the failure telemetry since postInstall will not be called.
82-
sendTelemetry(await PlatformInformation.GetPlatformInformation());
110+
sendTelemetry(info);
83111
}
84112
} else {
85113
// The extension has been installed and activated before.
@@ -88,20 +116,18 @@ async function processRuntimeDependencies(): Promise<void> {
88116
} else {
89117
// No lock file, need to download and install dependencies.
90118
try {
91-
await onlineInstallation();
119+
await onlineInstallation(info);
92120
} catch (error) {
93121
handleError(error);
94122

95123
// Send the failure telemetry since postInstall will not be called.
96-
sendTelemetry(await PlatformInformation.GetPlatformInformation());
124+
sendTelemetry(info);
97125
}
98126
}
99127
}
100128

101-
async function offlineInstallation(): Promise<void> {
102-
setInstallationStage('getPlatformInfo');
129+
async function offlineInstallation(info: PlatformInformation): Promise<void> {
103130
setInstallationType(InstallationType.Offline);
104-
const info: PlatformInformation = await PlatformInformation.GetPlatformInformation();
105131

106132
setInstallationStage('cleanUpUnusedBinaries');
107133
await cleanUpUnusedBinaries(info);
@@ -122,10 +148,8 @@ async function offlineInstallation(): Promise<void> {
122148
await postInstall(info);
123149
}
124150

125-
async function onlineInstallation(): Promise<void> {
126-
setInstallationStage('getPlatformInfo');
151+
async function onlineInstallation(info: PlatformInformation): Promise<void> {
127152
setInstallationType(InstallationType.Online);
128-
const info: PlatformInformation = await PlatformInformation.GetPlatformInformation();
129153

130154
await downloadAndInstallPackages(info);
131155

0 commit comments

Comments
 (0)