Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2018-02-08 19:58:26 +0000
committerJeff Johnston2018-02-08 20:03:09 +0000
commitba7f4f26eb8f799d45e40cf84fa68b7857f6df3f (patch)
tree14ba65795fdc36c1bb9e0b86fbffcde6034c42ad /build/org.eclipse.cdt.meson.ui
parentdb1cd491d62bf7bfa18eaa82a03f5844c20084af (diff)
downloadorg.eclipse.cdt-ba7f4f26eb8f799d45e40cf84fa68b7857f6df3f.tar.gz
org.eclipse.cdt-ba7f4f26eb8f799d45e40cf84fa68b7857f6df3f.tar.xz
org.eclipse.cdt-ba7f4f26eb8f799d45e40cf84fa68b7857f6df3f.zip
Add Run ninja command context menu item for Meson projects
- add new RunNinjaCommandHandler, RunNinja, AbstractMesonCommandHandler, and RunNinjaPage classes to support running ninja manually with env variables added and options specified - add a new build method to MesonBuildConfiguration which specifies ninja options and environment variables - add SWTImagesFactory for supplying the meson logo image - add WizardMessages class for specifying messages for meson ui wizards - add new MesonUtils class and move stripEnvVars from MesonBuildConfiguration to here - add new constants to IMesonConstants interface Change-Id: I8d635b2bd96792800bb07f4b3f1730be6e41eb24
Diffstat (limited to 'build/org.eclipse.cdt.meson.ui')
-rw-r--r--build/org.eclipse.cdt.meson.ui/plugin.properties2
-rw-r--r--build/org.eclipse.cdt.meson.ui/plugin.xml58
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java103
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java242
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/RunNinjaCommandHandler.java105
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinja.java56
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinjaPage.java102
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java33
-rw-r--r--build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/wizardmessages.properties17
9 files changed, 718 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.meson.ui/plugin.properties b/build/org.eclipse.cdt.meson.ui/plugin.properties
index 2987c590423..a42e8b3bc50 100644
--- a/build/org.eclipse.cdt.meson.ui/plugin.properties
+++ b/build/org.eclipse.cdt.meson.ui/plugin.properties
@@ -7,3 +7,5 @@
###############################################################################
meson.preferences.name = Meson
+meson.run.ninja.label=Run ninja
+meson.run.ninja.mnemonic=j
diff --git a/build/org.eclipse.cdt.meson.ui/plugin.xml b/build/org.eclipse.cdt.meson.ui/plugin.xml
index e9ea3f91911..08b35350319 100644
--- a/build/org.eclipse.cdt.meson.ui/plugin.xml
+++ b/build/org.eclipse.cdt.meson.ui/plugin.xml
@@ -74,5 +74,63 @@
tabClass="org.eclipse.cdt.internal.meson.ui.MesonBuildTab">
</provider>
</extension>
+ <extension
+ id="org.eclipse.cdt.meson.ui.commands.ninja"
+ name="%meson.run.ninja.label"
+ point="org.eclipse.ui.commands">
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.cdt.internal.meson.ui.commands.RunNinjaCommandHandler"
+ commandId="org.eclipse.cdt.meson.ui.command.runninja">
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.definitions">
+ <definition
+ id="org.eclipse.cdt.meson.ui.handlerEnablement">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.cdt.meson.core.mesonNature">
+ </test>
+ </adapt>
+ </iterate>
+ </with>
+ </definition>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?before=additions">
+ <separator
+ name="mesonGroup"
+ visible="true">
+ </separator>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=mesonGroup">
+ <command
+ commandId="org.eclipse.cdt.meson.ui.command.runninja"
+ id="ninja"
+ label="%meson.run.ninja.label"
+ mnemonic="%meson.run.ninja.mnemonic"
+ style="push">
+ <visibleWhen checkEnabled="true"/>
+ </command>
+ </menuContribution>
+ </extension>
+
+
</plugin>
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java
new file mode 100644
index 00000000000..72a7f02911b
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/SWTImagesFactory.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat Inc. and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.meson.ui;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.cdt.meson.ui.Activator;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+
+public class SWTImagesFactory {
+ // The plug-in registry
+ private static ImageRegistry imageRegistry = Activator.getPlugin()
+ .getImageRegistry();
+
+ // Sub-directory (under the package containing this class) where 16 color
+ // images are
+ private static URL fgIconBaseURL;
+
+ static {
+ try {
+ fgIconBaseURL = new URL(Activator.getPlugin().getBundle()
+ .getEntry("/"), "icons/"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (MalformedURLException e) {
+ Activator.log(e);
+ }
+ }
+ private static final String NAME_PREFIX = Activator.PLUGIN_ID + '.';
+ private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
+ public static final String IMG_MESON = NAME_PREFIX + "meson-logo.png"; //$NON-NLS-1$
+ public static final ImageDescriptor DESC_MESON = createManaged("",
+ IMG_MESON);
+
+ private static ImageDescriptor createManaged(String prefix, String name) {
+ return createManaged(imageRegistry, prefix, name);
+ }
+
+ private static ImageDescriptor createManaged(ImageRegistry registry,
+ String prefix, String name) {
+ ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(
+ prefix, name.substring(NAME_PREFIX_LENGTH)));
+ registry.put(name, result);
+ return result;
+ }
+
+ public static Image get(String key) {
+ return imageRegistry.get(key);
+ }
+
+ private static ImageDescriptor create(String prefix, String name) {
+ return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
+ }
+
+ private static URL makeIconFileURL(String prefix, String name) {
+ StringBuffer buffer = new StringBuffer(prefix);
+ buffer.append(name);
+ try {
+ return new URL(fgIconBaseURL, buffer.toString());
+ } catch (MalformedURLException e) {
+ Activator.log(e);
+ return null;
+ }
+ }
+
+ /**
+ * Sets all available image descriptors for the given action.
+ *
+ * @param action
+ * - action
+ * @param type
+ * - type of image descriptor
+ * @param relPath
+ * - relative path
+ */
+ public static void setImageDescriptors(IAction action, String type,
+ String relPath) {
+ if (relPath.startsWith(NAME_PREFIX))
+ relPath = relPath.substring(NAME_PREFIX_LENGTH);
+ action.setDisabledImageDescriptor(create("d" + type, relPath)); //$NON-NLS-1$
+ action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
+
+ }
+
+ /**
+ * Helper method to access the image registry from the CUIPlugin class.
+ */
+ static ImageRegistry getImageRegistry() {
+ return imageRegistry;
+ }
+
+}
+
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java
new file mode 100644
index 00000000000..ea3b887e28f
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/AbstractMesonCommandHandler.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat Inc. and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.meson.ui.commands;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public abstract class AbstractMesonCommandHandler extends AbstractHandler {
+
+ private IContainer fContainer;
+
+ protected abstract void run(Shell activeShell);
+
+ protected Object execute1(ExecutionEvent event) {
+ ISelection k = HandlerUtil.getCurrentSelection(event);
+ if (!k.isEmpty() && k instanceof IStructuredSelection) {
+ Object obj = ((IStructuredSelection)k).getFirstElement();
+ IContainer container = getContainer(obj);
+ if (container != null) {
+ setSelectedContainer(container);
+ run(HandlerUtil.getActiveShell(event));
+ }
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected IContainer getContainer(Object obj) {
+ IContainer fContainer = null;
+
+ if (obj instanceof Collection) {
+ Collection<Object> c = (Collection<Object>)obj;
+ Object[] objArray = c.toArray();
+ if (objArray.length > 0)
+ obj = objArray[0];
+ }
+ if (obj instanceof ICElement) {
+ if ( obj instanceof ICContainer || obj instanceof ICProject) {
+ fContainer = (IContainer) ((ICElement) obj).getUnderlyingResource();
+ } else {
+ obj = ((ICElement)obj).getResource();
+ if ( obj != null) {
+ fContainer = ((IResource)obj).getParent();
+ }
+ }
+ } else if (obj instanceof IResource) {
+ if (obj instanceof IContainer) {
+ fContainer = (IContainer) obj;
+ } else {
+ fContainer = ((IResource)obj).getParent();
+ }
+ } else {
+ fContainer = null;
+ }
+ return fContainer;
+ }
+
+ public final String SHELL_COMMAND = "sh"; //$NON-NLS-1$
+
+ protected void showError(String title, String content) {
+ MessageDialog.openError(new Shell(), title, content);
+ }
+
+ /**
+ * Separate targets to array from a string.
+ *
+ * @param rawArgList
+ * @return targets in string[] array. if targets are not formatted properly,
+ * returns null
+ */
+ protected List<String> separateTargets(String rawArgList) {
+
+ StringTokenizer st = new StringTokenizer(rawArgList, " "); //$NON-NLS-1$
+ List<String> targetList = new ArrayList<>();
+
+ while (st.hasMoreTokens()) {
+ String currentWord = st.nextToken().trim();
+
+ if (currentWord.startsWith("'")) { //$NON-NLS-1$
+ StringBuilder tmpTarget = new StringBuilder();
+ while (!currentWord.endsWith("'")) { //$NON-NLS-1$
+ tmpTarget.append(currentWord).append(' ');
+ if (!st.hasMoreTokens()) {
+ // quote not closed properly, so return null
+ return null;
+ }
+ currentWord = st.nextToken().trim();
+ }
+
+ tmpTarget.append(currentWord);
+ targetList.add(tmpTarget.toString());
+ continue;
+ }
+
+ if (currentWord.startsWith("\"")) { //$NON-NLS-1$
+ StringBuilder tmpTarget = new StringBuilder();
+ while (!currentWord.endsWith("\"")) { //$NON-NLS-1$
+ tmpTarget.append(currentWord).append(' ');
+ if (!st.hasMoreTokens()) {
+ // double quote not closed properly, so return null
+ return null;
+ }
+ currentWord = st.nextToken().trim();
+ }
+
+ tmpTarget.append(currentWord);
+ targetList.add(tmpTarget.toString());
+ continue;
+ }
+
+ // for targets without quote/double quotes.
+ targetList.add(currentWord);
+
+ }
+
+ return targetList;
+ }
+
+ protected List<String> separateOptions(String rawArgList) {
+ List<String> argList = new ArrayList<>();
+ // May be multiple user-specified options in which case we
+ // need to split them up into individual options
+ rawArgList = rawArgList.trim();
+ boolean finished = false;
+ int lastIndex = rawArgList.indexOf("--"); //$NON-NLS-1$
+ if (lastIndex != -1) {
+ while (!finished) {
+ int index = rawArgList.indexOf("--", lastIndex + 2); //$NON-NLS-1$
+ if (index != -1) {
+ String previous = rawArgList.substring(lastIndex, index).trim();
+ argList.add(previous);
+ rawArgList = rawArgList.substring(index);
+ } else {
+ argList.add(rawArgList);
+ finished = true;
+ }
+ }
+ }
+
+ return argList;
+
+ }
+
+ protected List<String> simpleParseOptions(String rawArgList) {
+ List<String> argList = new ArrayList<>();
+ int lastArgIndex = -1;
+ int i = 0;
+ while (i < rawArgList.length()) {
+ char ch = rawArgList.charAt(i);
+ // Skip white-space
+ while (Character.isWhitespace(ch)) {
+ ++i;
+ if (i < rawArgList.length())
+ ch = rawArgList.charAt(i);
+ else // Otherwise we are done
+ return argList;
+ }
+
+ // Simplistic parser. We break up into strings delimited
+ // by blanks. If quotes are used, we ignore blanks within.
+ // If a backslash is used, we ignore the next character and
+ // pass it through.
+ lastArgIndex = i;
+ boolean inString = false;
+ while (i < rawArgList.length()) {
+ ch = rawArgList.charAt(i);
+ if (ch == '\\') // escape character
+ ++i; // skip over the next character
+ else if (ch == '\"') { // double quotes
+ inString = !inString;
+ } else if (Character.isWhitespace(ch)) {
+ if (!inString) {
+ argList.add(rawArgList.substring(lastArgIndex, i));
+ break;
+ }
+ }
+ ++i;
+ }
+ // Look for the case where we ran out of chars for the last
+ // token.
+ if (i >= rawArgList.length())
+ argList.add(rawArgList.substring(lastArgIndex));
+ ++i;
+ }
+ return argList;
+ }
+
+ protected IPath getExecDir(IContainer container) {
+ int type = container.getType();
+ IPath execDir = null;
+ if (type == IResource.FILE) {
+ execDir = container.getLocation().removeLastSegments(1);
+ } else {
+ execDir = container.getLocation();
+ }
+ return execDir;
+ }
+
+ protected IPath getCWD(IContainer container) {
+ int type = container.getType();
+ IPath cwd = null;
+ if (type == IResource.FILE) {
+ cwd = container.getFullPath().removeLastSegments(1);
+ } else {
+ cwd = container.getFullPath();
+ }
+ return cwd;
+ }
+
+ protected IContainer getSelectedContainer() {
+ return fContainer;
+ }
+
+ public void setSelectedContainer(IContainer container) {
+ fContainer = container;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/RunNinjaCommandHandler.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/RunNinjaCommandHandler.java
new file mode 100644
index 00000000000..0b1f09fa8b7
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/commands/RunNinjaCommandHandler.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat Inc. and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.meson.ui.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.build.CBuildConfiguration;
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.internal.meson.core.MesonBuildConfiguration;
+import org.eclipse.cdt.internal.meson.core.MesonUtils;
+import org.eclipse.cdt.internal.meson.ui.wizards.RunNinja;
+import org.eclipse.cdt.meson.core.IMesonConstants;
+import org.eclipse.cdt.meson.ui.Activator;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class RunNinjaCommandHandler extends AbstractMesonCommandHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) {
+ return execute1(event);
+ }
+
+ @Override
+ public void run (Shell shell) {
+ // Set up console
+ IConsole console = CCorePlugin.getDefault().getConsole();
+ IProject project = getSelectedContainer().getAdapter(IProject.class);
+ console.start(project);
+ try {
+ ICBuildConfiguration buildConfig = ((CBuildConfiguration)project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
+
+ if (buildConfig instanceof MesonBuildConfiguration) {
+ MesonBuildConfiguration config = (MesonBuildConfiguration)buildConfig;
+ RunNinja wizard = new RunNinja(buildConfig);
+ final WizardDialog dialog = new WizardDialog(shell, wizard);
+ Display.getDefault().syncExec(() -> {
+ dialog.create();
+ dialog.open();
+ });
+ if (dialog.getReturnCode() == Window.OK) {
+ // Run ninja command in a Job so user can cancel if it stalls
+ Job buildJob = new Job("Running Ninja") {
+ @Override
+ public IStatus run(final IProgressMonitor monitor) {
+
+ String envString = config.getProperty(IMesonConstants.NINJA_ENV);
+ String[] ninjaEnv = null;
+ if (envString != null) {
+ ninjaEnv = MesonUtils.stripEnvVars(envString).toArray(new String[0]);
+ }
+
+ String argString = config.getProperty(IMesonConstants.NINJA_ARGUMENTS);
+ String[] ninjaArgs = null;
+ if (argString != null) {
+ List<String> ninjaArgList = new ArrayList<>();
+ Matcher m = Pattern.compile("([^\"]\\S*|\".+?\")\\s*").matcher(argString);
+ while (m.find()) {
+ ninjaArgList.add(m.group(1));
+ }
+ ninjaArgs = ninjaArgList.toArray(new String[0]);
+ }
+ try {
+ config.build(IncrementalProjectBuilder.FULL_BUILD, null, ninjaEnv, ninjaArgs, console, monitor);
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ } catch (CoreException e) {
+ Activator.log(e);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ buildJob.schedule();
+ }
+ }
+ } catch (CoreException e) {
+ Activator.log(e);
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinja.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinja.java
new file mode 100644
index 00000000000..a7172f6a497
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinja.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.cdt.internal.meson.ui.wizards;
+
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.meson.core.IMesonConstants;
+import org.eclipse.jface.wizard.Wizard;
+
+public class RunNinja extends Wizard {
+
+ private RunNinjaPage mainPage;
+ private ICBuildConfiguration config;
+ private String envStr;
+ private String ninjaArgs;
+
+ public RunNinja(ICBuildConfiguration config) {
+ this.config = config;
+ }
+
+ @Override
+ public void addPages() {
+ mainPage = new RunNinjaPage(config);
+ addPage(mainPage);
+ }
+
+ @Override
+ public boolean canFinish() {
+ return mainPage.isPageComplete();
+ }
+
+ @Override
+ public boolean performFinish() {
+ envStr = mainPage.getEnvStr();
+ config.setProperty(IMesonConstants.NINJA_ENV, envStr);
+ ninjaArgs = mainPage.getNinjaArgs();
+ config.setProperty(IMesonConstants.NINJA_ARGUMENTS, ninjaArgs);
+ return true;
+ }
+
+ public String getEnvStr() {
+ return envStr;
+ }
+
+ public String getNinjaArgs() {
+ return ninjaArgs;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinjaPage.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinjaPage.java
new file mode 100644
index 00000000000..466bbc7c2bf
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/RunNinjaPage.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2018 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.cdt.internal.meson.ui.wizards;
+
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.internal.meson.ui.SWTImagesFactory;
+import org.eclipse.cdt.meson.core.IMesonConstants;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A standard file selection dialog which solicits a list of files from the user.
+ * The <code>getResult</code> method returns the selected files.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * <p>
+ * Example:
+ * <pre>
+ * FileSelectionDialog dialog =
+ * new FileSelectionDialog(getShell(), rootElement, msg);
+ * dialog.setInitialSelections(selectedResources);
+ * dialog.open();
+ * return dialog.getResult();
+ * </pre>
+ * </p>
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class RunNinjaPage extends WizardPage {
+
+ private ICBuildConfiguration config;
+ private Text envText;
+ private Text ninjaArgs;
+
+ public RunNinjaPage(ICBuildConfiguration config) {
+ super(WizardMessages.RunNinjaPage_name);
+ setDescription(WizardMessages.RunNinjaPage_description);
+ setTitle(WizardMessages.RunNinjaPage_title);
+ setImageDescriptor(SWTImagesFactory.DESC_MESON);
+ this.config = config;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(1, true));
+
+ Label envLabel = new Label(composite, SWT.NONE);
+ envLabel.setText(WizardMessages.RunNinjaPage_env_label);
+ envLabel.setLayoutData(new GridData());
+
+ envText = new Text(composite, SWT.BORDER);
+ String lastEnv = config.getProperty(IMesonConstants.NINJA_ENV);
+ if (lastEnv == null) {
+ lastEnv = ""; //$NON-NLS-1$
+ }
+ envText.setToolTipText(WizardMessages.RunNinjaPage_env_description);
+ envText.setText(lastEnv);
+ GridData gdata = new GridData(SWT.FILL, SWT.FILL, true, false);
+ envText.setLayoutData(gdata);
+
+ Label argLabel = new Label(composite, SWT.NONE);
+ argLabel.setText(WizardMessages.RunNinjaPage_options_label);
+ argLabel.setLayoutData(new GridData());
+
+ ninjaArgs = new Text(composite, SWT.BORDER);
+ String lastNinjaArgs = config.getProperty(IMesonConstants.NINJA_ARGUMENTS);
+ if (lastNinjaArgs == null) {
+ lastNinjaArgs = ""; //$NON-NLS-1$
+ }
+ ninjaArgs.setToolTipText(WizardMessages.RunNinjaPage_options_description);
+ ninjaArgs.setText(lastNinjaArgs);
+ GridData gdata2 = new GridData(SWT.FILL, SWT.FILL, true, false);
+ ninjaArgs.setLayoutData(gdata2);
+
+ setControl(composite);
+ }
+
+ public String getEnvStr() {
+ return envText.getText();
+ }
+
+ public String getNinjaArgs() {
+ return ninjaArgs.getText();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java
new file mode 100644
index 00000000000..51c2d3c9880
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/WizardMessages.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat Inc. and others.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.meson.ui.wizards;
+
+import org.eclipse.osgi.util.NLS;
+
+public class WizardMessages extends NLS {
+
+ public static String RunNinjaPage_name;
+ public static String RunNinjaPage_description;
+ public static String RunNinjaPage_title;
+ public static String RunNinjaPage_env_label;
+ public static String RunNinjaPage_env_description;
+ public static String RunNinjaPage_options_label;
+ public static String RunNinjaPage_options_description;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages("org.eclipse.cdt.internal.meson.ui.wizards.wizardmessages", WizardMessages.class); //$NON-NLS-1$
+ }
+
+ private WizardMessages() {
+ }
+}
+
diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/wizardmessages.properties b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/wizardmessages.properties
new file mode 100644
index 00000000000..aa21ebd06a5
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/internal/meson/ui/wizards/wizardmessages.properties
@@ -0,0 +1,17 @@
+################################################################################
+# Copyright (c) 2018 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
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat Inc. - Initial Contribution
+################################################################################
+RunNinjaPage_name=Run ninja
+RunNinjaPage_description=Run ninja manually for the active build configuration
+RunNinjaPage_title=Run ninja manually
+RunNinjaPage_env_label=Environment:
+RunNinjaPage_env_description=Environment variables for ninja command
+RunNinjaPage_options_label=Options:
+RunNinjaPage_options_description=Options to pass to ninja command \ No newline at end of file

Back to the top