Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitbake settings sanity checks #46

Merged
merged 1 commit into from
Nov 3, 2023
Merged
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
14 changes: 7 additions & 7 deletions client/src/ui/ClientNotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ export class ClientNotificationManager {

buildHandlers (): Disposable[] {
const handlers = [
this.buildBitBakeNotFoundHandler()
this.bitBakeSettingsErrorHandler()
]

return handlers
}

private buildBitBakeNotFoundHandler (): Disposable {
const isNeverShowAgain = this.checkIsNeverShowAgain('custom/bitBakeNotFound')
private bitBakeSettingsErrorHandler (): Disposable {
const isNeverShowAgain = this.checkIsNeverShowAgain('custom/bitbakeSettingsError')
if (isNeverShowAgain) {
return { dispose: () => {} }
}
return this._client.onNotification('custom/bitBakeNotFound', () => {
return this._client.onNotification('custom/bitbakeSettingsError', (message?: string) => {
void window.showErrorMessage(
'BitBake folder could not be found. Please set its path in the settings. Optionally, also set an environment script.',
'BitBake could not be configured and started. To enable advanced Bitbake features, please configure the Bitbake extension.\n\n' + message,
'Open Settings',
'Close',
'Never Show Again'
)
.then((item) => {
if (item === 'Open Settings') {
void commands.executeCommand('workbench.action.openSettings', 'bitbake')
void commands.executeCommand('workbench.action.openWorkspaceSettings', '@ext:savoirfairelinux.bitbake')
} else if (item === 'Never Show Again') {
void this.neverShowAgain('custom/bitBakeNotFound')
void this.neverShowAgain('custom/bitbakeSettingsError')
}
})
})
Expand Down
6 changes: 3 additions & 3 deletions server/src/ServerNotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function setNotificationManagerConnection (connection: Connection): void
}

export type NotificationType =
'custom/bitBakeNotFound'
'custom/bitbakeSettingsError'

class ServerNotificationManager {
send (type: NotificationType, message?: string): void {
Expand All @@ -27,8 +27,8 @@ class ServerNotificationManager {
void _connection.sendNotification(type, message)
}

sendBitBakeNotFound (): void {
this.send('custom/bitBakeNotFound')
sendBitBakeSettingsError (message?: string): void {
this.send('custom/bitbakeSettingsError', message)
}
}

Expand Down
15 changes: 12 additions & 3 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,30 @@ function setSymbolScanner (newSymbolScanner: SymbolScanner | null): void {
contextHandler.symbolScanner = newSymbolScanner
}

function checkBitbakePresence (): void {
function checkBitbakeSettingsSanity (): boolean {
const bitbakeFolder = bitBakeProjectScanner.bitbakeDriver.bitbakeSettings.pathToBitbakeFolder
const bitbakeBinPath = bitbakeFolder + '/bin/bitbake'

if (!fs.existsSync(bitbakeBinPath)) {
serverNotificationManager.sendBitBakeNotFound()
serverNotificationManager.sendBitBakeSettingsError("Bitbake binary doesn't exist: " + bitbakeBinPath)
return false
}

const pathToEnvScript = bitBakeProjectScanner.bitbakeDriver.bitbakeSettings.pathToEnvScript
if (!fs.existsSync(pathToEnvScript)) {
serverNotificationManager.sendBitBakeSettingsError("Bitbake environment script doesn't exist: " + pathToEnvScript)
return false
}

return true
}

connection.onDidChangeConfiguration((change) => {
logger.level = change.settings.bitbake.loggingLevel
bitBakeProjectScanner.loadSettings(change.settings.bitbake, workspaceRoot)
checkBitbakeSettingsSanity()
bitBakeDocScanner.parseVariablesFile(bitBakeProjectScanner.bitbakeDriver.bitbakeSettings.pathToBitbakeFolder)
bitBakeDocScanner.parseVariableFlagFile(bitBakeProjectScanner.bitbakeDriver.bitbakeSettings.pathToBitbakeFolder)
checkBitbakePresence()
bitBakeProjectScanner.rescanProject()
})

Expand Down
Loading