mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Cosmetics
Change-Id: I584622013f810d8ac51dcb618074663a79cd5b19
This commit is contained in:
parent
d3fecaa15e
commit
33d12e75c9
1 changed files with 162 additions and 193 deletions
|
@ -57,50 +57,40 @@ public class BuildStep implements IBuildStep {
|
||||||
private ITool fLibTool;
|
private ITool fLibTool;
|
||||||
private boolean fAssignToCalculated;
|
private boolean fAssignToCalculated;
|
||||||
|
|
||||||
protected BuildStep(BuildDescription des, ITool tool, IInputType inputType){
|
protected BuildStep(BuildDescription des, ITool tool, IInputType inputType) {
|
||||||
fTool = tool;
|
fTool = tool;
|
||||||
fInputType = inputType;
|
fInputType = inputType;
|
||||||
fBuildDescription = des;
|
fBuildDescription = des;
|
||||||
|
|
||||||
if(DbgUtil.DEBUG)
|
if (DbgUtil.DEBUG)
|
||||||
DbgUtil.trace("step " + DbgUtil.stepName(this) + " created"); //$NON-NLS-1$ //$NON-NLS-2$
|
DbgUtil.trace("step " + DbgUtil.stepName(this) + " created"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
des.stepCreated(this);
|
des.stepCreated(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getInputIOTypes()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildIOType[] getInputIOTypes() {
|
public IBuildIOType[] getInputIOTypes() {
|
||||||
return fInputTypes.toArray(new BuildIOType[fInputTypes.size()]);
|
return fInputTypes.toArray(new BuildIOType[fInputTypes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getOutputIOTypes()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildIOType[] getOutputIOTypes() {
|
public IBuildIOType[] getOutputIOTypes() {
|
||||||
return fOutputTypes.toArray(new BuildIOType[fOutputTypes.size()]);
|
return fOutputTypes.toArray(new BuildIOType[fOutputTypes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#needsRebuild()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsRebuild() {
|
public boolean needsRebuild() {
|
||||||
if(fNeedsRebuild
|
if (fNeedsRebuild || (fTool != null && fTool.needsRebuild())
|
||||||
|| (fTool != null && fTool.needsRebuild())
|
|
||||||
|| (fLibTool != null && fLibTool.needsRebuild()))
|
|| (fLibTool != null && fLibTool.needsRebuild()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(fBuildGroup != null && fBuildGroup.needsRebuild())
|
if (fBuildGroup != null && fBuildGroup.needsRebuild())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRebuildState(boolean rebuild){
|
public void setRebuildState(boolean rebuild) {
|
||||||
fNeedsRebuild = rebuild;
|
fNeedsRebuild = rebuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +98,7 @@ public class BuildStep implements IBuildStep {
|
||||||
|
|
||||||
BuildResource rcs[] = type.remove();
|
BuildResource rcs[] = type.remove();
|
||||||
|
|
||||||
if(type.isInput())
|
if (type.isInput())
|
||||||
fInputTypes.remove(type);
|
fInputTypes.remove(type);
|
||||||
else
|
else
|
||||||
fOutputTypes.remove(type);
|
fOutputTypes.remove(type);
|
||||||
|
@ -116,11 +106,11 @@ public class BuildStep implements IBuildStep {
|
||||||
return rcs;
|
return rcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildResource[][] remove(){
|
BuildResource[][] remove() {
|
||||||
BuildResource[][] rcs = clear();
|
BuildResource[][] rcs = clear();
|
||||||
|
|
||||||
if(DbgUtil.DEBUG)
|
if (DbgUtil.DEBUG)
|
||||||
DbgUtil.trace("step " + DbgUtil.stepName(this) + " removed"); //$NON-NLS-1$ //$NON-NLS-2$
|
DbgUtil.trace("step " + DbgUtil.stepName(this) + " removed"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
fBuildDescription.stepRemoved(this);
|
fBuildDescription.stepRemoved(this);
|
||||||
fBuildDescription = null;
|
fBuildDescription = null;
|
||||||
|
@ -128,43 +118,43 @@ public class BuildStep implements IBuildStep {
|
||||||
return rcs;
|
return rcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildResource[][] clear(){
|
BuildResource[][] clear() {
|
||||||
BuildResource[][] rcs = new BuildResource[2][];
|
BuildResource[][] rcs = new BuildResource[2][];
|
||||||
|
|
||||||
rcs[0] = (BuildResource[])getInputResources();
|
rcs[0] = (BuildResource[]) getInputResources();
|
||||||
rcs[1] = (BuildResource[])getOutputResources();
|
rcs[1] = (BuildResource[]) getOutputResources();
|
||||||
|
|
||||||
BuildIOType types[] = (BuildIOType[])getInputIOTypes();
|
BuildIOType types[] = (BuildIOType[]) getInputIOTypes();
|
||||||
for(int i = 0; i < types.length; i++){
|
for (int i = 0; i < types.length; i++) {
|
||||||
removeIOType(types[i]);
|
removeIOType(types[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
types = (BuildIOType[])getOutputIOTypes();
|
types = (BuildIOType[]) getOutputIOTypes();
|
||||||
for(int i = 0; i < types.length; i++){
|
for (int i = 0; i < types.length; i++) {
|
||||||
removeIOType(types[i]);
|
removeIOType(types[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rcs;
|
return rcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeResource(BuildIOType type, BuildResource rc, boolean rmTypeIfEmpty){
|
public void removeResource(BuildIOType type, BuildResource rc, boolean rmTypeIfEmpty) {
|
||||||
type.removeResource(rc);
|
type.removeResource(rc);
|
||||||
if(rmTypeIfEmpty && type.getResources().length == 0){
|
if (rmTypeIfEmpty && type.getResources().length == 0) {
|
||||||
removeIOType(type);
|
removeIOType(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildIOType createIOType(boolean input, boolean primary, /*String ext,*/ IBuildObject ioType) {
|
public BuildIOType createIOType(boolean input, boolean primary, /* String ext, */ IBuildObject ioType) {
|
||||||
if(input){
|
if (input) {
|
||||||
if(fBuildDescription.getInputStep() == this)
|
if (fBuildDescription.getInputStep() == this)
|
||||||
throw new IllegalArgumentException("input step can not have inputs"); //$NON-NLS-1$
|
throw new IllegalArgumentException("input step can not have inputs"); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
if(fBuildDescription.getOutputStep() == this)
|
if (fBuildDescription.getOutputStep() == this)
|
||||||
throw new IllegalArgumentException("input step can not have outputs"); //$NON-NLS-1$
|
throw new IllegalArgumentException("input step can not have outputs"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildIOType arg = new BuildIOType(this, input, primary, /*ext,*/ ioType);
|
BuildIOType arg = new BuildIOType(this, input, primary, /* ext, */ ioType);
|
||||||
if(input)
|
if (input)
|
||||||
fInputTypes.add(arg);
|
fInputTypes.add(arg);
|
||||||
else
|
else
|
||||||
fOutputTypes.add(arg);
|
fOutputTypes.add(arg);
|
||||||
|
@ -172,98 +162,88 @@ public class BuildStep implements IBuildStep {
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTool(ITool tool){
|
public void setTool(ITool tool) {
|
||||||
fTool = tool;
|
fTool = tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITool getTool(){
|
public ITool getTool() {
|
||||||
return fTool;
|
return fTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildIOType[] getPrimaryTypes(boolean input){
|
public BuildIOType[] getPrimaryTypes(boolean input) {
|
||||||
List<BuildIOType> types = input ? fInputTypes : fOutputTypes;
|
List<BuildIOType> types = input ? fInputTypes : fOutputTypes;
|
||||||
|
|
||||||
List<BuildIOType> list = new ArrayList<BuildIOType>();
|
List<BuildIOType> list = new ArrayList<BuildIOType>();
|
||||||
for (BuildIOType arg : types) {
|
for (BuildIOType arg : types) {
|
||||||
if(arg.isPrimary())
|
if (arg.isPrimary())
|
||||||
list.add(arg);
|
list.add(arg);
|
||||||
}
|
}
|
||||||
return list.toArray(new BuildIOType[list.size()]);
|
return list.toArray(new BuildIOType[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildIOType getIOTypeForType(IBuildObject ioType, boolean input){
|
public BuildIOType getIOTypeForType(IBuildObject ioType, boolean input) {
|
||||||
List<BuildIOType> list = input ? fInputTypes : fOutputTypes;
|
List<BuildIOType> list = input ? fInputTypes : fOutputTypes;
|
||||||
|
|
||||||
if(ioType != null){
|
if (ioType != null) {
|
||||||
for (BuildIOType arg : list) {
|
for (BuildIOType arg : list) {
|
||||||
if(arg.getIoType() == ioType)
|
if (arg.getIoType() == ioType)
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(list.size() > 0)
|
if (list.size() > 0)
|
||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setGroup(BuildGroup group){
|
protected void setGroup(BuildGroup group) {
|
||||||
fBuildGroup = group;
|
fBuildGroup = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getInputResources()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildResource[] getInputResources() {
|
public IBuildResource[] getInputResources() {
|
||||||
return getResources(true);
|
return getResources(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getOutputResources()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildResource[] getOutputResources() {
|
public IBuildResource[] getOutputResources() {
|
||||||
return getResources(false);
|
return getResources(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBuildResource[] getResources(boolean input){
|
public IBuildResource[] getResources(boolean input) {
|
||||||
List<BuildIOType> list = input ? fInputTypes : fOutputTypes;
|
List<BuildIOType> list = input ? fInputTypes : fOutputTypes;
|
||||||
Set<IBuildResource> set = new HashSet<IBuildResource>();
|
Set<IBuildResource> set = new HashSet<IBuildResource>();
|
||||||
|
|
||||||
for (BuildIOType arg : list) {
|
for (BuildIOType arg : list) {
|
||||||
IBuildResource rcs[] = arg.getResources();
|
IBuildResource rcs[] = arg.getResources();
|
||||||
for(int j = 0; j < rcs.length; j++){
|
for (int j = 0; j < rcs.length; j++) {
|
||||||
set.add(rcs[j]);
|
set.add(rcs[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return set.toArray(new BuildResource[set.size()]);
|
return set.toArray(new BuildResource[set.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getCommands(org.eclipse.core.runtime.IPath, java.util.Map, java.util.Map, boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildCommand[] getCommands(IPath cwd, Map inputArgValues, Map outputArgValues, boolean resolveAll) {
|
public IBuildCommand[] getCommands(IPath cwd, Map inputArgValues, Map outputArgValues,
|
||||||
if(cwd == null)
|
boolean resolveAll) {
|
||||||
|
if (cwd == null)
|
||||||
cwd = calcCWD();
|
cwd = calcCWD();
|
||||||
|
|
||||||
|
if (fTool == null) {
|
||||||
if(fTool == null){
|
|
||||||
String step = null;
|
String step = null;
|
||||||
String appendToLastStep = null;
|
String appendToLastStep = null;
|
||||||
if(this == fBuildDescription.getInputStep()){
|
if (this == fBuildDescription.getInputStep()) {
|
||||||
step = fBuildDescription.getConfiguration().getPrebuildStep();
|
step = fBuildDescription.getConfiguration().getPrebuildStep();
|
||||||
} else if(this == fBuildDescription.getOutputStep()){
|
} else if (this == fBuildDescription.getOutputStep()) {
|
||||||
step = fBuildDescription.getConfiguration().getPostbuildStep();
|
step = fBuildDescription.getConfiguration().getPostbuildStep();
|
||||||
} else if(this == fBuildDescription.getCleanStep()){
|
} else if (this == fBuildDescription.getCleanStep()) {
|
||||||
step = fBuildDescription.getConfiguration().getCleanCommand();
|
step = fBuildDescription.getConfiguration().getCleanCommand();
|
||||||
|
|
||||||
IBuildResource[] generated = fBuildDescription.getResources(true);
|
IBuildResource[] generated = fBuildDescription.getResources(true);
|
||||||
|
|
||||||
if(generated.length != 0){
|
if (generated.length != 0) {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
for(int i = 0; i < generated.length; i++){
|
for (int i = 0; i < generated.length; i++) {
|
||||||
buf.append(' ');
|
buf.append(' ');
|
||||||
|
|
||||||
IPath rel = BuildDescriptionManager.getRelPath(cwd, generated[i].getLocation());
|
IPath rel = BuildDescriptionManager.getRelPath(cwd, generated[i].getLocation());
|
||||||
|
@ -273,19 +253,19 @@ public class BuildStep implements IBuildStep {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(step != null && (step = step.trim()).length() > 0){
|
if (step != null && (step = step.trim()).length() > 0) {
|
||||||
step = resolveMacros(step, resolveAll);
|
step = resolveMacros(step, resolveAll);
|
||||||
if(step != null && (step = step.trim()).length() > 0){
|
if (step != null && (step = step.trim()).length() > 0) {
|
||||||
String commands[] = step.split(";"); //$NON-NLS-1$
|
String commands[] = step.split(";"); //$NON-NLS-1$
|
||||||
|
|
||||||
if(appendToLastStep != null && commands.length != 0){
|
if (appendToLastStep != null && commands.length != 0) {
|
||||||
commands[commands.length - 1] = commands[commands.length - 1] + appendToLastStep;
|
commands[commands.length - 1] = commands[commands.length - 1] + appendToLastStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IBuildCommand> list = new ArrayList<IBuildCommand>();
|
List<IBuildCommand> list = new ArrayList<IBuildCommand>();
|
||||||
for(int i = 0; i < commands.length; i++){
|
for (int i = 0; i < commands.length; i++) {
|
||||||
IBuildCommand cmds[] = createCommandsFromString(commands[i], cwd, getEnvironment());
|
IBuildCommand cmds[] = createCommandsFromString(commands[i], cwd, getEnvironment());
|
||||||
for(int j = 0; j < cmds.length; j++){
|
for (int j = 0; j < cmds.length; j++) {
|
||||||
list.add(cmds[j]);
|
list.add(cmds[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +275,6 @@ public class BuildStep implements IBuildStep {
|
||||||
return new IBuildCommand[0];
|
return new IBuildCommand[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
performAsignToOption(cwd);
|
performAsignToOption(cwd);
|
||||||
|
|
||||||
BuildResource inRc = getRcForMacros(true);
|
BuildResource inRc = getRcForMacros(true);
|
||||||
|
@ -309,22 +288,19 @@ public class BuildStep implements IBuildStep {
|
||||||
outPrefix = resolveMacros(outPrefix, data, true);
|
outPrefix = resolveMacros(outPrefix, data, true);
|
||||||
outRcPath = rmNamePrefix(outRcPath, outPrefix);
|
outRcPath = rmNamePrefix(outRcPath, outPrefix);
|
||||||
|
|
||||||
IManagedCommandLineInfo info = gen.generateCommandLineInfo(fTool,
|
IManagedCommandLineInfo info = gen.generateCommandLineInfo(fTool, fTool.getToolCommand(),
|
||||||
fTool.getToolCommand(),
|
getCommandFlags(inRcPath, outRcPath, resolveAll), fTool.getOutputFlag(), outPrefix,
|
||||||
getCommandFlags(inRcPath, outRcPath, resolveAll),
|
listToString(resourcesToStrings(cwd, getPrimaryResources(false), outPrefix), " "), //$NON-NLS-1$
|
||||||
fTool.getOutputFlag(),
|
getInputResources(cwd, getPrimaryResources(true)), fTool.getCommandLinePattern());
|
||||||
outPrefix,
|
|
||||||
listToString(resourcesToStrings(cwd, getPrimaryResources(false), outPrefix), " "), //$NON-NLS-1$
|
|
||||||
getInputResources(cwd, getPrimaryResources(true)),
|
|
||||||
fTool.getCommandLinePattern());
|
|
||||||
|
|
||||||
return createCommandsFromString(resolveMacros(info.getCommandLine(), data, true), cwd, getEnvironment());
|
return createCommandsFromString(resolveMacros(info.getCommandLine(), data, true), cwd,
|
||||||
|
getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPath rmNamePrefix(IPath path, String prefix){
|
private IPath rmNamePrefix(IPath path, String prefix) {
|
||||||
if(prefix != null && prefix.length() != 0){
|
if (prefix != null && prefix.length() != 0) {
|
||||||
String name = path.lastSegment();
|
String name = path.lastSegment();
|
||||||
if(name.startsWith(prefix)){
|
if (name.startsWith(prefix)) {
|
||||||
name = name.substring(prefix.length());
|
name = name.substring(prefix.length());
|
||||||
path = path.removeLastSegments(1).append(name);
|
path = path.removeLastSegments(1).append(name);
|
||||||
}
|
}
|
||||||
|
@ -364,52 +340,52 @@ public class BuildStep implements IBuildStep {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPath calcCWD(){
|
private IPath calcCWD() {
|
||||||
IPath cwd = fBuildDescription.getDefaultBuildDirLocation();
|
IPath cwd = fBuildDescription.getDefaultBuildDirLocation();
|
||||||
|
|
||||||
if(!cwd.isAbsolute())
|
if (!cwd.isAbsolute())
|
||||||
cwd = fBuildDescription.getConfiguration().getOwner().getProject().getLocation().append(cwd);
|
cwd = fBuildDescription.getConfiguration().getOwner().getProject().getLocation().append(cwd);
|
||||||
|
|
||||||
return cwd;
|
return cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, String> getEnvironment(){
|
protected Map<String, String> getEnvironment() {
|
||||||
return fBuildDescription.getEnvironment();
|
return fBuildDescription.getEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IBuildCommand[] createCommandsFromString(String cmd, IPath cwd, Map<String, String> env){
|
protected IBuildCommand[] createCommandsFromString(String cmd, IPath cwd, Map<String, String> env) {
|
||||||
char arr[] = cmd.toCharArray();
|
char arr[] = cmd.toCharArray();
|
||||||
char expect = 0;
|
char expect = 0;
|
||||||
char prev = 0;
|
char prev = 0;
|
||||||
// int start = 0;
|
// int start = 0;
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
for(int i = 0; i < arr.length; i++){
|
for (int i = 0; i < arr.length; i++) {
|
||||||
char ch = arr[i];
|
char ch = arr[i];
|
||||||
switch(ch){
|
switch (ch) {
|
||||||
case '\'':
|
case '\'':
|
||||||
case '"':
|
case '"':
|
||||||
if(expect == ch){
|
if (expect == ch) {
|
||||||
// String s = cmd.substring(start, i);
|
// String s = cmd.substring(start, i);
|
||||||
// list.add(s);
|
// list.add(s);
|
||||||
expect = 0;
|
expect = 0;
|
||||||
// start = i + 1;
|
// start = i + 1;
|
||||||
} else if (expect == 0){
|
} else if (expect == 0) {
|
||||||
// String s = cmd.substring(start, i);
|
// String s = cmd.substring(start, i);
|
||||||
// list.add(s);
|
// list.add(s);
|
||||||
expect = ch;
|
expect = ch;
|
||||||
// start = i + 1;
|
// start = i + 1;
|
||||||
} else {
|
} else {
|
||||||
buf.append(ch);
|
buf.append(ch);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
if(expect == 0){
|
if (expect == 0) {
|
||||||
if(prev != ' '){
|
if (prev != ' ') {
|
||||||
list.add(buf.toString());
|
list.add(buf.toString());
|
||||||
buf.delete(0, buf.length());
|
buf.delete(0, buf.length());
|
||||||
}
|
}
|
||||||
// start = i + 1;
|
// start = i + 1;
|
||||||
} else {
|
} else {
|
||||||
buf.append(ch);
|
buf.append(ch);
|
||||||
}
|
}
|
||||||
|
@ -422,25 +398,25 @@ public class BuildStep implements IBuildStep {
|
||||||
prev = ch;
|
prev = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buf.length() > 0)
|
if (buf.length() > 0)
|
||||||
list.add(buf.toString());
|
list.add(buf.toString());
|
||||||
|
|
||||||
IPath c = new Path(list.remove(0));
|
IPath c = new Path(list.remove(0));
|
||||||
String[] args = list.toArray(new String[list.size()]);
|
String[] args = list.toArray(new String[list.size()]);
|
||||||
|
|
||||||
return new IBuildCommand[]{new BuildCommand(c, args, env, cwd, this)};
|
return new IBuildCommand[] { new BuildCommand(c, args, env, cwd, this) };
|
||||||
}
|
}
|
||||||
|
|
||||||
private BuildResource[] getPrimaryResources(boolean input){
|
private BuildResource[] getPrimaryResources(boolean input) {
|
||||||
BuildIOType[] types = getPrimaryTypes(input);
|
BuildIOType[] types = getPrimaryTypes(input);
|
||||||
if(types.length == 0)
|
if (types.length == 0)
|
||||||
types = input ? (BuildIOType[])getInputIOTypes() : (BuildIOType[])getOutputIOTypes();
|
types = input ? (BuildIOType[]) getInputIOTypes() : (BuildIOType[]) getOutputIOTypes();
|
||||||
List<BuildResource> list = new ArrayList<BuildResource>();
|
List<BuildResource> list = new ArrayList<BuildResource>();
|
||||||
|
|
||||||
for(int i = 0; i < types.length; i++){
|
for (int i = 0; i < types.length; i++) {
|
||||||
BuildResource [] rcs = (BuildResource[])types[i].getResources();
|
BuildResource[] rcs = (BuildResource[]) types[i].getResources();
|
||||||
|
|
||||||
for(int j = 0; j < rcs.length; j++){
|
for (int j = 0; j < rcs.length; j++) {
|
||||||
list.add(rcs[j]);
|
list.add(rcs[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,10 +424,10 @@ public class BuildStep implements IBuildStep {
|
||||||
return list.toArray(new BuildResource[list.size()]);
|
return list.toArray(new BuildResource[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] resourcesToStrings(IPath cwd, BuildResource rcs[], String prefixToRm){
|
private String[] resourcesToStrings(IPath cwd, BuildResource rcs[], String prefixToRm) {
|
||||||
List<String> list = new ArrayList<String>(rcs.length);
|
List<String> list = new ArrayList<String>(rcs.length);
|
||||||
|
|
||||||
for(int i = 0; i < rcs.length; i++){
|
for (int i = 0; i < rcs.length; i++) {
|
||||||
IPath path = BuildDescriptionManager.getRelPath(cwd, rcs[i].getLocation());
|
IPath path = BuildDescriptionManager.getRelPath(cwd, rcs[i].getLocation());
|
||||||
path = rmNamePrefix(path, prefixToRm);
|
path = rmNamePrefix(path, prefixToRm);
|
||||||
list.add(path.toOSString());
|
list.add(path.toOSString());
|
||||||
|
@ -459,16 +435,17 @@ public class BuildStep implements IBuildStep {
|
||||||
return list.toArray(new String[list.size()]);
|
return list.toArray(new String[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveMacros(String str, IFileContextData fileData, boolean resolveAll){
|
private String resolveMacros(String str, IFileContextData fileData, boolean resolveAll) {
|
||||||
String result = str;
|
String result = str;
|
||||||
try {
|
try {
|
||||||
if(resolveAll){
|
if (resolveAll) {
|
||||||
IConfiguration cfg = getBuildDescription().getConfiguration();
|
IConfiguration cfg = getBuildDescription().getConfiguration();
|
||||||
IBuilder builder = cfg.getBuilder();
|
IBuilder builder = cfg.getBuilder();
|
||||||
SupplierBasedCdtVariableSubstitutor sub = createSubstitutor(cfg, builder, fileData);
|
SupplierBasedCdtVariableSubstitutor sub = createSubstitutor(cfg, builder, fileData);
|
||||||
result = CdtVariableResolver.resolveToString(str, sub);
|
result = CdtVariableResolver.resolveToString(str, sub);
|
||||||
} else {
|
} else {
|
||||||
result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", " ", IBuildMacroProvider.CONTEXT_FILE, fileData); //$NON-NLS-1$ //$NON-NLS-2$
|
result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", //$NON-NLS-1$
|
||||||
|
" ", IBuildMacroProvider.CONTEXT_FILE, fileData); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch (CdtVariableException e) {
|
} catch (CdtVariableException e) {
|
||||||
}
|
}
|
||||||
|
@ -476,14 +453,16 @@ public class BuildStep implements IBuildStep {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveMacros(String str, boolean resolveAll){
|
private String resolveMacros(String str, boolean resolveAll) {
|
||||||
String result = str;
|
String result = str;
|
||||||
try {
|
try {
|
||||||
IConfiguration cfg = getBuildDescription().getConfiguration();
|
IConfiguration cfg = getBuildDescription().getConfiguration();
|
||||||
if(resolveAll){
|
if (resolveAll) {
|
||||||
result = ManagedBuildManager.getBuildMacroProvider().resolveValue(str, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg); //$NON-NLS-1$ //$NON-NLS-2$
|
result = ManagedBuildManager.getBuildMacroProvider().resolveValue(str, "", " ", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg);
|
||||||
} else {
|
} else {
|
||||||
result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", " ", IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg); //$NON-NLS-1$ //$NON-NLS-2$
|
result = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(str, "", //$NON-NLS-1$
|
||||||
|
" ", IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} catch (CdtVariableException e) {
|
} catch (CdtVariableException e) {
|
||||||
}
|
}
|
||||||
|
@ -491,27 +470,24 @@ public class BuildStep implements IBuildStep {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SupplierBasedCdtVariableSubstitutor createSubstitutor(IConfiguration cfg, IBuilder builder, IFileContextData fileData){
|
private SupplierBasedCdtVariableSubstitutor createSubstitutor(IConfiguration cfg, IBuilder builder,
|
||||||
BuildMacroProvider prov = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
|
IFileContextData fileData) {
|
||||||
|
BuildMacroProvider prov = (BuildMacroProvider) ManagedBuildManager.getBuildMacroProvider();
|
||||||
IMacroContextInfo info = prov.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE, fileData);
|
IMacroContextInfo info = prov.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE, fileData);
|
||||||
FileMacroExplicitSubstitutor sub = new FileMacroExplicitSubstitutor(
|
FileMacroExplicitSubstitutor sub = new FileMacroExplicitSubstitutor(info, cfg, builder, "", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
info,
|
|
||||||
cfg,
|
|
||||||
builder,
|
|
||||||
"", " "); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
|
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getCommandFlags(IPath inRcPath, IPath outRcPath, boolean resolveAll){
|
private String[] getCommandFlags(IPath inRcPath, IPath outRcPath, boolean resolveAll) {
|
||||||
try {
|
try {
|
||||||
if(resolveAll) {
|
if (resolveAll) {
|
||||||
IConfiguration cfg = getBuildDescription().getConfiguration();
|
IConfiguration cfg = getBuildDescription().getConfiguration();
|
||||||
IBuilder builder = cfg.getBuilder();
|
IBuilder builder = cfg.getBuilder();
|
||||||
return ((Tool)fTool).getToolCommandFlags(inRcPath, outRcPath,
|
return ((Tool) fTool).getToolCommandFlags(inRcPath, outRcPath,
|
||||||
createSubstitutor(cfg, builder,
|
createSubstitutor(cfg, builder,
|
||||||
new FileContextData(inRcPath, outRcPath, null, fTool)),
|
new FileContextData(inRcPath, outRcPath, null, fTool)),
|
||||||
BuildMacroProvider.getDefault());
|
BuildMacroProvider.getDefault());
|
||||||
}
|
}
|
||||||
return fTool.getToolCommandFlags(inRcPath, outRcPath);
|
return fTool.getToolCommandFlags(inRcPath, outRcPath);
|
||||||
} catch (BuildException e) {
|
} catch (BuildException e) {
|
||||||
|
@ -519,46 +495,43 @@ public class BuildStep implements IBuildStep {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private String listToString(String[] list, String delimiter){
|
private String listToString(String[] list, String delimiter) {
|
||||||
if(list == null || list.length == 0)
|
if (list == null || list.length == 0)
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
|
|
||||||
StringBuilder buf = new StringBuilder(list[0]);
|
StringBuilder buf = new StringBuilder(list[0]);
|
||||||
|
|
||||||
for(int i = 1; i < list.length; i++){
|
for (int i = 1; i < list.length; i++) {
|
||||||
buf.append(delimiter).append(list[i]);
|
buf.append(delimiter).append(list[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BuildResource getRcForMacros(boolean input){
|
private BuildResource getRcForMacros(boolean input) {
|
||||||
IBuildIOType types[] = getPrimaryTypes(input);
|
IBuildIOType types[] = getPrimaryTypes(input);
|
||||||
if(types.length != 0){
|
if (types.length != 0) {
|
||||||
for(int i = 0; i < types.length; i++){
|
for (int i = 0; i < types.length; i++) {
|
||||||
IBuildResource rcs[] = types[i].getResources();
|
IBuildResource rcs[] = types[i].getResources();
|
||||||
if(rcs.length != 0)
|
if (rcs.length != 0)
|
||||||
return (BuildResource)rcs[0];
|
return (BuildResource) rcs[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
types = input ? getInputIOTypes() : getOutputIOTypes();
|
types = input ? getInputIOTypes() : getOutputIOTypes();
|
||||||
if(types.length != 0){
|
if (types.length != 0) {
|
||||||
for(int i = 0; i < types.length; i++){
|
for (int i = 0; i < types.length; i++) {
|
||||||
IBuildResource rcs[] = types[i].getResources();
|
IBuildResource rcs[] = types[i].getResources();
|
||||||
if(rcs.length != 0)
|
if (rcs.length != 0)
|
||||||
return (BuildResource)rcs[0];
|
return (BuildResource) rcs[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#isRemoved()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRemoved(){
|
public boolean isRemoved() {
|
||||||
return fIsRemoved;
|
return fIsRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,40 +540,38 @@ public class BuildStep implements IBuildStep {
|
||||||
fNeedsRebuild = false;
|
fNeedsRebuild = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildStep#getBuildDescription()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBuildDescription getBuildDescription(){
|
public IBuildDescription getBuildDescription() {
|
||||||
return fBuildDescription;
|
return fBuildDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isMultiAction(){
|
boolean isMultiAction() {
|
||||||
BuildIOType args[] = getPrimaryTypes(true);
|
BuildIOType args[] = getPrimaryTypes(true);
|
||||||
BuildIOType arg = args.length > 0 ? args[0] : null;
|
BuildIOType arg = args.length > 0 ? args[0] : null;
|
||||||
|
|
||||||
if(arg != null){
|
if (arg != null) {
|
||||||
if(arg.getIoType() != null)
|
if (arg.getIoType() != null)
|
||||||
return ((IInputType)arg.getIoType()).getMultipleOfType();
|
return ((IInputType) arg.getIoType()).getMultipleOfType();
|
||||||
return fTool != null && fTool == ((Configuration)fBuildDescription.getConfiguration()).calculateTargetTool();
|
return fTool != null
|
||||||
|
&& fTool == ((Configuration) fBuildDescription.getConfiguration()).calculateTargetTool();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IInputType getInputType(){
|
public IInputType getInputType() {
|
||||||
return fInputType;
|
return fInputType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLibTool(ITool libTool){
|
public void setLibTool(ITool libTool) {
|
||||||
fLibTool = libTool;
|
fLibTool = libTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITool getLibTool(){
|
public ITool getLibTool() {
|
||||||
return fLibTool;
|
return fLibTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void performAsignToOption(IPath cwd){
|
protected void performAsignToOption(IPath cwd) {
|
||||||
if(fTool == null && !fAssignToCalculated)
|
if (fTool == null && !fAssignToCalculated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fAssignToCalculated = true;
|
fAssignToCalculated = true;
|
||||||
|
@ -608,47 +579,44 @@ public class BuildStep implements IBuildStep {
|
||||||
IConfiguration cfg = fBuildDescription.getConfiguration();
|
IConfiguration cfg = fBuildDescription.getConfiguration();
|
||||||
|
|
||||||
for (BuildIOType bType : fInputTypes) {
|
for (BuildIOType bType : fInputTypes) {
|
||||||
IInputType type = (IInputType)bType.getIoType();
|
IInputType type = (IInputType) bType.getIoType();
|
||||||
|
|
||||||
if(type == null)
|
if (type == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IOption option = fTool.getOptionBySuperClassId(type.getOptionId());
|
IOption option = fTool.getOptionBySuperClassId(type.getOptionId());
|
||||||
IOption assignToOption = fTool.getOptionBySuperClassId(type.getAssignToOptionId());
|
IOption assignToOption = fTool.getOptionBySuperClassId(type.getAssignToOptionId());
|
||||||
if (assignToOption != null && option == null) {
|
if (assignToOption != null && option == null) {
|
||||||
try {
|
try {
|
||||||
BuildResource bRcs[] = (BuildResource[])bType.getResources();
|
BuildResource bRcs[] = (BuildResource[]) bType.getResources();
|
||||||
int optType = assignToOption.getValueType();
|
int optType = assignToOption.getValueType();
|
||||||
if (optType == IOption.STRING) {
|
if (optType == IOption.STRING) {
|
||||||
String optVal = ""; //$NON-NLS-1$
|
String optVal = ""; //$NON-NLS-1$
|
||||||
for (int j=0; j<bRcs.length; j++) {
|
for (int j = 0; j < bRcs.length; j++) {
|
||||||
if (j != 0) {
|
if (j != 0) {
|
||||||
optVal += " "; //$NON-NLS-1$
|
optVal += " "; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
optVal += BuildDescriptionManager.getRelPath(cwd, bRcs[j].getLocation()).toOSString();
|
optVal += BuildDescriptionManager.getRelPath(cwd, bRcs[j].getLocation())
|
||||||
|
.toOSString();
|
||||||
}
|
}
|
||||||
ManagedBuildManager.setOption(cfg, fTool, assignToOption, optVal);
|
ManagedBuildManager.setOption(cfg, fTool, assignToOption, optVal);
|
||||||
} else if (
|
} else if (optType == IOption.STRING_LIST || optType == IOption.LIBRARIES
|
||||||
optType == IOption.STRING_LIST ||
|
|| optType == IOption.OBJECTS || optType == IOption.INCLUDE_PATH
|
||||||
optType == IOption.LIBRARIES ||
|
|| optType == IOption.PREPROCESSOR_SYMBOLS || optType == IOption.INCLUDE_FILES
|
||||||
optType == IOption.OBJECTS ||
|
|| optType == IOption.LIBRARY_PATHS || optType == IOption.LIBRARY_FILES
|
||||||
optType == IOption.INCLUDE_PATH ||
|
|| optType == IOption.MACRO_FILES || optType == IOption.UNDEF_INCLUDE_PATH
|
||||||
optType == IOption.PREPROCESSOR_SYMBOLS ||
|
|| optType == IOption.UNDEF_PREPROCESSOR_SYMBOLS
|
||||||
optType == IOption.INCLUDE_FILES ||
|
|| optType == IOption.UNDEF_INCLUDE_FILES
|
||||||
optType == IOption.LIBRARY_PATHS ||
|
|| optType == IOption.UNDEF_LIBRARY_PATHS
|
||||||
optType == IOption.LIBRARY_FILES ||
|
|| optType == IOption.UNDEF_LIBRARY_FILES
|
||||||
optType == IOption.MACRO_FILES ||
|
|| optType == IOption.UNDEF_MACRO_FILES) {
|
||||||
optType == IOption.UNDEF_INCLUDE_PATH ||
|
// Mote that when using the enumerated inputs, the path(s) must be translated from
|
||||||
optType == IOption.UNDEF_PREPROCESSOR_SYMBOLS ||
|
// project relative
|
||||||
optType == IOption.UNDEF_INCLUDE_FILES ||
|
// to top build directory relative
|
||||||
optType == IOption.UNDEF_LIBRARY_PATHS ||
|
|
||||||
optType == IOption.UNDEF_LIBRARY_FILES ||
|
|
||||||
optType == IOption.UNDEF_MACRO_FILES){
|
|
||||||
// Mote that when using the enumerated inputs, the path(s) must be translated from project relative
|
|
||||||
// to top build directory relative
|
|
||||||
String[] paths = new String[bRcs.length];
|
String[] paths = new String[bRcs.length];
|
||||||
for (int j=0; j<bRcs.length; j++) {
|
for (int j = 0; j < bRcs.length; j++) {
|
||||||
paths[j] = BuildDescriptionManager.getRelPath(cwd, bRcs[j].getLocation()).toOSString();
|
paths[j] = BuildDescriptionManager.getRelPath(cwd, bRcs[j].getLocation())
|
||||||
|
.toOSString();
|
||||||
}
|
}
|
||||||
ManagedBuildManager.setOption(cfg, fTool, assignToOption, paths);
|
ManagedBuildManager.setOption(cfg, fTool, assignToOption, paths);
|
||||||
} else if (optType == IOption.BOOLEAN) {
|
} else if (optType == IOption.BOOLEAN) {
|
||||||
|
@ -659,10 +627,11 @@ public class BuildStep implements IBuildStep {
|
||||||
}
|
}
|
||||||
} else if (optType == IOption.ENUMERATED || optType == IOption.TREE) {
|
} else if (optType == IOption.ENUMERATED || optType == IOption.TREE) {
|
||||||
if (bRcs.length > 0) {
|
if (bRcs.length > 0) {
|
||||||
ManagedBuildManager.setOption(cfg, fTool, assignToOption, BuildDescriptionManager.getRelPath(cwd, bRcs[0].getLocation()).toOSString());
|
ManagedBuildManager.setOption(cfg, fTool, assignToOption, BuildDescriptionManager
|
||||||
|
.getRelPath(cwd, bRcs[0].getLocation()).toOSString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch( BuildException ex ) {
|
} catch (BuildException ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue