Search in sources :

Example 11 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.

the class ToolchainValueHandler method listConfigs.

void listConfigs(IBuildObject configuration) {
    String configTypeID = "net.sourceforge.usbdm.cdt.toolchain.processor.mcpu";
    System.err.println("ToolchainValueHandler.isEnumValueAppropriate()");
    // first we check the preference for this project, if it exists
    IConfiguration config = null;
    if (configuration instanceof IConfiguration) {
        config = (IConfiguration) configuration;
    } else if (configuration instanceof IFolderInfo) {
        IFolderInfo folderInfo = (IFolderInfo) configuration;
        config = folderInfo.getParent();
    }
    if (config == null) {
        System.err.println("ToolchainValueHandler.isEnumValueAppropriate() config not found");
    }
    IToolChain toolChain = config.getToolChain();
    ITool[] tools = toolChain.getTools();
    IOption CPUListOption = null;
    for (int i = 0; i < tools.length; i++) {
        System.err.println("ToolchainValueHandler.isEnumValueAppropriate() Checking tool: " + tools[i].getId());
        if (tools[i].getOptionBySuperClassId(configTypeID) != null) {
            CPUListOption = tools[i].getOptionBySuperClassId(configTypeID);
        }
    }
    if (CPUListOption == null) {
        System.err.println("ToolchainValueHandler.isEnumValueAppropriate() CPUListOption not found");
    }
}
Also used : IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IOption(org.eclipse.cdt.managedbuilder.core.IOption) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) IFolderInfo(org.eclipse.cdt.managedbuilder.core.IFolderInfo) ITool(org.eclipse.cdt.managedbuilder.core.ITool)

Example 12 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmGCCSpecsRunSIProvider method getToolPrefix.

/**
 * @param project       The project to look in for options
 * @return              The prefix for the build tools
 */
private String getToolPrefix(IProject project) {
    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
    if (info == null) {
        return "";
    }
    IConfiguration cfg = info.getDefaultConfiguration();
    // System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found IConfiguration = " + cfg.getName());
    IToolChain toolChain = cfg.getToolChain();
    // System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found toolChain = " + toolChain.getName());
    // Find selected build tool (either ARM or Coldfire)
    IOption buildToolOption = toolChain.getOptionBySuperClassId(UsbdmConstants.ARM_BUILDTOOLS_OPTIONS);
    if (buildToolOption == null) {
        buildToolOption = toolChain.getOptionBySuperClassId(UsbdmConstants.COLDFIRE_BUILDTOOLS_OPTIONS);
    }
    if (buildToolOption == null) {
        return "";
    }
    // Get build path variable
    ToolInformationData toolData = ToolInformationData.getToolInformationTable().get(buildToolOption.getValue().toString());
    if (toolData == null) {
        return "";
    }
    String toolPrefixVariableId = toolData.getPrefixVariableName();
    if (toolPrefixVariableId == null) {
        return "";
    }
    UsbdmSharedSettings settings = UsbdmSharedSettings.getSharedSettings();
    String toolPrefix = null;
    if (settings != null) {
        toolPrefix = settings.get(toolPrefixVariableId);
    }
    if (toolPrefix == null) {
        toolPrefix = "Tool Prefix not set";
        return "";
    }
    // System.err.println("UsbdmGCCSpecsRunSIProvider.initialize() Found tool prefix = " + toolPrefix);
    return toolPrefix;
}
Also used : UsbdmSharedSettings(net.sourceforge.usbdm.constants.UsbdmSharedSettings) IManagedBuildInfo(org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo) ToolInformationData(net.sourceforge.usbdm.constants.ToolInformationData) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IOption(org.eclipse.cdt.managedbuilder.core.IOption) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration)

Example 13 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.

the class ConfigurationEnvironmentVariableSupplier method getToolPath.

/**
 * @param configuration       The configuration to look in for options
 * @return                    The path to the build tools bin directory or null if error
 */
