From d36cf439847b2f9e3940f36c49e952e41005d3b6 Mon Sep 17 00:00:00 2001 From: goerlibe <23436477+goerlibe@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:23:25 +0100 Subject: [PATCH] feat: passing custom options to explorer,optimizer,hotspotDetection --- src/DiscoPoPExtension.ts | 9 +- src/configurationManager/Configuration.ts | 18 ++-- .../ConfigurationDeserializer.ts | 7 +- .../ConfigurationTreeDataProvider.ts | 21 ++--- .../AdvancedConfigurationSettings.ts | 89 +++++++++++++++++++ .../ConfigurationCMake.ts | 80 ++++++++++++++--- .../ConfigurationViewOnly.ts | 4 + .../CMakeBasedInstrumentation.ts | 5 +- src/runners/tools/DiscoPoPExplorer.ts | 11 ++- src/runners/tools/DiscoPoPOptimizer.ts | 16 ++-- src/runners/tools/HotspotDetection.ts | 16 +++- .../workflows/DiscoPoPCMakeWorkflow.ts | 11 ++- .../workflows/DiscoPoPCMakeWorkflowUI.ts | 10 ++- .../HotspotDetectionCMakeWorkflow.ts | 10 ++- .../HotspotDetectionCMakeWorkflowUI.ts | 10 ++- src/runners/workflows/OptimizerWorkflow.ts | 7 +- src/runners/workflows/OptimizerWorkflowUI.ts | 9 +- 17 files changed, 270 insertions(+), 63 deletions(-) create mode 100644 src/configurationManager/configurationImplementations/AdvancedConfigurationSettings.ts diff --git a/src/DiscoPoPExtension.ts b/src/DiscoPoPExtension.ts index 3fcf3bd..7beedc2 100644 --- a/src/DiscoPoPExtension.ts +++ b/src/DiscoPoPExtension.ts @@ -32,6 +32,7 @@ import { Decoration } from './utils/Decorations' import { SimpleTreeNode } from './utils/SimpleTree' import { UIPrompts } from './utils/UIPrompts' import path = require('path') +import { config } from 'process' function logAndShowErrorMessageHandler(error: any, optionalMessage?: string) { if (optionalMessage) { @@ -328,13 +329,9 @@ export class DiscoPoPExtension { this.context.subscriptions.push( vscode.commands.registerCommand( Commands.runOptimizer, - async (configuration: Configuration) => { - // HotspotDetection + async (configuration: RunCapableConfiguration) => { try { - const hsRunner = new OptimizerWorkflowUI( - configuration.dotDiscoPoP - ) - this.dpResults = await hsRunner.run() + this.dpResults = await configuration.runOptimizer() } catch (error: any) { if (error instanceof CancellationError) { UIPrompts.showMessageForSeconds( diff --git a/src/configurationManager/Configuration.ts b/src/configurationManager/Configuration.ts index 645048e..f50fac4 100644 --- a/src/configurationManager/Configuration.ts +++ b/src/configurationManager/Configuration.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode' -import { TreeItem, ThemeIcon, TreeItemCollapsibleState } from 'vscode' -import { ConfigurationTreeItem } from './ConfigurationTreeItem' -import { Editable } from './Editable' +import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode' import { DiscoPoPResults } from '../discoPoP/classes/DiscoPoPResults' import { HotspotDetectionResults } from '../hotspotDetection/classes/HotspotDetectionResults' +import { ConfigurationTreeItem } from './ConfigurationTreeItem' +import { Editable } from './Editable' export interface ConfigurationObserver { onConfigurationChange(configuration: Configuration): void @@ -12,7 +12,7 @@ export interface ConfigurationObserver { export abstract class Configuration implements ConfigurationTreeItem, Editable { public constructor( private _name: string, - onConfigurationChange: ConfigurationObserver + onConfigurationChange: ConfigurationObserver | undefined ) { this._running = false if (onConfigurationChange !== undefined) { @@ -96,11 +96,17 @@ export interface RunCapableConfiguration extends Configuration { runDiscoPoP(): Promise /** - * Runs the HotspotDetection using the configuration's settings. After running, the results are stored in the .discopop directory. - * @returns true if successfully completed, false if aborted + * Runs the HotspotDetection using the configuration's settings. Returns the parsed results * @throws if errors occured */ runHotspotDetection(): Promise + + /** + * !!! Assumes that DiscoPoP was run before !!! + * Runs the optimizer using the configuration's settings. Returns the parsed results + * @throws if errors occured + */ + runOptimizer(): Promise } export enum ConfigurationType { diff --git a/src/configurationManager/ConfigurationDeserializer.ts b/src/configurationManager/ConfigurationDeserializer.ts index 9e6580a..652834c 100644 --- a/src/configurationManager/ConfigurationDeserializer.ts +++ b/src/configurationManager/ConfigurationDeserializer.ts @@ -13,14 +13,17 @@ export default function configurationFromJSON( switch (json.configurationType) { case ConfigurationType.CMake: return new ConfigurationCMake( + observer, json.name, json.projectPath, json.buildPath, - json.buildArguments, json.executableName, json.executableArgumentsForDiscoPoP, json.executableArgumentsForHotspotDetection, - observer + json.buildArguments || '', + json.overrideExplorerArguments || '', + json.overrideOptimizerArguments || '', + json.overrideHotspotDetectionArguments || '' ) case ConfigurationType.ViewOnly: return new ConfigurationViewOnly( diff --git a/src/configurationManager/ConfigurationTreeDataProvider.ts b/src/configurationManager/ConfigurationTreeDataProvider.ts index fd886a9..3105f83 100644 --- a/src/configurationManager/ConfigurationTreeDataProvider.ts +++ b/src/configurationManager/ConfigurationTreeDataProvider.ts @@ -75,13 +75,13 @@ export class ConfigurationTreeDataProvider return } - const buildArguments = await vscode.window.showInputBox({ - prompt: 'Enter the build arguments', - ignoreFocusOut: true, - }) - if (buildArguments === undefined) { - return - } + // const buildArguments = await vscode.window.showInputBox({ + // prompt: 'Enter the build arguments', + // ignoreFocusOut: true, + // }) + // if (buildArguments === undefined) { + // return + // } const executableName = await vscode.window.showInputBox({ prompt: 'Enter the name of the executable', @@ -105,14 +105,15 @@ export class ConfigurationTreeDataProvider ) configuration = new ConfigurationCMake( + this, name, projectPath, buildPath, - buildArguments, executableName, executableArgumentsForDiscoPoP, - [], - this + [] + // use default for the buildArguments + // use default for all override... arguements ) break case ConfigurationType.ViewOnly: diff --git a/src/configurationManager/configurationImplementations/AdvancedConfigurationSettings.ts b/src/configurationManager/configurationImplementations/AdvancedConfigurationSettings.ts new file mode 100644 index 0000000..18095c8 --- /dev/null +++ b/src/configurationManager/configurationImplementations/AdvancedConfigurationSettings.ts @@ -0,0 +1,89 @@ +import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode' +import { ConfigurationTreeItem } from '../ConfigurationTreeItem' +import { Property, PropertyObserver, StringProperty } from '../Property' +import { ConfigurationCMake } from './ConfigurationCMake' + +export class AdvancedConfigurationSettings + implements ConfigurationTreeItem, PropertyObserver +{ + public constructor( + private cmakeConfig: ConfigurationCMake, + overrideExplorerArguments: string = '', + overrideOptimizerArguments: string = '', + overrideHotspotDetectionArguments: string = '' + ) { + this._overrideExplorerArguments = new StringProperty( + 'Override Explorer Arguments', + overrideExplorerArguments, + 'If not empty: override the discopop_explorer arguments with the provided string.', + this + ) + this._overrideOptimizerArguments = new StringProperty( + 'Override Optimizer Arguments', + overrideOptimizerArguments, + 'If not empty: override the optimizer arguments with the provided string.', + this + ) + this._overrideHotspotDetectionArguments = new StringProperty( + 'Override Hotspot Detection Arguments', + overrideHotspotDetectionArguments, + 'If not empty: override the hotspot_detection arguments with the provided string.', + this + ) + } + onPropertyChanged(property: Property): void { + this.refresh() + } + + private readonly _overrideExplorerArguments: StringProperty + public get overrideExplorerArguments(): string { + return this._overrideExplorerArguments.value + } + public set overrideExplorerArguments(value: string) { + this._overrideExplorerArguments.value = value + this.refresh() + } + + private readonly _overrideOptimizerArguments: StringProperty + public get overrideOptimizerArguments(): string { + return this._overrideOptimizerArguments.value + } + public set overrideOptimizerArguments(value: string) { + this._overrideOptimizerArguments.value = value + this.refresh() + } + + private readonly _overrideHotspotDetectionArguments: StringProperty + public get overrideHotspotDetectionArguments(): string { + return this._overrideHotspotDetectionArguments.value + } + public set overrideHotspotDetectionArguments(value: string) { + this._overrideHotspotDetectionArguments.value = value + this.refresh() + } + + public getView(): TreeItem { + const treeItem = new TreeItem( + 'Advanced Settings', + TreeItemCollapsibleState.Collapsed + ) + treeItem.description = + 'Override the default arguments for the explorer, optimizer, and hotspot detection.' + treeItem.iconPath = new ThemeIcon('symbol-class') + treeItem.tooltip = + 'Override the default arguments for the explorer, optimizer, and hotspot detection.' + return treeItem + } + + getChildren(): ConfigurationTreeItem[] { + return [ + this._overrideExplorerArguments, + this._overrideOptimizerArguments, + this._overrideHotspotDetectionArguments, + ] + } + + refresh(): void { + this.cmakeConfig.refresh() + } +} diff --git a/src/configurationManager/configurationImplementations/ConfigurationCMake.ts b/src/configurationManager/configurationImplementations/ConfigurationCMake.ts index 9292d33..bb533f5 100644 --- a/src/configurationManager/configurationImplementations/ConfigurationCMake.ts +++ b/src/configurationManager/configurationImplementations/ConfigurationCMake.ts @@ -1,10 +1,16 @@ -import { CancellationError, TreeItem } from 'vscode' +import { TreeItem } from 'vscode' +import { DiscoPoPResults } from '../../discoPoP/classes/DiscoPoPResults' +import { HotspotDetectionResults } from '../../hotspotDetection/classes/HotspotDetectionResults' +import { DiscoPoPCMakeWorkflowUI } from '../../runners/workflows/DiscoPoPCMakeWorkflowUI' +import { HotspotDetectionCMakeWorkflowUI } from '../../runners/workflows/HotspotDetectionCMakeWorkflowUI' +import { OptimizerWorkflowUI } from '../../runners/workflows/OptimizerWorkflowUI' import { Configuration, ConfigurationObserver, ConfigurationType, RunCapableConfiguration, } from '../Configuration' +import { ConfigurationTreeItem } from '../ConfigurationTreeItem' import { Property, PropertyObserver, @@ -12,24 +18,24 @@ import { StringProperty, SupportedType, } from '../Property' -import { DiscoPoPResults } from '../../discoPoP/classes/DiscoPoPResults' -import { DiscoPoPCMakeWorkflowUI } from '../../runners/workflows/DiscoPoPCMakeWorkflowUI' -import { HotspotDetectionResults } from '../../hotspotDetection/classes/HotspotDetectionResults' -import { HotspotDetectionCMakeWorkflowUI } from '../../runners/workflows/HotspotDetectionCMakeWorkflowUI' +import { AdvancedConfigurationSettings } from './AdvancedConfigurationSettings' export class ConfigurationCMake extends Configuration implements RunCapableConfiguration, PropertyObserver { public constructor( + onConfigurationChange: ConfigurationObserver | undefined, name: string, projectPath: string, buildPath: string, - buildArguments: string, executableName: string, - executableArgumentsForDiscoPoP: string, - executableArgumentsForHotspotDetection: string[], - onConfigurationChange?: ConfigurationObserver + executableArgumentsForDiscoPoP: string = '', + executableArgumentsForHotspotDetection: string[] = [], + buildArguments: string = '', + overrideExplorerArguments: string = '', + overrideOptimizerArguments: string = '', + overrideHotspotDetectionArguments: string = '' ) { super(name, onConfigurationChange) this._projectPath = new StringProperty( @@ -69,6 +75,12 @@ export class ConfigurationCMake 'Arguments to pass to the executable when running the Hotspot Detection.', this ) + this._advancedConfigurationSettings = new AdvancedConfigurationSettings( + this, + overrideExplorerArguments, + overrideOptimizerArguments, + overrideHotspotDetectionArguments + ) } onPropertyChanged( @@ -145,6 +157,31 @@ export class ConfigurationCMake this.refresh() } + private readonly _advancedConfigurationSettings: AdvancedConfigurationSettings + public get overrideExplorerArguments(): string { + return this._advancedConfigurationSettings.overrideExplorerArguments + } + public set overrideExplorerArguments(value: string) { + this._advancedConfigurationSettings.overrideExplorerArguments = value + this.refresh() + } + public get overrideOptimizerArguments(): string { + return this._advancedConfigurationSettings.overrideOptimizerArguments + } + public set overrideOptimizerArguments(value: string) { + this._advancedConfigurationSettings.overrideOptimizerArguments = value + this.refresh() + } + public get overrideHotspotDetectionArguments(): string { + return this._advancedConfigurationSettings + .overrideHotspotDetectionArguments + } + public set overrideHotspotDetectionArguments(value: string) { + this._advancedConfigurationSettings.overrideHotspotDetectionArguments = + value + this.refresh() + } + // TODO note to self: we should add a PropertyGroup class, which will be collapsible and will contain multiple properties to allow changing advanced settings // e.g. should another discopop installation be used? // e.g. should the build directory be cleared? @@ -159,11 +196,15 @@ export class ConfigurationCMake name: this.name, projectPath: this.projectPath, buildPath: this.buildPath, - buildArguments: this.buildArguments, executableName: this.executableName, executableArgumentsForDiscoPoP: this.executableArgumentsForDiscoPoP, executableArgumentsForHotspotDetection: this.executableArgumentsForHotspotDetection, + buildArguments: this.buildArguments, + overrideExplorerArguments: this.overrideExplorerArguments, + overrideOptimizerArguments: this.overrideOptimizerArguments, + overrideHotspotDetectionArguments: + this.overrideHotspotDetectionArguments, } } @@ -173,7 +214,7 @@ export class ConfigurationCMake return treeItem } - public getChildren(): Property[] { + public getChildren(): ConfigurationTreeItem[] { return [ this._projectPath, this._buildPath, @@ -181,6 +222,7 @@ export class ConfigurationCMake this._executableName, this._executableArgumentsForDiscoPoP, this._executableArgumentsForHotspotDetection, + this._advancedConfigurationSettings, ] } @@ -192,7 +234,10 @@ export class ConfigurationCMake this.executableName, this.executableArgumentsForDiscoPoP, this.buildPathForDiscoPoP, - this.dotDiscoPoP + this.dotDiscoPoP, + this.buildArguments, + this.overrideExplorerArguments, + this.overrideOptimizerArguments ) return await dpRunner.run() // await because we want to catch errors here } catch (error) { @@ -210,7 +255,11 @@ export class ConfigurationCMake this.executableName, this.executableArgumentsForHotspotDetection, this.dotDiscoPoP, - this.buildPathForHotspotDetection + this.buildPathForHotspotDetection, + this.buildArguments, + this.overrideHotspotDetectionArguments + ? this.overrideHotspotDetectionArguments + : undefined ) return await hsRunner.run() // await because we want to catch errors here } catch (error) { @@ -219,4 +268,9 @@ export class ConfigurationCMake this.running = false } } + + public async runOptimizer(): Promise { + const optimizerRunner = new OptimizerWorkflowUI(this.dotDiscoPoP) + return optimizerRunner.run(this.overrideOptimizerArguments) + } } diff --git a/src/configurationManager/configurationImplementations/ConfigurationViewOnly.ts b/src/configurationManager/configurationImplementations/ConfigurationViewOnly.ts index d40f31c..b219347 100644 --- a/src/configurationManager/configurationImplementations/ConfigurationViewOnly.ts +++ b/src/configurationManager/configurationImplementations/ConfigurationViewOnly.ts @@ -35,6 +35,10 @@ export class ConfigurationViewOnly this.refresh() } + public get overrideOptimizerArguments(): string | undefined { + return undefined + } + public readonly configurationType = ConfigurationType.ViewOnly public constructor( diff --git a/src/runners/instrumentation/CMakeBasedInstrumentation.ts b/src/runners/instrumentation/CMakeBasedInstrumentation.ts index 938dfe0..9cd12a8 100644 --- a/src/runners/instrumentation/CMakeBasedInstrumentation.ts +++ b/src/runners/instrumentation/CMakeBasedInstrumentation.ts @@ -19,6 +19,7 @@ export interface CMakeProjectInfo { readonly executableName: string /** the executable will be run once for each entry in the array, providing the entry as command line arguments */ readonly executableArguments: string[] + readonly buildArguments?: string } export class CMakeBasedInstrumentation { @@ -56,8 +57,8 @@ export class CMakeBasedInstrumentation { } await CommandExecution.execute({ command: `${await this.wrapperInfo.cmakeWrapper} ${ - this.projectInfo.srcDirectory - }`, + this.projectInfo.buildArguments || '' + } ${this.projectInfo.srcDirectory}`, cwd: this.projectInfo.buildDirectory, cancelToken: cancelToken, throwOnNonZeroExitCode: true, diff --git a/src/runners/tools/DiscoPoPExplorer.ts b/src/runners/tools/DiscoPoPExplorer.ts index 28dd27b..210abc1 100644 --- a/src/runners/tools/DiscoPoPExplorer.ts +++ b/src/runners/tools/DiscoPoPExplorer.ts @@ -4,14 +4,21 @@ import { CommandExecution } from '../helpers/CommandExecution' export class DiscoPoPExplorer { public constructor(public readonly dotDiscoPoP: string) {} - public async run(cancelToken?: CancelToken): Promise { + public async run( + cancelToken?: CancelToken, + overrideExplorerArguments?: string + ): Promise { await CommandExecution.commandExists( 'discopop_explorer', true, 'Is DiscoPoP installed?' ) + let commandWithArgs = 'discopop_explorer' + if (overrideExplorerArguments) { + commandWithArgs += ' ' + overrideExplorerArguments + } await CommandExecution.execute({ - command: `discopop_explorer`, + command: commandWithArgs, cwd: this.dotDiscoPoP, cancelToken: cancelToken, throwOnNonZeroExitCode: true, diff --git a/src/runners/tools/DiscoPoPOptimizer.ts b/src/runners/tools/DiscoPoPOptimizer.ts index 989de35..6919de3 100644 --- a/src/runners/tools/DiscoPoPOptimizer.ts +++ b/src/runners/tools/DiscoPoPOptimizer.ts @@ -64,7 +64,7 @@ export class DiscoPoPOptimizer { } public async run( - options: OptimizerOptions = DefaultOptimizerOptions, + options: OptimizerOptions | string = DefaultOptimizerOptions, cancelToken?: CancelToken ): Promise { await CommandExecution.commandExists( @@ -73,10 +73,16 @@ export class DiscoPoPOptimizer { 'Is DiscoPoP installed?' ) - // merge provided options with default options - options = { ...DefaultOptimizerOptions, ...options } - - const command = this._buildCommand(options) + // build the command string + let command: string + if (typeof options === 'string') { + console.log('Using override options for optimizer') // TODO: remove (or add it to the other overrides as well) + command = `discopop_optimizer ${options}` + } else { + // merge provided options with default options + options = { ...DefaultOptimizerOptions, ...options } + command = this._buildCommand(options) + } await CommandExecution.execute({ command: command, diff --git a/src/runners/tools/HotspotDetection.ts b/src/runners/tools/HotspotDetection.ts index a8dd442..2361551 100644 --- a/src/runners/tools/HotspotDetection.ts +++ b/src/runners/tools/HotspotDetection.ts @@ -4,14 +4,26 @@ import { CancelToken } from '../helpers/cancellation/CancelToken' export class HotspotDetection { public constructor(public readonly dotDiscoPoP: string) {} - public async run(cancelToken: CancelToken): Promise { + public async run( + cancelToken: CancelToken, + overrideHotspotDetectionArguments?: string + ): Promise { + // Check if hotspot_analyzer is installed await CommandExecution.commandExists( 'hotspot_analyzer', true, 'Is Hotspot Detection installed?' ) + + // build the command + let command: string = `hotspot_analyzer` + if (overrideHotspotDetectionArguments) { + command += ` ${overrideHotspotDetectionArguments}` + } + + // run await CommandExecution.execute({ - command: `hotspot_analyzer`, + command: command, cwd: this.dotDiscoPoP, cancelToken: cancelToken, throwOnNonZeroExitCode: true, diff --git a/src/runners/workflows/DiscoPoPCMakeWorkflow.ts b/src/runners/workflows/DiscoPoPCMakeWorkflow.ts index 0d7804a..4ffe201 100644 --- a/src/runners/workflows/DiscoPoPCMakeWorkflow.ts +++ b/src/runners/workflows/DiscoPoPCMakeWorkflow.ts @@ -23,7 +23,10 @@ export class DiscoPoPCMakeWorkflow { public readonly executableArguments: string = '', public readonly dotDiscoPoP: string = srcDirectory + 'build/.discopop', public readonly buildDirectory: string = srcDirectory + - '/build/DiscoPoP' + '/build/DiscoPoP', + public readonly buildArguments: string = '', + public readonly overrideExplorerArguments?: string, + public readonly overrideOptimizerArguments?: string ) {} /** @@ -49,6 +52,7 @@ export class DiscoPoPCMakeWorkflow { executableName: this.executableName, executableArguments: [this.executableArguments], buildDirectory: this.buildDirectory, + buildArguments: this.buildArguments, } ) @@ -87,7 +91,10 @@ export class DiscoPoPCMakeWorkflow { this.throwUponCancellation(cancelToken) reportMessage('Running Pattern Detection...', 0) - await toolSuite.discopopExplorer.run(cancelToken) // TODO allow additional arguments? + await toolSuite.discopopExplorer.run( + cancelToken, + this.overrideExplorerArguments + ) // TODO allow additional arguments? reportProgress(30) this.throwUponCancellation(cancelToken) diff --git a/src/runners/workflows/DiscoPoPCMakeWorkflowUI.ts b/src/runners/workflows/DiscoPoPCMakeWorkflowUI.ts index 1128869..bf1dbcd 100644 --- a/src/runners/workflows/DiscoPoPCMakeWorkflowUI.ts +++ b/src/runners/workflows/DiscoPoPCMakeWorkflowUI.ts @@ -11,7 +11,10 @@ export class DiscoPoPCMakeWorkflowUI { public readonly executableName: string, public readonly executableArguments: string = '', public readonly buildDirectory?: string, - public readonly dotDiscoPoP?: string + public readonly dotDiscoPoP?: string, + public readonly buildArguments?: string, + public readonly overrideExplorerArguments?: string, + public readonly overrideOptimizerArguments?: string ) { if (!this.buildDirectory) { this.buildDirectory = projectDirectory + '/build/DiscoPoP' @@ -62,7 +65,10 @@ export class DiscoPoPCMakeWorkflowUI { this.executableName, this.executableArguments, this.dotDiscoPoP, - this.buildDirectory + this.buildDirectory, + this.buildArguments, + this.overrideExplorerArguments, + this.overrideOptimizerArguments ) // await because we want to catch errors diff --git a/src/runners/workflows/HotspotDetectionCMakeWorkflow.ts b/src/runners/workflows/HotspotDetectionCMakeWorkflow.ts index a402a2b..defc70c 100644 --- a/src/runners/workflows/HotspotDetectionCMakeWorkflow.ts +++ b/src/runners/workflows/HotspotDetectionCMakeWorkflow.ts @@ -23,7 +23,9 @@ export class HotspotDetectionCMakeWorkflow { public readonly executableArguments: string[], public readonly dotDiscoPoP: string = srcDirectory + 'build/.discopop', public readonly buildDirectory: string = srcDirectory + - '/build/HotspotDetection' + '/build/HotspotDetection', + public readonly buildArguments: string = '', + public readonly overrideExplorerArguments?: string ) {} /** @@ -49,6 +51,7 @@ export class HotspotDetectionCMakeWorkflow { executableName: this.executableName, executableArguments: this.executableArguments, buildDirectory: this.buildDirectory, + buildArguments: this.buildArguments, } ) @@ -87,7 +90,10 @@ export class HotspotDetectionCMakeWorkflow { this.throwUponCancellation(cancelToken) reportMessage('Running Hotspot Analysis...', 0) - await dpRunner.hotspotDetection.run(cancelToken) // TODO allow additional arguments? + await dpRunner.hotspotDetection.run( + cancelToken, + this.overrideExplorerArguments + ) // TODO allow additional arguments? reportProgress(30) this.throwUponCancellation(cancelToken) diff --git a/src/runners/workflows/HotspotDetectionCMakeWorkflowUI.ts b/src/runners/workflows/HotspotDetectionCMakeWorkflowUI.ts index 9586455..e1564f3 100644 --- a/src/runners/workflows/HotspotDetectionCMakeWorkflowUI.ts +++ b/src/runners/workflows/HotspotDetectionCMakeWorkflowUI.ts @@ -1,8 +1,8 @@ import * as vscode from 'vscode' +import { HotspotDetectionResults } from '../../hotspotDetection/classes/HotspotDetectionResults' import { UIPrompts } from '../../utils/UIPrompts' import { CancelToken } from '../helpers/cancellation/CancelToken' import { UICancelTokenWrapper as UICancelToken } from '../helpers/cancellation/UICancelTokenWrapper' -import { HotspotDetectionResults } from '../../hotspotDetection/classes/HotspotDetectionResults' import { HotspotDetectionCMakeWorkflow } from './HotspotDetectionCMakeWorkflow' export class HotspotDetectionCMakeWorkflowUI { @@ -13,7 +13,9 @@ export class HotspotDetectionCMakeWorkflowUI { public readonly dotDiscoPoP: string = projectDirectory + 'build/.discopop', public readonly buildDirectory: string = projectDirectory + - '/build/HotspotDetection' + '/build/HotspotDetection', + public readonly buildArguments: string = '', + public readonly overridHotspotDetectionArguments?: string ) {} public async run(): Promise { @@ -58,7 +60,9 @@ export class HotspotDetectionCMakeWorkflowUI { this.executableName, this.executableArguments, this.dotDiscoPoP, - this.buildDirectory + this.buildDirectory, + this.buildArguments, + this.overridHotspotDetectionArguments ) // await because we want to catch errors diff --git a/src/runners/workflows/OptimizerWorkflow.ts b/src/runners/workflows/OptimizerWorkflow.ts index 13c9d8b..50a3b7b 100644 --- a/src/runners/workflows/OptimizerWorkflow.ts +++ b/src/runners/workflows/OptimizerWorkflow.ts @@ -10,13 +10,16 @@ export class OptimizerWorkflow { public async run( reportMessage: (message: string, nesting: number) => void, reportProgress: (progress: number) => void, - cancelToken: CancelToken + cancelToken: CancelToken, + overrideOptionsString?: string ): Promise { const toolSuite = new ToolSuite(this.dotDiscoPoP) reportMessage('Running Optimizer...', 0) await toolSuite.discopopOptimizer.run( - DefaultOptimizerOptions, + overrideOptionsString + ? overrideOptionsString + : DefaultOptimizerOptions, cancelToken ) reportProgress(80) diff --git a/src/runners/workflows/OptimizerWorkflowUI.ts b/src/runners/workflows/OptimizerWorkflowUI.ts index 4be2df1..7544f68 100644 --- a/src/runners/workflows/OptimizerWorkflowUI.ts +++ b/src/runners/workflows/OptimizerWorkflowUI.ts @@ -7,7 +7,7 @@ import { OptimizerWorkflow } from './OptimizerWorkflow' export class OptimizerWorkflowUI { public constructor(public readonly dotDiscoPoP: string) {} - public async run(): Promise { + public async run(overrideOptionsString?: string): Promise { return vscode.window.withProgress( { location: vscode.ProgressLocation.Notification, @@ -38,12 +38,13 @@ export class OptimizerWorkflowUI { const cancelToken: CancelToken = new UICancelTokenWrapper(token) - const dpRunnerCMake = new OptimizerWorkflow(this.dotDiscoPoP) + const optimizerRunner = new OptimizerWorkflow(this.dotDiscoPoP) - return await dpRunnerCMake.run( + return await optimizerRunner.run( reportMessageWrapper, reportProgressWrapper, - cancelToken + cancelToken, + overrideOptionsString ? overrideOptionsString : undefined // ternary operator to avoid passing empty string, instead pass undefined ) } )