use of org.eclipse.cdt.managedbuilder.core.IInputType in project arduino-eclipse-plugin by Sloeber.
the class ArduinoManagedBuildGnuToolInfo method calculateDependencies.
/**
* @param lastChance
*/
public boolean calculateDependencies(ArduinoGnuMakefileGenerator makeGen, IConfiguration config, HashSet<String> handledInputExtensions, ToolInfoHolder h, boolean lastChance) {
// Get the dependencies for this tool invocation
boolean done = true;
Vector<String> myCommandDependencies = new Vector<>();
Vector<String> myAdditionalTargets = new Vector<>();
// Vector myEnumeratedDependencies = new Vector();
HashMap<String, List<IPath>> myOutputMacros = new HashMap<>();
IInputType[] inTypes = this.tool.getInputTypes();
if (inTypes != null && inTypes.length > 0) {
for (int i = 0; i < inTypes.length; i++) {
IInputType type = inTypes[i];
// Handle dependencies from the dependencyCalculator
IManagedDependencyGeneratorType depGen = type.getDependencyGenerator();
String[] extensionsList = type.getSourceExtensions(this.tool);
if (depGen != null) {
done = callDependencyCalculator(makeGen, config, handledInputExtensions, depGen, extensionsList, myCommandDependencies, myOutputMacros, myAdditionalTargets, h, done);
}
// Add additional dependencies specified in AdditionalInput
// elements
IAdditionalInput[] addlInputs = type.getAdditionalInputs();
if (addlInputs != null && addlInputs.length > 0) {
for (int j = 0; j < addlInputs.length; j++) {
IAdditionalInput addlInput = addlInputs[j];
int kind = addlInput.getKind();
if (kind == IAdditionalInput.KIND_ADDITIONAL_DEPENDENCY || kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
String[] paths = addlInput.getPaths();
if (paths != null) {
for (int k = 0; k < paths.length; k++) {
// Translate the path from project relative
// to
// build directory relative
String path = paths[k];
if (!(path.startsWith("$("))) {
// $NON-NLS-1$
IResource addlResource = this.project.getFile(path);
if (addlResource != null) {
IPath addlPath = addlResource.getLocation();
if (addlPath != null) {
path = ManagedBuildManager.calculateRelativePath(makeGen.getTopBuildDir(), addlPath).toOSString();
}
}
}
myCommandDependencies.add(path);
// myEnumeratedInputs.add(path);
}
}
}
}
}
}
} else {
if (this.bIsTargetTool) {
// For support of pre-CDT 3.0 integrations.
// NOTE WELL: This only supports the case of a single
// "target tool"
// with the following characteristics:
// 1. The tool consumes exactly all of the object files produced
// by other tools in the build and produces a single output
// 2. The target name comes from the configuration artifact name
// The rule looks like:
// <targ_prefix><target>.<extension>: $(OBJS) <refd_project_1
// ... refd_project_n>
// $NON-NLS-1$
myCommandDependencies.add("$(OBJS)");
// $NON-NLS-1$
myCommandDependencies.add("$(USER_OBJS)");
} else {
// Handle dependencies from the dependencyCalculator
IManagedDependencyGeneratorType depGen = this.tool.getDependencyGenerator();
String[] extensionsList = this.tool.getAllInputExtensions();
if (depGen != null) {
done = callDependencyCalculator(makeGen, config, handledInputExtensions, depGen, extensionsList, myCommandDependencies, myOutputMacros, myAdditionalTargets, h, done);
}
}
}
// Add the output macros of this tool to the buildOutVars map
Set<Entry<String, List<IPath>>> entrySet = myOutputMacros.entrySet();
for (Entry<String, List<IPath>> entry : entrySet) {
String macroName = entry.getKey();
List<IPath> newMacroValue = entry.getValue();
Map<String, List<IPath>> map = makeGen.getBuildOutputVars();
if (map.containsKey(macroName)) {
List<IPath> macroValue = map.get(macroName);
macroValue.addAll(newMacroValue);
map.put(macroName, macroValue);
} else {
map.put(macroName, newMacroValue);
}
}
if (done) {
this.commandDependencies.addAll(myCommandDependencies);
this.additionalTargets.addAll(myAdditionalTargets);
// enumeratedDependencies.addAll(myEnumeratedDependencies);
this.dependenciesCalculated = true;
return true;
}
return false;
}
Aggregations