Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2016-05-03 18:24:40 -0400
committerGerrit Code Review @ Eclipse.org2016-05-16 12:02:50 -0400
commit022e9428fd07f17fc19724af8a13cfcf84236dec (patch)
tree6d707635acfbcce296bc5d8b45a44972796b54f2 /build/org.eclipse.cdt.autotools.core/src
parent9fd79b05968022428a26aa0308609cc95e3ad09e (diff)
downloadorg.eclipse.cdt-022e9428fd07f17fc19724af8a13cfcf84236dec.tar.gz
org.eclipse.cdt-022e9428fd07f17fc19724af8a13cfcf84236dec.tar.xz
org.eclipse.cdt-022e9428fd07f17fc19724af8a13cfcf84236dec.zip
Add a Debug configuration for Autotools projects
- set default CFLAGS and CXXFLAGS for debug configuration Autotool projects - pass project when creating a new AutotoolsConfiguration - add new Debug (GNU) configuration - add new build type property to Debug configuration - look for property when initializing AutotoolsConfiguration Change-Id: I95e6fa59f854dad3aff71507a4a85ffa55f4b2bc
Diffstat (limited to 'build/org.eclipse.cdt.autotools.core/src')
-rw-r--r--build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java62
-rw-r--r--build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java14
2 files changed, 67 insertions, 9 deletions
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java
index 9e26fb89a8..a9a71b4368 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java
@@ -18,6 +18,14 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.autotools.core.AutotoolsOptionConstants;
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.managedbuilder.core.IBuildObjectProperties;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
public class AutotoolsConfiguration implements IAConfiguration {
@@ -25,6 +33,7 @@ public class AutotoolsConfiguration implements IAConfiguration {
public static class Option {
private String name;
private String transformedName;
+ private String superClassId;
private int type;
private String defaultValue;
@@ -45,6 +54,14 @@ public class AutotoolsConfiguration implements IAConfiguration {
this.defaultValue = defaultValue;
}
+ public Option(String name, String transformedName, String defaultValue, String superClassId, int type) {
+ this.name = name;
+ this.transformedName = transformedName;
+ this.type = type;
+ this.defaultValue = defaultValue;
+ this.superClassId = superClassId;
+ }
+
public String getName() {
return name;
}
@@ -57,6 +74,10 @@ public class AutotoolsConfiguration implements IAConfiguration {
return defaultValue;
}
+ public String getSuperClassId() {
+ return superClassId;
+ }
+
public String getDescription() {
return ConfigureMessages.getConfigureDescription(transformedName);
}
@@ -121,15 +142,21 @@ public class AutotoolsConfiguration implements IAConfiguration {
private String id;
private boolean isDirty;
private boolean isParmsDirty;
+ private IProject project;
private Map<String, IConfigureOption> configOptions;
private ArrayList<String> configParms = new ArrayList<>();
public AutotoolsConfiguration(String name) {
- this(name, true);
+ this(null, name, true);
+ }
+
+ public AutotoolsConfiguration(IProject project, String name) {
+ this(project, name, true);
}
- private AutotoolsConfiguration(String name, boolean initialize) {
+ private AutotoolsConfiguration(IProject project, String name, boolean initialize) {
this.id = name;
+ this.project = project;
configOptions = new HashMap<>();
if (initialize)
initConfigOptions();
@@ -140,6 +167,16 @@ public class AutotoolsConfiguration implements IAConfiguration {
// Put configure options in hash map. Ignore categories.
ArrayList<Option> tools = new ArrayList<>();
FlagConfigureOption lastFlag = null;
+ IConfiguration configuration = null;
+ IBuildObjectProperties buildProperties = null;
+ if (project != null) {
+ ICConfigurationDescription cfgd = CoreModel.getDefault().getProjectDescription(project)
+ .getConfigurationById(id);
+
+ configuration = ManagedBuildManager.getConfigurationForDescription(cfgd);
+ if (configuration != null)
+ buildProperties = configuration.getBuildProperties();
+ }
for (int i = 0; i < configOpts.length; ++i) {
Option opt = configOpts[i];
String defaultValue = opt.getDefaultValue();
@@ -165,6 +202,23 @@ public class AutotoolsConfiguration implements IAConfiguration {
break;
case IConfigureOption.MULTIARG:
MultiArgConfigureOption m = new MultiArgConfigureOption(opt.name, opt.transformedName, this);
+ if (buildProperties != null) {
+ // Check to see if we have a Debug configuration in which
+ // case, default the compiler flags
+ // appropriately (for C or C/C++).
+ if (opt.name.equals("user")) { //$NON-NLS-1$
+ if (buildProperties.containsValue("org.eclipse.cdt.build.core.buildType", //$NON-NLS-1$
+ "org.eclipse.linuxtools.cdt.autotools.core.buildType.debug")) { //$NON-NLS-1$
+ defaultValue = "CFLAGS='-g -O0'"; //$NON-NLS-1$
+ try {
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID))
+ defaultValue += " CXXFLAGS='-g -O0'"; //$NON-NLS-1$
+ } catch (CoreException e) {
+ // do nothing
+ }
+ }
+ }
+ }
if (defaultValue != null)
m.setValue(defaultValue);
configOptions.put(opt.name, m);
@@ -251,12 +305,12 @@ public class AutotoolsConfiguration implements IAConfiguration {
@Override
public IAConfiguration copy() {
- return copy(id);
+ return copy(this.id);
}
@Override
public IAConfiguration copy(String newId) {
- AutotoolsConfiguration cfg = new AutotoolsConfiguration(newId, false);
+ AutotoolsConfiguration cfg = new AutotoolsConfiguration(project, newId, false);
Collection<IConfigureOption> oldValues = configOptions.values();
for (Iterator<IConfigureOption> i = oldValues.iterator(); i.hasNext();) {
IConfigureOption opt = i.next();
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java
index fc1428746b..c63fce0a56 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java
@@ -100,6 +100,10 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
return new AutotoolsConfiguration(id);
}
+ public synchronized IAConfiguration createDefaultConfiguration(IProject project, String id) {
+ return new AutotoolsConfiguration(project, id);
+ }
+
public synchronized IAConfiguration findCfg(IProject p, String id) {
Map<String, IAConfiguration> cfgs = getConfigurations(p);
return cfgs.get(id);
@@ -112,7 +116,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
public synchronized IAConfiguration getConfiguration(IProject p, String cfgId, boolean persist) {
IAConfiguration cfg = findCfg(p, cfgId);
if (cfg == null) {
- cfg = createDefaultConfiguration(cfgId);
+ cfg = createDefaultConfiguration(p, cfgId);
if (persist) {
addConfiguration(p, cfg);
}
@@ -223,7 +227,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
else
continue; // have to punt, this doesn't map to real cfg
}
- IAConfiguration cfg = new AutotoolsConfiguration(cfgId);
+ IAConfiguration cfg = new AutotoolsConfiguration(project, cfgId);
NodeList l = n.getChildNodes();
for (int y = 0; y < l.getLength(); ++y) {
Node child = l.item(y);
@@ -304,7 +308,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
if (savedList != null)
oldCfg = savedList.get(oldId);
if (oldCfg != null) {
- IAConfiguration newCfg = oldCfg.copy(cfgd.getId());
+ IAConfiguration newCfg = oldCfg.copy(newId);
tmpList.put(cfgd.getId(), newCfg);
// Check to see if the new configuration is already stored as part of the project description.
// If yes, it should already be saved. This can occur if the configuration was added as part of
@@ -394,7 +398,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
String id = cfgd.getId();
IAConfiguration cfg = cfgs.get(id);
if (cfg == null) {
- cfg = createDefaultConfiguration(id);
+ cfg = createDefaultConfiguration(project, id);
}
p.println("<configuration id=\"" + cfg.getId() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
for (int j = 0; j < optionList.length; ++j) {
@@ -626,7 +630,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
// Get set of configuration options and convert to set of IAutotoolOptions
Map<String, IConfigureOption> cfgOptions = cfg.getOptions();
- IAConfiguration dummyCfg = createDefaultConfiguration(createDummyId());
+ IAConfiguration dummyCfg = createDefaultConfiguration(project, createDummyId());
for (Iterator<Entry<String, IConfigureOption>> i = cfgOptions.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, IConfigureOption> entry = i.next();
String name = entry.getKey();

Back to the top