diff options
Diffstat (limited to 'qt')
14 files changed, 314 insertions, 274 deletions
diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF index 5624d3662a5..a0e498d558f 100644 --- a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF +++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.qt.core;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.2.0.qualifier Bundle-Activator: org.eclipse.cdt.internal.qt.core.Activator Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime, diff --git a/qt/org.eclipse.cdt.qt.core/pom.xml b/qt/org.eclipse.cdt.qt.core/pom.xml index 231985bf8da..b49db781a8b 100644 --- a/qt/org.eclipse.cdt.qt.core/pom.xml +++ b/qt/org.eclipse.cdt.qt.core/pom.xml @@ -11,7 +11,7 @@ <relativePath>../../pom.xml</relativePath> </parent> - <version>2.1.0-SNAPSHOT</version> + <version>2.2.0-SNAPSHOT</version> <artifactId>org.eclipse.cdt.qt.core</artifactId> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Messages.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Messages.java index f279816ae76..9a6f0ec4f5e 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Messages.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/Messages.java @@ -4,7 +4,10 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.qt.core.messages"; //$NON-NLS-1$ + public static String QtBuildConfiguration_ConfigNotFound; + public static String QtBuildConfiguration_MakeNotFound; public static String QtBuilder_0; + public static String QtBuildTab_Name; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java index 81ca2ccd005..ba12633a2c9 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java @@ -33,6 +33,8 @@ import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.internal.qt.core.Activator; +import org.eclipse.cdt.internal.qt.core.Messages; +import org.eclipse.cdt.internal.qt.core.QtInstallManager; import org.eclipse.cdt.qt.core.IQtBuildConfiguration; import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstallListener; @@ -53,13 +55,18 @@ import org.osgi.service.prefs.Preferences; public class QtBuildConfiguration extends CBuildConfiguration implements ICBuildConfiguration, IQtBuildConfiguration, IQtInstallListener { + public static final String QMAKE_COMMAND = "cdt.qt.qmake.command"; //$NON-NLS-1$ + public static final String QMAKE_ARGS = "cdt.qt.qmake.args"; //$NON-NLS-1$ + public static final String BUILD_COMMAND = "cdt.qt.buildCommand"; //$NON-NLS-1$ + private static final String QTINSTALL_NAME = "cdt.qt.install.name"; //$NON-NLS-1$ private static final String QTINSTALL_SPEC = "cdt.qt.install.spec"; //$NON-NLS-1$ private static final String LAUNCH_MODE = "cdt.qt.launchMode"; //$NON-NLS-1$ private final String qtInstallSpec; private IQtInstall qtInstall; - private Map<String, String> properties; + private Map<String, String> qtProperties; + private boolean doFullBuild; private IEnvironmentVariable pathVar = new IEnvironmentVariable() { @Override @@ -74,7 +81,7 @@ public class QtBuildConfiguration extends CBuildConfiguration @Override public String getName() { - return "PATH"; + return "PATH"; //$NON-NLS-1$ } @Override @@ -107,7 +114,7 @@ public class QtBuildConfiguration extends CBuildConfiguration if (getQtInstall() == null) { throw new CoreException( - Activator.error(String.format("Qt Install for build configuration %s not found.", name))); + Activator.error(String.format(Messages.QtBuildConfiguration_ConfigNotFound, name))); } String oldLaunchMode = settings.get(LAUNCH_MODE, null); @@ -144,6 +151,17 @@ public class QtBuildConfiguration extends CBuildConfiguration } } + @SuppressWarnings("unchecked") + @Override + public <T> T getAdapter(Class<T> adapter) { + if (adapter.equals(IQtBuildConfiguration.class)) { + return (T) this; + } else { + return super.getAdapter(adapter); + } + } + + @Override public IQtInstall getQtInstall() { if (qtInstall == null && !qtInstallSpec.isEmpty()) { // find one that matches the spec @@ -171,6 +189,11 @@ public class QtBuildConfiguration extends CBuildConfiguration @Override public String[] getQmakeConfig() { + String qmakeArgs = getProperties().get(QMAKE_ARGS); + if (qmakeArgs != null) { + return qmakeArgs.split(" "); //$NON-NLS-1$ + } + String launchMode = getLaunchMode(); if (launchMode != null) { switch (launchMode) { @@ -217,8 +240,8 @@ public class QtBuildConfiguration extends CBuildConfiguration } } - public String getProperty(String key) { - if (properties == null) { + public String getQtProperty(String key) { + if (qtProperties == null) { List<String> cmd = new ArrayList<>(); cmd.add(getQmakeCommand().toString()); cmd.add("-E"); //$NON-NLS-1$ @@ -238,13 +261,13 @@ public class QtBuildConfiguration extends CBuildConfiguration setBuildEnvironment(processBuilder.environment()); Process proc = processBuilder.start(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) { - properties = new HashMap<>(); + qtProperties = new HashMap<>(); for (String line = reader.readLine(); line != null; line = reader.readLine()) { int i = line.indexOf('='); if (i >= 0) { String k = line.substring(0, i); String v = line.substring(i + 1); - properties.put(k.trim(), v.trim()); + qtProperties.put(k.trim(), v.trim()); } } } @@ -253,12 +276,12 @@ public class QtBuildConfiguration extends CBuildConfiguration } } - return properties != null ? properties.get(key) : null; + return qtProperties != null ? qtProperties.get(key) : null; } @Override public IEnvironmentVariable getVariable(String name) { - if ("PATH".equals(name)) { + if ("PATH".equals(name)) { //$NON-NLS-1$ return pathVar; } else { return null; @@ -274,7 +297,7 @@ public class QtBuildConfiguration extends CBuildConfiguration public IScannerInfo getScannerInformation(IResource resource) { IQtInstall qtInstall = getQtInstall(); - String cxx = getProperty("QMAKE_CXX"); //$NON-NLS-1$ + String cxx = getQtProperty("QMAKE_CXX"); //$NON-NLS-1$ if (cxx == null) { Activator.log("No QMAKE_CXX for " + qtInstall.getSpec()); //$NON-NLS-1$ return null; @@ -286,7 +309,7 @@ public class QtBuildConfiguration extends CBuildConfiguration for (int i = 1; i < cxxSplit.length; ++i) { args.add(cxxSplit[i]); } - args.addAll(Arrays.asList(getProperty("QMAKE_CXXFLAGS").split(" "))); //$NON-NLS-1$ //$NON-NLS-2$ + args.addAll(Arrays.asList(getQtProperty("QMAKE_CXXFLAGS").split(" "))); //$NON-NLS-1$ //$NON-NLS-2$ args.add("-o"); //$NON-NLS-1$ args.add("-"); //$NON-NLS-1$ @@ -300,7 +323,7 @@ public class QtBuildConfiguration extends CBuildConfiguration srcFile = "scannerInfo.cpp"; //$NON-NLS-1$ } - String[] includePaths = getProperty("INCLUDEPATH").split(" "); //$NON-NLS-1$ //$NON-NLS-2$ + String[] includePaths = getQtProperty("INCLUDEPATH").split(" "); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < includePaths.length; ++i) { Path path = Paths.get(includePaths[i]); if (!path.isAbsolute()) { @@ -330,15 +353,15 @@ public class QtBuildConfiguration extends CBuildConfiguration ConsoleOutputStream errStream = console.getErrorStream(); ConsoleOutputStream outStream = console.getOutputStream(); - Path makeCommand = getMakeCommand(); + String[] makeCommand = getMakeCommand(); if (makeCommand == null) { - errStream.write("'make' not found.\n"); + errStream.write(Messages.QtBuildConfiguration_MakeNotFound); return null; } Path buildDir = getBuildDirectory(); - if (!buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$ + if (doFullBuild || !buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$ // Need to run qmake List<String> command = new ArrayList<>(); command.add(getQmakeCommand().toString()); @@ -366,16 +389,18 @@ public class QtBuildConfiguration extends CBuildConfiguration // TODO qmake error parser watchProcess(process, new IConsoleParser[0], console); + doFullBuild = false; } try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this, getToolChain().getErrorParserIds())) { // run make - ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString(), "all") //$NON-NLS-1$ - .directory(buildDir.toFile()); + List<String> command = new ArrayList<>(Arrays.asList(makeCommand)); + command.add("all"); //$NON-NLS-1$ + ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); setBuildEnvironment(processBuilder.environment()); Process process = processBuilder.start(); - outStream.write(makeCommand.toString() + '\n'); + outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$ watchProcess(process, new IConsoleParser[] { epm }, console); } @@ -395,9 +420,9 @@ public class QtBuildConfiguration extends CBuildConfiguration ConsoleOutputStream errStream = console.getErrorStream(); ConsoleOutputStream outStream = console.getOutputStream(); - Path makeCommand = getMakeCommand(); + String[] makeCommand = getMakeCommand(); if (makeCommand == null) { - errStream.write("'make' not found.\n"); + errStream.write(Messages.QtBuildConfiguration_MakeNotFound); return; } @@ -406,11 +431,12 @@ public class QtBuildConfiguration extends CBuildConfiguration try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this, getToolChain().getErrorParserIds())) { // run make - ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString(), "clean") //$NON-NLS-1$ - .directory(buildDir.toFile()); + List<String> command = new ArrayList<>(Arrays.asList(makeCommand)); + command.add("clean"); //$NON-NLS-1$ + ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); setBuildEnvironment(processBuilder.environment()); Process process = processBuilder.start(); - outStream.write(makeCommand.toString() + "clean\n"); //$NON-NLS-1$ + outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$ watchProcess(process, new IConsoleParser[] { epm }, console); } @@ -420,12 +446,85 @@ public class QtBuildConfiguration extends CBuildConfiguration } } - public Path getMakeCommand() { - Path makeCommand = findCommand("make"); //$NON-NLS-1$ - if (makeCommand == null) { - makeCommand = findCommand("mingw32-make"); //$NON-NLS-1$ + public String[] getMakeCommand() { + String buildCommandStr = getProperties().get(BUILD_COMMAND); + if (buildCommandStr != null) { + String[] buildCommand = buildCommandStr.split(" "); //$NON-NLS-1$ + Path command = findCommand(buildCommand[0]); + if (command == null) { + command = findCommand("make"); //$NON-NLS-1$ + if (command == null) { + command = findCommand("mingw32-make"); //$NON-NLS-1$ + } + } + + if (command != null) { + buildCommand[0] = command.toString(); + } + return buildCommand; + } else { + return null; + } + + } + + @Override + public Map<String, String> getDefaultProperties() { + Map<String, String> defaults = super.getDefaultProperties(); + + String qmakeCommand = qtInstall.getQmakePath().toString(); + defaults.put(QMAKE_COMMAND, qmakeCommand); + + String qmakeArgs; + String launchMode = getLaunchMode(); + if (launchMode != null) { + switch (launchMode) { + case "run": //$NON-NLS-1$ + qmakeArgs = "CONFIG-=debug_and_release CONFIG+=release"; //$NON-NLS-1$ + break; + case "debug": //$NON-NLS-1$ + qmakeArgs = "CONFIG-=debug_and_release CONFIG+=debug"; //$NON-NLS-1$ + break; + default: + qmakeArgs = "CONFIG-=debug_and_release CONFIG+=launch_mode_" + launchMode; //$NON-NLS-1$ + } + } else { + qmakeArgs = "CONFIG+=debug_and_release CONFIG+=launch_modeall"; //$NON-NLS-1$ + } + defaults.put(QMAKE_ARGS, qmakeArgs); + + String buildCommand = "make"; //$NON-NLS-1$ + if (findCommand(buildCommand) == null) { + buildCommand = "mingw32-make"; //$NON-NLS-1$ + if (findCommand(buildCommand) == null) { + // Neither was found, default to make + buildCommand = "make"; //$NON-NLS-1$ + } + } + defaults.put(BUILD_COMMAND, buildCommand); + + return defaults; + } + + @Override + public boolean setProperties(Map<String, String> properties) { + if (super.setProperties(properties)) { + String qmakeCommand = properties.get(QMAKE_COMMAND); + if (qmakeCommand != null && !qmakeCommand.equals(qtInstall.getQmakePath().toString())) { + // TODO change the qtInstall + QtInstallManager installManager = Activator.getService(QtInstallManager.class); + IQtInstall newInstall = installManager.getInstall(Paths.get(qmakeCommand)); + if (newInstall != null) { + qtInstall = newInstall; + } + } + + // Do a full build to take in new properties + doFullBuild = true; + return true; + } else { + return false; } - return makeCommand; } } 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 c442de5da81..0a266365ce1 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 @@ -7,7 +7,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.qt.core.build; -import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -117,41 +116,4 @@ public class QtBuildConfigurationProvider implements ICBuildConfigurationProvide return null; } - // TODO this goes when the launch delegate goes - public IQtBuildConfiguration getConfiguration(IProject project, Map<String, String> properties, String launchMode, - IProgressMonitor monitor) throws CoreException { - Collection<IToolChain> toolChains = toolChainManager.getToolChainsMatching(properties); - 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())) { - for (IToolChain toolChain : toolChains) { - if (qtConfig.getToolChain().equals(toolChain)) { - return qtConfig; - } - } - } - } - } - - // Not found, create one - for (IToolChain toolChain : toolChains) { - for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { - if (qtInstallManager.supports(qtInstall, toolChain)) { - // 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; - } - } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java deleted file mode 100644 index 15034619d36..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/launch/QtLocalDebugLaunchConfigDelegate.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * 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.internal.qt.core.launch; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.concurrent.ExecutionException; - -import org.eclipse.cdt.core.build.IToolChain; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.Query; -import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; -import org.eclipse.cdt.dsf.concurrent.Sequence; -import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; -import org.eclipse.cdt.dsf.gdb.launching.GdbSourceLookupDirector; -import org.eclipse.cdt.dsf.gdb.launching.ServicesLaunchSequence; -import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; -import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; -import org.eclipse.cdt.dsf.service.DsfServicesTracker; -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.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.DebugException; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.launch.ITargetedLaunch; - -public class QtLocalDebugLaunchConfigDelegate extends QtLaunchConfigurationDelegate { - - @Override - public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target) - throws CoreException { - GdbLaunch launch = new GdbLaunch(configuration, mode, null); - launch.setLaunchTarget(target); - launch.initialize(); - - GdbSourceLookupDirector locator = new GdbSourceLookupDirector(launch.getSession()); - String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String) null); - if (memento == null) { - locator.initializeDefaults(configuration); - } else { - locator.initializeFromMemento(memento, configuration); - } - - launch.setSourceLocator(locator); - return launch; - } - - @Override - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) - throws CoreException { - GdbLaunch gdbLaunch = (GdbLaunch) launch; - ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); - IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); - - IToolChain toolChain = qtBuildConfig.getToolChain(); - gdbLaunch.setGDBPath(toolChain.getCommandPath(Paths.get("gdb")).toString()); //$NON-NLS-1$ - String gdbVersion = gdbLaunch.getGDBVersion(); - - Path exeFile = qtBuildConfig.getProgramPath(); - gdbLaunch.setProgramPath(exeFile.toString()); - - gdbLaunch.setServiceFactory(new GdbDebugServicesFactory(gdbVersion, configuration)); - - Sequence servicesLaunchSequence = new ServicesLaunchSequence(gdbLaunch.getSession(), gdbLaunch, monitor); - gdbLaunch.getSession().getExecutor().execute(servicesLaunchSequence); - try { - servicesLaunchSequence.get(); - } catch (InterruptedException | ExecutionException e) { - throw new DebugException(new Status(IStatus.ERROR, Activator.ID, "Failure launching with gdb", e)); - } - - gdbLaunch.initializeControl(); - - gdbLaunch.addCLIProcess(gdbLaunch.getGDBPath().toOSString() + " (" + gdbVersion + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - - Query<Object> ready = new Query<Object>() { - @Override - protected void execute(final DataRequestMonitor<Object> rm) { - DsfServicesTracker tracker = new DsfServicesTracker( - Activator.getDefault().getBundle().getBundleContext(), gdbLaunch.getSession().getId()); - IGDBControl control = tracker.getService(IGDBControl.class); - tracker.dispose(); - control.completeInitialization( - new RequestMonitorWithProgress(ImmediateExecutor.getInstance(), monitor) { - @Override - protected void handleCompleted() { - if (isCanceled()) { - rm.cancel(); - } else { - rm.setStatus(getStatus()); - } - rm.done(); - } - }); - } - }; - - // Start it up - gdbLaunch.getSession().getExecutor().execute(ready); - try { - ready.get(); - } catch (ExecutionException | InterruptedException e) { - throw new DebugException(new Status(IStatus.ERROR, Activator.ID, "Failure to start debug session", e)); - } - } - -} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/messages.properties b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/messages.properties index f0d9d351b15..2c7efdfea3d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/messages.properties +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/messages.properties @@ -1 +1,4 @@ +QtBuildConfiguration_ConfigNotFound=Qt Install for build configuration %s not found. +QtBuildConfiguration_MakeNotFound='make' not found.\n QtBuilder_0=Error: Qt has not been configured.\nPlease add a Qt install in the Qt preferences page.\n +QtBuildTab_Name=Qt Build 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 3c429001412..024a91a9688 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 @@ -12,6 +12,11 @@ import java.nio.file.Path; import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.core.runtime.CoreException;
+/**
+ * Qt specific build configuration settings.
+ *
+ * @noimplement
+ */
public interface IQtBuildConfiguration extends ICBuildConfiguration {
Path getBuildDirectory() throws CoreException;
@@ -28,4 +33,6 @@ public interface IQtBuildConfiguration extends ICBuildConfiguration { String getLaunchMode();
+ IQtInstall getQtInstall();
+
}
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java deleted file mode 100644 index 998546284d7..00000000000 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java +++ /dev/null @@ -1,86 +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 org.eclipse.cdt.core.build.ICBuildConfigurationManager; -import org.eclipse.cdt.core.build.IToolChain; -import org.eclipse.cdt.internal.qt.core.Activator; -import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationProvider; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -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.ILaunchConfiguration; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate; - -public abstract class QtLaunchConfigurationDelegate extends LaunchConfigurationTargetedDelegate { - - @Override - public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target, - IProgressMonitor monitor) throws CoreException { - IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor); - - // If found, set as active, if not just return - if (qtBuildConfig != null) { - IProject project = qtBuildConfig.getBuildConfiguration().getProject(); - IProjectDescription desc = project.getDescription(); - desc.setActiveBuildConfig(qtBuildConfig.getBuildConfiguration().getName()); - project.setDescription(desc, monitor); - return superBuildForLaunch(configuration, mode, monitor); - } else { - return false; - } - } - - @Override - protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { - // 1. Extract project from configuration - // TODO dependencies too. - IProject project = configuration.getMappedResources()[0].getProject(); - return new IProject[] { project }; - } - - protected void populateToolChainProperties(ILaunchTarget target, Map<String, String> properties) { - String os = target.getAttribute(ILaunchTarget.ATTR_OS, null); - if (os != null) { - properties.put(IToolChain.ATTR_OS, os.toLowerCase()); - } - String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, null); - if (arch != null) { - properties.put(IToolChain.ATTR_ARCH, arch.toLowerCase()); - } - } - - protected IQtBuildConfiguration getQtBuildConfiguration(ILaunchConfiguration configuration, String mode, - ILaunchTarget target, IProgressMonitor monitor) throws CoreException { - // Find the Qt build config - ICBuildConfigurationManager configManager = Activator.getService(ICBuildConfigurationManager.class); - QtBuildConfigurationProvider provider = (QtBuildConfigurationProvider) configManager - .getProvider(QtBuildConfigurationProvider.ID); - IProject project = configuration.getMappedResources()[0].getProject(); - - Map<String, String> properties = new HashMap<>(); - populateToolChainProperties(target, properties); - - IQtBuildConfiguration qtConfig = provider.getConfiguration(project, properties, mode, monitor); - if (qtConfig != null) { - return qtConfig; - } - - // Couldn't find any - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, - String.format("No suitable SDK found for target %s.", target.getId()))); - } - -} diff --git a/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF index 238a0518e34..83d562f3ad2 100644 --- a/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF +++ b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF @@ -21,7 +21,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.tools.templates.ui;bundle-version="1.0.0", org.eclipse.launchbar.core;bundle-version="2.0.0", org.eclipse.launchbar.ui;bundle-version="2.0.0", - org.eclipse.tools.templates.freemarker;bundle-version="1.0.0" + org.eclipse.tools.templates.freemarker;bundle-version="1.0.0", + org.eclipse.cdt.launch;bundle-version="9.1.0", + org.eclipse.cdt.debug.core;bundle-version="8.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.internal.qt.ui.assist;x-friends:="org.eclipse.cdt.qt.ui.tests", diff --git a/qt/org.eclipse.cdt.qt.ui/plugin.xml b/qt/org.eclipse.cdt.qt.ui/plugin.xml index a366ec0d587..c301bbb42ca 100644 --- a/qt/org.eclipse.cdt.qt.ui/plugin.xml +++ b/qt/org.eclipse.cdt.qt.ui/plugin.xml @@ -149,4 +149,11 @@ id="org.eclipse.cdt.qt.core.launchConfigurationType.image"> </launchConfigurationTypeImage> </extension> + <extension + point="org.eclipse.cdt.launch.coreBuildTab"> + <provider + nature="org.eclipse.cdt.qt.core.qtNature" + tabClass="org.eclipse.cdt.internal.qt.ui.launch.QtBuildTab"> + </provider> + </extension> </plugin> diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/Messages.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/Messages.java index 4d5c663e07b..1c53e610422 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/Messages.java +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/Messages.java @@ -21,6 +21,10 @@ public class Messages extends NLS { public static String NewQtInstallWizardPage_5; public static String NewQtInstallWizardPage_8; public static String NewQtInstallWizardPage_9; + public static String QtBuildTab_buildCommand; + public static String QtBuildTab_Name; + public static String QtBuildTab_qmakeArgs; + public static String QtBuildTab_qmakeCommand; public static String QtPreferencePage_0; public static String QtPreferencePage_1; public static String QtPreferencePage_2; diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/launch/QtBuildTab.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/launch/QtBuildTab.java new file mode 100644 index 00000000000..7430c6cf653 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/launch/QtBuildTab.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * 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.internal.qt.ui.launch; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate; +import org.eclipse.cdt.internal.qt.core.build.QtBuildConfiguration; +import org.eclipse.cdt.internal.qt.ui.Activator; +import org.eclipse.cdt.internal.qt.ui.Messages; +import org.eclipse.cdt.launch.ui.corebuild.CommonBuildTab; +import org.eclipse.cdt.qt.core.IQtInstall; +import org.eclipse.cdt.qt.core.IQtInstallManager; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class QtBuildTab extends CommonBuildTab { + + Combo qmakeCombo; + Text qmakeArgsText; + Text buildCmdText; + + @Override + public void createControl(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new GridLayout(2, false)); + setControl(comp); + + Label label = new Label(comp, SWT.NONE); + label.setText(Messages.QtBuildTab_qmakeCommand); + + qmakeCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY); + qmakeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + label = new Label(comp, SWT.NONE); + label.setText(Messages.QtBuildTab_qmakeArgs); + + qmakeArgsText = new Text(comp, SWT.BORDER); + qmakeArgsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + label = new Label(comp, SWT.NONE); + label.setText(Messages.QtBuildTab_buildCommand); + + buildCmdText = new Text(comp, SWT.BORDER); + buildCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + try { + String mode = getLaunchConfigurationDialog().getMode(); + configuration.setAttribute(CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode), + getBuildConfiguration(configuration).getDefaultProperties()); + } catch (CoreException e) { + Activator.log(e); + } + } + + private Map<String, String> getProperties(ILaunchConfiguration configuration) throws CoreException { + String mode = getLaunchConfigurationDialog().getMode(); + Map<String, String> properties = configuration + .getAttribute(CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode), new HashMap<>()); + if (properties.isEmpty()) { + properties = getBuildConfiguration(configuration).getProperties(); + } + + return properties; + } + + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + try { + Map<String, String> properties = getProperties(configuration); + + // qmake command + IToolChainManager tcManager = Activator.getService(IToolChainManager.class); + IQtInstallManager qtManager = Activator.getService(IQtInstallManager.class); + ILaunchTarget target = getLaunchTarget(); + + String qmakeCmd = properties.get(QtBuildConfiguration.QMAKE_COMMAND); + qmakeCombo.removeAll(); + Collection<IToolChain> toolChains = tcManager.getToolChainsMatching(target.getAttributes()); + int select = -1; + for (IQtInstall qtInstall : qtManager.getInstalls()) { + for (IToolChain toolChain : toolChains) { + if (qtManager.supports(qtInstall, toolChain)) { + qmakeCombo.add(qtInstall.getQmakePath().toString()); + if (qmakeCmd != null && qmakeCmd.equals(qtInstall.getQmakePath().toString())) { + select = qmakeCombo.getItemCount() - 1; + } + break; + } + } + } + + if (select != -1) { + qmakeCombo.select(select); + } + + // qmake args + String qmakeArgs = properties.get(QtBuildConfiguration.QMAKE_ARGS); + if (qmakeArgs != null) { + qmakeArgsText.setText(qmakeArgs); + } + + // build command + String buildCommand = properties.get(QtBuildConfiguration.BUILD_COMMAND); + if (buildCommand != null) { + buildCmdText.setText(buildCommand); + } + } catch (CoreException e) { + Activator.log(e); + } + } + + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + try { + Map<String, String> properties = new HashMap<>(getProperties(configuration)); + properties.put(QtBuildConfiguration.QMAKE_COMMAND, qmakeCombo.getItem(qmakeCombo.getSelectionIndex())); + properties.put(QtBuildConfiguration.QMAKE_ARGS, qmakeArgsText.getText().trim()); + properties.put(QtBuildConfiguration.BUILD_COMMAND, buildCmdText.getText().trim()); + + String mode = getLaunchBarLaunchConfigDialog().getMode(); + configuration.setAttribute(CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode), properties); + } catch (CoreException e) { + Activator.log(e); + } + } + + @Override + public String getName() { + return Messages.QtBuildTab_Name; + } + +} diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/messages.properties b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/messages.properties index 2f96228e735..afe942b2405 100644 --- a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/messages.properties +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/internal/qt/ui/messages.properties @@ -8,6 +8,10 @@ NewQtInstallWizardPage_4=Browse... NewQtInstallWizardPage_5=Select location of qmake NewQtInstallWizardPage_8=Get Qt Spec NewQtInstallWizardPage_9=mkspec: +QtBuildTab_buildCommand=Build command: +QtBuildTab_Name=Qt Build +QtBuildTab_qmakeArgs=qmake arguments: +QtBuildTab_qmakeCommand=qmake command: QtPreferencePage_0=Qt Installs QtPreferencePage_1=Location QtPreferencePage_2=mkspec |