// this
// input-type
String variable = type.getBuildVariable();
boolean primaryInput = type.getPrimaryInput();
boolean useFileExts = false;
IOption option = tool.getOptionBySuperClassId(type.getOptionId());
IOption assignToOption = tool.getOptionBySuperClassId(type.getAssignToOptionId());
// Option?
if (option != null) {
try {
List<String> inputs = new ArrayList<String>();
int optType = option.getValueType();
if (optType == IOption.STRING) {
inputs.add(option.getStringValue());
} else if (optType == IOption.STRING_LIST || optType == IOption.LIBRARIES || optType == IOption.OBJECTS
|| optType == IOption.INCLUDE_FILES || optType == IOption.LIBRARY_PATHS || optType == IOption.LIBRARY_FILES
|| optType == IOption.MACRO_FILES) {
@SuppressWarnings("unchecked")
List<String> valueList = (List<String>) option.getValue();
inputs = valueList;
tool.filterValues(optType, inputs);
tool.filterValues(optType, inputs);
}
for (int j = 0; j < inputs.size(); j++) {
String inputName = inputs.get(j);
try {
// try to resolve the build macros in the output
// names
String resolved = null;
// does the input name contain spaces?
// TODO: support other special characters
if (inputName.indexOf(" ") != -1) //$NON-NLS-1$
{
// resolve to string
resolved = ManagedBuildManager.getBuildMacroProvider().resolveValue(inputName, "", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(option, tool));
} else {
// resolve to makefile variable format
resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(inputName, "", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_OPTION, new OptionContextData(option, tool));
}
if ((resolved = resolved.trim()).length() > 0)
inputName = resolved;
} catch (BuildMacroException e) {// JABA is not
// going to add
// code
}
if (primaryInput) {
itCommandDependencies.add(j, inputName);
} else {
itCommandDependencies.add(inputName);
}
// NO - itCommandInputs.add(inputName);
// NO - itEnumeratedInputs.add(inputName);
}
} catch (BuildException ex) {// JABA is not going to add
// code
}
} else {
// Build Variable?
if (variable.length() > 0) {
String cmdVariable = variable = "$(" + variable + ")"; //$NON-NLS-1$ //$NON-NLS-2$
itCommandInputs.add(cmdVariable);
if (primaryInput) {
itCommandDependencies.add(0, cmdVariable);
} else {
itCommandDependencies.add(cmdVariable);
}
// If there is an output variable with the same name,
// get
// the files associated with it.
List<String> outMacroList = makeGen.getBuildVariableList(h, variable, ArduinoGnuMakefileGenerator.PROJECT_RELATIVE, null,
true);
if (outMacroList != null) {
itEnumeratedInputs.addAll(outMacroList);
} else {
// If "last chance", then calculate using file
// extensions below
if (lastChance) {
useFileExts = true;
} else {
done = false;
break;
}
}
}
// Use file extensions
if (variable.length() == 0 || useFileExts) {
// if (type.getMultipleOfType()) {
// Calculate EnumeratedInputs using the file extensions
// and the resources in the project
// Note: This is only correct for tools with
// multipleOfType == true, but for other tools
// it gives us an input resource for generating default
// names
// Determine the set of source input macros to use
HashSet<String> handledInputExtensions = new HashSet<String>();
String[] exts = type.getSourceExtensions(tool);
if (projResources != null) {
for (IResource rc : projResources) {
if (rc.getType() == IResource.FILE) {
String fileExt = rc.getFileExtension();
// fix for NPE, bugzilla 99483
if (fileExt == null) {
fileExt = ""; //$NON-NLS-1$
}
for (int k = 0; k < exts.length; k++) {
if (fileExt.equals(exts[k])) {
if (!useFileExts) {
if (!handledInputExtensions.contains(fileExt)) {
handledInputExtensions.add(fileExt);
String buildMacro = "$(" + makeGen.getSourceMacroName(fileExt).toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
itCommandInputs.add(buildMacro);
if (primaryInput) {
itCommandDependencies.add(0, buildMacro);
} else {
itCommandDependencies.add(buildMacro);
}
}
}
if (type.getMultipleOfType() || itEnumeratedInputs.size() == 0) {
// Add a path that is relative
// to the project directory
itEnumeratedInputs.add(rc.getProjectRelativePath().toString());
}
break;
}
}
}
}
}
// }
}
}
// Get any additional inputs specified in the manifest file or
// the project file
IAdditionalInput[] addlInputs = type.getAdditionalInputs();
if (addlInputs != null) {
for (int j = 0; j < addlInputs.length; j++) {
IAdditionalInput addlInput = addlInputs[j];
int kind = addlInput.getKind();
if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT || kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
String[] paths = addlInput.getPaths();
if (paths != null) {
for (int k = 0; k < paths.length; k++) {
String path = paths[k];
itEnumeratedInputs.add(path);
// Translate the path from project relative
// to build directory relative
if (!(path.startsWith("$("))) { //$NON-NLS-1$
IResource addlResource = project.getFile(path);
if (addlResource != null) {
IPath addlPath = addlResource.getLocation();
if (addlPath != null) {
path = ManagedBuildManager.calculateRelativePath(makeGen.getTopBuildDir(), addlPath).toString();
}
}
}
itCommandInputs.add(path);
}
}
}
}
}
// If the assignToOption attribute is specified, set the
// input(s) as the value of that option
if (assignToOption != null && option == null) {
try {
int optType = assignToOption.getValueType();
if (optType == IOption.STRING) {
String optVal = ""; //$NON-NLS-1$
for (int j = 0; j < itCommandInputs.size(); j++) {
if (j != 0) {
optVal += " "; //$NON-NLS-1$