mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
added project to createion of make target for initial default settings
This commit is contained in:
parent
ffaa2d3da7
commit
428e119084
4 changed files with 43 additions and 33 deletions
|
@ -15,7 +15,7 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public interface IMakeTargetManager {
|
||||
IMakeTarget createTarget(String targetName, String targetID);
|
||||
IMakeTarget createTarget(IProject project, String targetName, String targetID) throws CoreException;
|
||||
void addTarget(IContainer container, IMakeTarget target) throws CoreException;
|
||||
void removeTarget(IMakeTarget target) throws CoreException;
|
||||
void renameTarget(IMakeTarget target, String name) throws CoreException;
|
||||
|
|
|
@ -33,10 +33,15 @@ public class MakeTarget implements IMakeTarget {
|
|||
private IContainer container;
|
||||
private MakeTargetManager manager;
|
||||
|
||||
MakeTarget(MakeTargetManager manager, String targetBuilderID, String name) {
|
||||
MakeTarget(MakeTargetManager manager, IProject project, String targetBuilderID, String name) throws CoreException {
|
||||
this.manager = manager;
|
||||
this.targetBuilderID = targetBuilderID;
|
||||
this.name = name;
|
||||
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(project, manager.getBuilderID(targetBuilderID));
|
||||
buildCommand = info.getBuildCommand();
|
||||
buildArguments = info.getBuildArguments();
|
||||
isDefaultBuildCmd = info.isDefaultBuildCmd();
|
||||
isStopOnError = info.isStopOnError();
|
||||
}
|
||||
|
||||
void setContainer(IContainer container) {
|
||||
|
|
|
@ -58,8 +58,8 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
public MakeTargetManager() {
|
||||
}
|
||||
|
||||
public IMakeTarget createTarget(String name, String targetBuilderID) {
|
||||
return new MakeTarget(this, targetBuilderID, name);
|
||||
public IMakeTarget createTarget(IProject project, String name, String targetBuilderID) throws CoreException {
|
||||
return new MakeTarget(this, project, targetBuilderID, name);
|
||||
}
|
||||
|
||||
public void addTarget(IContainer container, IMakeTarget target) throws CoreException {
|
||||
|
@ -123,7 +123,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
|||
}
|
||||
|
||||
public String[] getTargetBuilders(IProject project) {
|
||||
if (fProjects.contains(project)) {
|
||||
if (fProjects.contains(project) || hasTargetBuilder(project)) {
|
||||
try {
|
||||
Vector ids = new Vector();
|
||||
IProjectDescription description = project.getDescription();
|
||||
|
|
|
@ -42,9 +42,9 @@ public class ProjectTargets {
|
|||
private static final String TARGET_STOP_ON_ERROR = "stopOnError";
|
||||
private static final String TARGET_USE_DEFAULT_CMD = "useDefaultCommand";
|
||||
private static final String TARGET_ARGUMENTS = "buildArguments";
|
||||
private static final String TARGET_COMMAND ="buildCommand";
|
||||
private static final String TARGET_COMMAND = "buildCommand";
|
||||
private static final String TARGET = "buidlTarget";
|
||||
|
||||
|
||||
private HashMap targetMap = new HashMap();
|
||||
|
||||
private IProject project;
|
||||
|
@ -79,29 +79,34 @@ public class ProjectTargets {
|
|||
} else {
|
||||
container = project;
|
||||
}
|
||||
MakeTarget target = new MakeTarget(manager, attr.getNamedItem(TARGET_ATTR_ID).getNodeValue(), attr.getNamedItem(TARGET_ATTR_NAME).getNodeValue());
|
||||
target.setContainer(container);
|
||||
String option = getString(node, TARGET_STOP_ON_ERROR);
|
||||
if (option != null) {
|
||||
target.setStopOnError(Boolean.valueOf(option).booleanValue());
|
||||
}
|
||||
option = getString(node, TARGET_USE_DEFAULT_CMD);
|
||||
if (option != null) {
|
||||
target.setUseDefaultBuildCmd(Boolean.valueOf(option).booleanValue());
|
||||
}
|
||||
option = getString(node, TARGET_COMMAND);
|
||||
if (option != null) {
|
||||
target.setBuildCommand(new Path(option));
|
||||
}
|
||||
option = getString(node, TARGET_ARGUMENTS);
|
||||
if (option != null) {
|
||||
target.setBuildArguments(option);
|
||||
}
|
||||
option = getString(node, TARGET);
|
||||
if (option != null) {
|
||||
target.setBuildTarget(option);
|
||||
}
|
||||
try {
|
||||
MakeTarget target =
|
||||
new MakeTarget(
|
||||
manager,
|
||||
project,
|
||||
attr.getNamedItem(TARGET_ATTR_ID).getNodeValue(),
|
||||
attr.getNamedItem(TARGET_ATTR_NAME).getNodeValue());
|
||||
target.setContainer(container);
|
||||
String option = getString(node, TARGET_STOP_ON_ERROR);
|
||||
if (option != null) {
|
||||
target.setStopOnError(Boolean.valueOf(option).booleanValue());
|
||||
}
|
||||
option = getString(node, TARGET_USE_DEFAULT_CMD);
|
||||
if (option != null) {
|
||||
target.setUseDefaultBuildCmd(Boolean.valueOf(option).booleanValue());
|
||||
}
|
||||
option = getString(node, TARGET_COMMAND);
|
||||
if (option != null) {
|
||||
target.setBuildCommand(new Path(option));
|
||||
}
|
||||
option = getString(node, TARGET_ARGUMENTS);
|
||||
if (option != null) {
|
||||
target.setBuildArguments(option);
|
||||
}
|
||||
option = getString(node, TARGET);
|
||||
if (option != null) {
|
||||
target.setBuildTarget(option);
|
||||
}
|
||||
add(target);
|
||||
} catch (CoreException e) {
|
||||
MakeCorePlugin.log(e);
|
||||
|
@ -188,7 +193,7 @@ public class ProjectTargets {
|
|||
doc.appendChild(targetsRootElement);
|
||||
Iterator container = targetMap.entrySet().iterator();
|
||||
while (container.hasNext()) {
|
||||
List targets = (List) ((Map.Entry)container.next()).getValue();
|
||||
List targets = (List) ((Map.Entry) container.next()).getValue();
|
||||
for (int i = 0; i < targets.size(); i++) {
|
||||
MakeTarget target = (MakeTarget) targets.get(i);
|
||||
targetsRootElement.appendChild(createTargetElement(doc, target));
|
||||
|
@ -205,7 +210,7 @@ public class ProjectTargets {
|
|||
Element elem = doc.createElement(TARGET_COMMAND);
|
||||
targetElem.appendChild(elem);
|
||||
elem.appendChild(doc.createTextNode(target.getBuildCommand().toString()));
|
||||
|
||||
|
||||
elem = doc.createElement(TARGET_ARGUMENTS);
|
||||
elem.appendChild(doc.createTextNode(target.getBuildArguments()));
|
||||
targetElem.appendChild(elem);
|
||||
|
@ -217,11 +222,11 @@ public class ProjectTargets {
|
|||
elem = doc.createElement(TARGET_STOP_ON_ERROR);
|
||||
elem.appendChild(doc.createTextNode(new Boolean(target.isStopOnError()).toString()));
|
||||
targetElem.appendChild(elem);
|
||||
|
||||
|
||||
elem = doc.createElement(TARGET_USE_DEFAULT_CMD);
|
||||
elem.appendChild(doc.createTextNode(new Boolean(target.isDefaultBuildCmd()).toString()));
|
||||
targetElem.appendChild(elem);
|
||||
return targetElem;
|
||||
return targetElem;
|
||||
}
|
||||
|
||||
public void saveTargets(OutputStream output) throws IOException {
|
||||
|
|
Loading…
Add table
Reference in a new issue