Skip to content

Commit 183a23b

Browse files
committed
More changes need to test
1 parent c6ed6a3 commit 183a23b

File tree

2 files changed

+30
-73
lines changed

2 files changed

+30
-73
lines changed

src/setup_utilities/west-operations.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,23 @@ export async function westUpdateWithRequirements(context: vscode.ExtensionContex
343343
return true;
344344
}
345345

346-
export async function postWorkspaceSetup(context: vscode.ExtensionContext, wsConfig: WorkspaceConfig, globalConfig: GlobalConfig, setupPath: string) {
346+
export async function postWorkspaceSetup(context: vscode.ExtensionContext, wsConfig: WorkspaceConfig, globalConfig: GlobalConfig, setupPath: string, westSelection: WestLocation | undefined) {
347+
// Setup west environment before initialization
348+
const venvPath = path.join(setupPath, ".venv");
349+
if (!fs.pathExistsSync(venvPath)) {
350+
output.appendLine("[SETUP] No .venv folder found, setting up west environment...");
351+
await setupWestEnvironment(context, wsConfig, globalConfig, false);
352+
output.appendLine("[SETUP] Continuing...");
353+
}
354+
355+
if (westSelection) {
356+
let westInitResult = await westInit(context, wsConfig, globalConfig, false, westSelection);
357+
if (!westInitResult) {
358+
vscode.window.showErrorMessage("Failed to initialize west with git repository.");
359+
return false;
360+
}
361+
}
362+
347363
return westUpdateWithRequirements(context, wsConfig, globalConfig, {
348364
solo: true,
349365
isWorkspaceSetup: true,

src/setup_utilities/workspace-setup.ts

Lines changed: 13 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ export async function workspaceSetupFromWestGit(context: vscode.ExtensionContext
129129
return false;
130130
}
131131

132-
// Setup west environment before initialization
133-
await setupWestEnvironment(context, wsConfig, globalConfig, false);
134132

135133
// Initialize west with the provided git URL
136134
let westSelection: WestLocation = {
@@ -140,14 +138,8 @@ export async function workspaceSetupFromWestGit(context: vscode.ExtensionContext
140138
additionalArgs: ""
141139
};
142140

143-
let westInitResult = await westInit(context, wsConfig, globalConfig, false, westSelection);
144-
145-
if (!westInitResult) {
146-
vscode.window.showErrorMessage("Failed to initialize west with git repository.");
147-
return false;
148-
}
149141
// Run post-setup process
150-
postWorkspaceSetup(context, wsConfig, globalConfig, currentDir);
142+
postWorkspaceSetup(context, wsConfig, globalConfig, currentDir, westSelection);
151143
return true;
152144
}
153145

@@ -181,23 +173,8 @@ export async function workspaceSetupStandard(context: vscode.ExtensionContext, w
181173
return false;
182174
}
183175

184-
// If west selector created a manifest, we need to run west init
185-
if (westSelection.path || westSelection.gitRepo) {
186-
output.appendLine("[SETUP] Initializing west with selected configuration...");
187-
188-
// Setup west environment before initialization
189-
await setupWestEnvironment(context, wsConfig, globalConfig, false);
190-
191-
let westInitResult = await westInit(context, wsConfig, globalConfig, false, westSelection);
192-
193-
if (!westInitResult) {
194-
vscode.window.showErrorMessage("Failed to initialize west workspace.");
195-
return false;
196-
}
197-
}
198-
199176
// Run post-setup process (same as current directory)
200-
postWorkspaceSetup(context, wsConfig, globalConfig, currentDir);
177+
postWorkspaceSetup(context, wsConfig, globalConfig, currentDir, westSelection);
201178
return true;
202179
}
203180

@@ -330,30 +307,22 @@ export async function workspaceSetupFromCurrentDirectory(context: vscode.Extensi
330307

331308
}
332309

333-
if (using_current_directory_for_install) {
334-
// Check if .venv folder exists - if not, setup west environment
335-
const venvPath = path.join(currentDir, ".venv");
336-
if (!fs.pathExistsSync(venvPath)) {
337-
output.appendLine("[SETUP] No .venv folder found, setting up west environment...");
338-
await setupWestEnvironment(context, wsConfig, globalConfig, false);
339-
output.appendLine("[SETUP] Continuing...");
340-
}
310+
let westSelection: WestLocation | undefined = undefined;
341311

312+
if (using_current_directory_for_install) {
342313
// Set up the workspace using current directory
343314
await setSetupState(context, wsConfig, globalConfig, currentDir);
344315
if (westYmlPath) {
345-
let westSelection: WestLocation = {
316+
westSelection = {
346317
path: westYmlPath,
347318
failed: false,
348319
gitRepo: "",
349320
additionalArgs: ""
350321
};
351-
352-
westInit(context, wsConfig, globalConfig, false, westSelection);
353322
}
354323
}
355324
// Run post-setup process
356-
postWorkspaceSetup(context, wsConfig, globalConfig, currentDir);
325+
postWorkspaceSetup(context, wsConfig, globalConfig, currentDir, westSelection);
357326
return true;
358327
}
359328

@@ -421,24 +390,10 @@ export async function workspaceSetupGlobalZephyr(context: vscode.ExtensionContex
421390
return false;
422391
}
423392

424-
// If west selector created a manifest, we need to run west init
425-
if (westSelection.path || westSelection.gitRepo) {
426-
output.appendLine("[SETUP] Initializing west with selected configuration...");
427-
428-
// Setup west environment before initialization
429-
await setupWestEnvironment(context, wsConfig, globalConfig, false);
430-
431-
let westInitResult = await westInit(context, wsConfig, globalConfig, false, westSelection);
432-
433-
if (!westInitResult) {
434-
vscode.window.showErrorMessage("Failed to initialize west workspace.");
435-
return false;
436-
}
437-
}
438393

439394
// Run post-setup process
440395

441-
postWorkspaceSetup(context, wsConfig, globalConfig, globalToolsDir).then(
396+
postWorkspaceSetup(context, wsConfig, globalConfig, globalToolsDir, westSelection).then(
442397
result => {
443398
if (result) {
444399
vscode.window.showInformationMessage(`Global Zephyr installation created and workspace configured at: ${globalToolsDir}`);
@@ -530,23 +485,9 @@ export async function workspaceSetupCreateNewShared(context: vscode.ExtensionCon
530485
return false;
531486
}
532487

533-
// If west selector created a manifest, we need to run west init
534-
if (westSelection.path || westSelection.gitRepo) {
535-
output.appendLine("[SETUP] Initializing west with selected configuration...");
536-
537-
// Setup west environment before initialization
538-
await setupWestEnvironment(context, wsConfig, globalConfig, false);
539-
540-
let westInitResult = await westInit(context, wsConfig, globalConfig, false, westSelection);
541-
542-
if (!westInitResult) {
543-
vscode.window.showErrorMessage("Failed to initialize west workspace.");
544-
return false;
545-
}
546-
}
547488

548489
// Run post-setup process
549-
postWorkspaceSetup(context, wsConfig, globalConfig, selectedPath).then(
490+
postWorkspaceSetup(context, wsConfig, globalConfig, selectedPath, westSelection).then(
550491
result => {
551492
if (result) {
552493
vscode.window.showInformationMessage(`New shared Zephyr installation created at: ${selectedPath}`);
@@ -570,14 +511,14 @@ async function selectExistingInstallation(wsConfig: WorkspaceConfig, globalConfi
570511
const setupState = globalConfig.setupStateDictionary[installPath];
571512
let description = "";
572513

573-
// Add helpful descriptions
574-
const versionStr = setupState.zephyrVersion ? String(setupState.zephyrVersion) : "installation";
514+
// Add helpful descriptionsconst
515+
let versionStr = setupState.zephyrVersion ? setupState.zephyrVersion.major + "." + setupState.zephyrVersion.minor + "." + setupState.zephyrVersion.patch : "installation";
575516
if (installPath === getToolsDir()) {
576-
description = `Global ${versionStr}`;
517+
description = `Global Zephyr ${versionStr}`;
577518
} else if (installPath === wsConfig.rootPath) {
578-
description = `Current ${versionStr}`;
519+
description = `Current Zephyr ${versionStr}`;
579520
} else if (setupState.zephyrVersion) {
580-
description = versionStr;
521+
description = `Zephyr ` + versionStr;
581522
} else {
582523
description = "West installation";
583524
}

0 commit comments

Comments
 (0)