|
@@ -7,27 +7,41 @@ import * as vscode from 'vscode';
|
|
|
import * as os from 'os';
|
|
import * as os from 'os';
|
|
|
import * as path from 'path';
|
|
import * as path from 'path';
|
|
|
import * as fs from 'fs';
|
|
import * as fs from 'fs';
|
|
|
-import { checkIfFileExists, downloadFile, unzipFile } from './directoryUtilities';
|
|
|
|
|
-
|
|
|
|
|
-const LLDB_RESOURCE_DIR = "resource/debug";
|
|
|
|
|
-const LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP: Partial<Record<NodeJS.Platform, string>> = {
|
|
|
|
|
- "linux": "x86_64-ubuntu-22.04",
|
|
|
|
|
- "darwin": "universal-macos-latest"
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ checkIfFileExists,
|
|
|
|
|
+ downloadFile,
|
|
|
|
|
+ unzipFile,
|
|
|
|
|
+} from './directoryUtilities';
|
|
|
|
|
+
|
|
|
|
|
+const LLDB_RESOURCE_DIR = 'resource/debug';
|
|
|
|
|
+const LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP: Partial<
|
|
|
|
|
+ Record<NodeJS.Platform, string>
|
|
|
|
|
+> = {
|
|
|
|
|
+ linux: 'x86_64-ubuntu-22.04',
|
|
|
|
|
+ darwin: 'universal-macos-latest',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const WAMR_LLDB_NOT_SUPPORTED_ERROR = new Error("WAMR LLDB is not supported on this platform");
|
|
|
|
|
|
|
+const WAMR_LLDB_NOT_SUPPORTED_ERROR = new Error(
|
|
|
|
|
+ 'WAMR LLDB is not supported on this platform'
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
function getLLDBUnzipFilePath(destinationFolder: string, filename: string) {
|
|
function getLLDBUnzipFilePath(destinationFolder: string, filename: string) {
|
|
|
- const dirs = filename.split("/");
|
|
|
|
|
- if (dirs[0] === "inst") {
|
|
|
|
|
|
|
+ const dirs = filename.split('/');
|
|
|
|
|
+ if (dirs[0] === 'inst') {
|
|
|
dirs.shift();
|
|
dirs.shift();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return path.join(destinationFolder, ...dirs);
|
|
return path.join(destinationFolder, ...dirs);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+export function getWAMRExtensionVersion(
|
|
|
|
|
+ context: vscode.ExtensionContext
|
|
|
|
|
+): string {
|
|
|
|
|
+ return require(path.join(context.extensionPath, 'package.json')).version;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function getLLDBDownloadUrl(context: vscode.ExtensionContext): string {
|
|
function getLLDBDownloadUrl(context: vscode.ExtensionContext): string {
|
|
|
- const wamrVersion = require(path.join(context.extensionPath, "package.json")).version;
|
|
|
|
|
|
|
+ const wamrVersion = getWAMRExtensionVersion(context);
|
|
|
const lldbOsUrlSuffix = LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP[os.platform()];
|
|
const lldbOsUrlSuffix = LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP[os.platform()];
|
|
|
|
|
|
|
|
if (!lldbOsUrlSuffix) {
|
|
if (!lldbOsUrlSuffix) {
|
|
@@ -40,15 +54,25 @@ function getLLDBDownloadUrl(context: vscode.ExtensionContext): string {
|
|
|
export function isLLDBInstalled(context: vscode.ExtensionContext): boolean {
|
|
export function isLLDBInstalled(context: vscode.ExtensionContext): boolean {
|
|
|
const extensionPath = context.extensionPath;
|
|
const extensionPath = context.extensionPath;
|
|
|
const lldbOSDir = os.platform();
|
|
const lldbOSDir = os.platform();
|
|
|
- const lldbBinaryPath = path.join(extensionPath, LLDB_RESOURCE_DIR, lldbOSDir, "bin", "lldb");
|
|
|
|
|
|
|
+ const lldbBinaryPath = path.join(
|
|
|
|
|
+ extensionPath,
|
|
|
|
|
+ LLDB_RESOURCE_DIR,
|
|
|
|
|
+ lldbOSDir,
|
|
|
|
|
+ 'bin',
|
|
|
|
|
+ 'lldb'
|
|
|
|
|
+ );
|
|
|
return checkIfFileExists(lldbBinaryPath);
|
|
return checkIfFileExists(lldbBinaryPath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export async function promptInstallLLDB(context: vscode.ExtensionContext) {
|
|
export async function promptInstallLLDB(context: vscode.ExtensionContext) {
|
|
|
const extensionPath = context.extensionPath;
|
|
const extensionPath = context.extensionPath;
|
|
|
- const setupPrompt = "setup";
|
|
|
|
|
- const skipPrompt = "skip";
|
|
|
|
|
- const response = await vscode.window.showWarningMessage('No LLDB instance found. Setup now?', setupPrompt, skipPrompt);
|
|
|
|
|
|
|
+ const setupPrompt = 'setup';
|
|
|
|
|
+ const skipPrompt = 'skip';
|
|
|
|
|
+ const response = await vscode.window.showWarningMessage(
|
|
|
|
|
+ 'No LLDB instance found. Setup now?',
|
|
|
|
|
+ setupPrompt,
|
|
|
|
|
+ skipPrompt
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
if (response === skipPrompt) {
|
|
if (response === skipPrompt) {
|
|
|
return;
|
|
return;
|
|
@@ -61,23 +85,31 @@ export async function promptInstallLLDB(context: vscode.ExtensionContext) {
|
|
|
throw WAMR_LLDB_NOT_SUPPORTED_ERROR;
|
|
throw WAMR_LLDB_NOT_SUPPORTED_ERROR;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const lldbDestinationFolder = path.join(extensionPath, LLDB_RESOURCE_DIR, destinationDir);
|
|
|
|
|
- const lldbZipPath = path.join(lldbDestinationFolder, "bundle.zip");
|
|
|
|
|
|
|
+ const lldbDestinationFolder = path.join(
|
|
|
|
|
+ extensionPath,
|
|
|
|
|
+ LLDB_RESOURCE_DIR,
|
|
|
|
|
+ destinationDir
|
|
|
|
|
+ );
|
|
|
|
|
+ const lldbZipPath = path.join(lldbDestinationFolder, 'bundle.zip');
|
|
|
|
|
|
|
|
vscode.window.showInformationMessage(`Downloading LLDB...`);
|
|
vscode.window.showInformationMessage(`Downloading LLDB...`);
|
|
|
|
|
|
|
|
await downloadFile(downloadUrl, lldbZipPath);
|
|
await downloadFile(downloadUrl, lldbZipPath);
|
|
|
|
|
|
|
|
- vscode.window.showInformationMessage(`LLDB downloaded to ${lldbZipPath}. Installing...`);
|
|
|
|
|
|
|
+ vscode.window.showInformationMessage(
|
|
|
|
|
+ `LLDB downloaded to ${lldbZipPath}. Installing...`
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- const lldbFiles = await unzipFile(lldbZipPath, filename => getLLDBUnzipFilePath(lldbDestinationFolder, filename));
|
|
|
|
|
|
|
+ const lldbFiles = await unzipFile(lldbZipPath, filename =>
|
|
|
|
|
+ getLLDBUnzipFilePath(lldbDestinationFolder, filename)
|
|
|
|
|
+ );
|
|
|
// Allow execution of lldb
|
|
// Allow execution of lldb
|
|
|
- lldbFiles.forEach(file => fs.chmodSync(file, "0775"));
|
|
|
|
|
|
|
+ lldbFiles.forEach(file => fs.chmodSync(file, '0775'));
|
|
|
|
|
|
|
|
- vscode.window.showInformationMessage(`LLDB installed at ${lldbDestinationFolder}`);
|
|
|
|
|
|
|
+ vscode.window.showInformationMessage(
|
|
|
|
|
+ `LLDB installed at ${lldbDestinationFolder}`
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
// Remove the bundle.zip
|
|
// Remove the bundle.zip
|
|
|
fs.unlink(lldbZipPath, () => {});
|
|
fs.unlink(lldbZipPath, () => {});
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|