From e371ba0919f68b50543500521c4d0d111e0e2650 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Tue, 27 Sep 2016 23:35:36 -0400 Subject: [PATCH] Updates for Core Build. Change-Id: I8720d5b57e335adde538838790c3ecdd465a7ed7 --- .../internal/CMakeBuildConfiguration.java | 77 +++++--- .../META-INF/MANIFEST.MF | 4 +- build/org.eclipse.cdt.cmake.ui/plugin.xml | 8 + .../cdt/cmake/ui/internal/CMakeBuildTab.java | 167 ++++++++++++++++++ .../cdt/core/build/CBuildConfiguration.java | 26 ++- .../cdt/core/build/ICBuildConfiguration.java | 88 ++++++++- .../build/StandardBuildConfiguration.java | 136 ++++++++++++++ .../wizards/project/NewCDTProjectWizard.java | 1 + .../plugin.properties | 2 +- debug/org.eclipse.cdt.debug.core/plugin.xml | 3 +- .../CoreBuildLocalRunLaunchDelegate.java | 5 + debug/org.eclipse.cdt.debug.ui/plugin.xml | 8 - .../META-INF/MANIFEST.MF | 2 +- launch/org.eclipse.cdt.launch/plugin.xml | 9 + launch/org.eclipse.cdt.launch/pom.xml | 2 +- .../schema/coreBuildTab.exsd | 117 ++++++++++++ .../LocalLaunchConfigurationTabGroup.java | 13 +- .../launch/ui/corebuild/CoreBuildMainTab.java | 79 +++++++++ .../cdt/launch/ui/corebuild/CoreBuildTab.java | 141 +++++++++++++++ qt/org.eclipse.cdt.qt.core/plugin.xml | 45 ----- .../qt/core/build/QtBuildConfiguration.java | 6 +- .../build/QtBuildConfigurationProvider.java | 42 ++++- .../qt/core/launch/QtLaunchDescriptor.java | 50 ------ .../core/launch/QtLaunchDescriptorType.java | 41 ----- .../QtLocalLaunchConfigationProvider.java | 36 ---- .../QtLocalRunLaunchConfigDelegate.java | 66 ------- .../qt/core/project/QtProjectGenerator.java | 23 ++- .../cdt/qt/core/IQtBuildConfiguration.java | 4 + .../core/QtLaunchConfigurationProvider.java | 98 ---------- .../templates/project2/appProject/main.cpp | 2 +- .../templates/project2/appProject/main.pro | 2 +- .../templates/project2/appProject/main.qrc | 2 +- .../project2/appProject/manifest.xml | 5 +- .../org.eclipse.cdt.arduino.core/plugin.xml | 3 +- .../build/ArduinoBuildConfiguration.java | 54 +++--- .../project/NewArduinoProjectWizard.java | 2 + 36 files changed, 943 insertions(+), 426 deletions(-) create mode 100644 build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java create mode 100644 core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java create mode 100644 launch/org.eclipse.cdt.launch/schema/coreBuildTab.exsd rename {debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch => launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild}/LocalLaunchConfigurationTabGroup.java (69%) create mode 100644 launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java create mode 100644 launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java delete mode 100644 qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptor.java delete mode 100644 qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptorType.java delete mode 100644 qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalLaunchConfigationProvider.java delete mode 100644 qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java delete mode 100644 qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java index 1b684999dad..c7ea5cdacaf 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java @@ -14,7 +14,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -32,7 +31,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; @@ -40,6 +38,11 @@ import com.google.gson.Gson; public class CMakeBuildConfiguration extends CBuildConfiguration { + public static final String CMAKE_GENERATOR = "cmake.generator"; //$NON-NLS-1$ + public static final String CMAKE_ARGUMENTS = "cmake.arguments"; //$NON-NLS-1$ + public static final String BUILD_COMMAND = "cmake.command.build"; //$NON-NLS-1$ + public static final String CLEAN_COMMAND = "cmake.command.clean"; //$NON-NLS-1$ + private static final String TOOLCHAIN_FILE = "cdt.cmake.toolchainfile"; //$NON-NLS-1$ private ICMakeToolChainFile toolChainFile; @@ -85,6 +88,12 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { throws CoreException { IProject project = getProject(); try { + Map properties = getProperties(); + String generator = properties.get(CMAKE_GENERATOR); + if (generator == null) { + generator = "Unix Makefiles"; //$NON-NLS-1$ + } + project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); ConsoleOutputStream outStream = console.getOutputStream(); @@ -93,24 +102,19 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { outStream.write(String.format("Building in: %s\n", buildDir.toString())); - if (!Files.exists(buildDir.resolve("Makefile"))) { //$NON-NLS-1$ + if (!Files.exists(buildDir.resolve("CMakeFiles"))) { //$NON-NLS-1$ List command = new ArrayList<>(); - // TODO assuming cmake is in the path here, probably need a - // preference in case it isn't. - Path cmakePath = CBuildConfiguration.getCommandFromPath(Paths.get("cmake")); //$NON-NLS-1$ - if (cmakePath == null) { - if (!Platform.getOS().equals(Platform.OS_WIN32)) { - cmakePath = Paths.get("/usr/local/bin/cmake"); //$NON-NLS-1$ - } else { - cmakePath = Paths.get("cmake"); //$NON-NLS-1$ - } + // TODO location of CMake out of preferences if not found here + Path cmakePath = findCommand("cmake"); //$NON-NLS-1$ + if (cmakePath != null) { + command.add(cmakePath.toString()); + } else { + command.add("cmake"); //$NON-NLS-1$ } - command.add(cmakePath.toString()); command.add("-G"); //$NON-NLS-1$ - // TODO ninja? - command.add("Unix Makefiles"); //$NON-NLS-1$ + command.add(generator); if (toolChainFile != null) { command.add("-DCMAKE_TOOLCHAIN_FILE=" + toolChainFile.getPath().toString()); //$NON-NLS-1$ @@ -128,9 +132,21 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this, getToolChain().getErrorParserIds())) { - // TODO need to figure out which builder to call. Hardcoding to - // make for now. - List command = Arrays.asList("make"); //$NON-NLS-1$ + String buildCommand = properties.get(BUILD_COMMAND); + if (buildCommand == null) { + if (generator.equals("Ninja")) { //$NON-NLS-1$ + buildCommand = "ninja"; //$NON-NLS-1$ + } else { + buildCommand = "make"; //$NON-NLS-1$ + } + } + String[] command = buildCommand.split(" "); //$NON-NLS-1$ + + Path cmdPath = findCommand(command[0]); + if (cmdPath != null) { + command[0] = cmdPath.toString(); + } + ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); setBuildEnvironment(processBuilder.environment()); Process process = processBuilder.start(); @@ -153,20 +169,35 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { public void clean(IConsole console, IProgressMonitor monitor) throws CoreException { IProject project = getProject(); try { + Map properties = getProperties(); + String generator = properties.get(CMAKE_GENERATOR); + project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); ConsoleOutputStream outStream = console.getOutputStream(); Path buildDir = getBuildDirectory(); - if (!Files.exists(buildDir.resolve("Makefile"))) { //$NON-NLS-1$ - outStream.write("Makefile not found. Assuming clean."); + if (!Files.exists(buildDir.resolve("CMakeFiles"))) { //$NON-NLS-1$ + outStream.write("CMakeFiles not found. Assuming clean."); return; } - // TODO need to figure out which builder to call. Hardcoding to make - // for now. - List command = Arrays.asList("make", "clean"); //$NON-NLS-1$ + String cleanCommand = properties.get(CLEAN_COMMAND); + if (cleanCommand == null) { + if (generator.equals("Ninja")) { //$NON-NLS-1$ + cleanCommand = "ninja clean"; //$NON-NLS-1$ + } else { + cleanCommand = "make clean"; //$NON-NLS-1$ + } + } + String[] command = cleanCommand.split(" "); //$NON-NLS-1$ + + Path cmdPath = findCommand(command[0]); + if (cmdPath != null) { + command[0] = cmdPath.toString(); + } + ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); Process process = processBuilder.start(); outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF index 20ba12ee10d..1b5caf16d01 100644 --- a/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF @@ -11,7 +11,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.ide, org.eclipse.cdt.cmake.core, org.eclipse.tools.templates.ui;bundle-version="1.1.0", - org.eclipse.cdt.core;bundle-version="6.1.0" + org.eclipse.cdt.core;bundle-version="6.1.0", + org.eclipse.debug.ui;bundle-version="3.11.200", + org.eclipse.cdt.launch;bundle-version="9.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/build/org.eclipse.cdt.cmake.ui/plugin.xml b/build/org.eclipse.cdt.cmake.ui/plugin.xml index 09a01d710fb..b0483065a3f 100644 --- a/build/org.eclipse.cdt.cmake.ui/plugin.xml +++ b/build/org.eclipse.cdt.cmake.ui/plugin.xml @@ -51,5 +51,13 @@ + + + + diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java new file mode 100644 index 00000000000..200550cb617 --- /dev/null +++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java @@ -0,0 +1,167 @@ +package org.eclipse.cdt.cmake.ui.internal; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.cmake.core.internal.CMakeBuildConfiguration; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class CMakeBuildTab extends AbstractLaunchConfigurationTab { + + private Button unixGenButton; + private Button ninjaGenButton; + private Text cmakeArgsText; + private Text buildCommandText; + private Text cleanCommandText; + + @Override + public void createControl(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new GridLayout()); + setControl(comp); + + Label label = new Label(comp, SWT.NONE); + label.setText("Generator"); + + Composite genComp = new Composite(comp, SWT.BORDER); + genComp.setLayout(new GridLayout(2, true)); + + unixGenButton = new Button(genComp, SWT.RADIO); + unixGenButton.setText("Unix Makefiles"); + unixGenButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateLaunchConfigurationDialog(); + } + }); + + ninjaGenButton = new Button(genComp, SWT.RADIO); + ninjaGenButton.setText("Ninja"); + ninjaGenButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateLaunchConfigurationDialog(); + } + }); + + label = new Label(comp, SWT.NONE); + label.setText("Additional CMake arguments:"); + + cmakeArgsText = new Text(comp, SWT.BORDER); + cmakeArgsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + cmakeArgsText.addModifyListener(e -> updateLaunchConfigurationDialog()); + + label = new Label(comp, SWT.NONE); + label.setText("Build command"); + + buildCommandText = new Text(comp, SWT.BORDER); + buildCommandText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + buildCommandText.addModifyListener(e -> updateLaunchConfigurationDialog()); + + label = new Label(comp, SWT.NONE); + label.setText("Clean command"); + + cleanCommandText = new Text(comp, SWT.BORDER); + cleanCommandText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + cleanCommandText.addModifyListener(e -> updateLaunchConfigurationDialog()); + } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + String mode = getLaunchConfigurationDialog().getMode(); + configuration.removeAttribute("COREBUILD_" + mode); //$NON-NLS-1$ + } + + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + try { + String mode = getLaunchConfigurationDialog().getMode(); + // TODO find a home for the attribute name + Map properties = configuration.getAttribute("COREBUILD_" + mode, //$NON-NLS-1$ + new HashMap<>()); + + String generator = properties.get(CMakeBuildConfiguration.CMAKE_GENERATOR); + updateGeneratorButtons(generator); + + String cmakeArgs = properties.get(CMakeBuildConfiguration.CMAKE_ARGUMENTS); + if (cmakeArgs != null) { + cmakeArgsText.setText(cmakeArgs); + } else { + cmakeArgsText.setText(""); //$NON-NLS-1$ + } + + String buildCommand = properties.get(CMakeBuildConfiguration.BUILD_COMMAND); + if (buildCommand != null) { + buildCommandText.setText(buildCommand); + } else { + buildCommandText.setText(""); //$NON-NLS-1$ + } + + String cleanCommand = properties.get(CMakeBuildConfiguration.CLEAN_COMMAND); + if (cleanCommand != null) { + cleanCommandText.setText(buildCommand); + } else { + cleanCommandText.setText(""); //$NON-NLS-1$ + } + } catch (CoreException e) { + Activator.log(e); + } + } + + private void updateGeneratorButtons(String generator) { + if (generator != null && generator.equals("Ninja")) { //$NON-NLS-1$ + ninjaGenButton.setSelection(true); + } else { + unixGenButton.setSelection(true); + } + } + + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + Map properties = new HashMap<>(); + + if (ninjaGenButton.getSelection()) { + properties.put(CMakeBuildConfiguration.CMAKE_GENERATOR, "Ninja"); //$NON-NLS-1$ + } + + String cmakeArgs = cmakeArgsText.getText().trim(); + if (!cmakeArgs.isEmpty()) { + properties.put(CMakeBuildConfiguration.CMAKE_ARGUMENTS, cmakeArgs); + } + + String buildCommand = buildCommandText.getText().trim(); + if (!buildCommand.isEmpty()) { + properties.put(CMakeBuildConfiguration.BUILD_COMMAND, buildCommand); + } + + String cleanCommand = cleanCommandText.getText().trim(); + if (!cleanCommand.isEmpty()) { + properties.put(CMakeBuildConfiguration.CLEAN_COMMAND, cleanCommand); + } + + String mode = getLaunchConfigurationDialog().getMode(); + if (!properties.isEmpty()) { + configuration.setAttribute("COREBUILD_" + mode, properties); //$NON-NLS-1$ + } else { + configuration.removeAttribute("COREBUILD_" + mode); //$NON-NLS-1$ + } + } + + @Override + public String getName() { + return "CMake"; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java index 360aa7c9131..53adab3ce6a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java @@ -102,6 +102,8 @@ public abstract class CBuildConfiguration extends PlatformObject private final Map> scannerInfoListeners = new HashMap<>(); private ScannerInfoCache scannerInfoCache; + private Map properties; + protected CBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { this.config = config; this.name = name; @@ -169,13 +171,15 @@ public abstract class CBuildConfiguration extends PlatformObject // TODO should really be passing a monitor in here or create this in // a better spot. should also throw the core exception // TODO make the name of this folder a project property - IFolder buildRootFolder = getProject().getFolder("build"); //$NON-NLS-1$ + IProgressMonitor monitor = new NullProgressMonitor(); + IProject project = getProject(); + IFolder buildRootFolder = project.getFolder("build"); //$NON-NLS-1$ if (!buildRootFolder.exists()) { - buildRootFolder.create(IResource.FORCE | IResource.DERIVED, true, new NullProgressMonitor()); + buildRootFolder.create(IResource.FORCE | IResource.DERIVED, true, monitor); } IFolder buildFolder = buildRootFolder.getFolder(name); if (!buildFolder.exists()) { - buildFolder.create(IResource.FORCE | IResource.DERIVED, true, new NullProgressMonitor()); + buildFolder.create(IResource.FORCE | IResource.DERIVED, true, monitor); } return buildFolder; @@ -662,4 +666,20 @@ public abstract class CBuildConfiguration extends PlatformObject return null; } + /** + * @since 6.2 + */ + @Override + public void setProperties(Map properties) { + this.properties = properties; + } + + /** + * @since 6.2 + */ + @Override + public Map getProperties() { + return properties != null ? properties : new HashMap<>(); + } + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java index dc622120fe9..a48143fac1c 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java @@ -7,6 +7,7 @@ *******************************************************************************/ package org.eclipse.cdt.core.build; +import java.util.HashMap; import java.util.Map; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; @@ -50,18 +51,65 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider { */ IToolChain getToolChain() throws CoreException; + /** + * Ids for the Binary Parsers to use when checking whether a file is a + * binary that can be launched. + * + * @return binary parser ids + * @throws CoreException + */ String getBinaryParserId() throws CoreException; + /** + * Return a build environment variable with a given name. + * + * @param name + * build environment variable name + * @return value of the build environment variable. + * @throws CoreException + */ IEnvironmentVariable getVariable(String name) throws CoreException; + /** + * Return all of the build environment variables for this configuration. + * + * @return + * @throws CoreException + */ IEnvironmentVariable[] getVariables() throws CoreException; + /** + * Perform the build. + * + * @param kind + * build type + * @param args + * build arguments + * @param console + * console to show build output + * @param monitor + * progress monitor + * @return the list of projects for which this builder would like deltas the + * next time it is run or null if none + * @throws CoreException + */ IProject[] build(int kind, Map args, IConsole console, IProgressMonitor monitor) throws CoreException; + /** + * Perform clean. + * + * @param console + * console to show clean output + * @param monitor + * progress monitor + * @throws CoreException + */ void clean(IConsole console, IProgressMonitor monitor) throws CoreException; /** - * @return build output IContainer + * The binaries produced by the build. + * + * @return binaries produced by the build. * @throws CoreException * @since 6.1 */ @@ -70,10 +118,48 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider { } /** + * Set the environment for the builds. Generally the environment from a + * ProcessBuilder would be passed here. * * @param env + * build environment * @since 6.1 */ default void setBuildEnvironment(Map env) { } + + /** + * Set the properties for this build configuration. These will often come + * from launch configurations which have build settings as attributes. + * + * @param properties + * build properties + * @since 6.2 + */ + default void setProperties(Map properties) { + } + + /** + * Return the properties for this build configuration. + * + * @return default properties + * @since 6.2 + */ + default Map getProperties() { + return new HashMap<>(); + } + + /** + * Returns whether this build configuration supports the given build + * properties. + * + * @param properties + * build properties + * @return whether this build configuration supports those properties + * @since 6.2 + */ + default boolean supportsProperties(Map properties) { + return false; + } + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java new file mode 100644 index 00000000000..ceeb95c4995 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems 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 + *******************************************************************************/ +package org.eclipse.cdt.core.build; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Map; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ConsoleOutputStream; +import org.eclipse.cdt.core.ErrorParserManager; +import org.eclipse.cdt.core.IConsoleParser; +import org.eclipse.cdt.core.model.ICModelMarker; +import org.eclipse.cdt.core.resources.IConsole; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +/** + * A Standard Build Configuration that simply calls a specified command for + * build and clean. By default, it calls 'make all' and 'make clean'. + * + * @since 6.2 + */ +public class StandardBuildConfiguration extends CBuildConfiguration { + + private String[] buildCommand = { "make", "all" }; //$NON-NLS-1$ //$NON-NLS-2$ + private String[] cleanCommand = { "make", "clean" }; //$NON-NLS-1$ //$NON-NLS-2$ + private IContainer buildContainer; + + public StandardBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { + super(config, name); + } + + public StandardBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain, + String launchMode) { + super(config, name, toolChain); + } + + public void setBuildContainer(IContainer buildContainer) { + this.buildContainer = buildContainer; + } + + public void setBuildCommand(String[] buildCommand) { + this.buildCommand = buildCommand; + } + + public void setCleanCommand(String[] cleanCommand) { + this.cleanCommand = cleanCommand; + } + + @Override + public IContainer getBuildContainer() throws CoreException { + // If a container isn't set, assume build bits can go anywhere in the + // project + return buildContainer != null ? buildContainer : getProject(); + } + + @Override + public IProject[] build(int kind, Map args, IConsole console, IProgressMonitor monitor) + throws CoreException { + IProject project = getProject(); + try { + project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); + + ConsoleOutputStream outStream = console.getOutputStream(); + + Path buildDir = getBuildDirectory(); + + outStream.write(String.format("Building in: %s\n", buildDir.toString())); + + String[] command = new String[buildCommand.length]; + Path make = findCommand(buildCommand[0]); + command[0] = make.toString(); + System.arraycopy(buildCommand, 1, command, 1, buildCommand.length - 1); + + try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this, + getToolChain().getErrorParserIds())) { + // run make + console.getOutputStream().write(String.format("%s\n", String.join(" ", command))); //$NON-NLS-1$ //$NON-NLS-2$ + ProcessBuilder processBuilder = new ProcessBuilder(command) + .directory(getBuildDirectory().toFile()); + setBuildEnvironment(processBuilder.environment()); + Process process = processBuilder.start(); + IConsoleParser[] consoleParsers = new IConsoleParser[] { epm, this }; + watchProcess(process, consoleParsers, console); + } + + project.refreshLocal(IResource.DEPTH_INFINITE, monitor); + + return new IProject[] { project }; + } catch (IOException e) { + throw new CoreException( + new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Building " + project.getName(), e)); //$NON-NLS-1$ + } + } + + @Override + public void clean(IConsole console, IProgressMonitor monitor) throws CoreException { + IProject project = getProject(); + try { + project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); + + ConsoleOutputStream outStream = console.getOutputStream(); + + String[] command = new String[cleanCommand.length]; + Path make = findCommand(cleanCommand[0]); + command[0] = make.toString(); + System.arraycopy(cleanCommand, 1, command, 1, cleanCommand.length - 1); + + // run make + outStream.write(String.format("%s\n", String.join(" ", command))); //$NON-NLS-1$ //$NON-NLS-2$ + ProcessBuilder processBuilder = new ProcessBuilder(command) + .directory(getBuildDirectory().toFile()); + setBuildEnvironment(processBuilder.environment()); + Process process = processBuilder.start(); + watchProcess(process, new IConsoleParser[0], console); + + project.refreshLocal(IResource.DEPTH_INFINITE, monitor); + } catch (IOException e) { + throw new CoreException( + new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Building " + project.getName(), e)); //$NON-NLS-1$ + } + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java index 1e74e5c6103..17c23314c69 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java @@ -15,6 +15,7 @@ public class NewCDTProjectWizard extends NewWizard { public NewCDTProjectWizard() { super(cdtTag); + setWindowTitle("New C/C++ Project"); setTemplateSelectionPageTitle("Templates for New C/C++ Project"); } diff --git a/debug/org.eclipse.cdt.debug.core/plugin.properties b/debug/org.eclipse.cdt.debug.core/plugin.properties index 13fc4ebc6e0..6c5079cacbf 100644 --- a/debug/org.eclipse.cdt.debug.core/plugin.properties +++ b/debug/org.eclipse.cdt.debug.core/plugin.properties @@ -24,7 +24,7 @@ AttachLaunch.name=C/C++ Attach to Application PostMortemLaunch.name=C/C++ Postmortem Debugger RemoteApplicationLaunch.name=C/C++ Remote Application -localApplicationLaunch.name=C/C++ Local Application (auto) +localApplicationLaunch.name=Auto C/C++ Local Application CDebugger.name=C/C++ Development Tools Core Debugger Extension BreakpointAction.name=Breakpoint Action Extension diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml index 65b5feba7fc..51fa9e3f419 100644 --- a/debug/org.eclipse.cdt.debug.core/plugin.xml +++ b/debug/org.eclipse.cdt.debug.core/plugin.xml @@ -467,7 +467,8 @@ delegate="org.eclipse.cdt.debug.internal.core.launch.CoreBuildLocalRunLaunchDelegate" id="org.eclipse.cdt.debug.core.localLaunchConfigurationType" modes="run" - name="%localApplicationLaunch.name"> + name="%localApplicationLaunch.name" + public="false"> buildProps = configuration.getAttribute("COREBUILD_" + mode, new HashMap<>()); //$NON-NLS-1$ + if (!buildProps.isEmpty()) { + config.setProperties(buildProps); + } } } diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 3da4f2088ed..f01dee13ba8 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -2575,13 +2575,5 @@ id="org.eclipse.cdt.debug.ui.localLaunchConfigurationTypeImage"> - - - - diff --git a/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF b/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF index 496f56b6b63..a3661afac97 100644 --- a/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF +++ b/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true -Bundle-Version: 9.0.1.qualifier +Bundle-Version: 9.1.0.qualifier Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index 49427d1bce1..fb521cdfd42 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -2,6 +2,7 @@ + @@ -141,4 +142,12 @@ + + + + diff --git a/launch/org.eclipse.cdt.launch/pom.xml b/launch/org.eclipse.cdt.launch/pom.xml index 2500d51799f..b9832703daf 100644 --- a/launch/org.eclipse.cdt.launch/pom.xml +++ b/launch/org.eclipse.cdt.launch/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 9.0.1-SNAPSHOT + 9.1.0-SNAPSHOT org.eclipse.cdt.launch eclipse-plugin diff --git a/launch/org.eclipse.cdt.launch/schema/coreBuildTab.exsd b/launch/org.eclipse.cdt.launch/schema/coreBuildTab.exsd new file mode 100644 index 00000000000..783f9cc11f9 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/schema/coreBuildTab.exsd @@ -0,0 +1,117 @@ + + + + + + + + + Allows Core Build Providers to provide content for the Build tab in Launch Configurations + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A provider of content for the Build tab with Core Build launches. + + + + + + + The tab implementation class. The class is instantiation and rendered in the Build tab. + + + + + + + + + + Project nature of build system for which this tab applies. + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LocalLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/LocalLaunchConfigurationTabGroup.java similarity index 69% rename from debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LocalLaunchConfigurationTabGroup.java rename to launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/LocalLaunchConfigurationTabGroup.java index f202e165b3e..f71ada7cd78 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LocalLaunchConfigurationTabGroup.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/LocalLaunchConfigurationTabGroup.java @@ -5,8 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.launch; +package org.eclipse.cdt.launch.internal.corebuild; +import org.eclipse.cdt.launch.ui.corebuild.CoreBuildMainTab; +import org.eclipse.cdt.launch.ui.corebuild.CoreBuildTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; @@ -15,8 +17,13 @@ public class LocalLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio @Override public void createTabs(ILaunchConfigurationDialog dialog, String mode) { - // empty for now - setTabs(new ILaunchConfigurationTab[0]); + ILaunchConfigurationTab mainTab = new CoreBuildMainTab(); + ILaunchConfigurationTab buildTab = new CoreBuildTab(); + + setTabs(new ILaunchConfigurationTab[] { + mainTab, + buildTab + }); } } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java new file mode 100644 index 00000000000..e913e2d05e9 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildMainTab.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems 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 + *******************************************************************************/ +package org.eclipse.cdt.launch.ui.corebuild; + +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +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; + +/** + * @since 9.1 + */ +public class CoreBuildMainTab extends AbstractLaunchConfigurationTab { + + private Text projectName; + + @Override + public void createControl(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new GridLayout()); + + Label label = new Label(comp, SWT.NONE); + label.setText("This launch configuration was automatically created."); + label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + label = new Label(comp, SWT.NONE); + label.setText("Project:"); + + projectName = new Text(comp, SWT.READ_ONLY | SWT.BORDER); + projectName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + setControl(comp); + } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + // none + } + + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + try { + for (IResource resource : configuration.getMappedResources()) { + if (resource instanceof IProject) { + projectName.setText(resource.getName()); + break; + } + } + } catch (CoreException e) { + LaunchUIPlugin.log(e.getStatus()); + } + } + + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + // TODO Auto-generated method stub + + } + + @Override + public String getName() { + return "Main"; + } + +} diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java new file mode 100644 index 00000000000..2607c6e773d --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems 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 + *******************************************************************************/ +package org.eclipse.cdt.launch.ui.corebuild; + +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.debug.ui.ILaunchConfigurationTab; +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.Control; +import org.eclipse.swt.widgets.Label; + +public class CoreBuildTab extends AbstractLaunchConfigurationTab { + + private Composite container; + private IProject activeProject; + private ILaunchConfigurationTab activeTab; + + @Override + public void createControl(Composite parent) { + container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = layout.marginWidth = 0; + container.setLayout(layout); + setControl(container); + defaultTab(); + } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + if (activeTab != null) { + activeTab.setDefaults(configuration); + } + } + + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + IProject project = getProject(configuration); + if (project == null) { + defaultTab(); + } else if (!project.equals(activeProject)) { + activeProject = project; + activeTab = getTab(project); + if (activeTab == null) { + defaultTab(); + } else { + for (Control child : container.getChildren()) { + child.dispose(); + } + + activeTab.createControl(container); + activeTab.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + } + } + + if (activeTab != null) { + activeTab.setLaunchConfigurationDialog(getLaunchConfigurationDialog()); + activeTab.initializeFrom(configuration); + } + } + + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + if (activeTab != null) { + activeTab.performApply(configuration); + } + } + + @Override + public String getName() { + return "Build"; + } + + private IProject getProject(ILaunchConfiguration configuration) { + try { + for (IResource resource : configuration.getMappedResources()) { + if (resource instanceof IProject) { + return (IProject) resource; + } + } + } catch (CoreException e) { + LaunchUIPlugin.log(e.getStatus()); + } + + return null; + } + + private void defaultTab() { + // Clear out old contents + for (Control child : container.getChildren()) { + child.dispose(); + } + + Composite comp = new Composite(container, SWT.NONE); + comp.setLayout(new GridLayout()); + + Label label = new Label(comp, SWT.NONE); + label.setText("No build options required."); + + activeTab = null; + } + + private ILaunchConfigurationTab getTab(IProject project) { + try { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint point = registry.getExtensionPoint(LaunchUIPlugin.PLUGIN_ID, "coreBuildTab"); //$NON-NLS-1$ + String[] natures = project.getDescription().getNatureIds(); + for (IConfigurationElement element : point.getConfigurationElements()) { + String nature = element.getAttribute("nature"); //$NON-NLS-1$ + if (nature != null) { + for (String n : natures) { + if (n.equals(nature)) { + return (ILaunchConfigurationTab) element.createExecutableExtension("tabClass"); //$NON-NLS-1$ + } + } + } + } + } catch (CoreException e) { + LaunchUIPlugin.log(e.getStatus()); + } + + return null; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/plugin.xml b/qt/org.eclipse.cdt.qt.core/plugin.xml index 56a4eb9ca0c..e55bf9b4b46 100644 --- a/qt/org.eclipse.cdt.qt.core/plugin.xml +++ b/qt/org.eclipse.cdt.qt.core/plugin.xml @@ -114,51 +114,6 @@ - - - - - - - - - - - - - - - - - - - - T getAdapter(Class adapter) { - return super.getAdapter(adapter); - } - public IQtInstall getQtInstall() { if (qtInstall == null && !qtInstallSpec.isEmpty()) { // find one that matches the spec @@ -176,6 +171,7 @@ public class QtBuildConfiguration extends CBuildConfiguration } } + @Deprecated @Override public Path getProgramPath() throws CoreException { // TODO get the app name from the .pro file. diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java index 019c1c29eb5..c442de5da81 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java @@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.qt.core.IQtBuildConfiguration; import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstallManager; -import org.eclipse.cdt.qt.core.QtMinGWToolChainProvider; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -78,6 +77,47 @@ public class QtBuildConfigurationProvider implements ICBuildConfigurationProvide } } + @Override + public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain, String launchMode, + IProgressMonitor monitor) throws CoreException { + IQtInstall qtInstall = getQtInstall(toolChain); + if (qtInstall != null) { + // See if one exists + for (IBuildConfiguration config : project.getBuildConfigs()) { + ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class); + if (cconfig != null) { + IQtBuildConfiguration qtConfig = cconfig.getAdapter(IQtBuildConfiguration.class); + if (qtConfig != null && launchMode.equals(qtConfig.getLaunchMode()) && + qtConfig.getToolChain().equals(toolChain)) { + return qtConfig; + } + } + } + + // TODO what if multiple matches, this returns first match + String configName = "qt." + qtInstall.getSpec() + "." + launchMode; //$NON-NLS-1$ //$NON-NLS-2$ + IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, + monitor); + QtBuildConfiguration qtConfig = new QtBuildConfiguration(config, configName, toolChain, qtInstall, + launchMode); + configManager.addBuildConfiguration(config, qtConfig); + return qtConfig; + } + + return null; + } + + private IQtInstall getQtInstall(IToolChain toolChain) { + for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { + if (qtInstallManager.supports(qtInstall, toolChain)) { + return qtInstall; + } + } + + return null; + } + + // TODO this goes when the launch delegate goes public IQtBuildConfiguration getConfiguration(IProject project, Map properties, String launchMode, IProgressMonitor monitor) throws CoreException { Collection toolChains = toolChainManager.getToolChainsMatching(properties); diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptor.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptor.java deleted file mode 100644 index 73c5851521c..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptor.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems 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 - *******************************************************************************/ -package org.eclipse.cdt.internal.qt.core.launch; - -import org.eclipse.cdt.qt.core.IQtLaunchDescriptor; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.launchbar.core.ILaunchDescriptorType; - -public class QtLaunchDescriptor extends PlatformObject implements IQtLaunchDescriptor { - - private final QtLaunchDescriptorType type; - private final IProject project; - - public QtLaunchDescriptor(QtLaunchDescriptorType type, IProject project) { - this.type = type; - this.project = project; - } - - @Override - public String getName() { - return project.getName(); - } - - @Override - public ILaunchDescriptorType getType() { - return type; - } - - @Override - public IProject getProject() { - return project; - } - - @SuppressWarnings("unchecked") - @Override - public T getAdapter(Class adapter) { - if (adapter.equals(IProject.class)) { - return (T) project; - } else { - return super.getAdapter(adapter); - } - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptorType.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptorType.java deleted file mode 100644 index 41f8cbdbe13..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLaunchDescriptorType.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems 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 - *******************************************************************************/ -package org.eclipse.cdt.internal.qt.core.launch; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.cdt.internal.qt.core.QtNature; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.ILaunchDescriptorType; - -public class QtLaunchDescriptorType implements ILaunchDescriptorType { - - private Map descriptors = new HashMap<>(); - - @Override - public ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException { - // TODO also check to make sure it's an application project and not a library. - // qmake -E will give the TEMPLATE variable - if (launchObject instanceof IProject) { - IProject project = (IProject) launchObject; - if (QtNature.hasNature(project)) { - QtLaunchDescriptor desc = descriptors.get(project); - if (desc == null) { - desc = new QtLaunchDescriptor(this, project); - descriptors.put(project, desc); - } - return desc; - } - } - return null; - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalLaunchConfigationProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalLaunchConfigationProvider.java deleted file mode 100644 index f985c07209c..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalLaunchConfigationProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems 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 - *******************************************************************************/ -package org.eclipse.cdt.internal.qt.core.launch; - -import org.eclipse.cdt.qt.core.QtLaunchConfigurationProvider; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.ILaunchTargetManager; - -/** - * Launch config provider for Qt projects running on the Local connection. - * Simply uses the C++ Application launch config type. - */ -public class QtLocalLaunchConfigationProvider extends QtLaunchConfigurationProvider { - - @Override - public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { - return ILaunchTargetManager.localLaunchTargetTypeId.equals(target.getTypeId()); - } - - @Override - public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) - throws CoreException { - return DebugPlugin.getDefault().getLaunchManager() - .getLaunchConfigurationType(QtLocalRunLaunchConfigDelegate.TYPE_ID); - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java deleted file mode 100644 index c300c209f8d..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalRunLaunchConfigDelegate.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems 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 - *******************************************************************************/ -package org.eclipse.cdt.internal.qt.core.launch; - -import java.io.IOException; -import java.util.Map; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.envvar.IEnvironmentVariable; -import org.eclipse.cdt.internal.qt.core.Activator; -import org.eclipse.cdt.qt.core.IQtBuildConfiguration; -import org.eclipse.cdt.qt.core.QtLaunchConfigurationDelegate; -import org.eclipse.core.resources.IBuildConfiguration; -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.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.launch.ITargetedLaunch; - -public class QtLocalRunLaunchConfigDelegate extends QtLaunchConfigurationDelegate { - - public static final String TYPE_ID = Activator.ID + ".launchConfigurationType"; //$NON-NLS-1$ - - @Override - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) - throws CoreException { - ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); - IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); - - IBuildConfiguration buildConfig = qtBuildConfig.getBuildConfiguration(); - ProcessBuilder processBuilder = new ProcessBuilder(qtBuildConfig.getProgramPath().toString()) - .directory(buildConfig.getProject().getLocation().toFile()); - - Map env = processBuilder.environment(); - for (IEnvironmentVariable var : CCorePlugin.getDefault().getBuildEnvironmentManager() - .getVariables(qtBuildConfig.getBuildConfiguration(), true)) { - env.put(var.getName(), var.getValue()); - } - - Map configEnv = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, - (Map) null); - if (configEnv != null) { - for (Map.Entry entry : configEnv.entrySet()) { - env.put(entry.getKey(), entry.getValue()); - } - } - - try { - Process process = processBuilder.start(); - DebugPlugin.newProcess(launch, process, qtBuildConfig.getProgramPath().toString()); - } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Launching", e)); - } - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java index f1726f09bbd..1345c8f9225 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/project/QtProjectGenerator.java @@ -48,17 +48,26 @@ public class QtProjectGenerator extends FMProjectGenerator { public void generate(Map model, IProgressMonitor monitor) throws CoreException { super.generate(model, monitor); - // Create the sourcefolders + // Create the source folders IProject project = getProject(); List entries = new ArrayList<>(); - for (SourceRoot srcRoot : getManifest().getSrcRoots()) { - IFolder sourceFolder = project.getFolder(srcRoot.getDir()); - if (!sourceFolder.exists()) { - sourceFolder.create(true, true, monitor); - } + List srcRoots = getManifest().getSrcRoots(); + if (srcRoots != null && !srcRoots.isEmpty()) { + for (SourceRoot srcRoot : srcRoots) { + IFolder sourceFolder = project.getFolder(srcRoot.getDir()); + if (!sourceFolder.exists()) { + sourceFolder.create(true, true, monitor); + } - entries.add(CoreModel.newSourceEntry(sourceFolder.getFullPath())); + entries.add(CoreModel.newSourceEntry(sourceFolder.getFullPath())); + } + } else { + entries.add(CoreModel.newSourceEntry(getProject().getFullPath())); } + + // build directory as output folder + entries.add(CoreModel.newOutputEntry(getProject().getFolder("build").getFullPath())); //$NON-NLS-1$ + CoreModel.getDefault().create(project).setRawPathEntries(entries.toArray(new IPathEntry[entries.size()]), monitor); } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java index ee55522304f..3c429001412 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/IQtBuildConfiguration.java @@ -20,6 +20,10 @@ public interface IQtBuildConfiguration extends ICBuildConfiguration { String[] getQmakeConfig(); + /** + * @deprecated use getBuildOutput() instead + */ + @Deprecated Path getProgramPath() throws CoreException; String getLaunchMode(); diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java deleted file mode 100644 index 0ef7ef98c1a..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationProvider.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems 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 - *******************************************************************************/ -package org.eclipse.cdt.qt.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.internal.qt.core.launch.QtLaunchDescriptor; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.launchbar.core.AbstractLaunchConfigProvider; -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.target.ILaunchTarget; - -public abstract class QtLaunchConfigurationProvider extends AbstractLaunchConfigProvider { - - private Map configs = new HashMap<>(); - - @Override - public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) - throws CoreException { - ILaunchConfiguration config = null; - IProject project = descriptor.getAdapter(IProject.class); - if (project != null) { - config = configs.get(project); - if (config == null) { - config = createLaunchConfiguration(descriptor, target); - // launch config added will get called below to add it to the - // configs map - } - } - return config; - } - - @Override - protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target, - ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { - super.populateLaunchConfiguration(descriptor, target, workingCopy); - - // Main is actually in the library. Don't stop there - workingCopy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false); - - // Set the project and the connection - QtLaunchDescriptor qtDesc = (QtLaunchDescriptor) descriptor; - workingCopy.setMappedResources(new IResource[] { qtDesc.getProject() }); - } - - @Override - public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException { - if (ownsLaunchConfiguration(configuration)) { - IProject project = configuration.getMappedResources()[0].getProject(); - configs.put(project, configuration); - return true; - } - return false; - } - - @Override - public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException { - for (Entry entry : configs.entrySet()) { - if (configuration.equals(entry.getValue())) { - configs.remove(entry.getKey()); - return true; - } - } - return false; - } - - @Override - public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException { - // TODO not sure I care - return false; - } - - @Override - public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException { - IProject project = descriptor.getAdapter(IProject.class); - if (project != null) { - configs.remove(project); - } - } - - @Override - public void launchTargetRemoved(ILaunchTarget target) throws CoreException { - // nothing to do since the Local connection can't be removed - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.cpp b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.cpp index b3e29a3b85e..9835fbac6ba 100644 --- a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.cpp +++ b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.cpp @@ -5,7 +5,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/src/${projectName}.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/${projectName}.qml"))); return app.exec(); } diff --git a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro index f80ccb38ca4..0ff331f0480 100644 --- a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro +++ b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.pro @@ -5,7 +5,7 @@ CONFIG += c++11 RESOURCES += ${projectName}.qrc -qml.files = src/${projectName}.qml +qml.files = ${projectName}.qml launch_modeall { CONFIG(debug, debug|release) { diff --git a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.qrc b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.qrc index 30335ce99ed..274d26dc9bb 100644 --- a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.qrc +++ b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/main.qrc @@ -1,5 +1,5 @@ - src/${projectName}.qml + ${projectName}.qml diff --git a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/manifest.xml b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/manifest.xml index 91eac749421..7a88c74085c 100644 --- a/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/manifest.xml +++ b/qt/org.eclipse.cdt.qt.core/templates/project2/appProject/manifest.xml @@ -1,9 +1,8 @@ - + dest="/${projectName}/${projectName}.cpp"/> + dest="/${projectName}/${projectName}.qml"/> + name="Arduino" + public="false"> getBuildModel() throws CoreException { @@ -263,7 +263,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration buildModel.put("libraries_path", pathString(ArduinoPreferences.getArduinoHome().resolve("libraries"))); //$NON-NLS-1$ //$NON-NLS-2$ // the recipes - properties.putAll(getProperties()); + properties.putAll(getBoardProperties()); buildModel.put("build_path", properties.get("build.path")); //$NON-NLS-1$ //$NON-NLS-2$ buildModel.put("project_name", project.getName()); //$NON-NLS-1$ @@ -471,7 +471,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration } public int getMaxCodeSize() throws CoreException { - String sizeStr = getProperties().getProperty("upload.maximum_size"); //$NON-NLS-1$ + String sizeStr = getBoardProperties().getProperty("upload.maximum_size"); //$NON-NLS-1$ return sizeStr != null ? Integer.parseInt(sizeStr) : -1; } @@ -480,13 +480,13 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration } public int getMaxDataSize() throws CoreException { - String sizeStr = getProperties().getProperty("upload.maximum_data_size"); //$NON-NLS-1$ + String sizeStr = getBoardProperties().getProperty("upload.maximum_data_size"); //$NON-NLS-1$ return sizeStr != null ? Integer.parseInt(sizeStr) : -1; } public String[] getUploadCommand(String serialPort) throws CoreException { Properties properties = new Properties(); - properties.putAll(getProperties()); + properties.putAll(getBoardProperties()); String toolName = properties.getProperty("upload.tool"); //$NON-NLS-1$ ArduinoPlatform platform = getBoard().getPlatform(); @@ -610,7 +610,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration ArduinoPlatform platform = getBoard().getPlatform(); Properties properties = new Properties(); - properties.putAll(getProperties()); + properties.putAll(getBoardProperties()); // Overrides for scanner discovery properties.put("source_file", ""); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/project/NewArduinoProjectWizard.java b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/project/NewArduinoProjectWizard.java index 1efdf44d375..5c044f0e587 100644 --- a/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/project/NewArduinoProjectWizard.java +++ b/toolchains/arduino/org.eclipse.cdt.arduino.ui/src/org/eclipse/cdt/arduino/ui/internal/project/NewArduinoProjectWizard.java @@ -15,6 +15,8 @@ public class NewArduinoProjectWizard extends NewWizard { public NewArduinoProjectWizard() { super(ARDUINO_TAG_ID); + setWindowTitle("New Arduino C++ Project"); + setTemplateSelectionPageTitle("Templates for New Arduino C++ Project"); } }