1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Bug 438092 - Advanced Autotools flags not set for C++ projects

- Replace previous fix with better one
- Continue to use the name CFLAGS for the compiler flags but add
  a default value of CFLAGS|CXXFLAGS so that multiple flags will be
  issued on configure
- enhance the FlagConfigureOption to handle multiple flags at once by
  using the value and splitting on the | delimiter to generate separate
  multiple flags if needed
- Change title of Autotools compiler flag options to be
  Compiler Flags instead of CFLAGS (previous) and CFLAGS|CXXFLAGS (new)
- Add transformed name for CFLAGS|CXXFLAGS
- Add tests to verify multiple flags are used


Change-Id: Ic7f8028f07469d04c9de3105f818a5e37e06246a
Reviewed-on: https://git.eclipse.org/r/28943
Tested-by: Hudson CI
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
Tested-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
Jeff Johnston 2014-06-24 19:00:50 -04:00
parent e6b392ffbc
commit 6592f4dc24
7 changed files with 14 additions and 10 deletions

View file

@ -43,7 +43,7 @@ public class AutotoolsOptionConstants {
/**
* @since 1.4
*/
public final static String FLAG_CFLAGS_CXXFLAGS = "CFLAGS|CXXFLAGS"; // $NON-NLS-1$
public final static String FLAG_CFLAGS_FLAGS = "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$

View file

@ -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_CXXFLAGS, IConfigureOption.FLAG),
new Option(AutotoolsOptionConstants.FLAG_CFLAGS, "cflags", AutotoolsOptionConstants.FLAG_CFLAGS_FLAGS, IConfigureOption.FLAG), // $NON-NLS-1$
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$

View file

@ -28,6 +28,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
import org.eclipse.cdt.autotools.core.AutotoolsOptionConstants;
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
import org.eclipse.cdt.autotools.core.IAutotoolsOption;
import org.eclipse.cdt.core.model.CoreModel;
@ -238,7 +239,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
// read in flag values
NamedNodeMap optionAttrs = child.getAttributes();
Node id = optionAttrs.getNamedItem("id"); // $NON-NLS-1$
IConfigureOption opt = cfg.getOption(id.getNodeValue());
String idValue = id.getNodeValue();
IConfigureOption opt = cfg.getOption(idValue);
if (opt instanceof FlagConfigureOption) {
NodeList l2 = child.getChildNodes();
for (int z = 0; z < l2.getLength(); ++z) {
@ -407,7 +409,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
Option option = optionList[j];
IConfigureOption opt = cfg.getOption(option.getName());
if (opt.isFlag()) {
p.println("<flag id=\"" + option.getName() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
p.println("<flag id=\"" + option.getName() + "\" value=\"" + xmlEscape(option.getDefaultValue()) + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FlagConfigureOption fco = (FlagConfigureOption)opt;
ArrayList<String> children = fco.getChildren();
for (int k = 0; k < children.size(); ++k) {

View file

@ -89,6 +89,8 @@ Option.configure.cflags_gcov=Gcov support (-fprofile-arcs -ftest-coverage)
Option.configure.cflags_gcov.tip=Specify this to compile your executable so it will generate gcov coverage data when run
Option.configure.cflags_gcov.parm=-fprofile-arcs -ftest-coverage
Option.configure.cflags=Compiler Flags:
Option.configure.autogen=autogen
Option.configure.options=Options
Option.configure.autogenOpts=Additional command-line options

View file

@ -21,12 +21,12 @@ public class FlagConfigureOption extends AbstractConfigurationOption {
public FlagConfigureOption(String name, AutotoolsConfiguration cfg) {
super(name, cfg);
this.value = ""; // $NON-NLS-1$
this.value = name;
}
public FlagConfigureOption(String name, String msgName, AutotoolsConfiguration cfg) {
super(name, msgName, cfg);
this.value = ""; // $NON-NLS-1$
this.value = name;
}
@SuppressWarnings("unchecked")
@ -40,7 +40,7 @@ public class FlagConfigureOption extends AbstractConfigurationOption {
public String getParameter() {
StringBuffer parms = new StringBuffer();
// Multiple flags are designated by putting multiple flags together using "|" as delimiter
String[] flagNames = getName().split("\\|"); //$NON-NLS-1$
String[] flagNames = getValue().split("\\|"); //$NON-NLS-1$
String flagSeparator = "";
for (String flagName : flagNames) {
parms.append(flagSeparator);
@ -84,7 +84,7 @@ public class FlagConfigureOption extends AbstractConfigurationOption {
}
public void setValue(String value) {
// can't occur
this.value = value;
}
public IConfigureOption copy(AutotoolsConfiguration config) {

View file

@ -201,7 +201,7 @@ public class UpdateConfigureTest extends TestCase {
assertFalse(k.canUpdate());
assertEquals(k.getType(), IAutotoolsOption.CATEGORY);
k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS_CXXFLAGS);
k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS);
assertFalse(k.canUpdate());
assertEquals(k.getType(), IAutotoolsOption.FLAG);

View file

@ -105,7 +105,7 @@ public class AutotoolsCategoryPropertyOptionPage extends
break;
case IConfigureOption.FLAG:
parent = getFieldEditorParent();
FieldEditor l = createLabelEditor(parent, option.getName());
FieldEditor l = createLabelEditor(parent, option.getDescription());
addField(l);
fieldEditors.add(l);
break;