Skip to content

Commit 7d54a7e

Browse files
committed
added commands to setup the sdk and tools
1 parent 04bd45f commit 7d54a7e

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

extension.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,39 @@ function activate(context) {
7878
}
7979
});
8080

81+
// Register individual component installation commands
82+
let installCompilerDisposable = vscode.commands.registerCommand('ps1-dev-extension.installCompiler', async function () {
83+
try {
84+
await installComponent('gcc');
85+
} catch (error) {
86+
vscode.window.showErrorMessage(`Failed to install compiler: ${error.message}`);
87+
}
88+
});
89+
90+
let installSDKDisposable = vscode.commands.registerCommand('ps1-dev-extension.installSDK', async function () {
91+
try {
92+
await installComponent('psn00b_sdk');
93+
} catch (error) {
94+
vscode.window.showErrorMessage(`Failed to install SDK: ${error.message}`);
95+
}
96+
});
97+
98+
let installEmulatorDisposable = vscode.commands.registerCommand('ps1-dev-extension.installEmulator', async function () {
99+
try {
100+
await installComponent('emulator');
101+
} catch (error) {
102+
vscode.window.showErrorMessage(`Failed to install emulator: ${error.message}`);
103+
}
104+
});
105+
106+
let installDebuggerDisposable = vscode.commands.registerCommand('ps1-dev-extension.installDebugger', async function () {
107+
try {
108+
await installComponent('gdb_multiarch_win');
109+
} catch (error) {
110+
vscode.window.showErrorMessage(`Failed to install debugger: ${error.message}`);
111+
}
112+
});
113+
81114
// Fix permissions
82115
const fixPermissionsDisposable = vscode.commands.registerCommand('ps1-dev-extension.fixPermissions', async () => {
83116
await fixToolPermissions();
@@ -88,6 +121,10 @@ function activate(context) {
88121
context.subscriptions.push(buildProjectDisposable);
89122
context.subscriptions.push(runEmulatorDisposable);
90123
context.subscriptions.push(generateISODisposable);
124+
context.subscriptions.push(installCompilerDisposable);
125+
context.subscriptions.push(installSDKDisposable);
126+
context.subscriptions.push(installEmulatorDisposable);
127+
context.subscriptions.push(installDebuggerDisposable);
91128
context.subscriptions.push(fixPermissionsDisposable);
92129
}
93130

@@ -234,6 +271,26 @@ async function setupEnvironment(isManualSetup = false) {
234271
}
235272
}
236273

274+
// Function to install a component
275+
async function installComponent(componentName) {
276+
const config = loadConfig();
277+
const component = config.tools[componentName];
278+
279+
if (component.installed) {
280+
vscode.window.showInformationMessage(`${componentName} is already installed.`);
281+
return;
282+
}
283+
284+
const success = await downloadAndExtractTool(componentName);
285+
if (success) {
286+
component.installed = true;
287+
saveConfig(config);
288+
vscode.window.showInformationMessage(`${componentName} installed successfully.`);
289+
} else {
290+
vscode.window.showErrorMessage(`Failed to install ${componentName}.`);
291+
}
292+
}
293+
237294
// Function to create a Hello World project
238295
async function createHelloWorld() {
239296
// Get the workspace folder

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@
4949
{
5050
"command": "ps1-dev-extension.generateISO",
5151
"title": "PS1: Generate ISO"
52+
},
53+
{
54+
"command": "ps1-dev-extension.installCompiler",
55+
"title": "PS1: Install Compiler"
56+
},
57+
{
58+
"command": "ps1-dev-extension.installSDK",
59+
"title": "PS1: Install SDK"
60+
},
61+
{
62+
"command": "ps1-dev-extension.installEmulator",
63+
"title": "PS1: Install Emulator"
64+
},
65+
{
66+
"command": "ps1-dev-extension.installDebugger",
67+
"title": "PS1: Install Debugger"
5268
}
5369
]
5470
},

0 commit comments

Comments
 (0)