mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
[autotools]Bug 402595:added code that gets the current list of build
commands to the job that sets build commands for an autotools project. Change-Id: Ib4782aa32a99da3da34ff2c1a22a544f531c2d54 Reviewed-on: https://git.eclipse.org/r/10919 Reviewed-by: Jesse Weinstein <Jesse.Weinstein@clinicomp.com> Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> IP-Clean: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
parent
395e7c941e
commit
a6a57864bb
1 changed files with 55 additions and 39 deletions
|
@ -1,13 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Red Hat Inc.. and others
|
||||
* Copyright (c) 2008, 2013 Red Hat Inc.. and others
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat Incorporated - initial implementation
|
||||
* IBM Rational Software - add and remove nature static methods
|
||||
* Red Hat Incorporated - initial implementation
|
||||
* IBM Rational Software - add and remove nature static methods
|
||||
* Anna Dushistova (MontaVista) - [402595]Autotools nature loses builders added by contributed wizard pages
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.core;
|
||||
|
||||
|
@ -80,39 +81,8 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
|||
// Add the builder to the project
|
||||
IProjectDescription description = project.getDescription();
|
||||
ICommand[] commands = description.getBuildSpec();
|
||||
ArrayList<ICommand> commandList = new ArrayList<ICommand>();
|
||||
|
||||
// Make sure the Autotools Configuration builder just precedes the Common Builder
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
ICommand command = commands[i];
|
||||
if (command.getBuilderName().equals(AutotoolsConfigurationBuilder.BUILDER_ID)) {
|
||||
// ignore it
|
||||
} else {
|
||||
if (command.getBuilderName().equals(OLD_AUTOTOOLS_BUILDER_ID)) {
|
||||
ICommand newCommand = description.newCommand();
|
||||
newCommand.setBuilderName(BUILDER_ID);
|
||||
command = newCommand;
|
||||
}
|
||||
if (command.getBuilderName().equals(BUILDER_ID)) {
|
||||
// add Autotools Configuration builder just before builder
|
||||
ICommand newCommand = description.newCommand();
|
||||
newCommand.setBuilderName(AutotoolsConfigurationBuilder.BUILDER_ID);
|
||||
commandList.add(newCommand);
|
||||
}
|
||||
commandList.add(command);
|
||||
}
|
||||
}
|
||||
final ICommand[] newCommands = commandList.toArray(new ICommand[commandList.size()]);
|
||||
if (newCommands.length == commands.length) {
|
||||
boolean hasCorrectBuilderCommands = true;
|
||||
for (int j = 0; j < commands.length; ++j) {
|
||||
if (!commands[j].getBuilderName().equals(newCommands[j].getBuilderName())) {
|
||||
hasCorrectBuilderCommands = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasCorrectBuilderCommands)
|
||||
return;
|
||||
if(checkEquals(commands,getBuildCommandsList(description, commands))){
|
||||
return;
|
||||
}
|
||||
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
|
||||
final IProject proj = project;
|
||||
|
@ -129,9 +99,15 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
|||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
turnOffAutoBuild(workspace);
|
||||
IProjectDescription description = proj.getDescription();
|
||||
description.setBuildSpec(newCommands);
|
||||
proj.setDescription(description, new NullProgressMonitor());
|
||||
IProjectDescription prDescription = proj.getDescription();
|
||||
//Other pieces of wizard might have contributed new builder commands;
|
||||
//need to make sure we are using the most recent ones
|
||||
ICommand[] currentCommands = prDescription.getBuildSpec();
|
||||
ICommand[] newCommands = getBuildCommandsList(prDescription, currentCommands);
|
||||
if(!checkEquals(currentCommands,newCommands)){
|
||||
prDescription.setBuildSpec(newCommands);
|
||||
proj.setDescription(prDescription, new NullProgressMonitor());
|
||||
}
|
||||
restoreAutoBuild(workspace);
|
||||
}
|
||||
|
||||
|
@ -160,6 +136,46 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
|||
backgroundJob.schedule();
|
||||
}
|
||||
|
||||
static boolean checkEquals(ICommand[] commands,
|
||||
ICommand[] newCommands) {
|
||||
if (newCommands.length != commands.length){
|
||||
return false;
|
||||
}
|
||||
for (int j = 0; j < commands.length; ++j) {
|
||||
if (!commands[j].getBuilderName().equals(newCommands[j].getBuilderName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static ICommand[] getBuildCommandsList(IProjectDescription description,
|
||||
ICommand[] commands) {
|
||||
ArrayList<ICommand> commandList = new ArrayList<ICommand>();
|
||||
|
||||
// Make sure the Autotools Configuration builder just precedes the Common Builder
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
ICommand command = commands[i];
|
||||
if (command.getBuilderName().equals(AutotoolsConfigurationBuilder.BUILDER_ID)) {
|
||||
// ignore it
|
||||
} else {
|
||||
if (command.getBuilderName().equals(OLD_AUTOTOOLS_BUILDER_ID)) {
|
||||
ICommand newCommand = description.newCommand();
|
||||
newCommand.setBuilderName(BUILDER_ID);
|
||||
command = newCommand;
|
||||
}
|
||||
if (command.getBuilderName().equals(BUILDER_ID)) {
|
||||
// add Autotools Configuration builder just before builder
|
||||
ICommand newCommand = description.newCommand();
|
||||
newCommand.setBuilderName(AutotoolsConfigurationBuilder.BUILDER_ID);
|
||||
commandList.add(newCommand);
|
||||
}
|
||||
commandList.add(command);
|
||||
}
|
||||
}
|
||||
return commandList.toArray(new ICommand[commandList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for adding an autotools nature to a project.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue