Search in sources :

Example 6 with IInputType

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) IManagedDependencyGeneratorType(org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType) IAdditionalInput(org.eclipse.cdt.managedbuilder.core.IAdditionalInput) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) IInputType(org.eclipse.cdt.managedbuilder.core.IInputType) Vector(java.util.Vector) IResource(org.eclipse.core.resources.IResource)

Aggregations

IInputType (org.eclipse.cdt.managedbuilder.core.IInputType)6 ArrayList (java.util.ArrayList)5 IResource (org.eclipse.core.resources.IResource)4 IPath (org.eclipse.core.runtime.IPath)4 List (java.util.List)3 ITool (org.eclipse.cdt.managedbuilder.core.ITool)3 Vector (java.util.Vector)2 BuildException (org.eclipse.cdt.managedbuilder.core.BuildException)2 IAdditionalInput (org.eclipse.cdt.managedbuilder.core.IAdditionalInput)2 IOption (org.eclipse.cdt.managedbuilder.core.IOption)2 IOutputType (org.eclipse.cdt.managedbuilder.core.IOutputType)2 IResourceInfo (org.eclipse.cdt.managedbuilder.core.IResourceInfo)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Entry (java.util.Map.Entry)1 IFileInfo (org.eclipse.cdt.managedbuilder.core.IFileInfo)1 OptionContextData (org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData)1 BuildMacroException (org.eclipse.cdt.managedbuilder.macros.BuildMacroException)1 IManagedDependencyGeneratorType (org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType)1