Search in sources :

Example 1 with ProcessFailureException

use of org.eclipse.cdt.core.templateengine.process.ProcessFailureException in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmSetCrossCommand method process.

@Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
    String projectName = null;
    String crossCommandPath = null;
    String crossCommandPrefix = null;
    for (ProcessArgument arg : args) {
        if (arg.getName().equals("projectName")) {
            // Name of project to get handle
            projectName = arg.getSimpleValue();
        } else if (arg.getName().equals("crossCommandPath")) {
            // Cross Command path
            crossCommandPath = arg.getSimpleValue();
        } else if (arg.getName().equals("crossCommandPrefix")) {
            // Cross Command prefix
            crossCommandPrefix = arg.getSimpleValue();
        } else {
            // $NON-NLS-1$
            throw new ProcessFailureException("UsbdmSetCrossCommand.process() - Unexpected argument \'" + arg.getName() + "\'");
        }
    }
    if ((projectName == null) || (crossCommandPath == null) || (crossCommandPrefix == null)) {
        // $NON-NLS-1$
        throw new ProcessFailureException("UsbdmSetCrossCommand.process() - Missing arguments");
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    if (!project.exists()) {
        return;
    }
    IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
    if (buildInfo == null) {
        return;
    }
// IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
// for (IConfiguration config : configs) {
// IToolChain toolchain = config.getToolChain();
// IOption option;
// System.err.println("UsbdmSetCrossCommand.process()");
// option = toolchain.getOptionBySuperClassId(UsbdmConstants.USBDM_GCC_PREFIX_OPTION_KEY); //$NON-NLS-1$
// System.err.println("UsbdmSetCrossCommand.process() UsbdmConstants.USBDM_GCC_PREFIX_OPTION_KEY => "+option);
// ManagedBuildManager.setOption(config, toolchain, option, crossCommandPrefix);
// option = toolchain.getOptionBySuperClassId(UsbdmConstants.USBDM_GCC_PATH_OPTION_KEY); //$NON-NLS-1$
// System.err.println("UsbdmSetCrossCommand.process() UsbdmConstants.USBDM_GCC_PATH_OPTION_KEY => "+option);
// ManagedBuildManager.setOption(config, toolchain, option, crossCommandPath);
// ICfgScannerConfigBuilderInfo2Set cbi = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(config);
// Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = cbi.getInfoMap();
// for (CfgInfoContext cfgInfoContext : map.keySet()) {
// IScannerConfigBuilderInfo2 bi = map.get(cfgInfoContext);
// String providerId = "specsFile"; //$NON-NLS-1$
// String runCommand = bi.getProviderRunCommand(providerId);
// runCommand = crossCommandPrefix + runCommand;
// bi.setProviderRunCommand(providerId, runCommand);
// try {
// bi.save();
// } catch (CoreException e) {
// System.err.println("Exception in SetCrossCommand.process()"+e.toString());
// }
// 
// // Clear the path info that was captured at project creation time
// 
// DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project);
// InfoContext infoContext = cfgInfoContext.toInfoContext();
// 
// // 1. Remove scanner info from .metadata/.plugins/org.eclipse.cdt.make.core/Project.sc
// DiscoveredScannerInfoStore dsiStore = DiscoveredScannerInfoStore.getInstance();
// try {
// dsiStore.saveDiscoveredScannerInfoToState(project, infoContext, pathInfo);
// } catch (CoreException e) {
// e.printStackTrace();
// }
// 
// // 2. Remove scanner info from CfgDiscoveredPathManager cache and from the Tool
// CfgDiscoveredPathManager cdpManager = CfgDiscoveredPathManager.getInstance();
// cdpManager.removeDiscoveredInfo(project, cfgInfoContext);
// 
// // 3. Remove scanner info from SI collector
// IScannerConfigBuilderInfo2 buildInfo2 = map.get(cfgInfoContext);
// if (buildInfo2!=null) {
// ScannerConfigProfileManager scpManager = ScannerConfigProfileManager.getInstance();
// String selectedProfileId = buildInfo2.getSelectedProfileId();
// SCProfileInstance profileInstance = scpManager.getSCProfileInstance(project, infoContext, selectedProfileId);
// 
// IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
// if (collector instanceof IScannerInfoCollectorCleaner) {
// ((IScannerInfoCollectorCleaner) collector).deleteAll(project);
// }
// buildInfo2 = null;
// }
// }
// }
// ManagedBuildManager.saveBuildInfo(project, true);
// 
// for (IConfiguration config : configs) {
// ScannerConfigBuilder.build(config, ScannerConfigBuilder.PERFORM_CORE_UPDATE, new NullProgressMonitor());
// }
}
Also used : IManagedBuildInfo(org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo) ProcessFailureException(org.eclipse.cdt.core.templateengine.process.ProcessFailureException) ProcessArgument(org.eclipse.cdt.core.templateengine.process.ProcessArgument) IProject(org.eclipse.core.resources.IProject)

Example 2 with ProcessFailureException

use of org.eclipse.cdt.core.templateengine.process.ProcessFailureException in project usbdm-eclipse-plugins by podonoghue.

the class ApplyOptions method addToOptionForResourceConfig.

// static void listArray(String values[]) {
// for (String s:values) {
// System.err.println("\'"+s+"\'");
// }
// }
private boolean addToOptionForResourceConfig(String id, String[] value, boolean replace, IResourceConfiguration resourceConfig, IOption[] options, IHoldsOptions optionHolder) throws Exception {
    boolean modified = false;
    String lowerId = id.toLowerCase();
    for (IOption option : options) {
        if (option.getBaseId().toLowerCase().matches(lowerId)) {
            int optionType = option.getBasicValueType();
            if ((optionType == IOption.STRING)) {
                String newValue = "";
                if (!replace) {
                    // Append to existing values
                    newValue = option.getStringValue();
                }
                if (value.length > 0) {
                    newValue = newValue + value[0];
                }
                ManagedBuildManager.setOption(resourceConfig, optionHolder, option, newValue);
                modified = true;
            } else if ((optionType == IOption.ENUMERATED)) {
                ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value[0]);
                modified = true;
            } else if ((optionType == IOption.BOOLEAN)) {
                ManagedBuildManager.setOption(resourceConfig, optionHolder, option, value[0].equals("true"));
                modified = true;
            } else if ((optionType == IOption.STRING_LIST)) {
                String[] oldValues = new String[] {};
                if (!replace) {
                    // Append to existing values
                    oldValues = option.getBasicStringListValue();
                }
                ManagedBuildManager.setOption(resourceConfig, optionHolder, option, appendArrays(oldValues, value));
                modified = true;
            } else {
                // $NON-NLS-1$ //$NON-NLS-2$
                throw new ProcessFailureException("Unexpected option type " + optionType);
            }
        }
    }
    return modified;
}
Also used : IOption(org.eclipse.cdt.managedbuilder.core.IOption) ProcessFailureException(org.eclipse.cdt.core.templateengine.process.ProcessFailureException)

Aggregations

ProcessFailureException (org.eclipse.cdt.core.templateengine.process.ProcessFailureException)2 ProcessArgument (org.eclipse.cdt.core.templateengine.process.ProcessArgument)1 IManagedBuildInfo (org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo)1 IOption (org.eclipse.cdt.managedbuilder.core.IOption)1 IProject (org.eclipse.core.resources.IProject)1