Skip to content

Commit

Permalink
Feature: Display Bitbake and Devtool builds in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
deribaucourt committed Dec 27, 2023
1 parent 045c6e4 commit 7a4f0de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/src/driver/BitbakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import childProcess from 'child_process'
import fs from 'fs'
import EventEmitter from 'events'

import { logger } from '../lib/src/utils/OutputLogger'
import { type BitbakeSettings, loadBitbakeSettings } from '../lib/src/BitbakeSettings'
Expand All @@ -18,6 +19,7 @@ export class BitbakeDriver {
bitbakeSettings: BitbakeSettings = { pathToBitbakeFolder: '', pathToBuildFolder: '', pathToEnvScript: '', workingDirectory: '', commandWrapper: '' }
bitbakeProcess: childProcess.ChildProcess | undefined
bitbakeProcessCommand: string | undefined
onBitbakeProcessChange: EventEmitter = new EventEmitter()

loadSettings (settings: any, workspaceFolder: string = '.'): void {
this.bitbakeSettings = loadBitbakeSettings(settings, workspaceFolder)
Expand Down Expand Up @@ -47,9 +49,13 @@ export class BitbakeDriver {
})
this.bitbakeProcess = child
this.bitbakeProcessCommand = command
child.on('spawn', () => {
this.onBitbakeProcessChange.emit('spawn', command)
})
child.on('close', () => {
this.bitbakeProcess = undefined
this.bitbakeProcessCommand = undefined
this.onBitbakeProcessChange.emit('close')
})
return child
}
Expand Down
20 changes: 20 additions & 0 deletions client/src/ui/BitbakeStatusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class BitbakeStatusBar {
readonly statusBarItem: vscode.StatusBarItem
private scanInProgress = false
private parsingInProgress = false
private commandInProgress: string | undefined
private scanExitCode = 0

constructor (bitbakeProjectScanner: BitBakeProjectScanner) {
Expand All @@ -33,6 +34,15 @@ export class BitbakeStatusBar {
this.updateStatusBar()
})

this.bitbakeProjectScanner.bitbakeDriver.onBitbakeProcessChange.on('spawn', (command) => {
this.commandInProgress = command
this.updateStatusBar()
})
this.bitbakeProjectScanner.bitbakeDriver.onBitbakeProcessChange.on('close', () => {
this.commandInProgress = undefined
this.updateStatusBar()
})

vscode.tasks.onDidStartTask((e: vscode.TaskStartEvent) => {
if (e.execution.task.name === 'Bitbake: Parse' && e.execution.task.source === 'bitbake') {
this.parsingInProgress = true
Expand Down Expand Up @@ -61,6 +71,16 @@ export class BitbakeStatusBar {
this.statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.prominentBackground')
return
}
if (this.commandInProgress !== undefined) {
let displayText = 'Building...'
if (this.commandInProgress.includes('which bitbake')) displayText = 'Scanning...'
if (this.commandInProgress.includes('devtool')) displayText = 'Devtool...'
this.statusBarItem.text = '$(loading~spin) BitBake: ' + displayText
this.statusBarItem.tooltip = 'BitBake: ' + displayText
this.statusBarItem.command = undefined
this.statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.prominentBackground')
return
}
if (this.scanExitCode !== 0) {
this.statusBarItem.text = '$(error) BitBake: Parsing error'
this.statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground')
Expand Down

0 comments on commit 7a4f0de

Please sign in to comment.