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