Skip to content

Commit

Permalink
Fix: Revert devtool --help ide-sdk discovery for eSDKMode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deribaucourt committed Jan 6, 2025
1 parent 3fdc528 commit cbbb429
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
6 changes: 3 additions & 3 deletions client/src/__tests__/unit-tests/ui/bitbake-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ describe('Devtool ide-sdk command', () => {

it('should properly detect devtool modify options', async () => {
// Test addDevtoolDebugBuild
expect(addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings)).toBe(' --debug-build')
expect(addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: true} as BitbakeSettings)).toBe('')
expect(addDevtoolDebugBuild('', {_bitbakeVersion: '1.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings)).toBe('')
expect(await addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings, undefined as unknown as BitbakeDriver)).toBe(' --debug-build')
expect(await addDevtoolDebugBuild('', {_bitbakeVersion: '3.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: true} as BitbakeSettings, undefined as unknown as BitbakeDriver)).toBe('')
expect(await addDevtoolDebugBuild('', {_bitbakeVersion: '1.0.0'} as BitbakeScanResult, {disableDevtoolDebugBuild: false} as BitbakeSettings, undefined as unknown as BitbakeDriver)).toBe('')
})
})
34 changes: 24 additions & 10 deletions client/src/ui/BitbakeCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ async function rescanProject (bitBakeProjectScanner: BitBakeProjectScanner): Pro
}

// Exported for testing
export function addDevtoolDebugBuild(command: string, scanResult: BitbakeScanResult, settings: BitbakeSettings): string {
if (checkDevtoolDebugBuildAvailable(scanResult) && !settings.disableDevtoolDebugBuild) {
export async function addDevtoolDebugBuild(command: string, scanResult: BitbakeScanResult, settings: BitbakeSettings, bitbakeDriver: BitbakeDriver): Promise<string> {
if (await checkDevtoolDebugBuildAvailable(scanResult, bitbakeDriver) && !settings.disableDevtoolDebugBuild) {
command += ' --debug-build'
}
return command
Expand All @@ -392,7 +392,7 @@ async function devtoolModifyCommand (bitbakeWorkspace: BitbakeWorkspace, bitBake
if (chosenRecipe !== undefined) {
logger.debug(`Command: devtool-modify: ${chosenRecipe}`)
let command = `devtool modify ${chosenRecipe}`
command = addDevtoolDebugBuild(command, bitBakeProjectScanner.scanResult, bitBakeProjectScanner.bitbakeDriver.bitbakeSettings)
command = await addDevtoolDebugBuild(command, bitBakeProjectScanner.scanResult, bitBakeProjectScanner.bitbakeDriver.bitbakeSettings, bitBakeProjectScanner.bitbakeDriver)
const process = await runBitbakeTerminalCustomCommand(bitBakeProjectScanner.bitbakeDriver, command, `Bitbake: Devtool Modify: ${chosenRecipe}`)
process.onExit((event) => {
if (event.exitCode === 0) {
Expand Down Expand Up @@ -442,7 +442,7 @@ async function devtoolIdeSDKCommand (bitbakeWorkspace: BitbakeWorkspace, bitBake
clientNotificationManager.showSDKConfigurationError()
return
}
if (!checkIdeSdkAvailable(bitBakeProjectScanner.scanResult)) {
if (!await checkIdeSdkAvailable(bitBakeProjectScanner.scanResult, bitBakeProjectScanner.bitbakeDriver)) {
clientNotificationManager.showSDKUnavailableError(chosenRecipe)
return
}
Expand All @@ -453,14 +453,28 @@ async function devtoolIdeSDKCommand (bitbakeWorkspace: BitbakeWorkspace, bitBake
}
}

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

function checkDevtoolDebugBuildAvailable (scanResult: BitbakeScanResult): boolean {
// devtool debug-build appeared in Yocto version Walnascard
return bitbakeVersionAbove(scanResult, '2.12.0')
async function checkDevtoolDebugBuildAvailable (scanResult: BitbakeScanResult, bitbakeDriver: BitbakeDriver): Promise<boolean> {
if(!bitbakeESDKMode) {
// devtool debug-build appeared in Yocto version Walnascard
return bitbakeVersionAbove(scanResult, '2.12.0')
} else {
const command = "devtool modify --help | grep '\\-\\-debug-build'"
const process = runBitbakeTerminalCustomCommand(bitbakeDriver, command, 'Bitbake: Devtool debug-build: check')
const res = await finishProcessExecution(process)
return res.status === 0
}
}

function checkIdeSdkConfiguration (bitbakeDriver: BitbakeDriver): boolean {
Expand Down

0 comments on commit cbbb429

Please sign in to comment.