Search in sources :

Example 1 with IResourceConfiguration

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

the class ApplyOptions method setOptionValue.

// public void updateConfigurations(IProgressMonitor monitor) {
// ManagedBuildManager.saveBuildInfo(projectHandle, true);
// IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
// for (IConfiguration config : projectConfigs) {
// ScannerConfigBuilder.build(config, ScannerConfigBuilder.PERFORM_CORE_UPDATE, monitor);
// }
// }
private boolean setOptionValue(String id, String[] value, String path, boolean replace, String targetConfig, IProgressMonitor monitor) throws Exception {
    IConfiguration[] projectConfigs = ManagedBuildManager.getBuildInfo(projectHandle).getManagedProject().getConfigurations();
    // $NON-NLS-1$ //$NON-NLS-2$
    boolean resource = !(path == null || path.equals("") || path.equals("/"));
    boolean modified = false;
    for (IConfiguration config : projectConfigs) {
        if ((targetConfig != null) && !config.getId().contains(targetConfig)) {
            // System.err.println("ApplyOptions() - Skipping config " + config.getId()); //$NON-NLS-1$
            continue;
        }
        IResourceConfiguration resourceConfig = null;
        if (resource) {
            resourceConfig = config.getResourceConfiguration(path);
            if (resourceConfig == null) {
                IFile file = projectHandle.getFile(path);
                if (file == null) {
                    // $NON-NLS-1$
                    throw new Exception("ApplyOptions() file is null for path = " + path);
                }
                resourceConfig = config.createResourceConfiguration(file);
            }
            ITool[] tools = resourceConfig.getTools();
            for (ITool tool : tools) {
                modified |= addToOptionForResourceConfig(id, value, replace, resourceConfig, tool.getOptions(), tool);
            }
        } else {
            IToolChain toolChain = config.getToolChain();
            modified |= addToOptionForConfig(id, value, replace, config, toolChain.getOptions(), toolChain);
            ITool[] tools = config.getTools();
            for (ITool tool : tools) {
                modified |= addToOptionForConfig(id, value, replace, config, tool.getOptions(), tool);
            }
        }
    }
    return modified;
}
Also used : IFile(org.eclipse.core.resources.IFile) IResourceConfiguration(org.eclipse.cdt.managedbuilder.core.IResourceConfiguration) IToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration) ITool(org.eclipse.cdt.managedbuilder.core.ITool) BuildException(org.eclipse.cdt.managedbuilder.core.BuildException) ProcessFailureException(org.eclipse.cdt.core.templateengine.process.ProcessFailureException)

Aggregations

ProcessFailureException (org.eclipse.cdt.core.templateengine.process.ProcessFailureException)1 BuildException (org.eclipse.cdt.managedbuilder.core.BuildException)1 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)1 IResourceConfiguration (org.eclipse.cdt.managedbuilder.core.IResourceConfiguration)1 ITool (org.eclipse.cdt.managedbuilder.core.ITool)1 IToolChain (org.eclipse.cdt.managedbuilder.core.IToolChain)1 IFile (org.eclipse.core.resources.IFile)1