Launch targets/config bug fixes. Invoke make separately for clean. (#158)
* Launch targets/config bug fixes. Invoke make separately for clean. * PR feedback.
This commit is contained in:
Родитель
4453266b74
Коммит
13320c8df4
|
@ -380,9 +380,11 @@ export async function stringToLaunchConfiguration(str: string): Promise<LaunchCo
|
|||
|
||||
let currentLaunchConfiguration: LaunchConfiguration | undefined;
|
||||
export function getCurrentLaunchConfiguration(): LaunchConfiguration | undefined { return currentLaunchConfiguration; }
|
||||
export function setCurrentLaunchConfiguration(configuration: LaunchConfiguration): void {
|
||||
export async function setCurrentLaunchConfiguration(configuration: LaunchConfiguration): Promise<void> {
|
||||
currentLaunchConfiguration = configuration;
|
||||
statusBar.setLaunchConfiguration(launchConfigurationToString(currentLaunchConfiguration));
|
||||
let launchConfigStr: string = launchConfigurationToString(currentLaunchConfiguration);
|
||||
statusBar.setLaunchConfiguration(launchConfigStr);
|
||||
await extension._projectOutlineProvider.updateLaunchTarget(launchConfigStr);
|
||||
}
|
||||
|
||||
function getLaunchConfiguration(name: string): LaunchConfiguration | undefined {
|
||||
|
@ -397,21 +399,33 @@ function getLaunchConfiguration(name: string): LaunchConfiguration | undefined {
|
|||
// Read the identifier from workspace state storage, then find the corresponding object
|
||||
// in the launch configurations array from settings.
|
||||
// Also update the status bar item.
|
||||
function readCurrentLaunchConfiguration(): void {
|
||||
async function readCurrentLaunchConfiguration(): Promise<void> {
|
||||
readLaunchConfigurations();
|
||||
let currentLaunchConfigurationName: string | undefined = extension.getState().launchConfiguration;
|
||||
if (currentLaunchConfigurationName) {
|
||||
currentLaunchConfiguration = getLaunchConfiguration(currentLaunchConfigurationName);
|
||||
}
|
||||
|
||||
let launchConfigStr : string = "No launch configuration set.";
|
||||
if (currentLaunchConfiguration) {
|
||||
let launchConfigStr: string = launchConfigurationToString(currentLaunchConfiguration);
|
||||
launchConfigStr = launchConfigurationToString(currentLaunchConfiguration);
|
||||
logger.message(`Reading current launch configuration "${launchConfigStr}" from the workspace state.`);
|
||||
statusBar.setLaunchConfiguration(launchConfigStr);
|
||||
} else {
|
||||
logger.message("No current launch configuration is set in the workspace state.");
|
||||
statusBar.setLaunchConfiguration("No launch configuration set.");
|
||||
// A null launch configuration after a non empty launch configuration string name
|
||||
// means that the name stored in the project state does not match any of the entries in settings.
|
||||
// This typically happens after the user modifies manually "makefile.launchConfigurations"
|
||||
// in the .vscode/settings.json, specifically the entry that corresponds to the current launch configuration.
|
||||
// Make sure to unset the launch configuration in this scenario.
|
||||
if (currentLaunchConfigurationName !== undefined && currentLaunchConfigurationName !== "") {
|
||||
logger.message(`Launch configuration "${currentLaunchConfigurationName}" is no longer defined in settings "makefile.launchConfigurations".`);
|
||||
await setLaunchConfigurationByName("");
|
||||
} else {
|
||||
logger.message("No current launch configuration is set in the workspace state.");
|
||||
}
|
||||
}
|
||||
|
||||
statusBar.setLaunchConfiguration(launchConfigStr);
|
||||
await extension._projectOutlineProvider.updateLaunchTarget(launchConfigStr);
|
||||
}
|
||||
|
||||
export interface DefaultLaunchConfiguration {
|
||||
|
@ -485,7 +499,7 @@ export function getCommandForConfiguration(configuration: string | undefined): v
|
|||
let configurationCommandPath: string = makeParsedPathConfigurations?.dir || makeParsedPathSettings?.dir || "";
|
||||
configurationMakeCommand = path.join(configurationCommandPath, configurationMakeCommand);
|
||||
// Add the ".exe" extension on windows if no extension was specified, otherwise the file search APIs don't find it.
|
||||
if (process.platform === "win32" && configurationMakeCommandExtension === undefined) {
|
||||
if (process.platform === "win32" && configurationMakeCommandExtension === "") {
|
||||
configurationMakeCommand += ".exe";
|
||||
}
|
||||
|
||||
|
@ -776,7 +790,7 @@ export async function initFromStateAndSettings(): Promise<void> {
|
|||
readCurrentMakefileConfiguration();
|
||||
readMakefileConfigurations();
|
||||
readCurrentTarget();
|
||||
readCurrentLaunchConfiguration();
|
||||
await readCurrentLaunchConfiguration();
|
||||
readDefaultLaunchConfiguration();
|
||||
readConfigureOnOpen();
|
||||
readConfigureOnEdit();
|
||||
|
@ -868,7 +882,7 @@ export async function initFromStateAndSettings(): Promise<void> {
|
|||
if (!util.areEqual(updatedLaunchConfigurations, launchConfigurations)) {
|
||||
// Changing a launch configuration does not impact the make or compiler tools invocations,
|
||||
// so no IntelliSense update is needed.
|
||||
readCurrentLaunchConfiguration(); // this gets a refreshed view of all launch configurations
|
||||
await readCurrentLaunchConfiguration(); // this gets a refreshed view of all launch configurations
|
||||
// and also updates the current one in case it was affected
|
||||
updatedSettingsSubkeys.push(subKey);
|
||||
}
|
||||
|
@ -1353,7 +1367,7 @@ export async function selectLaunchConfiguration(): Promise<void> {
|
|||
|
||||
// In the quick pick, include also any makefile.launchConfigurations entries,
|
||||
// as long as they exist on disk and without allowing duplicates.
|
||||
let launchTargetsNames: string[] = launchTargets;
|
||||
let launchTargetsNames: string[] = [...launchTargets];
|
||||
launchConfigurations.forEach(launchConfiguration => {
|
||||
if (util.checkFileExistsSync(launchConfiguration.binaryPath)) {
|
||||
launchTargetsNames.push(launchConfigurationToString(launchConfiguration));
|
||||
|
|
26
src/make.ts
26
src/make.ts
|
@ -158,20 +158,18 @@ async function saveAll(): Promise<boolean> {
|
|||
}
|
||||
}
|
||||
|
||||
export function prepareBuildTarget(target: string, clean: boolean = false): string[] {
|
||||
export function prepareBuildTarget(target: string): string[] {
|
||||
let makeArgs: string[] = [];
|
||||
|
||||
// Prepend the target to the arguments given in the configurations json.
|
||||
// If a clean build is desired, "clean" should precede the target.
|
||||
if (clean) {
|
||||
makeArgs.push("clean");
|
||||
}
|
||||
if (target) {
|
||||
makeArgs.push(target);
|
||||
}
|
||||
|
||||
makeArgs = makeArgs.concat(configuration.getConfigurationMakeArgs());
|
||||
|
||||
logger.message("Building the current target. Command: " + configuration.getConfigurationMakeCommand() + " " + makeArgs.join(" "));
|
||||
logger.message(`Building target "${target}" with command: "` + configuration.getConfigurationMakeCommand() + " " + makeArgs.join(" ") + '"');
|
||||
return makeArgs;
|
||||
}
|
||||
|
||||
|
@ -264,7 +262,15 @@ export async function buildTarget(triggeredBy: TriggeredBy, target: string, clea
|
|||
});
|
||||
|
||||
setIsBuilding(true);
|
||||
let retc: number = await doBuildTarget(progress, target, clean);
|
||||
if (clean) {
|
||||
// We don't need to track the return code for 'make "clean"'.
|
||||
// We want to proceed with the 'make "target"' step anyway.
|
||||
// The relevant return code for telemetry will be the second one.
|
||||
// If the clean step fails, doBuildTarget will print an error message in the log.
|
||||
await doBuildTarget(progress, "clean");
|
||||
}
|
||||
|
||||
let retc: number = await doBuildTarget(progress, target);
|
||||
|
||||
// We need to know whether this build was cancelled by the user
|
||||
// more than the real exit code of the make process in this circumstance.
|
||||
|
@ -306,8 +312,8 @@ export async function buildTarget(triggeredBy: TriggeredBy, target: string, clea
|
|||
}
|
||||
}
|
||||
|
||||
export async function doBuildTarget(progress: vscode.Progress<{}>, target: string, clean: boolean = false): Promise<number> {
|
||||
let makeArgs: string[] = prepareBuildTarget(target, clean);
|
||||
export async function doBuildTarget(progress: vscode.Progress<{}>, target: string): Promise<number> {
|
||||
let makeArgs: string[] = prepareBuildTarget(target);
|
||||
try {
|
||||
// Append without end of line since there is one already included in the stdout/stderr fragments
|
||||
let stdout: any = (result: string): void => {
|
||||
|
@ -1357,8 +1363,8 @@ export async function doConfigure(progress: vscode.Progress<{}>, cancel: vscode.
|
|||
// By this point, configuration.getLaunchTargets() contains a complete list (old and new).
|
||||
let currentLaunchConfiguration: configuration.LaunchConfiguration | undefined = configuration.getCurrentLaunchConfiguration();
|
||||
let currentLaunchConfigurationStr: string | undefined = currentLaunchConfiguration ? configuration.launchConfigurationToString(currentLaunchConfiguration) : "";
|
||||
if (currentLaunchConfigurationStr !== "" &&
|
||||
!configuration.getLaunchTargets().includes(currentLaunchConfigurationStr)) {
|
||||
if (currentLaunchConfigurationStr !== "" && currentLaunchConfiguration &&
|
||||
!configuration.getLaunchConfigurations().includes(currentLaunchConfiguration)) {
|
||||
logger.message(`Current launch configuration ${currentLaunchConfigurationStr} is no longer present in the available list.`);
|
||||
await configuration.setLaunchConfigurationByName("");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче