mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
New interfaces to allow reading and updating of Autotool configuration
options for a given build configuration. Change-Id: I54d866abb4251fe7e5f7df47493b280b5ac2cd33 Reviewed-on: https://git.eclipse.org/r/6942 Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> IP-Clean: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
parent
eee6cbd94d
commit
c00c0bb52a
6 changed files with 244 additions and 24 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2012-07-20 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/autotools/core/AutotoolsPlugin.java (getAutotoolCfgOptions): New publicly accessible
|
||||||
|
method for retrieving Autotool configuration options for a given build configuration.
|
||||||
|
(updateAutotoolCfgOptions): New publicly accessible method for updating Autotool configuration options for
|
||||||
|
a given build configuration.
|
||||||
|
* src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureMessages.properties: Add new messages for
|
||||||
|
errors caused by user reading and updating configuration options.
|
||||||
|
* src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java: Add synchronization to
|
||||||
|
all public methods.
|
||||||
|
(updateAutotoolCfgOptions): New method to allow external users to update configuration options.
|
||||||
|
(getAutotoolsCfgOptions): New method to get configuration options for a given configuration id.
|
||||||
|
|
||||||
2012-04-20 Jeff Johnston <jjohnstn@redhat.com>
|
2012-04-20 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
* META-INF/MANIFEST.MF: Bump up version to 1.1.0.
|
* META-INF/MANIFEST.MF: Bump up version to 1.1.0.
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %Bundle-Name.0
|
Bundle-Name: %Bundle-Name.0
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.autotools.core;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.autotools.core;singleton:=true
|
||||||
Bundle-Version: 1.1.0.qualifier
|
Bundle-Version: 1.2.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.autotools.core.AutotoolsPlugin
|
Bundle-Activator: org.eclipse.cdt.autotools.core.AutotoolsPlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.ui;bundle-version="3.4.0",
|
Require-Bundle: org.eclipse.ui;bundle-version="3.4.0",
|
||||||
|
|
|
@ -12,9 +12,11 @@ package org.eclipse.cdt.autotools.core;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
@ -290,4 +292,34 @@ public class AutotoolsPlugin extends AbstractUIPlugin {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return set of Autotool configuration options for a given build configuration id.
|
||||||
|
*
|
||||||
|
* @param project existing autotools project
|
||||||
|
* @param cfgId configuration id
|
||||||
|
* @return a copy of Autotools configurations for the given configuration id
|
||||||
|
* @throws CoreException if project is not valid Autotools project or cfgId does not exist
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
public Map<String, IAutotoolsOption> getAutotoolCfgOptions(IProject project,
|
||||||
|
String cfgId) throws CoreException {
|
||||||
|
return AutotoolsConfigurationManager.getInstance().getAutotoolsCfgOptions(project, cfgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Autotool configuration options for a specified build configuration
|
||||||
|
*
|
||||||
|
* @param project existing autotools project
|
||||||
|
* @param cfgId configuation id
|
||||||
|
* @param options set of updated Autotool configuration options
|
||||||
|
* @throws CoreException if project is not valid Autotools project or cfgId does not exist
|
||||||
|
*
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
public void updateAutotoolCfgOptions(IProject project, String cfgId,
|
||||||
|
Map<String,IAutotoolsOption> options) throws CoreException {
|
||||||
|
AutotoolsConfigurationManager.getInstance().updateAutotoolCfgOptions(project, cfgId, options);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.eclipse.cdt.autotools.core;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
public interface IAutotoolsOption {
|
||||||
|
public final static int CATEGORY = 0;
|
||||||
|
public final static int BIN = 1;
|
||||||
|
public final static int STRING = 2;
|
||||||
|
public final static int INTERNAL = 3;
|
||||||
|
public final static int MULTIARG = 4;
|
||||||
|
public final static int TOOL = 5;
|
||||||
|
public final static int FLAG = 6;
|
||||||
|
public final static int FLAGVALUE = 7;
|
||||||
|
public int getType();
|
||||||
|
public boolean canUpdate();
|
||||||
|
public void setValue(String value) throws CoreException;
|
||||||
|
public String getValue();
|
||||||
|
}
|
|
@ -20,12 +20,16 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
|
||||||
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
|
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
|
||||||
|
import org.eclipse.cdt.autotools.core.IAutotoolsOption;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
|
@ -45,7 +49,10 @@ import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
|
@ -58,8 +65,18 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
public final static String CFG_FILE_NAME = ".autotools"; //$NON-NLS-1$
|
public final static String CFG_FILE_NAME = ".autotools"; //$NON-NLS-1$
|
||||||
private final static String CFG_CANT_SAVE = "Configure.Error.NoProjectToSave"; //$NON-NLS-1$
|
private final static String CFG_CANT_SAVE = "Configure.Error.NoProjectToSave"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
public static final String INVALID_AUTOTOOLS_PROJECT = "CfgOptions.Invalid.Project"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final String INVALID_AUTOTOOLS_CONFIG_ID = "CfgOptions.Invalid.Config"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static AutotoolsConfigurationManager instance;
|
private static AutotoolsConfigurationManager instance;
|
||||||
|
private static Random rand = new Random();
|
||||||
|
|
||||||
private boolean isSyncing;
|
private boolean isSyncing;
|
||||||
|
|
||||||
|
@ -79,21 +96,21 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAConfiguration createDefaultConfiguration(IProject project, String id) {
|
public synchronized IAConfiguration createDefaultConfiguration(IProject project, String id) {
|
||||||
IAConfiguration cfg = new AutotoolsConfiguration(id);
|
IAConfiguration cfg = new AutotoolsConfiguration(id);
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAConfiguration findCfg(IProject p, String id) {
|
public synchronized IAConfiguration findCfg(IProject p, String id) {
|
||||||
Map<String, IAConfiguration> cfgs = getConfigurations(p);
|
Map<String, IAConfiguration> cfgs = getConfigurations(p);
|
||||||
return cfgs.get(id);
|
return cfgs.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAConfiguration getConfiguration(IProject p, String cfgId) {
|
public synchronized IAConfiguration getConfiguration(IProject p, String cfgId) {
|
||||||
return getConfiguration(p, cfgId, true);
|
return getConfiguration(p, cfgId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAConfiguration getConfiguration(IProject p, String cfgId, boolean persist) {
|
public synchronized IAConfiguration getConfiguration(IProject p, String cfgId, boolean persist) {
|
||||||
IAConfiguration cfg = findCfg(p, cfgId);
|
IAConfiguration cfg = findCfg(p, cfgId);
|
||||||
if (cfg == null) {
|
if (cfg == null) {
|
||||||
cfg = createDefaultConfiguration(p, cfgId);
|
cfg = createDefaultConfiguration(p, cfgId);
|
||||||
|
@ -109,14 +126,14 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isConfigurationAlreadySaved(IProject project, ICConfigurationDescription cfgd) {
|
public synchronized boolean isConfigurationAlreadySaved(IProject project, ICConfigurationDescription cfgd) {
|
||||||
Map<String, IAConfiguration> cfgs = getSavedConfigs(project);
|
Map<String, IAConfiguration> cfgs = getSavedConfigs(project);
|
||||||
if (cfgs != null)
|
if (cfgs != null)
|
||||||
return cfgs.get(cfgd.getId()) != null;
|
return cfgs.get(cfgd.getId()) != null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConfiguration(IProject project, IAConfiguration cfg) {
|
public synchronized void addConfiguration(IProject project, IAConfiguration cfg) {
|
||||||
String projectName = project.getName();
|
String projectName = project.getName();
|
||||||
Map<String, IAConfiguration> cfgs = getSavedConfigs(project);
|
Map<String, IAConfiguration> cfgs = getSavedConfigs(project);
|
||||||
if (cfgs == null) {
|
if (cfgs == null) {
|
||||||
|
@ -127,11 +144,11 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
saveConfigs(project);
|
saveConfigs(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSyncing() {
|
public synchronized boolean isSyncing() {
|
||||||
return isSyncing;
|
return isSyncing;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSyncing(boolean value) {
|
private synchronized void setSyncing(boolean value) {
|
||||||
isSyncing = value;
|
isSyncing = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +161,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
* @param project to synchronize configurations for
|
* @param project to synchronize configurations for
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void syncConfigurations(IProject project) {
|
public synchronized void syncConfigurations(IProject project) {
|
||||||
setSyncing(true);
|
setSyncing(true);
|
||||||
clearTmpConfigurations(project);
|
clearTmpConfigurations(project);
|
||||||
ICProjectDescription pd = CoreModel.getDefault().getProjectDescription(project);
|
ICProjectDescription pd = CoreModel.getDefault().getProjectDescription(project);
|
||||||
|
@ -160,13 +177,13 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
replaceProjectConfigurations(project, newCfgList);
|
replaceProjectConfigurations(project, newCfgList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs) {
|
public synchronized void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs) {
|
||||||
String projectName = project.getName();
|
String projectName = project.getName();
|
||||||
configs.put(projectName, cfgs);
|
configs.put(projectName, cfgs);
|
||||||
saveConfigs(project);
|
saveConfigs(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs, ICConfigurationDescription[] cfgds) {
|
public synchronized void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs, ICConfigurationDescription[] cfgds) {
|
||||||
String projectName = project.getName();
|
String projectName = project.getName();
|
||||||
configs.put(projectName, cfgs);
|
configs.put(projectName, cfgs);
|
||||||
saveConfigs(project, cfgds);
|
saveConfigs(project, cfgds);
|
||||||
|
@ -258,7 +275,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAConfiguration getTmpConfiguration(IProject p, ICConfigurationDescription cfgd) {
|
public synchronized IAConfiguration getTmpConfiguration(IProject p, ICConfigurationDescription cfgd) {
|
||||||
Map <String, IAConfiguration> list = getTmpConfigs(p);
|
Map <String, IAConfiguration> list = getTmpConfigs(p);
|
||||||
IAConfiguration acfg = list.get(cfgd.getId());
|
IAConfiguration acfg = list.get(cfgd.getId());
|
||||||
if (acfg != null) {
|
if (acfg != null) {
|
||||||
|
@ -278,7 +295,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
* @param cfgd the configuration descriptor for the clone
|
* @param cfgd the configuration descriptor for the clone
|
||||||
* @return true if the configuration is already saved, false otherwise
|
* @return true if the configuration is already saved, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean cloneCfg(IProject p, String oldId, ICConfigurationDescription cfgd) {
|
public synchronized boolean cloneCfg(IProject p, String oldId, ICConfigurationDescription cfgd) {
|
||||||
if (isConfigurationAlreadySaved(p, cfgd))
|
if (isConfigurationAlreadySaved(p, cfgd))
|
||||||
return true;
|
return true;
|
||||||
Map <String, IAConfiguration> tmpList = getTmpConfigs(p);
|
Map <String, IAConfiguration> tmpList = getTmpConfigs(p);
|
||||||
|
@ -316,14 +333,16 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
return tmpList;
|
return tmpList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearTmpConfigurations(IProject p) {
|
public synchronized void clearTmpConfigurations(IProject p) {
|
||||||
tmpConfigs.remove(p.getName());
|
tmpConfigs.remove(p.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveConfigs(IProject project) {
|
public synchronized void saveConfigs(IProject project) {
|
||||||
|
synchronized (project) {
|
||||||
ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(project).getConfigurations();
|
ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(project).getConfigurations();
|
||||||
saveConfigs(project, cfgds);
|
saveConfigs(project, cfgds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void syncNameField(ICConfigurationDescription cfgd) {
|
private void syncNameField(ICConfigurationDescription cfgd) {
|
||||||
IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd);
|
IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd);
|
||||||
|
@ -417,7 +436,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
// with any changes currently that have been made to them. If a configuration has been renamed, but this
|
// with any changes currently that have been made to them. If a configuration has been renamed, but this
|
||||||
// has not yet been confirmed by the end-user, then only the changes to the configuration are made. The
|
// has not yet been confirmed by the end-user, then only the changes to the configuration are made. The
|
||||||
// name currently remains the same in the output file.
|
// name currently remains the same in the output file.
|
||||||
public void applyConfigs(String projectName, ICConfigurationDescription[] cfgds) {
|
public synchronized void applyConfigs(String projectName, ICConfigurationDescription[] cfgds) {
|
||||||
try {
|
try {
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IResource res = (IProject)root.findMember(projectName, false);
|
IResource res = (IProject)root.findMember(projectName, false);
|
||||||
|
@ -489,7 +508,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, IAConfiguration> getConfigurations(IProject project) {
|
public synchronized Map<String, IAConfiguration> getConfigurations(IProject project) {
|
||||||
Map<String, IAConfiguration> list = getSavedConfigs(project);
|
Map<String, IAConfiguration> list = getSavedConfigs(project);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new HashMap<String, IAConfiguration>();
|
list = new HashMap<String, IAConfiguration>();
|
||||||
|
@ -498,7 +517,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resourceChanged(IResourceChangeEvent event) {
|
public synchronized void resourceChanged(IResourceChangeEvent event) {
|
||||||
IResource res = event.getResource();
|
IResource res = event.getResource();
|
||||||
if (!(res instanceof IProject))
|
if (!(res instanceof IProject))
|
||||||
return;
|
return;
|
||||||
|
@ -527,4 +546,134 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class AutotoolsOption implements IAutotoolsOption {
|
||||||
|
|
||||||
|
private IConfigureOption option;
|
||||||
|
private final static String UNMODIFIABLE_CONFIG_OPTION = "CfgOptions.Unmodifiable.Option"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
|
public AutotoolsOption(IConfigureOption option) {
|
||||||
|
this.option = option;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return option.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUpdate() {
|
||||||
|
int type = getType();
|
||||||
|
switch (type) {
|
||||||
|
case STRING:
|
||||||
|
case BIN:
|
||||||
|
case TOOL:
|
||||||
|
case FLAGVALUE:
|
||||||
|
case MULTIARG:
|
||||||
|
case INTERNAL:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(String value) throws CoreException {
|
||||||
|
if (!canUpdate()) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID,
|
||||||
|
ConfigureMessages.getString(UNMODIFIABLE_CONFIG_OPTION)));
|
||||||
|
}
|
||||||
|
synchronized (option) {
|
||||||
|
option.setValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
synchronized (option) {
|
||||||
|
return option.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createDummyId() {
|
||||||
|
for (;;) {
|
||||||
|
String id = "TEMP_" + rand.nextInt();
|
||||||
|
if (tmpConfigs.get(id) == null)
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
public synchronized Map<String, IAutotoolsOption> getAutotoolsCfgOptions(IProject project,
|
||||||
|
String cfgId) throws CoreException {
|
||||||
|
|
||||||
|
// Verify project is valid Autotools project
|
||||||
|
if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID,
|
||||||
|
ConfigureMessages.getString(INVALID_AUTOTOOLS_PROJECT)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify configuration id is valid
|
||||||
|
ICConfigurationDescription cfgd =
|
||||||
|
CoreModel.getDefault().getProjectDescription(project).getConfigurationById(cfgId);
|
||||||
|
IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd);
|
||||||
|
if (icfg == null) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID,
|
||||||
|
ConfigureMessages.getString(INVALID_AUTOTOOLS_CONFIG_ID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
IAConfiguration cfg = getConfiguration(project, cfgId);
|
||||||
|
HashMap<String, IAutotoolsOption> options = new HashMap<String, IAutotoolsOption>();
|
||||||
|
|
||||||
|
// Get set of configuration options and convert to set of IAutotoolOptions
|
||||||
|
Map<String, IConfigureOption> cfgOptions = cfg.getOptions();
|
||||||
|
IAConfiguration dummyCfg = createDefaultConfiguration(project, createDummyId());
|
||||||
|
for (Iterator<Entry<String, IConfigureOption>> i = cfgOptions.entrySet().iterator(); i.hasNext();) {
|
||||||
|
Map.Entry<String, IConfigureOption> entry = (Entry<String, IConfigureOption>) i.next();
|
||||||
|
String name = entry.getKey();
|
||||||
|
IAutotoolsOption configOption =
|
||||||
|
new AutotoolsOption(entry.getValue().copy((AutotoolsConfiguration)dummyCfg));
|
||||||
|
options.put(name, configOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
public synchronized void updateAutotoolCfgOptions(IProject project, String cfgId,
|
||||||
|
Map<String,IAutotoolsOption> options) throws CoreException {
|
||||||
|
|
||||||
|
// Verify project is valid Autotools project
|
||||||
|
if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID,
|
||||||
|
ConfigureMessages.getString(INVALID_AUTOTOOLS_PROJECT)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify configuration id is valid
|
||||||
|
IAConfiguration cfg = findCfg(project, cfgId);
|
||||||
|
if (cfg == null) {
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID,
|
||||||
|
ConfigureMessages.getString(INVALID_AUTOTOOLS_CONFIG_ID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get set of configuration options and convert to set of IAutotoolOptions
|
||||||
|
for (Iterator<Entry<String, IAutotoolsOption>> i = options.entrySet().iterator(); i.hasNext();) {
|
||||||
|
Map.Entry<String, IAutotoolsOption> entry = (Entry<String, IAutotoolsOption>) i.next();
|
||||||
|
String name = entry.getKey();
|
||||||
|
IAutotoolsOption option = entry.getValue();
|
||||||
|
IConfigureOption cfgOption = cfg.getOption(name);
|
||||||
|
if (cfgOption != null) {
|
||||||
|
cfgOption.setValue(option.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save changes
|
||||||
|
saveConfigs(project);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,3 +99,7 @@ Tool.allopts=All Options
|
||||||
|
|
||||||
Configure.Error.AlreadyExists="A configuration named {0} already exists"
|
Configure.Error.AlreadyExists="A configuration named {0} already exists"
|
||||||
Configure.Error.NoProjectToSave="Project: {0} does not exist at time of saving configuration"
|
Configure.Error.NoProjectToSave="Project: {0} does not exist at time of saving configuration"
|
||||||
|
|
||||||
|
CfgOptions.Invalid.Project=Specified project is not a valid existing Autotools project
|
||||||
|
CfgOptions.Invalid.Config=Specified configuration id does not correspond to an existing configuration
|
||||||
|
CfgOptions.Unmodifiable.Option=Attempting to modify an unmodifiable Autotools configure option
|
||||||
|
|
Loading…
Add table
Reference in a new issue