1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 12:55:40 +02:00

bug 319512: Compilation warnings

This commit is contained in:
Andrew Gvozdev 2010-08-22 02:58:21 +00:00
parent 393c776410
commit bbe979278f
5 changed files with 139 additions and 139 deletions

View file

@ -212,7 +212,7 @@ public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedD
IManagedCommandLineInfo cmdLInfo = null; IManagedCommandLineInfo cmdLInfo = null;
// Set up the command line options that will generate the dependency file // Set up the command line options that will generate the dependency file
Vector options = new Vector(); Vector<String> options = new Vector<String>();
// -w // -w
options.add("-w"); //$NON-NLS-1$ options.add("-w"); //$NON-NLS-1$
// -MM // -MM
@ -249,11 +249,11 @@ public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedD
// Save the -I, -D, -U options and discard the rest // Save the -I, -D, -U options and discard the rest
try { try {
String[] allFlags = tool.getToolCommandFlags(sourceLocation, outputLocation); String[] allFlags = tool.getToolCommandFlags(sourceLocation, outputLocation);
for (int i=0; i<allFlags.length; i++) { for (String flag : allFlags) {
if (allFlags[i].startsWith("-I") || //$NON-NLS-1$ if (flag.startsWith("-I") || //$NON-NLS-1$
allFlags[i].startsWith("-D") || //$NON-NLS-1$ flag.startsWith("-D") || //$NON-NLS-1$
allFlags[i].startsWith("-U")) { //$NON-NLS-1$ flag.startsWith("-U")) { //$NON-NLS-1$
options.add(allFlags[i]); options.add(flag);
} }
} }
} catch( BuildException ex ) { } catch( BuildException ex ) {
@ -261,7 +261,7 @@ public class DefaultGCCDependencyCalculatorPreBuildCommands implements IManagedD
// Call the command line generator // Call the command line generator
IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator(); IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator();
String[] flags = (String[])options.toArray(new String[options.size()]); String[] flags = options.toArray(new String[options.size()]);
String[] inputs = new String[1]; String[] inputs = new String[1];
inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO; inputs[0] = IManagedBuilderMakefileGenerator.IN_MACRO;
cmdLInfo = cmdLGen.generateCommandLineInfo( cmdLInfo = cmdLGen.generateCommandLineInfo(

View file

@ -10,11 +10,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.util.ArrayList;
/** /**
* *
* This class contains the desciption of a group of generated dependency files, * This class contains the description of a group of generated dependency files,
* e.g., .d files created by compilations * e.g., .d files created by compilations
* *
*/ */
@ -24,14 +23,14 @@ public class GnuDependencyGroupInfo {
// Member Variables // Member Variables
String groupBuildVar; String groupBuildVar;
boolean conditionallyInclude; boolean conditionallyInclude;
ArrayList groupFiles; // ArrayList groupFiles;
// Constructor // Constructor
public GnuDependencyGroupInfo(String groupName, boolean bConditionallyInclude) { public GnuDependencyGroupInfo(String groupName, boolean bConditionallyInclude) {
groupBuildVar = groupName; groupBuildVar = groupName;
conditionallyInclude = bConditionallyInclude; conditionallyInclude = bConditionallyInclude;
// Note: not yet needed // Note: not yet needed
groupFiles = null; // groupFiles = null;
} }
} }

View file

@ -182,7 +182,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (!generator.isGeneratedResource(resource)) { if (!generator.isGeneratedResource(resource)) {
generator.appendDeletedSubdirectory((IContainer)resource); generator.appendDeletedSubdirectory((IContainer)resource);
} }
default:
break; break;
} }
} }
@ -3126,7 +3125,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
optType == IOption.LIBRARY_PATHS || optType == IOption.LIBRARY_PATHS ||
optType == IOption.LIBRARY_FILES || optType == IOption.LIBRARY_FILES ||
optType == IOption.MACRO_FILES) { optType == IOption.MACRO_FILES) {
outputList = (List<String>)option.getValue(); @SuppressWarnings("unchecked")
List<String> value = (List<String>)option.getValue();
outputList = value;
((Tool)tool).filterValues(optType, outputList); ((Tool)tool).filterValues(optType, outputList);
// Add outputPrefix to each if necessary // Add outputPrefix to each if necessary
if (outputPrefix.length() > 0) { if (outputPrefix.length() > 0) {
@ -3866,13 +3867,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
/** /**
* Write all macro addition entries in a map to the buffer * Write all macro addition entries in a map to the buffer
*/ */
protected StringBuffer writeTopAdditionMacros(List<String> varList, HashMap<String, ?> varMap) { protected StringBuffer writeTopAdditionMacros(List<String> varList, HashMap<String, String> varMap) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
// Add the comment // Add the comment
buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_VARS) + NEWLINE); buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_VARS) + NEWLINE);
for (int i=0; i<varList.size(); i++) { for (int i=0; i<varList.size(); i++) {
String addition = (String) varMap.get(varList.get(i)); String addition = varMap.get(varList.get(i));
StringBuffer currentBuffer = new StringBuffer(); StringBuffer currentBuffer = new StringBuffer();
currentBuffer.append(addition); currentBuffer.append(addition);
currentBuffer.append(NEWLINE); currentBuffer.append(NEWLINE);
@ -4104,7 +4105,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
* *
* @return HashMap * @return HashMap
*/ */
public LinkedHashMap getTopBuildOutputVars() { public LinkedHashMap<String, String> getTopBuildOutputVars() {
return topBuildOutVars; return topBuildOutVars;
} }

View file

@ -36,14 +36,14 @@ public interface IManagedBuildGnuToolInfo {
* *
* @return Vector * @return Vector
*/ */
public Vector getCommandInputs(); public Vector<String> getCommandInputs();
/** /**
* Returns the raw list of tool's input file names. * Returns the raw list of tool's input file names.
* *
* @return Vector * @return Vector
*/ */
public Vector getEnumeratedInputs(); public Vector<String> getEnumeratedInputs();
/** /**
* Returns <code>true</code> if the tool's outputs have been calculated, * Returns <code>true</code> if the tool's outputs have been calculated,
@ -59,28 +59,28 @@ public interface IManagedBuildGnuToolInfo {
* *
* @return Vector * @return Vector
*/ */
public Vector getCommandOutputs(); public Vector<String> getCommandOutputs();
/** /**
* Returns the raw list of tool's primary output file names. * Returns the raw list of tool's primary output file names.
* *
* @return Vector * @return Vector
*/ */
public Vector getEnumeratedPrimaryOutputs(); public Vector<String> getEnumeratedPrimaryOutputs();
/** /**
* Returns the raw list of tool's secondary output file names. * Returns the raw list of tool's secondary output file names.
* *
* @return Vector * @return Vector
*/ */
public Vector getEnumeratedSecondaryOutputs(); public Vector<String> getEnumeratedSecondaryOutputs();
/** /**
* Returns the raw list of tool's output variable names. * Returns the raw list of tool's output variable names.
* *
* @return Vector * @return Vector
*/ */
public Vector getOutputVariables(); public Vector<String> getOutputVariables();
/** /**
* Returns <code>true</code> if the tool's dependencies have been calculated, * Returns <code>true</code> if the tool's dependencies have been calculated,
@ -97,7 +97,7 @@ public interface IManagedBuildGnuToolInfo {
* *
* @return Vector * @return Vector
*/ */
public Vector getCommandDependencies(); public Vector<String> getCommandDependencies();
/** /**
* Returns the tool's additional targets as determined by the * Returns the tool's additional targets as determined by the
@ -106,14 +106,14 @@ public interface IManagedBuildGnuToolInfo {
* *
* @return Vector * @return Vector
*/ */
public Vector getAdditionalTargets(); public Vector<String> getAdditionalTargets();
/** /**
* Returns the raw list of tool's input dependencies. * Returns the raw list of tool's input dependencies.
* *
* @return Vector * @return Vector
*/ */
//public Vector getEnumeratedDependencies(); //public Vector<String> getEnumeratedDependencies();
/** /**
* Returns <code>true</code> if this is the target tool * Returns <code>true</code> if this is the target tool

View file

@ -11,36 +11,35 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
import java.util.Iterator;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Vector; import java.util.Arrays;
import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput; import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IInputType; import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOutputType; import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages; import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.Tool; import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData; import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator; import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.ToolInfoHolder; import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.ToolInfoHolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -67,14 +66,14 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
private boolean outputsCalculated = false; private boolean outputsCalculated = false;
private boolean outputVariablesCalculated = false; private boolean outputVariablesCalculated = false;
private boolean dependenciesCalculated = false; private boolean dependenciesCalculated = false;
private Vector commandInputs = new Vector(); private Vector<String> commandInputs = new Vector<String>();
private Vector enumeratedInputs = new Vector(); private Vector<String> enumeratedInputs = new Vector<String>();
private Vector commandOutputs = new Vector(); private Vector<String> commandOutputs = new Vector<String>();
private Vector enumeratedPrimaryOutputs = new Vector(); private Vector<String> enumeratedPrimaryOutputs = new Vector<String>();
private Vector enumeratedSecondaryOutputs = new Vector(); private Vector<String> enumeratedSecondaryOutputs = new Vector<String>();
private Vector outputVariables = new Vector(); private Vector<String> outputVariables = new Vector<String>();
private Vector commandDependencies = new Vector(); private Vector<String> commandDependencies = new Vector<String>();
private Vector additionalTargets = new Vector(); private Vector<String> additionalTargets = new Vector<String>();
//private Vector enumeratedDependencies = new Vector(); //private Vector enumeratedDependencies = new Vector();
// Map of macro names (String) to values (List) // Map of macro names (String) to values (List)
@ -99,12 +98,12 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
// Command inputs are top build directory relative // Command inputs are top build directory relative
public Vector getCommandInputs() { public Vector<String> getCommandInputs() {
return commandInputs; return commandInputs;
} }
// Enumerated inputs are project relative // Enumerated inputs are project relative
public Vector getEnumeratedInputs() { public Vector<String> getEnumeratedInputs() {
return enumeratedInputs; return enumeratedInputs;
} }
@ -113,19 +112,19 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
// Command outputs are top build directory relative // Command outputs are top build directory relative
public Vector getCommandOutputs() { public Vector<String> getCommandOutputs() {
return commandOutputs; return commandOutputs;
} }
public Vector getEnumeratedPrimaryOutputs() { public Vector<String> getEnumeratedPrimaryOutputs() {
return enumeratedPrimaryOutputs; return enumeratedPrimaryOutputs;
} }
public Vector getEnumeratedSecondaryOutputs() { public Vector<String> getEnumeratedSecondaryOutputs() {
return enumeratedSecondaryOutputs; return enumeratedSecondaryOutputs;
} }
public Vector getOutputVariables() { public Vector<String> getOutputVariables() {
return outputVariables; return outputVariables;
} }
@ -138,12 +137,12 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
// Command dependencies are top build directory relative // Command dependencies are top build directory relative
public Vector getCommandDependencies() { public Vector<String> getCommandDependencies() {
return commandDependencies; return commandDependencies;
} }
// Additional targets are top build directory relative // Additional targets are top build directory relative
public Vector getAdditionalTargets() { public Vector<String> getAdditionalTargets() {
return additionalTargets; return additionalTargets;
} }
@ -170,17 +169,16 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
* 3. Use the file extensions and the resources in the project * 3. Use the file extensions and the resources in the project
*/ */
boolean done = true; boolean done = true;
Vector myCommandInputs = new Vector(); // Inputs for the tool command line Vector<String> myCommandInputs = new Vector<String>(); // Inputs for the tool command line
Vector myCommandDependencies = new Vector(); // Dependencies for the make rule Vector<String> myCommandDependencies = new Vector<String>(); // Dependencies for the make rule
Vector myEnumeratedInputs = new Vector(); // Complete list of individual inputs Vector<String> myEnumeratedInputs = new Vector<String>(); // Complete list of individual inputs
IInputType[] inTypes = tool.getInputTypes(); IInputType[] inTypes = tool.getInputTypes();
if (inTypes != null && inTypes.length > 0) { if (inTypes != null) {
for (int i=0; i<inTypes.length; i++) { for (IInputType type : inTypes) {
IInputType type = inTypes[i]; Vector<String> itCommandInputs = new Vector<String>(); // Inputs for the tool command line for this input-type
Vector itCommandInputs = new Vector(); // Inputs for the tool command line for this input-type Vector<String> itCommandDependencies = new Vector<String>(); // Dependencies for the make rule for this input-type
Vector itCommandDependencies = new Vector(); // Dependencies for the make rule for this input-type Vector<String> itEnumeratedInputs = new Vector<String>(); // Complete list of individual inputs for this input-type
Vector itEnumeratedInputs = new Vector(); // Complete list of individual inputs for this input-type
String variable = type.getBuildVariable(); String variable = type.getBuildVariable();
boolean primaryInput = type.getPrimaryInput(); boolean primaryInput = type.getPrimaryInput();
boolean useFileExts = false; boolean useFileExts = false;
@ -190,7 +188,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// Option? // Option?
if (option != null) { if (option != null) {
try { try {
List inputs = new ArrayList(); List<String> inputs = new ArrayList<String>();
int optType = option.getValueType(); int optType = option.getValueType();
if (optType == IOption.STRING) { if (optType == IOption.STRING) {
inputs.add(option.getStringValue()); inputs.add(option.getStringValue());
@ -202,11 +200,14 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
optType == IOption.LIBRARY_PATHS || optType == IOption.LIBRARY_PATHS ||
optType == IOption.LIBRARY_FILES || optType == IOption.LIBRARY_FILES ||
optType == IOption.MACRO_FILES) { optType == IOption.MACRO_FILES) {
inputs = (List)option.getValue(); @SuppressWarnings("unchecked")
List<String> valueList = (List<String>)option.getValue();
inputs = valueList;
tool.filterValues(optType, inputs);
tool.filterValues(optType, inputs); tool.filterValues(optType, inputs);
} }
for (int j=0; j<inputs.size(); j++) { for (int j=0; j<inputs.size(); j++) {
String inputName = (String)inputs.get(j); String inputName = inputs.get(j);
try { try {
@ -274,7 +275,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
// If there is an output variable with the same name, get // If there is an output variable with the same name, get
// the files associated with it. // the files associated with it.
List outMacroList = makeGen.getBuildVariableList(h, variable, GnuMakefileGenerator.PROJECT_RELATIVE, List<String> outMacroList = makeGen.getBuildVariableList(h, variable, GnuMakefileGenerator.PROJECT_RELATIVE,
null, true); null, true);
if (outMacroList != null) { if (outMacroList != null) {
itEnumeratedInputs.addAll(outMacroList); itEnumeratedInputs.addAll(outMacroList);
@ -296,12 +297,12 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// Note: This is only correct for tools with multipleOfType == true, but for other tools // Note: This is only correct for tools with multipleOfType == true, but for other tools
// it gives us an input resource for generating default names // it gives us an input resource for generating default names
// Determine the set of source input macros to use // Determine the set of source input macros to use
HashSet handledInputExtensions = new HashSet(); HashSet<String> handledInputExtensions = new HashSet<String>();
String[] exts = type.getSourceExtensions(tool); String[] exts = type.getSourceExtensions(tool);
if (projResources != null) { if (projResources != null) {
for (int j=0; j<projResources.length; j++) { for (IResource rc : projResources) {
if (projResources[j].getType() == IResource.FILE) { if (rc.getType() == IResource.FILE) {
String fileExt = projResources[j].getFileExtension(); String fileExt = rc.getFileExtension();
// fix for NPE, bugzilla 99483 // fix for NPE, bugzilla 99483
if(fileExt == null) if(fileExt == null)
@ -325,7 +326,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
if (type.getMultipleOfType() || itEnumeratedInputs.size() == 0) { if (type.getMultipleOfType() || itEnumeratedInputs.size() == 0) {
// Add a path that is relative to the project directory // Add a path that is relative to the project directory
itEnumeratedInputs.add(projResources[j].getProjectRelativePath().toString()); itEnumeratedInputs.add(rc.getProjectRelativePath().toString());
} }
break; break;
} }
@ -393,7 +394,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// to top build directory relative // to top build directory relative
String[] paths = new String[itEnumeratedInputs.size()]; String[] paths = new String[itEnumeratedInputs.size()];
for (int j=0; j<itEnumeratedInputs.size(); j++) { for (int j=0; j<itEnumeratedInputs.size(); j++) {
paths[j] = (String)itEnumeratedInputs.get(j); paths[j] = itEnumeratedInputs.get(j);
IResource enumResource = project.getFile(paths[j]); IResource enumResource = project.getFile(paths[j]);
if (enumResource != null) { if (enumResource != null) {
IPath enumPath = enumResource.getLocation(); IPath enumPath = enumResource.getLocation();
@ -411,7 +412,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
} else if (optType == IOption.ENUMERATED) { } else if (optType == IOption.ENUMERATED) {
if (itCommandInputs.size() > 0) { if (itCommandInputs.size() > 0) {
ManagedBuildManager.setOption(config, tool, assignToOption, (String)itCommandInputs.firstElement()); ManagedBuildManager.setOption(config, tool, assignToOption, itCommandInputs.firstElement());
} }
} }
itCommandInputs.removeAllElements(); itCommandInputs.removeAllElements();
@ -466,22 +467,22 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
* NOTE: If an option is not specified and this is not the primary output type, the outputs * NOTE: If an option is not specified and this is not the primary output type, the outputs
* from the type are not added to the command line * from the type are not added to the command line
*/ */
public boolean calculateOutputs(GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, boolean lastChance) { public boolean calculateOutputs(GnuMakefileGenerator makeGen, IConfiguration config, HashSet<String> handledInputExtensions, boolean lastChance) {
boolean done = true; boolean done = true;
Vector myCommandOutputs = new Vector(); Vector<String> myCommandOutputs = new Vector<String>();
Vector myEnumeratedPrimaryOutputs = new Vector(); Vector<String> myEnumeratedPrimaryOutputs = new Vector<String>();
Vector myEnumeratedSecondaryOutputs = new Vector(); Vector<String> myEnumeratedSecondaryOutputs = new Vector<String>();
HashMap myOutputMacros = new HashMap(); HashMap<String, List<IPath>> myOutputMacros = new HashMap<String, List<IPath>>();
// The next two fields are used together // The next two fields are used together
Vector myBuildVars = new Vector(); Vector<String> myBuildVars = new Vector<String>();
Vector myBuildVarsValues = new Vector(); Vector<Vector<String>> myBuildVarsValues = new Vector<Vector<String>>();
// Get the outputs for this tool invocation // Get the outputs for this tool invocation
IOutputType[] outTypes = tool.getOutputTypes(); IOutputType[] outTypes = tool.getOutputTypes();
if (outTypes != null && outTypes.length > 0) { if (outTypes != null && outTypes.length > 0) {
for (int i=0; i<outTypes.length; i++) { for (int i=0; i<outTypes.length; i++) {
Vector typeEnumeratedOutputs = new Vector(); Vector<String> typeEnumeratedOutputs = new Vector<String>();
IOutputType type = outTypes[i]; IOutputType type = outTypes[i];
String outputPrefix = type.getOutputPrefix(); String outputPrefix = type.getOutputPrefix();
@ -530,7 +531,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// 2. If an option is specified, use the value of the option // 2. If an option is specified, use the value of the option
if (option != null) { if (option != null) {
try { try {
List outputs = new ArrayList(); List<String> outputs = new ArrayList<String>();
int optType = option.getValueType(); int optType = option.getValueType();
if (optType == IOption.STRING) { if (optType == IOption.STRING) {
outputs.add(outputPrefix + option.getStringValue()); outputs.add(outputPrefix + option.getStringValue());
@ -542,7 +543,9 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
optType == IOption.LIBRARY_PATHS || optType == IOption.LIBRARY_PATHS ||
optType == IOption.LIBRARY_FILES || optType == IOption.LIBRARY_FILES ||
optType == IOption.MACRO_FILES) { optType == IOption.MACRO_FILES) {
outputs = (List)option.getValue(); @SuppressWarnings("unchecked")
List<String> value = (List<String>)option.getValue();
outputs = value;
tool.filterValues(optType, outputs); tool.filterValues(optType, outputs);
// Add outputPrefix to each if necessary // Add outputPrefix to each if necessary
if (outputPrefix.length() > 0) { if (outputPrefix.length() > 0) {
@ -552,7 +555,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
} }
for (int j=0; j<outputs.size(); j++) { for (int j=0; j<outputs.size(); j++) {
String outputName = (String)outputs.get(j); String outputName = outputs.get(j);
try{ try{
//try to resolve the build macros in the output names //try to resolve the build macros in the output names
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
@ -570,12 +573,12 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// NO - myCommandOutputs.addAll(outputs); // NO - myCommandOutputs.addAll(outputs);
typeEnumeratedOutputs.addAll(outputs); typeEnumeratedOutputs.addAll(outputs);
if (variable.length() > 0) { if (variable.length() > 0) {
List outputPaths = new ArrayList(); List<IPath> outputPaths = new ArrayList<IPath>();
for (int j=0; j<outputs.size(); j++) { for (int j=0; j<outputs.size(); j++) {
outputPaths.add(Path.fromOSString((String)outputs.get(j))); outputPaths.add(Path.fromOSString(outputs.get(j)));
} }
if (myOutputMacros.containsKey(variable)) { if (myOutputMacros.containsKey(variable)) {
List currList = (List)myOutputMacros.get(variable); List<IPath> currList = myOutputMacros.get(variable);
currList.addAll(outputPaths); currList.addAll(outputPaths);
myOutputMacros.put(variable, currList); myOutputMacros.put(variable, currList);
} else { } else {
@ -592,10 +595,10 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
if (!inputsCalculated) { if (!inputsCalculated) {
done = false; done = false;
} else { } else {
Vector inputs = getEnumeratedInputs(); Vector<String> inputs = getEnumeratedInputs();
IPath[] inputPaths = new IPath[inputs.size()]; IPath[] inputPaths = new IPath[inputs.size()];
for (int j=0; j<inputPaths.length; j++) { for (int j=0; j<inputPaths.length; j++) {
inputPaths[j] = Path.fromOSString((String)inputs.get(j)); inputPaths[j] = Path.fromOSString(inputs.get(j));
} }
outNames = nameProvider.getOutputNames(tool, inputPaths); outNames = nameProvider.getOutputNames(tool, inputPaths);
if (outNames != null) { if (outNames != null) {
@ -625,11 +628,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
if (variable.length() > 0 && outNames != null) { if (variable.length() > 0 && outNames != null) {
if (myOutputMacros.containsKey(variable)) { if (myOutputMacros.containsKey(variable)) {
List currList = (List)myOutputMacros.get(variable); List<IPath> currList = myOutputMacros.get(variable);
currList.addAll(Arrays.asList(outNames)); currList.addAll(Arrays.asList(outNames));
myOutputMacros.put(variable, currList); myOutputMacros.put(variable, currList);
} else { } else {
myOutputMacros.put(variable, new ArrayList(Arrays.asList(outNames))); myOutputMacros.put(variable, new ArrayList<IPath>(Arrays.asList(outNames)));
} }
} }
} else } else
@ -651,18 +654,18 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} catch (BuildMacroException e){ } catch (BuildMacroException e){
} }
} }
List namesList = Arrays.asList(outputNames); List<String> namesList = Arrays.asList(outputNames);
if (primaryOutput) { if (primaryOutput) {
myCommandOutputs.addAll(namesList); myCommandOutputs.addAll(namesList);
} }
typeEnumeratedOutputs.addAll(namesList); typeEnumeratedOutputs.addAll(namesList);
if (variable.length() > 0) { if (variable.length() > 0) {
List outputPaths = new ArrayList(); List<IPath> outputPaths = new ArrayList<IPath>();
for (int j=0; j<namesList.size(); j++) { for (int j=0; j<namesList.size(); j++) {
outputPaths.add(Path.fromOSString((String)namesList.get(j))); outputPaths.add(Path.fromOSString(namesList.get(j)));
} }
if (myOutputMacros.containsKey(variable)) { if (myOutputMacros.containsKey(variable)) {
List currList = (List)myOutputMacros.get(variable); List<IPath> currList = myOutputMacros.get(variable);
currList.addAll(outputPaths); currList.addAll(outputPaths);
myOutputMacros.put(variable, currList); myOutputMacros.put(variable, currList);
} else { } else {
@ -676,9 +679,9 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// using the built-in string substitution functions of <code>make</code>. // using the built-in string substitution functions of <code>make</code>.
if (multOfType) { if (multOfType) {
// This case is not handled - a nameProvider or outputNames must be specified // This case is not handled - a nameProvider or outputNames must be specified
List errList = new ArrayList(); List<String> errList = new ArrayList<String>();
errList.add(ManagedMakeMessages.getResourceString("MakefileGenerator.error.no.nameprovider")); //$NON-NLS-1$ errList.add(ManagedMakeMessages.getResourceString("MakefileGenerator.error.no.nameprovider")); //$NON-NLS-1$
myCommandOutputs.add(errList); myCommandOutputs.addAll(errList);
} else { } else {
String namePattern = type.getNamePattern(); String namePattern = type.getNamePattern();
if (namePattern == null || namePattern.length() == 0) { if (namePattern == null || namePattern.length() == 0) {
@ -697,11 +700,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
if (!inputsCalculated) { if (!inputsCalculated) {
done = false; done = false;
} else { } else {
Vector inputs = getEnumeratedInputs(); Vector<String> inputs = getEnumeratedInputs();
String fileName; String fileName;
if (inputs.size() > 0) { if (inputs.size() > 0) {
// Get the input file name // Get the input file name
fileName = (Path.fromOSString((String)inputs.get(0))).removeFileExtension().lastSegment(); fileName = (Path.fromOSString(inputs.get(0))).removeFileExtension().lastSegment();
// Check if this is a build macro. If so, use the raw macro name. // Check if this is a build macro. If so, use the raw macro name.
if (fileName.startsWith("$(") && fileName.endsWith(")")) { //$NON-NLS-1$ //$NON-NLS-2$ if (fileName.startsWith("$(") && fileName.endsWith(")")) { //$NON-NLS-1$ //$NON-NLS-2$
fileName = fileName.substring(2,fileName.length()-1); fileName = fileName.substring(2,fileName.length()-1);
@ -715,10 +718,10 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
typeEnumeratedOutputs.add(namePattern.replaceAll("%", fileName)); //$NON-NLS-1$ typeEnumeratedOutputs.add(namePattern.replaceAll("%", fileName)); //$NON-NLS-1$
if (variable.length() > 0) { if (variable.length() > 0) {
List outputs = new ArrayList(); List<IPath> outputs = new ArrayList<IPath>();
outputs.add(Path.fromOSString(fileName)); outputs.add(Path.fromOSString(fileName));
if (myOutputMacros.containsKey(variable)) { if (myOutputMacros.containsKey(variable)) {
List currList = (List)myOutputMacros.get(variable); List<IPath> currList = myOutputMacros.get(variable);
currList.addAll(outputs); currList.addAll(outputs);
myOutputMacros.put(variable, currList); myOutputMacros.put(variable, currList);
} else { } else {
@ -756,14 +759,13 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
// Add the output macros of this tool to the buildOutVars map // Add the output macros of this tool to the buildOutVars map
Iterator iterator = myOutputMacros.entrySet().iterator(); Set<Entry<String, List<IPath>>> entrySet = myOutputMacros.entrySet();
while (iterator.hasNext()) { for (Entry<String, List<IPath>> entry : entrySet) {
Map.Entry entry = (Map.Entry)iterator.next(); String macroName = entry.getKey();
String macroName = (String)entry.getKey(); List<IPath> newMacroValue = entry.getValue();
List newMacroValue = (List)entry.getValue(); HashMap<String, List<IPath>> map = makeGen.getBuildOutputVars();
HashMap map = makeGen.getBuildOutputVars();
if (map.containsKey(macroName)) { if (map.containsKey(macroName)) {
List macroValue = (List)map.get(macroName); List<IPath> macroValue = map.get(macroName);
macroValue.addAll(newMacroValue); macroValue.addAll(newMacroValue);
map.put(macroName, macroValue); map.put(macroName, macroValue);
} else { } else {
@ -779,7 +781,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
outputVariables.addAll(myOutputMacros.keySet()); outputVariables.addAll(myOutputMacros.keySet());
outputsCalculated = true; outputsCalculated = true;
for (int i=0; i<myBuildVars.size(); i++) { for (int i=0; i<myBuildVars.size(); i++) {
makeGen.addMacroAdditionFiles(makeGen.getTopBuildOutputVars(), (String)myBuildVars.get(i), (Vector)myBuildVarsValues.get(i)); makeGen.addMacroAdditionFiles(makeGen.getTopBuildOutputVars(), myBuildVars.get(i), myBuildVarsValues.get(i));
} }
return true; return true;
} }
@ -787,9 +789,9 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
return false; return false;
} }
private boolean callDependencyCalculator (GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, private boolean callDependencyCalculator (GnuMakefileGenerator makeGen, IConfiguration config, HashSet<String> handledInputExtensions,
IManagedDependencyGeneratorType depGen, String[] extensionsList, Vector myCommandDependencies, HashMap myOutputMacros, IManagedDependencyGeneratorType depGen, String[] extensionsList, Vector<String> myCommandDependencies, HashMap<String, List<IPath>> myOutputMacros,
Vector myAdditionalTargets, ToolInfoHolder h, boolean done) { Vector<String> myAdditionalTargets, ToolInfoHolder h, boolean done) {
int calcType = depGen.getCalculatorType(); int calcType = depGen.getCalculatorType();
switch (calcType) { switch (calcType) {
@ -811,11 +813,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
String depsMacroEntry = calculateSourceMacro(makeGen, extensionName, depExt, String depsMacroEntry = calculateSourceMacro(makeGen, extensionName, depExt,
IManagedBuilderMakefileGenerator.WILDCARD); IManagedBuilderMakefileGenerator.WILDCARD);
List depsList = new ArrayList(); List<IPath> depsList = new ArrayList<IPath>();
depsList.add(Path.fromOSString(depsMacroEntry)); depsList.add(Path.fromOSString(depsMacroEntry));
String depsMacro = makeGen.getDepMacroName(extensionName).toString(); String depsMacro = makeGen.getDepMacroName(extensionName).toString();
if (myOutputMacros.containsKey(depsMacro)) { if (myOutputMacros.containsKey(depsMacro)) {
List currList = (List)myOutputMacros.get(depsMacro); List<IPath> currList = myOutputMacros.get(depsMacro);
currList.addAll(depsList); currList.addAll(depsList);
myOutputMacros.put(depsMacro, currList); myOutputMacros.put(depsMacro, currList);
} else { } else {
@ -832,7 +834,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
if (!inputsCalculated) { if (!inputsCalculated) {
done = false; done = false;
} else { } else {
Vector inputs = getEnumeratedInputs(); Vector<String> inputs = getEnumeratedInputs();
if (calcType == IManagedDependencyGeneratorType.TYPE_CUSTOM) { if (calcType == IManagedDependencyGeneratorType.TYPE_CUSTOM) {
IManagedDependencyGenerator2 depGen2 = (IManagedDependencyGenerator2)depGen; IManagedDependencyGenerator2 depGen2 = (IManagedDependencyGenerator2)depGen;
@ -840,7 +842,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
for (int i=0; i<inputs.size(); i++) { for (int i=0; i<inputs.size(); i++) {
depInfo = depGen2.getDependencySourceInfo( depInfo = depGen2.getDependencySourceInfo(
Path.fromOSString((String)inputs.get(i)), config, tool, makeGen.getBuildWorkingDir()); Path.fromOSString(inputs.get(i)), config, tool, makeGen.getBuildWorkingDir());
if (depInfo instanceof IManagedDependencyCalculator) { if (depInfo instanceof IManagedDependencyCalculator) {
IManagedDependencyCalculator depCalc = (IManagedDependencyCalculator)depInfo; IManagedDependencyCalculator depCalc = (IManagedDependencyCalculator)depInfo;
@ -849,7 +851,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
for (int j=0; j<depPaths.length; j++) { for (int j=0; j<depPaths.length; j++) {
if (!depPaths[j].isAbsolute()) { if (!depPaths[j].isAbsolute()) {
// Convert from project relative to build directory relative // Convert from project relative to build directory relative
IPath absolutePath = project.getLocation().append((IPath)depPaths[j]); IPath absolutePath = project.getLocation().append(depPaths[j]);
depPaths[j] = ManagedBuildManager.calculateRelativePath( depPaths[j] = ManagedBuildManager.calculateRelativePath(
makeGen.getTopBuildDir(), absolutePath); makeGen.getTopBuildDir(), absolutePath);
} }
@ -866,12 +868,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
} else { } else {
IManagedDependencyGenerator oldDepGen = (IManagedDependencyGenerator)depGen; IManagedDependencyGenerator oldDepGen = (IManagedDependencyGenerator)depGen;
for (int i=0; i<inputs.size(); i++) { for (String input : inputs) {
IResource[] outNames = oldDepGen.findDependencies( IResource[] outNames = oldDepGen.findDependencies(project.getFile(input), project);
project.getFile((String)inputs.get(i)), project);
if (outNames != null) { if (outNames != null) {
for (int j=0; j<outNames.length; j++) { for (IResource outName : outNames) {
myCommandDependencies.add(outNames[j].toString()); myCommandDependencies.add(outName.toString());
} }
} }
} }
@ -886,13 +887,13 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
return done; return done;
} }
public boolean calculateDependencies(GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, ToolInfoHolder h, boolean lastChance) { public boolean calculateDependencies(GnuMakefileGenerator makeGen, IConfiguration config, HashSet<String> handledInputExtensions, ToolInfoHolder h, boolean lastChance) {
// Get the dependencies for this tool invocation // Get the dependencies for this tool invocation
boolean done = true; boolean done = true;
Vector myCommandDependencies = new Vector(); Vector<String> myCommandDependencies = new Vector<String>();
Vector myAdditionalTargets = new Vector(); Vector<String> myAdditionalTargets = new Vector<String>();
//Vector myEnumeratedDependencies = new Vector(); //Vector myEnumeratedDependencies = new Vector();
HashMap myOutputMacros = new HashMap(); HashMap<String, List<IPath>> myOutputMacros = new HashMap<String, List<IPath>>();
IInputType[] inTypes = tool.getInputTypes(); IInputType[] inTypes = tool.getInputTypes();
if (inTypes != null && inTypes.length > 0) { if (inTypes != null && inTypes.length > 0) {
@ -965,14 +966,13 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
} }
// Add the output macros of this tool to the buildOutVars map // Add the output macros of this tool to the buildOutVars map
Iterator iterator = myOutputMacros.entrySet().iterator(); Set<Entry<String, List<IPath>>> entrySet = myOutputMacros.entrySet();
while (iterator.hasNext()) { for (Entry<String, List<IPath>> entry : entrySet) {
Map.Entry entry = (Map.Entry)iterator.next(); String macroName = entry.getKey();
String macroName = (String)entry.getKey(); List<IPath> newMacroValue = entry.getValue();
List newMacroValue = (List)entry.getValue(); HashMap<String, List<IPath>> map = makeGen.getBuildOutputVars();
HashMap map = makeGen.getBuildOutputVars();
if (map.containsKey(macroName)) { if (map.containsKey(macroName)) {
List macroValue = (List)map.get(macroName); List<IPath> macroValue = map.get(macroName);
macroValue.addAll(newMacroValue); macroValue.addAll(newMacroValue);
map.put(macroName, macroValue); map.put(macroName, macroValue);
} else { } else {
@ -1008,7 +1008,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// OBJS = $(macroName1: ../%.input1=%.output1) ... $(macroNameN: ../%.inputN=%.outputN) // OBJS = $(macroName1: ../%.input1=%.output1) ... $(macroNameN: ../%.inputN=%.outputN)
StringBuffer objectsBuffer = new StringBuffer(); StringBuffer objectsBuffer = new StringBuffer();
objectsBuffer.append(IManagedBuilderMakefileGenerator.WHITESPACE + "$(" + macroName + //$NON-NLS-1$ objectsBuffer.append(IManagedBuilderMakefileGenerator.WHITESPACE + "$(" + macroName + //$NON-NLS-1$
IManagedBuilderMakefileGenerator.COLON + IManagedBuilderMakefileGenerator.ROOT + //$NON-NLS-1$ IManagedBuilderMakefileGenerator.COLON + IManagedBuilderMakefileGenerator.ROOT +
IManagedBuilderMakefileGenerator.SEPARATOR + IManagedBuilderMakefileGenerator.WILDCARD + IManagedBuilderMakefileGenerator.SEPARATOR + IManagedBuilderMakefileGenerator.WILDCARD +
DOT + srcExtensionName + "=" + wildcard + OptDotExt + ")" ); //$NON-NLS-1$ //$NON-NLS-2$ DOT + srcExtensionName + "=" + wildcard + OptDotExt + ")" ); //$NON-NLS-1$ //$NON-NLS-2$
return objectsBuffer.toString(); return objectsBuffer.toString();