@@ -7,27 +7,41 @@ import * as vscode from 'vscode';
77import * as os from 'os' ;
88import * as path from 'path' ;
99import * as fs from 'fs' ;
10- import { checkIfFileExists , downloadFile , unzipFile } from './directoryUtilities' ;
11-
12- const LLDB_RESOURCE_DIR = "resource/debug" ;
13- const LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP : Partial < Record < NodeJS . Platform , string > > = {
14- "linux" : "x86_64-ubuntu-22.04" ,
15- "darwin" : "universal-macos-latest"
10+ import {
11+ checkIfFileExists ,
12+ downloadFile ,
13+ unzipFile ,
14+ } from './directoryUtilities' ;
15+
16+ const LLDB_RESOURCE_DIR = 'resource/debug' ;
17+ const LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP : Partial <
18+ Record < NodeJS . Platform , string >
19+ > = {
20+ linux : 'x86_64-ubuntu-22.04' ,
21+ darwin : 'universal-macos-latest' ,
1622} ;
1723
18- const WAMR_LLDB_NOT_SUPPORTED_ERROR = new Error ( "WAMR LLDB is not supported on this platform" ) ;
24+ const WAMR_LLDB_NOT_SUPPORTED_ERROR = new Error (
25+ 'WAMR LLDB is not supported on this platform'
26+ ) ;
1927
2028function getLLDBUnzipFilePath ( destinationFolder : string , filename : string ) {
21- const dirs = filename . split ( "/" ) ;
22- if ( dirs [ 0 ] === " inst" ) {
29+ const dirs = filename . split ( '/' ) ;
30+ if ( dirs [ 0 ] === ' inst' ) {
2331 dirs . shift ( ) ;
2432 }
2533
2634 return path . join ( destinationFolder , ...dirs ) ;
2735}
2836
37+ export function getWAMRExtensionVersion (
38+ context : vscode . ExtensionContext
39+ ) : string {
40+ return require ( path . join ( context . extensionPath , 'package.json' ) ) . version ;
41+ }
42+
2943function getLLDBDownloadUrl ( context : vscode . ExtensionContext ) : string {
30- const wamrVersion = require ( path . join ( context . extensionPath , "package.json" ) ) . version ;
44+ const wamrVersion = getWAMRExtensionVersion ( context ) ;
3145 const lldbOsUrlSuffix = LLDB_OS_DOWNLOAD_URL_SUFFIX_MAP [ os . platform ( ) ] ;
3246
3347 if ( ! lldbOsUrlSuffix ) {
@@ -40,15 +54,25 @@ function getLLDBDownloadUrl(context: vscode.ExtensionContext): string {
4054export function isLLDBInstalled ( context : vscode . ExtensionContext ) : boolean {
4155 const extensionPath = context . extensionPath ;
4256 const lldbOSDir = os . platform ( ) ;
43- const lldbBinaryPath = path . join ( extensionPath , LLDB_RESOURCE_DIR , lldbOSDir , "bin" , "lldb" ) ;
57+ const lldbBinaryPath = path . join (
58+ extensionPath ,
59+ LLDB_RESOURCE_DIR ,
60+ lldbOSDir ,
61+ 'bin' ,
62+ 'lldb'
63+ ) ;
4464 return checkIfFileExists ( lldbBinaryPath ) ;
4565}
4666
4767export async function promptInstallLLDB ( context : vscode . ExtensionContext ) {
4868 const extensionPath = context . extensionPath ;
49- const setupPrompt = "setup" ;
50- const skipPrompt = "skip" ;
51- const response = await vscode . window . showWarningMessage ( 'No LLDB instance found. Setup now?' , setupPrompt , skipPrompt ) ;
69+ const setupPrompt = 'setup' ;
70+ const skipPrompt = 'skip' ;
71+ const response = await vscode . window . showWarningMessage (
72+ 'No LLDB instance found. Setup now?' ,
73+ setupPrompt ,
74+ skipPrompt
75+ ) ;
5276
5377 if ( response === skipPrompt ) {
5478 return ;
@@ -61,23 +85,31 @@ export async function promptInstallLLDB(context: vscode.ExtensionContext) {
6185 throw WAMR_LLDB_NOT_SUPPORTED_ERROR ;
6286 }
6387
64- const lldbDestinationFolder = path . join ( extensionPath , LLDB_RESOURCE_DIR , destinationDir ) ;
65- const lldbZipPath = path . join ( lldbDestinationFolder , "bundle.zip" ) ;
88+ const lldbDestinationFolder = path . join (
89+ extensionPath ,
90+ LLDB_RESOURCE_DIR ,
91+ destinationDir
92+ ) ;
93+ const lldbZipPath = path . join ( lldbDestinationFolder , 'bundle.zip' ) ;
6694
6795 vscode . window . showInformationMessage ( `Downloading LLDB...` ) ;
6896
6997 await downloadFile ( downloadUrl , lldbZipPath ) ;
7098
71- vscode . window . showInformationMessage ( `LLDB downloaded to ${ lldbZipPath } . Installing...` ) ;
99+ vscode . window . showInformationMessage (
100+ `LLDB downloaded to ${ lldbZipPath } . Installing...`
101+ ) ;
72102
73- const lldbFiles = await unzipFile ( lldbZipPath , filename => getLLDBUnzipFilePath ( lldbDestinationFolder , filename ) ) ;
103+ const lldbFiles = await unzipFile ( lldbZipPath , filename =>
104+ getLLDBUnzipFilePath ( lldbDestinationFolder , filename )
105+ ) ;
74106 // Allow execution of lldb
75- lldbFiles . forEach ( file => fs . chmodSync ( file , " 0775" ) ) ;
107+ lldbFiles . forEach ( file => fs . chmodSync ( file , ' 0775' ) ) ;
76108
77- vscode . window . showInformationMessage ( `LLDB installed at ${ lldbDestinationFolder } ` ) ;
109+ vscode . window . showInformationMessage (
110+ `LLDB installed at ${ lldbDestinationFolder } `
111+ ) ;
78112
79113 // Remove the bundle.zip
80114 fs . unlink ( lldbZipPath , ( ) => { } ) ;
81115}
82-
83-
0 commit comments