private String getToolPath(IConfiguration configuration) {
    if (configuration == null) {
        // No configuration - Use default settings
        // System.err.println("ConfigEnvVarSupplier.getToolPath() configuration = null");
        String toolPath = "";
        String pathVariableId = null;
        if (buildToolOptionId.equals(UsbdmConstants.COLDFIRE_BUILDTOOLS_OPTIONS)) {
            pathVariableId = "usbdm_codesourcery_coldfire_path";
        } else if (buildToolOptionId.equals(UsbdmConstants.ARM_BUILDTOOLS_OPTIONS)) {
            pathVariableId = "usbdm_armLtd_arm_path";
        }
        UsbdmSharedSettings settings = UsbdmSharedSettings.getSharedSettings();
        if ((settings != null) && (pathVariableId != null)) {
            toolPath = settings.get(pathVariableId);
        }
        // System.err.println("ConfigEnvVarSupplier.getToolPath() Found tool path = " + toolPath);
        return toolPath;
    }
    // System.err.println("ConfigEnvVarSupplier.getToolPath() configuration = "+configuration.getId());
    IToolChain toolChain = configuration.getToolChain();
    if (toolChain == null) {
        System.err.println("ConfigEnvVarSupplier.getToolPath() toolChain = null");
        return null;
    }
    // System.err.println("ConfigEnvVarSupplier.getToolPath() Checking toolchain: " + toolChain.getId());
    // Find selected build tool
    IOption buildToolOption = toolChain.getOptionBySuperClassId(buildToolOptionId);
    // }
    if (buildToolOption == null) {
        System.err.println("ConfigEnvVarSupplier.getToolPath() buildToolOption = null");
        return null;
    }
    // Get build path variable
    ToolInformationData toolData = ToolInformationData.getToolInformationTable().get(buildToolOption.getValue().toString());
    if (toolData == null) {
        System.err.println("ConfigEnvVarSupplier.getToolPath() toolData = null");
        System.err.println("ConfigEnvVarSupplier.getToolPath() configuration              = " + configuration.toString());
        System.err.println("ConfigEnvVarSupplier.getToolPath() toolChain                  = " + toolChain.toString());
        System.err.println("ConfigEnvVarSupplier.getToolPath() buildToolOption            = " + buildToolOption.toString());
        System.err.println("ConfigEnvVarSupplier.getToolPath() buildToolOption.getValue() = " + buildToolOption.getValue().toString());
        return null;
    }
    String pathVariableId = toolData.getPathVariableName();
    if (pathVariableId == null) {
        System.err.println("ConfigEnvVarSupplier.getToolPath() pathVariableId = null");
        return null;
    }
    // System.err.println("ConfigEnvVarSupplier.getToolPath() pathVariableId = "+pathVariableId);
    UsbdmSharedSettings settings = UsbdmSharedSettings.getSharedSettings();
    String toolPath = "";
    if (settings != null) {
        toolPath = settings.get(pathVariableId);
    }
    // }
    return toolPath;
}
Also used : UsbdmSharedSettings(net.sourceforge.usbdm.constants.UsbdmSharedSettings) ToolInformationData(net.sourceforge.usbdm.constants.ToolInformationData) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IOption(org.eclipse.cdt.managedbuilder.core.IOption)

Example 14 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.

the class GccCommandLineGenerator method addFlags.

private String[] addFlags(ITool tool, String[] flags) {
    IToolChain toolChain = getToolChain(tool);
    // Create list of new flags
    ArrayList<String> newFlags = new ArrayList<String>();
    if (toolChain != null) {
        for (String newFlag : optionKeys) {
            // $NON-NLS-1$
            IOption option = toolChain.getOptionBySuperClassId(newFlag);
            if (option == null) {
                // System.err.println("GccCommandLineGenerator.addFlags() - option("+newFlag+"): not found");
                continue;
            }
            try {
                String command = option.getCommand();
                if (command == null) {
                    command = "";
                }
                String value = null;
                if (option.getValueType() == IOption.ENUMERATED) {
                    String enumId = option.getSelectedEnum();
                    value = option.getEnumCommand(enumId);
                } else if (option.getValueType() == IOption.STRING) {
                    value = option.getStringValue();
                } else if (option.getValueType() == IOption.BOOLEAN) {
                    boolean booleanValue = option.getBooleanValue();
                    if (!booleanValue) {
                        command = option.getCommandFalse();
                    }
                    option.getDefaultValue();
                } else {
                    System.err.println("GccCommandLineGenerator.addFlags() - option(" + newFlag + "): Unexpected option type");
                    continue;
                }
                if (value == null) {
                    value = "";
                }
                if ((command.isEmpty()) && (value.isEmpty())) {
                    // System.err.println("GccCommandLineGenerator.addFlags() - option("+newFlag+"): Command && value ==> null/empty");
                    continue;
                }
                String flag = "";
                if (command.contains("{value}")) {
                    flag = command.replace("{value}", value);
                } else {
                    flag = command + value;
                }
                // System.err.println("GccCommandLineGenerator.addFlags() - option("+newFlag+") ==> \'"+flag+"\'");
                newFlags.add(flag);
            } catch (BuildException e) {
                e.printStackTrace();
            }
        }
    }
    // Create combined list of newFlags + flags as array
    if (flags == null) {
        flags = new String[0];
    }
    String[] allFlags = new String[newFlags.size() + flags.length];
    int index = 0;
    StringBuffer allFlagsBuffer = new StringBuffer();
    boolean firstFlag = false;
    for (String flag : newFlags) {
        allFlags[index] = flag;
        if (!firstFlag) {
            allFlagsBuffer.append(" ");
        }
        allFlagsBuffer.append(flag);
        index++;
    }
    for (String flag : flags) {
        allFlags[index++] = flag;
    }
    // String flag = UsbdmSharedSettings.getSharedSettings().get(UsbdmSharedConstants.USBDM_COMPILER_FLAGS_VAR);
    return allFlags;
}
Also used : IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) ArrayList(java.util.ArrayList) IOption(org.eclipse.cdt.managedbuilder.core.IOption) BuildException(org.eclipse.cdt.managedbuilder.core.BuildException)

