Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions client/src/__tests__/unit-tests/driver/eSDKMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'
import { BitbakeDriver } from '../../../driver/BitbakeDriver'
import * as BitbakeTerminal from '../../../ui/BitbakeTerminal'
import * as ProcessUtils from '../../../utils/ProcessUtils'
import { bitbakeESDKMode, setBitbakeESDKMode } from '../../../driver/BitbakeESDK'
import { clientNotificationManager } from '../../../ui/ClientNotificationManager'
Expand Down Expand Up @@ -47,7 +46,7 @@ describe('Devtool eSDK Mode Test Suite', () => {
pathToBuildFolder: 'nonexistent'
}
bitbakeDriver.loadSettings(bitbakeSettings, __dirname)
const bitbakeTerminalSpy = jest.spyOn(BitbakeTerminal, 'runBitbakeTerminalCustomCommand').mockImplementation(async () => (undefined as unknown as Promise<IPty>))
const bitbakeTerminalSpy = jest.spyOn(bitbakeDriver, 'runTerminalCommand').mockImplementation(async () => (undefined as unknown as Promise<IPty>))
const bitbakeExecutionSpy = jest.spyOn(ProcessUtils, 'finishProcessExecution')
clientNotificationManager.showBitbakeSettingsError = jest.fn()

Expand Down
19 changes: 13 additions & 6 deletions client/src/driver/BitbakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import fs from 'fs'

import { logger } from '../lib/src/utils/OutputLogger'
import { type BitbakeSettings, loadBitbakeSettings, sanitizeForShell, type BitbakeBuildConfigSettings, getBuildSetting } from '../lib/src/BitbakeSettings'
import { clientNotificationManager } from '../ui/ClientNotificationManager'
import { type BitbakeTaskDefinition } from '../ui/BitbakeTaskProvider'
import { runBitbakeTerminalCustomCommand } from '../ui/BitbakeTerminal'
import { bitbakeESDKMode, setBitbakeESDKMode } from './BitbakeESDK'
import { BITBAKE_EXIT_TIMEOUT, finishProcessExecution, pty } from '../utils/ProcessUtils'

Expand All @@ -23,6 +21,15 @@ export class BitbakeDriver {
bitbakeProcess: IPty | undefined
bitbakeProcessCommand: string | undefined
onBitbakeProcessChange: EventEmitter = new EventEmitter()
logBitbakeSettingsError: (message: string) => void = logger.error.bind(logger)
runTerminalCommand: (
bitbakeDriver: BitbakeDriver,
command: string,
terminalName: string,
isBackground?: boolean
) => Promise<IPty> = async () => {
return {} as IPty;
};

loadSettings (settings: Record<string, unknown>, workspaceFolder: string = '.'): void {
this.bitbakeSettings = loadBitbakeSettings(settings, workspaceFolder)
Expand Down Expand Up @@ -126,25 +133,25 @@ export class BitbakeDriver {

async checkBitbakeSettingsSanity (): Promise<boolean> {
if (!fs.existsSync(this.bitbakeSettings.pathToBitbakeFolder)) {
clientNotificationManager.showBitbakeSettingsError('Bitbake folder not found on disk.')
this.logBitbakeSettingsError('Bitbake folder not found on disk.')
return false
}

const workingDirectory = this.getBuildConfig('workingDirectory')
if (typeof workingDirectory === 'string' && !fs.existsSync(workingDirectory)) {
// If it is not defined, then we will use the workspace folder which is always valid
clientNotificationManager.showBitbakeSettingsError('Working directory does not exist.')
this.logBitbakeSettingsError('Working directory does not exist.')
return false
}

// We could test for devtool and bitbake to know if we are in an eSDK or not
const command = 'which devtool bitbake || true'
const process = runBitbakeTerminalCustomCommand(this, command, 'Bitbake: Sanity test', true)
const process = this.runTerminalCommand(this, command, 'Bitbake: Sanity test', true)
const ret = await finishProcessExecution(process, async () => { await this.killBitbake() })
const outLines = ret.stdout.toString().split(/\r?\n/g)

if (outLines.filter((line) => /devtool$/.test(line)).length === 0) {
clientNotificationManager.showBitbakeSettingsError('devtool not found in $PATH\nSee Bitbake Terminal for command output.')
this.logBitbakeSettingsError('devtool not found in $PATH\nSee Bitbake Terminal for command output.')
return false
}

Expand Down
19 changes: 19 additions & 0 deletions client/src/driver/BitbakeDriverVSCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2025 Savoir-faire Linux. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import { BitbakeDriver } from "./BitbakeDriver";
import { clientNotificationManager } from '../ui/ClientNotificationManager'
import { runBitbakeTerminalCustomCommand } from '../ui/BitbakeTerminal'
import { type IPty } from 'node-pty'

export class BitbakeDriverVSCode extends BitbakeDriver {
logBitbakeSettingsError: (message: string) => void = clientNotificationManager.showBitbakeSettingsError.bind(clientNotificationManager)
runTerminalCommand: (
bitbakeDriver: BitbakeDriver,
command: string,
terminalName: string,
isBackground?: boolean
) => Promise<IPty> = runBitbakeTerminalCustomCommand
}
4 changes: 2 additions & 2 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { type LanguageClient } from 'vscode-languageclient/node'
import { clientNotificationManager } from './ui/ClientNotificationManager'
import { logger } from './lib/src/utils/OutputLogger'
import { activateLanguageServer, deactivateLanguageServer } from './language/languageClient'
import { BitbakeDriver } from './driver/BitbakeDriver'
import { BitbakeDriverVSCode } from './driver/BitbakeDriverVSCode'
import { BitbakeTaskProvider } from './ui/BitbakeTaskProvider'
import { registerBitbakeCommands, registerDevtoolCommands } from './ui/BitbakeCommands'
import { BitbakeWorkspace } from './ui/BitbakeWorkspace'
Expand All @@ -30,7 +30,7 @@ import { embeddedLanguageDocsManager } from './language/EmbeddedLanguageDocsMana
import { NotificationMethod } from './lib/src/types/notifications'

let client: LanguageClient
const bitbakeDriver: BitbakeDriver = new BitbakeDriver()
const bitbakeDriver: BitbakeDriverVSCode = new BitbakeDriverVSCode()
let bitbakeTaskProvider: BitbakeTaskProvider
let taskProvider: vscode.Disposable
const bitbakeWorkspace: BitbakeWorkspace = new BitbakeWorkspace()
Expand Down
Loading