diff --git a/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF
index 07d2c86d0c2..e51da72da27 100644
--- a/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.eclipse.cdt.autotools.core;singleton:=true
-Bundle-Version: 1.3.0.qualifier
+Bundle-Version: 1.4.0.qualifier
Bundle-Activator: org.eclipse.cdt.autotools.core.AutotoolsPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="3.4.0",
diff --git a/build/org.eclipse.cdt.autotools.core/pom.xml b/build/org.eclipse.cdt.autotools.core/pom.xml
index d0c0ac6aabc..c1fe044c389 100644
--- a/build/org.eclipse.cdt.autotools.core/pom.xml
+++ b/build/org.eclipse.cdt.autotools.core/pom.xml
@@ -11,7 +11,7 @@
../../pom.xml
- 1.3.0-SNAPSHOT
+ 1.4.0-SNAPSHOT
org.eclipse.cdt.autotools.core
eclipse-plugin
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsOptionConstants.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsOptionConstants.java
index 43658956a40..46c102d853a 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsOptionConstants.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsOptionConstants.java
@@ -40,6 +40,10 @@ public class AutotoolsOptionConstants {
public final static String CATEGORY_FEATURES = "features"; // $NON-NLS-1$
public final static String OPT_ENABLE_MAINTAINER_MODE = "enable-maintainer-mode"; // $NON-NLS-1$
public final static String FLAG_CFLAGS = "CFLAGS"; // $NON-NLS-1$
+ /**
+ * @since 1.4
+ */
+ public final static String FLAG_CFLAGS_CXXFLAGS = "CFLAGS|CXXFLAGS"; // $NON-NLS-1$
public final static String OPT_CFLAGS_DEBUG = "cflags-debug"; // $NON-NLS-1$
public final static String OPT_CFLAGS_GPROF = "cflags-gprof"; // $NON-NLS-1$
public final static String OPT_CFLAGS_GCOV = "cflags-gcov"; // $NON-NLS-1$
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 40dfb2f30f7..93727fdd61a 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
@@ -103,7 +103,7 @@ public class AutotoolsConfiguration implements IAConfiguration {
new Option(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME, "program_transform_name", IConfigureOption.STRING), // $NON-NLS-1$
new Option(AutotoolsOptionConstants.CATEGORY_FEATURES, IConfigureOption.CATEGORY),
new Option(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE, "enable_maintainer_mode", IConfigureOption.BIN), // $NON-NLS-1$
- new Option(AutotoolsOptionConstants.FLAG_CFLAGS, IConfigureOption.FLAG),
+ new Option(AutotoolsOptionConstants.FLAG_CFLAGS_CXXFLAGS, IConfigureOption.FLAG),
new Option(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG, "cflags_debug", IConfigureOption.FLAGVALUE), // $NON-NLS-1$ // $NON-NLS-2$
new Option(AutotoolsOptionConstants.OPT_CFLAGS_GPROF, "cflags_gprof", IConfigureOption.FLAGVALUE), // $NON-NLS-1$ // $NON-NLS-2$
new Option(AutotoolsOptionConstants.OPT_CFLAGS_GCOV, "cflags_gcov", IConfigureOption.FLAGVALUE), // $NON-NLS-1$ // $NON-NLS-2$
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java
index 8f5080b265f..b886ad336e0 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat Inc.
+ * Copyright (c) 2011, 2014 Red Hat Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Red Hat Inc. - initial API and implementation
+ * Red Hat Inc. - add support for specifying multiple flag names at once
*******************************************************************************/
package org.eclipse.cdt.internal.autotools.core.configure;
@@ -37,27 +38,35 @@ public class FlagConfigureOption extends AbstractConfigurationOption {
}
public String getParameter() {
- StringBuffer parm = new StringBuffer(getName()+"=\""); //$NON-NLS-1$
- boolean haveParm = false;
- if (isParmSet()) {
- String separator = "";
- for (int i = 0; i < children.size(); ++i) {
- String fvname = children.get(i);
- IConfigureOption o = cfg.getOption(fvname);
- if (o.isParmSet()) {
- if (o instanceof IFlagConfigureValueOption) {
- parm.append(separator + ((IFlagConfigureValueOption)o).getFlags()); //$NON-NLS-1$
- separator = " ";
- haveParm = true;
+ StringBuffer parms = new StringBuffer();
+ // Multiple flags are designated by putting multiple flags together using "|" as delimiter
+ String[] flagNames = getName().split("\\|"); //$NON-NLS-1$
+ String flagSeparator = "";
+ for (String flagName : flagNames) {
+ parms.append(flagSeparator);
+ flagSeparator = " "; //$NON-NLS-1$
+ StringBuffer parm = new StringBuffer(flagName+"=\""); //$NON-NLS-1$
+ boolean haveParm = false;
+ if (isParmSet()) {
+ String separator = "";
+ for (int i = 0; i < children.size(); ++i) {
+ String fvname = children.get(i);
+ IConfigureOption o = cfg.getOption(fvname);
+ if (o.isParmSet()) {
+ if (o instanceof IFlagConfigureValueOption) {
+ parm.append(separator + ((IFlagConfigureValueOption)o).getFlags()); //$NON-NLS-1$
+ separator = " ";
+ haveParm = true;
+ }
}
}
- }
- if (haveParm) {
- parm.append("\""); //$NON-NLS-1$
- return parm.toString();
+ if (haveParm) {
+ parm.append("\""); //$NON-NLS-1$
+ parms.append(parm);
+ }
}
}
- return ""; //$NON-NLS-1$
+ return parms.toString();
}
public String getParameterName() {
diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java
index 9e3fa4aad41..6e62368bbe4 100644
--- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java
+++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java
@@ -12,8 +12,8 @@
package org.eclipse.cdt.autotools.tests;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
@@ -62,6 +62,101 @@ public class UpdateConfigureTest extends TestCase {
testProject.open(new NullProgressMonitor());
}
+ /**
+ * Test setting the special advanced options for gcov, gprof, and debug flags. Verify that
+ * the configure script sets both the C and C++ flags.
+ * @throws Exception
+ */
+ public void testGprofGcovDebugFlagOptions() throws Exception {
+ Path p = new Path("zip/project2.zip");
+ ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
+ assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
+ ProjectTools.setConfigDir(testProject, "src");
+ ProjectTools.markExecutable(testProject, "src/autogen.sh");
+ assertTrue(ProjectTools.build());
+ ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject).getActiveConfiguration();
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+ assertTrue(cfg.getName().equals("Build (GNU)"));
+ Map opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
+
+ IAutotoolsOption k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
+ k.setValue("true");
+
+ // Now update the options we changed
+ AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts);
+
+ // Rebuild project
+ assertTrue(ProjectTools.build());
+
+ org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("config.log");
+ assertTrue(testProject.exists(x));
+
+ IResource r = testProject.findMember(x);
+
+ File f = r.getLocation().toFile();
+
+ FileReader fr = new FileReader(f);
+
+ char[] cbuf = new char[2000];
+ fr.read(cbuf);
+
+ String s = new String(cbuf);
+
+ assertTrue(s.contains("testProject2/src/configure CFLAGS=-pg CXXFLAGS=-pg"));
+
+ fr.close();
+
+ // Reset gprof opt and set gcov opt
+ opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
+ k.setValue("false");
+
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV);
+ k.setValue("true");
+
+ // Now update the options we changed
+ AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts);
+
+ // Rebuild project
+ assertTrue(ProjectTools.build());
+
+ r = testProject.findMember(x);
+ f = r.getLocation().toFile();
+ fr = new FileReader(f);
+ fr.read(cbuf);
+
+ s = new String(cbuf);
+
+ assertTrue(s.contains("testProject2/src/configure CFLAGS=-fprofile-arcs -ftest-coverage CXXFLAGS=-fprofile-arcs -ftest-coverage"));
+
+ fr.close();
+
+ // Reset gcov opt and set debug opt
+ opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV);
+ k.setValue("false");
+
+ k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG);
+ k.setValue("true");
+
+ // Now update the options we changed
+ AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts);
+
+ // Rebuild project
+ assertTrue(ProjectTools.build());
+
+ r = testProject.findMember(x);
+ f = r.getLocation().toFile();
+ fr = new FileReader(f);
+ fr.read(cbuf);
+
+ s = new String(cbuf);
+
+ assertTrue(s.contains("testProject2/src/configure CFLAGS=-g CXXFLAGS=-g"));
+
+ fr.close();
+ }
+
/**
* Test getting and updating configuration options for an Autotools Project. The top-level
* contains autogen.sh which will build configure, but not run it.
@@ -106,7 +201,7 @@ public class UpdateConfigureTest extends TestCase {
assertFalse(k.canUpdate());
assertEquals(k.getType(), IAutotoolsOption.CATEGORY);
- k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS);
+ k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS_CXXFLAGS);
assertFalse(k.canUpdate());
assertEquals(k.getType(), IAutotoolsOption.FLAG);