Example 15 with IToolChain

use of org.eclipse.cdt.managedbuilder.core.IToolChain in project usbdm-eclipse-plugins by podonoghue.

the class PrefixedCommandLineGenerator method getToolPrefix.

/**
 * @param tool       The tool to look in for options
 * @return           The tool prefix e.g.arm-none-eabi-
 */
private String getToolPrefix(ITool tool) {
    if (buildToolOptionId == null) {
        // System.err.println("PrefixedCmdLineGenerator.getToolPrefix() buildToolOptionId null");
        return "";
    }
    IToolChain toolChain = getToolChain(tool);
    if (toolChain == null) {
        // System.err.println("PrefixedCmdLineGenerator.getToolPrefix() Toolchain null");
        return "";
    }
    // System.err.println("PrefixedCmdLineGenerator.getToolPrefix() buildToolOptionId = " +buildToolOptionId);
    // System.err.println("PrefixedCmdLineGenerator.getToolPrefix() Checking toolchain: " + toolChain.getId());
    // Find selected build tool
    IOption buildToolOption = toolChain.getOptionBySuperClassId(buildToolOptionId);
    // }
    if (buildToolOption == null) {
        return "";
    }
    // Get build path variable
    ToolInformationData toolData = ToolInformationData.getToolInformationTable().get(buildToolOption.getValue().toString());
    if (toolData == null) {
        return null;
    }
    String toolPrefixVariableId = toolData.getPrefixVariableName();
    if (toolPrefixVariableId == null) {
        return "";
    }
    UsbdmSharedSettings settings = UsbdmSharedSettings.getSharedSettings();
    String toolPrefix = null;
    if (settings != null) {
        toolPrefix = settings.get(toolPrefixVariableId);
    }
    if (toolPrefix == null) {
        toolPrefix = "Tool Prefix not set";
    }
    // }
    return toolPrefix;
}
Also used : UsbdmSharedSettings(net.sourceforge.usbdm.constants.UsbdmSharedSettings) ToolInformationData(net.sourceforge.usbdm.constants.ToolInformationData) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IOption(org.eclipse.cdt.managedbuilder.core.IOption)

Aggregations

IToolChain (org.eclipse.cdt.managedbuilder.core.IToolChain)15 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)10 IOption (org.eclipse.cdt.managedbuilder.core.IOption)10 ToolInformationData (net.sourceforge.usbdm.constants.ToolInformationData)5 ITool (org.eclipse.cdt.managedbuilder.core.ITool)5 UsbdmSharedSettings (net.sourceforge.usbdm.constants.UsbdmSharedSettings)4 IFolderInfo (org.eclipse.cdt.managedbuilder.core.IFolderInfo)3 IManagedBuildInfo (org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo)3 ArrayList (java.util.ArrayList)2 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)2 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)2 ICProjectDescriptionManager (org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager)2 BuildException (org.eclipse.cdt.managedbuilder.core.BuildException)2 CoreException (org.eclipse.core.runtime.CoreException)2 AbstractSettingsSynchroniser (com.github.sdedwards.m2e_nar.internal.cdt.AbstractSettingsSynchroniser)1 NarBuildArtifact (com.github.sdedwards.m2e_nar.internal.model.NarBuildArtifact)1 NarExecution (com.github.sdedwards.m2e_nar.internal.model.NarExecution)1 ConfigurationDescriptor (io.sloeber.core.api.ConfigurationDescriptor)1 ICProject (org.eclipse.cdt.core.model.ICProject)1 CConfigurationData (org.eclipse.cdt.core.settings.model.extension.CConfigurationData)1