Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2020-01-17 22:00:57 +0000
committerJeff Johnston2020-01-17 22:01:27 +0000
commitcc466a2e49cdaa1b6f418f8f0d4a162a7f3f4145 (patch)
tree0d6a94b72d05e9d956081a92ea75f3526d0e1461 /build/org.eclipse.cdt.meson.ui
parent0d5325df4e163fb0ea92cdf01b23118c033c9693 (diff)
downloadorg.eclipse.cdt-cc466a2e49cdaa1b6f418f8f0d4a162a7f3f4145.tar.gz
org.eclipse.cdt-cc466a2e49cdaa1b6f418f8f0d4a162a7f3f4145.tar.xz
org.eclipse.cdt-cc466a2e49cdaa1b6f418f8f0d4a162a7f3f4145.zip
Bug 548350 - meson projects fail
- add meson 0.50.support - fix MesonPropertyPage to look for meson-info directory if the project is already configured and use the intro-buildoptions.json file to parse the various options and default values etc... - fix description of MesonPropertyCheckbox to only show the first sentence of any description - fix tooltip to show on option name, not just the widget - bump up version of meson ui Change-Id: Id0a528d4ffb000bc63a007037c5e216c956a199c
Diffstat (limited to 'build/org.eclipse.cdt.meson.ui')
-rw-r--r--build/org.eclipse.cdt.meson.ui/META-INF/MANIFEST.MF7
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyArgs.java3
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCheckbox.java11
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCombo.java3
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java161
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertySpecialCheckbox.java4
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyText.java6
7 files changed, 153 insertions, 42 deletions
diff --git a/build/org.eclipse.cdt.meson.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.meson.ui/META-INF/MANIFEST.MF
index e31df844e8e..089e7f90cca 100644
--- a/build/org.eclipse.cdt.meson.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.meson.ui/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.meson.ui;singleton:=true
-Bundle-Version: 1.0.300.qualifier
+Bundle-Version: 1.0.400.qualifier
Bundle-Vendor: %vendorName
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Activator: org.eclipse.cdt.meson.ui.Activator
@@ -19,5 +19,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.13.0",
org.eclipse.core.resources;bundle-version="3.12.0",
org.eclipse.debug.core;bundle-version="3.11.0",
org.eclipse.cdt.launch;bundle-version="9.2.0",
- org.eclipse.debug.ui;bundle-version="3.12.50"
+ org.eclipse.debug.ui;bundle-version="3.12.50",
+ com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider;bundle-version="2.9.9",
+ com.fasterxml.jackson.core.jackson-databind;bundle-version="2.9.93",
+ com.fasterxml.jackson.core.jackson-core;bundle-version="2.9.9"
Automatic-Module-Name: org.eclipse.cdt.meson.ui
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyArgs.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyArgs.java
index 1d90412dee3..cce190ee8c6 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyArgs.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyArgs.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Red Hat Inc. and others.
+ * Copyright (c) 2018, 2020 Red Hat Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -23,7 +23,6 @@ public class MesonPropertyArgs extends MesonPropertyText {
@Override
public String getConfiguredString() {
- // TODO Auto-generated method stub
return "-D" + getFieldName() + "='" + getFieldValue() + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCheckbox.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCheckbox.java
index 1fd22d73650..2b713d683ed 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCheckbox.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCheckbox.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Red Hat Inc. and others.
+ * Copyright (c) 2018, 2020 Red Hat Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -40,7 +40,14 @@ public class MesonPropertyCheckbox implements IMesonPropertyPageControl {
data2.grabExcessHorizontalSpace = true;
data2.horizontalSpan = 1;
Label label = new Label(composite, SWT.NONE);
- label.setText(tooltip);
+ String labelText = tooltip;
+ if (tooltip.length() > 15) {
+ int period = labelText.indexOf("."); //$NON-NLS-1$
+ if (period > 0 && period < tooltip.length() - 1) {
+ labelText = tooltip.substring(0, period + 1);
+ }
+ }
+ label.setText(labelText);
label.setLayoutData(data2);
}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCombo.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCombo.java
index bff5d38fa5e..433eab9da91 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCombo.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyCombo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Red Hat Inc. and others.
+ * Copyright (c) 2018, 2020 Red Hat Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -30,6 +30,7 @@ public class MesonPropertyCombo implements IMesonPropertyPageControl {
this.initialValue = initialValue;
Label label = new Label(composite, SWT.NONE);
label.setText(name);
+ label.setToolTipText(tooltip);
label.setLayoutData(new GridData());
combo = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_BOTH);
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java
index 9007fcd215b..fa999130c5c 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016,2018 IAR Systems AB
+ * Copyright (c) 2016,2020 IAR Systems AB
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -53,6 +53,10 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PropertyPage;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
/**
* Property page for Meson projects. For unconfigured projects, we use the meson command and parse
* the output of the --help option. Otherwise, we use the meson configure command to find current
@@ -89,28 +93,40 @@ public class MesonPropertyPage extends PropertyPage {
configured = buildPath.toFile().exists();
if (configured) {
- ICommandLauncher launcher = CommandLauncherManager.getInstance()
- .getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
- launcher.setProject(project);
- if (launcher instanceof ICBuildCommandLauncher) {
- ((ICBuildCommandLauncher) launcher).setBuildConfiguration(buildConfig);
- }
- Process p = launcher.execute(new Path("meson"), new String[] { "configure", buildDir }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[0], sourceDir, new NullProgressMonitor());
- if (p != null) {
- ByteArrayOutputStream stdout = new ByteArrayOutputStream();
- ByteArrayOutputStream stderr = new ByteArrayOutputStream();
- int rc = -1;
- try {
- if (launcher.waitAndRead(stdout, stderr, new NullProgressMonitor()) == ICommandLauncher.OK) {
- p.waitFor();
- }
- rc = p.exitValue();
- } catch (InterruptedException e) {
- // ignore for now
+ IPath infoPath = new Path(buildDir).append("meson-info"); //$NON-NLS-1$
+ boolean newerMeson = infoPath.toFile().exists();
+ if (newerMeson) {
+ IPath optionsPath = infoPath.append("intro-buildoptions.json"); //$NON-NLS-1$
+ if (optionsPath.toFile().exists()) {
+ componentList = parseInfoOptions(optionsPath, composite);
+ } else {
+ return null;
+ }
+ } else {
+ ICommandLauncher launcher = CommandLauncherManager.getInstance()
+ .getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
+ launcher.setProject(project);
+ if (launcher instanceof ICBuildCommandLauncher) {
+ ((ICBuildCommandLauncher) launcher).setBuildConfiguration(buildConfig);
}
- if (rc == 0) {
- componentList = parseConfigureOutput(stdout, composite);
+ Process p = launcher.execute(new Path("meson"), new String[] { "configure", buildDir }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[0], sourceDir, new NullProgressMonitor());
+ if (p != null) {
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+ ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+ int rc = -1;
+ try {
+ if (launcher.waitAndRead(stdout, stderr,
+ new NullProgressMonitor()) == ICommandLauncher.OK) {
+ p.waitFor();
+ }
+ rc = p.exitValue();
+ } catch (InterruptedException e) {
+ // ignore for now
+ }
+ if (rc == 0) {
+ componentList = parseConfigureOutput(stdout, composite);
+ }
}
}
} else {
@@ -249,7 +265,7 @@ public class MesonPropertyPage extends PropertyPage {
args.add("configure"); //$NON-NLS-1$
for (IMesonPropertyPageControl control : componentList) {
if (control.isValueChanged()) {
- args.add(control.getConfiguredString()); //$NON-NLS-1$ //$NON-NLS-2$
+ args.add(control.getConfiguredString());
}
}
if (args.size() == 2) {
@@ -268,7 +284,7 @@ public class MesonPropertyPage extends PropertyPage {
}
args.add(buildDir);
Process p = launcher.execute(new Path("meson"), args.toArray(new String[0]), new String[0], sourceDir, //$NON-NLS-1$
- new NullProgressMonitor()); //$NON-NLS-2$
+ new NullProgressMonitor());
int rc = -1;
IConsole console = CCorePlugin.getDefault().getConsole();
console.start(project);
@@ -345,12 +361,12 @@ public class MesonPropertyPage extends PropertyPage {
try {
String output = stdout.toString(StandardCharsets.UTF_8.name()).replaceAll("\\r?\\n\\s+", " "); //$NON-NLS-1$ //$NON-NLS-2$
String[] lines = output.split("--"); //$NON-NLS-1$
- Pattern optionPattern = Pattern.compile("(([a-z-]+)\\s+(([A-Z_][A-Z_]+))?\\s*(\\{.*?\\})?([^\\[\\]]*))");
- Pattern descPattern1 = Pattern.compile("([^\\.]+).*");
- Pattern descPattern = Pattern.compile("([^\\(]*)(\\(default\\:\\s+([^\\)]+)\\).*)");
+ Pattern optionPattern = Pattern.compile("(([a-z-]+)\\s+(([A-Z_][A-Z_]+))?\\s*(\\{.*?\\})?([^\\[\\]]*))"); //$NON-NLS-1$
+ Pattern descPattern1 = Pattern.compile("([^\\.]+).*"); //$NON-NLS-1$
+ Pattern descPattern = Pattern.compile("([^\\(]*)(\\(default\\:\\s+([^\\)]+)\\).*)"); //$NON-NLS-1$
for (String line : lines) {
Matcher optionMatcher = optionPattern.matcher(line);
- if (optionMatcher.matches() && !optionMatcher.group(2).equals("help")) {
+ if (optionMatcher.matches() && !optionMatcher.group(2).equals("help")) { //$NON-NLS-1$
if (optionMatcher.group(3) != null) {
String defaultValue = argMap.get(optionMatcher.group(2));
String description = optionMatcher.group(6);
@@ -409,7 +425,7 @@ public class MesonPropertyPage extends PropertyPage {
Pattern optionWithValuesPattern = Pattern.compile(Messages.MesonPropertyPage_option_with_values_pattern);
Pattern optionLine = Pattern.compile("(\\w+)\\s+([\\w,\\-,/]+)\\s+(.*)$"); //$NON-NLS-1$
Pattern optionWithValuesLine = Pattern
- .compile("(\\w+)\\s+([\\w,\\-,/]+)\\s+\\[([\\w,\\-,/]+)((,\\s+[\\w,\\-]+)*)\\]\\s+(.*)$");
+ .compile("(\\w+)\\s+([\\w,\\-,/]+)\\s+\\[([\\w,\\-,/]+)((,\\s+[\\w,\\-]+)*)\\]\\s+(.*)$"); //$NON-NLS-1$
Pattern compilerOrLinkerArgs = Pattern.compile(Messages.MesonPropertyPage_compiler_or_link_args);
Pattern argLine = Pattern.compile("(\\w+)\\s+\\[([^\\]]*)\\]"); //$NON-NLS-1$
Pattern groupPattern = Pattern.compile("(([^:]*)):"); //$NON-NLS-1$
@@ -550,7 +566,7 @@ public class MesonPropertyPage extends PropertyPage {
String description = m4.group(6);
String[] values = new String[] { possibleValue };
if (!extraValues.isEmpty()) {
- values = extraValues.split(",\\s+");
+ values = extraValues.split(",\\s+"); //$NON-NLS-1$
values[0] = possibleValue;
}
IMesonPropertyPageControl control = new MesonPropertyCombo(parent, name, values, value,
@@ -576,4 +592,89 @@ public class MesonPropertyPage extends PropertyPage {
return controls;
}
+ List<IMesonPropertyPageControl> parseInfoOptions(IPath optionsPath, Composite composite) {
+ List<IMesonPropertyPageControl> controls = new ArrayList<>();
+ ObjectMapper mapper = new ObjectMapper();
+ Composite parent = composite;
+ try {
+ JsonNode root = mapper.readTree(optionsPath.toFile());
+ if (!root.isArray()) {
+ return null;
+ }
+ String lastSection = ""; //$NON-NLS-1$
+ for (JsonNode node : root) {
+ IMesonPropertyPageControl control = null;
+ String type = node.path("type").asText(); //$NON-NLS-1$
+ String section = node.path("section").asText(); //$NON-NLS-1$
+ String name = null;
+ String value = null;
+ String description = null;
+ if (!section.equals(lastSection)) {
+ Group group = new Group(composite, SWT.BORDER);
+ group.setLayout(new GridLayout(2, true));
+ group.setLayoutData(new GridData(GridData.FILL_BOTH));
+ String sectionName = section + " options:"; //$NON-NLS-1$
+ sectionName = sectionName.substring(0, 1).toUpperCase() + sectionName.substring(1);
+ group.setText(sectionName);
+ parent = group;
+ lastSection = section;
+ }
+ switch (type) {
+ case "combo": //$NON-NLS-1$
+ name = node.path("name").asText(); //$NON-NLS-1$
+ value = node.path("value").asText(); //$NON-NLS-1$
+ description = node.path("description").asText(); //$NON-NLS-1$
+ JsonNode choices = node.path("choices"); //$NON-NLS-1$
+ ArrayList<String> choiceList = new ArrayList<>();
+ for (JsonNode choiceNode : choices) {
+ String choice = choiceNode.asText();
+ choiceList.add(choice);
+ }
+ control = new MesonPropertyCombo(parent, name, choiceList.toArray(new String[0]), value,
+ description);
+ controls.add(control);
+ break;
+ case "boolean": //$NON-NLS-1$
+ name = node.path("name").asText(); //$NON-NLS-1$
+ value = node.path("value").asText(); //$NON-NLS-1$
+ description = node.path("description").asText(); //$NON-NLS-1$
+ control = new MesonPropertyCheckbox(parent, name, Boolean.getBoolean(value), description);
+ controls.add(control);
+ break;
+ case "string": //$NON-NLS-1$
+ name = node.path("name").asText(); //$NON-NLS-1$
+ value = node.path("value").asText(); //$NON-NLS-1$
+ description = node.path("description").asText(); //$NON-NLS-1$
+ control = new MesonPropertyText(parent, name, value, description);
+ controls.add(control);
+ break;
+ case "array": //$NON-NLS-1$
+ name = node.path("name").asText(); //$NON-NLS-1$
+ value = new String(""); //$NON-NLS-1$
+ for (JsonNode val : node.path("value")) { ////$NON-NLS-1$
+ if (!value.isEmpty()) {
+ value += ","; //$NON-NLS-1$
+ }
+ value += val.asText();
+ }
+ description = node.path("description").asText(); //$NON-NLS-1$
+ control = new MesonPropertyText(parent, name, value, description);
+ controls.add(control);
+ break;
+ case "integer": //$NON-NLS-1$
+ name = node.path("name").asText(); //$NON-NLS-1$
+ value = node.path("value").asText(); //$NON-NLS-1$
+ description = node.path("description").asText(); //$NON-NLS-1$
+ control = new MesonPropertyInteger(parent, this, name, value, description);
+ controls.add(control);
+ break;
+ }
+ }
+ } catch (JsonProcessingException e) {
+ Activator.log(e);
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ return controls;
+ }
} \ No newline at end of file
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertySpecialCheckbox.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertySpecialCheckbox.java
index 1bd5e1c3f27..ef15e16d0c0 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertySpecialCheckbox.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertySpecialCheckbox.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Red Hat Inc. and others.
+ * Copyright (c) 2018, 2020 Red Hat Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,7 +26,7 @@ public class MesonPropertySpecialCheckbox extends MesonPropertyCheckbox {
if (checkbox.getSelection()) {
return "--" + getFieldName(); //$NON-NLS-1$
}
- return "";
+ return ""; //$NON-NLS-1$
}
}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyText.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyText.java
index 951ce10b46e..ac819882650 100644
--- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyText.java
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyText.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Red Hat Inc. and others.
+ * Copyright (c) 2018, 2020 Red Hat Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -33,13 +33,13 @@ public class MesonPropertyText implements IMesonPropertyPageControl {
this.initialValue = initialValue;
Label label = new Label(composite, SWT.NONE);
label.setText(name);
+ label.setToolTipText(tooltip);
label.setLayoutData(new GridData());
text = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.grabExcessHorizontalSpace = true;
text.setLayoutData(data);
text.setText(initialValue);
- text.setToolTipText(tooltip);
}
@Override
@@ -68,7 +68,7 @@ public class MesonPropertyText implements IMesonPropertyPageControl {
if (value != null && !value.isEmpty()) {
return "--" + getFieldName() + "=" + getFieldValue(); //$NON-NLS-1$ //$NON-NLS-2$
}
- return "";
+ return ""; //$NON-NLS-1$
}
@Override

Back to the top