Skip to content

Commit c04d6f0

Browse files
committed
Fix: Revert devtool --help ide-sdk discovery for eSDKMode
In eSDK mode, we don't have access to the bitbake version. Revert to the previous behavior of checking the availability of devtool ide-sdk and devtool debug-build based on the help message.
1 parent 4674c70 commit c04d6f0

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

client/src/__tests__/unit-tests/ui/bitbake-commands.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ describe('Devtool ide-sdk command', () => {
9191

9292
it('should properly detect devtool modify options', async () => {
9393
// Test addDevtoolDebugBuild
94-
expect(addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings)).toBe(' --debug-build')
95-
expect(addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: true} as BitbakeSettings)).toBe('')
96-
expect(addDevtoolDebugBuild('', {_bitbakeVersion: '1.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings)).toBe('')
94+
expect(await addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings, undefined as unknown as BitbakeDriver)).toBe(' --debug-build')
95+
expect(await addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: true} as BitbakeSettings, undefined as unknown as BitbakeDriver)).toBe('')
96+
expect(await addDevtoolDebugBuild('', {_bitbakeVersion: '1.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings, undefined as unknown as BitbakeDriver)).toBe('')
9797
})
9898
})

client/src/ui/BitbakeCommands.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ async function rescanProject (bitBakeProjectScanner: BitBakeProjectScanner): Pro
380380
}
381381

382382
// Exported for testing
383-
export function addDevtoolDebugBuild(command: string, scanResult: BitbakeScanResult, settings: BitbakeSettings): string {
384-
if (checkDevtoolDebugBuildAvailable(scanResult) && !settings.disableDevtoolDebugBuild) {
383+
export async function addDevtoolDebugBuild(command: string, scanResult: BitbakeScanResult, settings: BitbakeSettings, bitbakeDriver: BitbakeDriver): Promise<string> {
384+
if (await checkDevtoolDebugBuildAvailable(scanResult, bitbakeDriver) && !settings.disableDevtoolDebugBuild) {
385385
command += ' --debug-build'
386386
}
387387
return command
@@ -392,7 +392,7 @@ async function devtoolModifyCommand (bitbakeWorkspace: BitbakeWorkspace, bitBake
392392
if (chosenRecipe !== undefined) {
393393
logger.debug(`Command: devtool-modify: ${chosenRecipe}`)
394394
let command = `devtool modify ${chosenRecipe}`
395-
command = addDevtoolDebugBuild(command, bitBakeProjectScanner.scanResult, bitBakeProjectScanner.bitbakeDriver.bitbakeSettings)
395+
command = await addDevtoolDebugBuild(command, bitBakeProjectScanner.scanResult, bitBakeProjectScanner.bitbakeDriver.bitbakeSettings, bitBakeProjectScanner.bitbakeDriver)
396396
const process = await runBitbakeTerminalCustomCommand(bitBakeProjectScanner.bitbakeDriver, command, `Bitbake: Devtool Modify: ${chosenRecipe}`)
397397
process.onExit((event) => {
398398
if (event.exitCode === 0) {
@@ -442,7 +442,7 @@ async function devtoolIdeSDKCommand (bitbakeWorkspace: BitbakeWorkspace, bitBake
442442
clientNotificationManager.showSDKConfigurationError()
443443
return
444444
}
445-
if (!checkIdeSdkAvailable(bitBakeProjectScanner.scanResult)) {
445+
if (!await checkIdeSdkAvailable(bitBakeProjectScanner.scanResult, bitBakeProjectScanner.bitbakeDriver)) {
446446
clientNotificationManager.showSDKUnavailableError(chosenRecipe)
447447
return
448448
}
@@ -453,14 +453,28 @@ async function devtoolIdeSDKCommand (bitbakeWorkspace: BitbakeWorkspace, bitBake
453453
}
454454
}
455455

456-
function checkIdeSdkAvailable (scanResult: BitbakeScanResult): boolean {
457-
// devtool ide-sdk appeared in Yocto version Scarthgap
458-
return bitbakeVersionAbove(scanResult, '2.8.0')
456+
async function checkIdeSdkAvailable (scanResult: BitbakeScanResult, bitbakeDriver: BitbakeDriver): Promise<boolean> {
457+
if(!bitbakeESDKMode) {
458+
// devtool ide-sdk appeared in Yocto version Scarthgap
459+
return bitbakeVersionAbove(scanResult, '2.8.0')
460+
} else {
461+
const command = "devtool --help | grep 'ide-sdk'"
462+
const process = runBitbakeTerminalCustomCommand(bitbakeDriver, command, 'Bitbake: Devtool ide-sdk: check')
463+
const res = await finishProcessExecution(process)
464+
return res.status === 0
465+
}
459466
}
460467

461-
function checkDevtoolDebugBuildAvailable (scanResult: BitbakeScanResult): boolean {
462-
// devtool debug-build appeared in Yocto version Walnascard
463-
return bitbakeVersionAbove(scanResult, '2.12.0')
468+
async function checkDevtoolDebugBuildAvailable (scanResult: BitbakeScanResult, bitbakeDriver: BitbakeDriver): Promise<boolean> {
469+
if(!bitbakeESDKMode) {
470+
// devtool debug-build appeared in Yocto version Walnascard
471+
return bitbakeVersionAbove(scanResult, '2.12.0')
472+
} else {
473+
const command = "devtool modify --help | grep '\\-\\-debug-build'"
474+
const process = runBitbakeTerminalCustomCommand(bitbakeDriver, command, 'Bitbake: Devtool debug-build: check')
475+
const res = await finishProcessExecution(process)
476+
return res.status === 0
477+
}
464478
}
465479

466480
function checkIdeSdkConfiguration (bitbakeDriver: BitbakeDriver): boolean {

0 commit comments

Comments
 (0)