Preconfigure support
This commit is contained in:
Родитель
dda1122df2
Коммит
024890fb87
17
package.json
17
package.json
|
@ -47,6 +47,7 @@
|
|||
"onCommand:makefile.launchDebug",
|
||||
"onCommand:makefile.launchRun",
|
||||
"onCommand:makefile.configure",
|
||||
"onCommand:makefile.preConfigure",
|
||||
"workspaceContains:makefile",
|
||||
"workspaceContains:Makefile"
|
||||
],
|
||||
|
@ -80,6 +81,10 @@
|
|||
{
|
||||
"command": "makefile.configure",
|
||||
"title": "Makefile: Configure"
|
||||
},
|
||||
{
|
||||
"command": "makefile.preConfigure",
|
||||
"title": "Makefile: Preconfigure"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
|
@ -280,6 +285,18 @@
|
|||
"default": true,
|
||||
"description": "Automatically configure Makefile project directories after relevant operations, like change build configuration or makefile target",
|
||||
"scope": "resource"
|
||||
},
|
||||
"makefile.preconfigureScript": {
|
||||
"type": "string",
|
||||
"description": "The path to the script that needs to be run at least once before configure",
|
||||
"default": null,
|
||||
"scope": "resource"
|
||||
},
|
||||
"makefile.alwaysPreconfigure": {
|
||||
"type": "boolean",
|
||||
"description": "Always run the preconfigure script before configure",
|
||||
"default": false,
|
||||
"scope": "resource"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,6 +178,35 @@ export function readExtensionLog(): void {
|
|||
}
|
||||
}
|
||||
|
||||
let preconfigureScript: string | undefined;
|
||||
export function getPreconfigureScript(): string | undefined { return preconfigureScript; }
|
||||
export function setPreconfigureScript(path: string): void { preconfigureScript = path; }
|
||||
|
||||
// Read from settings the path to a script file that needs to have been run at least once
|
||||
// before a sucessful configure of this project.
|
||||
export function readPreconfigureScript(): void {
|
||||
let workspaceConfiguration: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("makefile");
|
||||
preconfigureScript = workspaceConfiguration.get<string>("preconfigureScript");
|
||||
if (preconfigureScript) {
|
||||
preconfigureScript = util.resolvePathToRoot(preconfigureScript);
|
||||
logger.message('Found pre-configure script defined as {0}', preconfigureScript);
|
||||
if (!util.checkFileExistsSync(preconfigureScript)) {
|
||||
logger.message("Preconfigure script not found on disk.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let alwaysPreconfigure: boolean;
|
||||
export function getAlwaysPreconfigure(): boolean { return alwaysPreconfigure; }
|
||||
export function setAlwaysPreconfigure(path: boolean): void { alwaysPreconfigure = path; }
|
||||
|
||||
// Read from settings whether the preconfigure step is supposed to be executed
|
||||
// always before the configure operation.
|
||||
export function readAlwaysPreconfigure(): void {
|
||||
let workspaceConfiguration: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("makefile");
|
||||
alwaysPreconfigure = workspaceConfiguration.get<boolean>("alwaysPreconfigure", false);
|
||||
}
|
||||
|
||||
let dryrunCache: string;
|
||||
export function getDryrunCache(): string { return dryrunCache; }
|
||||
export function setDryrunCache(path: string): void { dryrunCache = path; }
|
||||
|
@ -518,6 +547,8 @@ export function initFromStateAndSettings(): void {
|
|||
readMakePath();
|
||||
readMakefilePath();
|
||||
readBuildLog();
|
||||
readPreconfigureScript();
|
||||
readAlwaysPreconfigure();
|
||||
readDryRunSwitches();
|
||||
readCurrentMakefileConfiguration();
|
||||
readCurrentMakefileConfigurationCommand();
|
||||
|
@ -588,20 +619,43 @@ export function initFromStateAndSettings(): void {
|
|||
readDebugConfig();
|
||||
}
|
||||
|
||||
let updatedBuildLog : string | undefined = workspaceConfiguration.get<string>("buildLog", "./build.log");
|
||||
if (util.resolvePathToRoot(updatedBuildLog) !== buildLog) {
|
||||
let updatedBuildLog : string | undefined = workspaceConfiguration.get<string>("buildLog");
|
||||
if (updatedBuildLog) {
|
||||
updatedBuildLog = util.resolvePathToRoot(updatedBuildLog);
|
||||
}
|
||||
if (updatedBuildLog !== buildLog) {
|
||||
updateConfigProviderAfterEdit = true;
|
||||
logger.message("makefile.buildLog setting changed.");
|
||||
readBuildLog();
|
||||
}
|
||||
|
||||
let updatedExtensionLog : string | undefined = workspaceConfiguration.get<string>("extensionLog", "./extension.log");
|
||||
if (util.resolvePathToRoot(updatedExtensionLog) !== extensionLog) {
|
||||
let updatedExtensionLog : string | undefined = workspaceConfiguration.get<string>("extensionLog");
|
||||
if (updatedExtensionLog) {
|
||||
updatedExtensionLog = util.resolvePathToRoot(updatedExtensionLog);
|
||||
}
|
||||
if (updatedExtensionLog !== extensionLog) {
|
||||
// No IntelliSense update needed.
|
||||
logger.message("makefile.extensionLog setting changed.");
|
||||
readExtensionLog();
|
||||
}
|
||||
|
||||
let updatedPreconfigureScript : string | undefined = workspaceConfiguration.get<string>("preconfigureScript");
|
||||
if (updatedPreconfigureScript) {
|
||||
updatedPreconfigureScript = util.resolvePathToRoot(updatedPreconfigureScript);
|
||||
}
|
||||
if (updatedPreconfigureScript !== preconfigureScript) {
|
||||
// No IntelliSense update needed.
|
||||
logger.message("makefile.preconfigureScript setting changed.");
|
||||
readPreconfigureScript();
|
||||
}
|
||||
|
||||
let updatedAlwaysPreconfigure : boolean = workspaceConfiguration.get<boolean>("alwaysPreconfigure", false);
|
||||
if (updatedAlwaysPreconfigure !== alwaysPreconfigure) {
|
||||
// No IntelliSense update needed.
|
||||
logger.message("makefile.alwaysPreconfigure setting changed.");
|
||||
readAlwaysPreconfigure();
|
||||
}
|
||||
|
||||
let updatedDryrunCache : string | undefined = workspaceConfiguration.get<string>("dryrunCache", "./dryrunCache.log");
|
||||
if (util.resolvePathToRoot(updatedDryrunCache) !== dryrunCache) {
|
||||
updateConfigProviderAfterEdit = true;
|
||||
|
@ -796,7 +850,6 @@ export async function setNewLaunchConfiguration(): Promise<void> {
|
|||
await util.spawnChildProcess(configurationMakeCommand, makeArgs, vscode.workspace.rootPath || "", stdout, stderr, closing);
|
||||
} catch (error) {
|
||||
logger.message(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -876,7 +929,6 @@ export async function setNewTarget(): Promise<void> {
|
|||
await util.spawnChildProcess(configurationMakeCommand, makeArgs, vscode.workspace.rootPath || "", stdout, stderr, closing);
|
||||
} catch (error) {
|
||||
logger.message(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,9 +158,16 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
|
|||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('makefile.configure', () => {
|
||||
if (configuration.getAlwaysPreconfigure()) {
|
||||
make.runPreconfigureScript();
|
||||
}
|
||||
make.parseBuildOrDryRun();
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('makefile.preConfigure', () => {
|
||||
make.runPreconfigureScript();
|
||||
}));
|
||||
|
||||
configuration.readLoggingLevel();
|
||||
configuration.readExtensionLog();
|
||||
|
||||
|
|
49
src/make.ts
49
src/make.ts
|
@ -45,7 +45,6 @@ export async function buildCurrentTarget(): Promise<void> {
|
|||
} catch (error) {
|
||||
// No need for notification popup, since the build result is visible already in the output channel
|
||||
logger.message(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
export function parseBuild(): boolean {
|
||||
|
@ -119,6 +118,52 @@ export async function parseBuildOrDryRun(): Promise<void> {
|
|||
await util.spawnChildProcess(configuration.getConfigurationMakeCommand(), makeArgs, vscode.workspace.rootPath || "", stdout, stderr, closing);
|
||||
} catch (error) {
|
||||
logger.message(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export async function runPreconfigureScript(): Promise<void> {
|
||||
let script: string | undefined = configuration.getPreconfigureScript();
|
||||
if (!script || !util.checkFileExistsSync(script)) {
|
||||
vscode.window.showErrorMessage("Could not find pre-configure script.");
|
||||
logger.message("Make sure a pre-configuration script path is defined with makefile.preconfigureScript and that it exists on disk.");
|
||||
return;
|
||||
}
|
||||
|
||||
let scriptArgs: string[] = [];
|
||||
let runCommand: string;
|
||||
if (process.platform === 'win32') {
|
||||
runCommand = "cmd";
|
||||
scriptArgs.push("/c");
|
||||
scriptArgs.push(script);
|
||||
} else {
|
||||
runCommand = "/bin/bash";
|
||||
scriptArgs.push("-c");
|
||||
scriptArgs.push(`"source ${script}"`);
|
||||
}
|
||||
|
||||
try {
|
||||
let stdoutStr: string = "";
|
||||
let stderrStr: string = "";
|
||||
|
||||
let stdout : any = (result: string): void => {
|
||||
stdoutStr += result;
|
||||
};
|
||||
|
||||
let stderr : any = (result: string): void => {
|
||||
stderrStr += result;
|
||||
};
|
||||
|
||||
let closing : any = (retCode: number, signal: string): void => {
|
||||
if (retCode === 0) {
|
||||
logger.message("The preconfigure script run successfully.");
|
||||
} else {
|
||||
logger.message("The preconfigure script failed. This project may not configure successfully.");
|
||||
logger.message(stderrStr);
|
||||
}
|
||||
};
|
||||
|
||||
await util.spawnChildProcess(runCommand, scriptArgs, vscode.workspace.rootPath || "", stdout, stderr, closing);
|
||||
} catch (error) {
|
||||
logger.message(error);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче