Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5e3ec6c65b988c44a66bb3b7940aa69c96a5cc58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * Created on 19-Aug-2003
 *
 * Copyright (c) 2002,2003 QNX Software Systems Ltd.
 * 
 * Contributors: 
 * QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.make.internal.core;

import java.util.HashMap;

import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;

public class MakeTarget implements IMakeTarget {

	private String target;
	private String buildArguments;
	private IPath buildCommand;
	private boolean isDefaultBuildCmd;
	private boolean isStopOnError;
	private String name;
	private String targetBuilderID;
	private IContainer container;
	private MakeTargetManager manager;
	
	MakeTarget(MakeTargetManager manager, String targetBuilderID, String name) {
		this.manager = manager;
		this.targetBuilderID = targetBuilderID;
		this.name = name;
	}

	void setContainer(IContainer container) {
		this.container = container;
	}

	void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public String getTargetBuilderID() {
		return targetBuilderID;
	}

	public boolean isStopOnError() {
		return isStopOnError;
	}

	public void setStopOnError(boolean stopOnError) {
		isStopOnError = stopOnError;
	}

	public boolean isDefaultBuildCmd() {
		return isDefaultBuildCmd;
	}

	public void setUseDefaultBuildCmd(boolean useDefault) {
		isDefaultBuildCmd = useDefault;
	}

	public IPath getBuildCommand() {
		return buildCommand != null ? buildCommand: new Path("");
	}

	public void setBuildCommand(IPath command) {
		buildCommand = command;
	}

	public String getBuildArguments() {
		return buildArguments != null ? buildArguments : "";
	}

	public void setBuildArguments(String arguments) {
		buildArguments = arguments;
	}

	public IContainer getContainer() {
		return container;
	}

	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (obj instanceof MakeTarget) {
			MakeTarget other = (MakeTarget) obj;
			return container.equals(other.getContainer()) && name.equals(other.getName());
		}
		return false;
	}

	public int hashCode() {
		return container.hashCode() * 17 + name.hashCode();
	}

	public void build(IProgressMonitor monitor) throws CoreException {
		IProject project = container.getProject();
		String builderID = manager.getBuilderID(targetBuilderID);
		HashMap infoMap = new HashMap();
		IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(infoMap, builderID);
		if ( buildArguments != null) {
			info.setBuildArguments(buildArguments);
		}
		if ( buildCommand != null ) {
			info.setBuildCommand(buildCommand);
		}
		info.setUseDefaultBuildCmd(isDefaultBuildCmd);
		info.setStopOnError(isStopOnError);
		info.setFullBuildEnable(true);
		info.setFullBuildTarget(target);
		info.setBuildLocation(container.getLocation());
		project.build(IncrementalProjectBuilder.FULL_BUILD, builderID, infoMap, monitor);
	}

	public void setBuildTarget(String target) {
		this.target = target;
		
	}

	public String getBuildTarget() {
		return target;
	}
}

Back to the top