1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 532967 - Meson config properties not being saved/restored properly

- change splitting logic in MesonPropertyPage to split the arg
  string using -- which precedes args and to perform trim()
  operation to remove spaces between
- don't process an empty arg after splitting
- fix the boolean arg logic to use parseBoolean instead of getBoolean
  which is only for system properties

Change-Id: I390911bbf9d7f63f0cf6a13278f3644fe175847b
This commit is contained in:
Jeff Johnston 2018-03-27 15:35:53 -04:00
parent 407352736a
commit 980eb1b25c
2 changed files with 14 additions and 10 deletions

View file

@ -46,7 +46,7 @@ public interface IMesonPropertyPageControl {
/** /**
* Get the command line parameter if never configured * Get the command line parameter if never configured
* @return String containing command-line parm for configured build dir * @return String containing command-line parm for unconfigured build dir
*/ */
default String getUnconfiguredString() { default String getUnconfiguredString() {
return "--" + getFieldName() + "=" + getFieldValue(); //$NON-NLS-1$ //$NON-NLS-2$ return "--" + getFieldName() + "=" + getFieldValue(); //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -134,13 +134,15 @@ public class MesonPropertyPage extends PropertyPage {
Map<String, String> argMap = new HashMap<>(); Map<String, String> argMap = new HashMap<>();
String mesonArgs = buildConfig.getProperty(IMesonConstants.MESON_ARGUMENTS); String mesonArgs = buildConfig.getProperty(IMesonConstants.MESON_ARGUMENTS);
if (mesonArgs != null) { if (mesonArgs != null) {
String[] argStrings = mesonArgs.split("\\s+"); //$NON-NLS-1$ String[] argStrings = mesonArgs.split("--"); //$NON-NLS-1$
for (String argString : argStrings) { for (String argString : argStrings) {
String[] s = argString.split("="); //$NON-NLS-1$ if (!argString.isEmpty()) {
if (s.length == 2) { String[] s = argString.split("="); //$NON-NLS-1$
argMap.put(s[0], s[1]); if (s.length == 2) {
} else { argMap.put(s[0], s[1].trim());
argMap.put(argString, "true"); //$NON-NLS-1$ } else {
argMap.put(argString.trim(), "true"); //$NON-NLS-1$
}
} }
} }
} }
@ -306,8 +308,10 @@ public class MesonPropertyPage extends PropertyPage {
} else { } else {
StringBuilder mesonargs = new StringBuilder(); StringBuilder mesonargs = new StringBuilder();
for (IMesonPropertyPageControl control : componentList) { for (IMesonPropertyPageControl control : componentList) {
mesonargs.append(control.getUnconfiguredString()); if (!control.getUnconfiguredString().isEmpty()) {
mesonargs.append(" "); //$NON-NLS-1$ mesonargs.append(control.getUnconfiguredString());
mesonargs.append(" "); //$NON-NLS-1$
}
} }
buildConfig.setProperty(IMesonConstants.MESON_ARGUMENTS, mesonargs.toString()); buildConfig.setProperty(IMesonConstants.MESON_ARGUMENTS, mesonargs.toString());
buildConfig.setProperty(IMesonConstants.MESON_ENV, envText.getText().trim()); buildConfig.setProperty(IMesonConstants.MESON_ENV, envText.getText().trim());
@ -366,7 +370,7 @@ public class MesonPropertyPage extends PropertyPage {
} else { } else {
boolean defaultValue = false; boolean defaultValue = false;
if (argMap.containsKey(optionMatcher.group(2))) { if (argMap.containsKey(optionMatcher.group(2))) {
defaultValue = Boolean.getBoolean(argMap.get(optionMatcher.group(2))); defaultValue = Boolean.parseBoolean(argMap.get(optionMatcher.group(2)));
} }
IMesonPropertyPageControl control = new MesonPropertySpecialCheckbox(group, optionMatcher.group(2), defaultValue, optionMatcher.group(6)); IMesonPropertyPageControl control = new MesonPropertySpecialCheckbox(group, optionMatcher.group(2), defaultValue, optionMatcher.group(6));
controls.add(control); controls.add(control);