mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 481978 - Lots of clean-up to the Qt Build and Launch.
Especially launch. Now have local and QNX launches (which are in our internal repo) working. Change-Id: I97bacc520cc6806fe9622700b2bb3f544e4aad94
This commit is contained in:
parent
5656acd253
commit
3dd8f57dcf
14 changed files with 160 additions and 86 deletions
|
@ -153,7 +153,7 @@
|
|||
</enablement>
|
||||
</descriptorType>
|
||||
<configProvider
|
||||
class="org.eclipse.cdt.internal.qt.core.launch.QtLocalLaunchConfigProvider"
|
||||
class="org.eclipse.cdt.internal.qt.core.launch.QtLocalLaunchConfigationProvider"
|
||||
descriptorType="org.eclipse.cdt.qt.core.launchDescriptorType"
|
||||
priority="10">
|
||||
</configProvider>
|
||||
|
@ -181,7 +181,7 @@
|
|||
adaptableType="org.eclipse.core.resources.IBuildConfiguration"
|
||||
class="org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory">
|
||||
<adapter
|
||||
type="org.eclipse.cdt.internal.qt.core.build.QtBuildConfiguration">
|
||||
type="org.eclipse.cdt.qt.core.QtBuildConfiguration">
|
||||
</adapter>
|
||||
</factory>
|
||||
</extension>
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.internal.qt.core.Activator;
|
|||
import org.eclipse.cdt.internal.qt.core.QtNature;
|
||||
import org.eclipse.cdt.qt.core.IQtInstall;
|
||||
import org.eclipse.cdt.qt.core.IQtInstallManager;
|
||||
import org.eclipse.cdt.qt.core.QtBuildConfiguration;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
|
|
|
@ -14,7 +14,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.build.core.IConsoleService;
|
||||
import org.eclipse.cdt.build.core.IToolChain;
|
||||
import org.eclipse.cdt.internal.qt.core.Activator;
|
||||
import org.eclipse.cdt.qt.core.QtBuildConfiguration;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -35,6 +37,7 @@ public class QtBuilder extends IncrementalProjectBuilder {
|
|||
try {
|
||||
IConsoleService console = Activator.getService(IConsoleService.class);
|
||||
QtBuildConfiguration qtConfig = getBuildConfig().getAdapter(QtBuildConfiguration.class);
|
||||
IToolChain toolChain = qtConfig.getToolChain();
|
||||
|
||||
Path buildDir = qtConfig.getBuildDirectory();
|
||||
if (!buildDir.resolve("Makefile").toFile().exists()) { //$NON-NLS-1$
|
||||
|
@ -50,7 +53,9 @@ public class QtBuilder extends IncrementalProjectBuilder {
|
|||
IFile projectFile = qtConfig.getProject().getFile("main.pro");
|
||||
command.add(projectFile.getLocation().toOSString());
|
||||
|
||||
Process process = new ProcessBuilder(command).directory(buildDir.toFile()).start();
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
|
||||
toolChain.setEnvironment(processBuilder.environment());
|
||||
Process process = processBuilder.start();
|
||||
StringBuffer msg = new StringBuffer();
|
||||
for (String arg : command) {
|
||||
msg.append(arg).append(' ');
|
||||
|
@ -72,6 +77,7 @@ public class QtBuilder extends IncrementalProjectBuilder {
|
|||
path = "C:/Qt/Tools/mingw492_32/bin;" + path;
|
||||
env.put("PATH", path);
|
||||
}
|
||||
toolChain.setEnvironment(procBuilder.environment());
|
||||
Process process = procBuilder.start();
|
||||
console.writeOutput("make\n"); //$NON-NLS-1$
|
||||
console.monitor(process, null, buildDir);
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.internal.qt.core.Activator;
|
||||
import org.eclipse.cdt.qt.core.QtBuildConfiguration;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
*******************************************************************************/
|
||||
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.ILaunchDescriptor;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
||||
|
||||
public class QtLaunchDescriptor extends PlatformObject implements ILaunchDescriptor {
|
||||
public class QtLaunchDescriptor extends PlatformObject implements IQtLaunchDescriptor {
|
||||
|
||||
private final QtLaunchDescriptorType type;
|
||||
private final IProject project;
|
||||
|
@ -32,6 +32,7 @@ public class QtLaunchDescriptor extends PlatformObject implements ILaunchDescrip
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,10 +13,8 @@ import java.nio.file.Path;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.qt.core.Activator;
|
||||
import org.eclipse.cdt.internal.qt.core.build.QtBuildConfiguration;
|
||||
import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.cdt.qt.core.QtBuildConfiguration;
|
||||
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;
|
||||
|
@ -28,20 +26,11 @@ 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;
|
||||
import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate;
|
||||
import org.eclipse.launchbar.core.target.launch.TargetedLaunch;
|
||||
|
||||
public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationTargetedDelegate {
|
||||
public class QtLocalRunLaunchConfigDelegate extends QtLaunchConfigurationDelegate {
|
||||
|
||||
public static final String TYPE_ID = Activator.ID + ".launchConfigurationType"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
// TODO sourcelocator?
|
||||
return new TargetedLaunch(configuration, mode, target, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
|
@ -111,34 +100,4 @@ public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationTargetedD
|
|||
}.schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor);
|
||||
|
||||
// Set it as active
|
||||
IProject project = qtBuildConfig.getProject();
|
||||
IProjectDescription desc = project.getDescription();
|
||||
desc.setActiveBuildConfig(qtBuildConfig.getBuildConfiguration().getName());
|
||||
project.setDescription(desc, monitor);
|
||||
|
||||
// And build
|
||||
return superBuildForLaunch(configuration, mode, monitor);
|
||||
}
|
||||
|
||||
@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 };
|
||||
}
|
||||
|
||||
private QtBuildConfiguration getQtBuildConfiguration(ILaunchConfiguration configuration, String mode,
|
||||
ILaunchTarget target, IProgressMonitor monitor) throws CoreException {
|
||||
// Find the Qt build config
|
||||
IProject project = configuration.getMappedResources()[0].getProject();
|
||||
return QtBuildConfigurationFactory.getConfig(project, mode, target, monitor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package org.eclipse.cdt.qt.core;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||
|
||||
public interface IQtLaunchDescriptor extends ILaunchDescriptor {
|
||||
|
||||
IProject getProject();
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.qt.core.build;
|
||||
package org.eclipse.cdt.qt.core;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -27,8 +27,6 @@ import org.eclipse.cdt.core.model.LanguageManager;
|
|||
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.internal.qt.core.Activator;
|
||||
import org.eclipse.cdt.qt.core.IQtInstall;
|
||||
import org.eclipse.cdt.qt.core.IQtInstallManager;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -154,7 +152,9 @@ public class QtBuildConfiguration extends CBuildConfiguration {
|
|||
cmd.add(getProjectFile().toString());
|
||||
|
||||
try {
|
||||
Process proc = new ProcessBuilder(cmd).directory(getBuildDirectory().toFile()).start();
|
||||
ProcessBuilder procBuilder = new ProcessBuilder(cmd).directory(getProjectFile().getParent().toFile());
|
||||
getToolChain().setEnvironment(procBuilder.environment());
|
||||
Process proc = procBuilder.start();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
|
||||
properties = new HashMap<>();
|
||||
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
||||
|
@ -179,6 +179,10 @@ public class QtBuildConfiguration extends CBuildConfiguration {
|
|||
IScannerInfo info = super.getScannerInfo(resource);
|
||||
if (info == null) {
|
||||
String cxx = getProperty("QMAKE_CXX"); //$NON-NLS-1$
|
||||
if (cxx == null) {
|
||||
Activator.log("No QMAKE_CXX for " + qtInstall.getSpec()); //$NON-NLS-1$
|
||||
return null;
|
||||
}
|
||||
String[] cxxSplit = cxx.split(" "); //$NON-NLS-1$
|
||||
String command = cxxSplit[0];
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* 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 org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationFactory;
|
||||
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.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 {
|
||||
QtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor);
|
||||
|
||||
// Set it as active
|
||||
IProject project = qtBuildConfig.getProject();
|
||||
IProjectDescription desc = project.getDescription();
|
||||
desc.setActiveBuildConfig(qtBuildConfig.getBuildConfiguration().getName());
|
||||
project.setDescription(desc, monitor);
|
||||
|
||||
// And build
|
||||
return superBuildForLaunch(configuration, mode, monitor);
|
||||
}
|
||||
|
||||
@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 QtBuildConfiguration getQtBuildConfiguration(ILaunchConfiguration configuration, String mode,
|
||||
ILaunchTarget target, IProgressMonitor monitor) throws CoreException {
|
||||
// Find the Qt build config
|
||||
IProject project = configuration.getMappedResources()[0].getProject();
|
||||
return QtBuildConfigurationFactory.getConfig(project, mode, target, monitor);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* 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;
|
||||
package org.eclipse.cdt.qt.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
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;
|
||||
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 QtLocalLaunchConfigProvider extends AbstractLaunchConfigProvider {
|
||||
public abstract class QtLaunchConfigurationProvider extends AbstractLaunchConfigProvider {
|
||||
|
||||
private Map<IProject, ILaunchConfiguration> configs = new HashMap<>();
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
|
||||
throws CoreException {
|
||||
ILaunchConfiguration config = configs.get(descriptor);
|
||||
if (config == null) {
|
||||
config = createLaunchConfiguration(descriptor, target);
|
||||
configs.put(descriptor.getAdapter(IProject.class), config);
|
||||
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;
|
||||
}
|
||||
|
@ -67,7 +47,9 @@ public class QtLocalLaunchConfigProvider extends AbstractLaunchConfigProvider {
|
|||
@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;
|
||||
}
|
|
@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.ui.editors,
|
||||
org.eclipse.ui.workbench.texteditor,
|
||||
org.eclipse.jface.text,
|
||||
org.eclipse.debug.ui;bundle-version="3.11.100",
|
||||
org.eclipse.cdt.ui,
|
||||
org.eclipse.cdt.core,
|
||||
org.eclipse.cdt.qt.core
|
||||
|
|
|
@ -80,4 +80,12 @@
|
|||
name="%preferences.qt.name">
|
||||
</page>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
||||
<launchConfigurationTabGroup
|
||||
class="org.eclipse.cdt.internal.qt.ui.launch.QtLocalLaunchConfigurationTabGroup"
|
||||
id="org.eclipse.cdt.qt.ui.launchConfigurationTabGroup"
|
||||
type="org.eclipse.cdt.qt.core.launchConfigurationType">
|
||||
</launchConfigurationTabGroup>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.eclipse.cdt.internal.qt.ui.launch;
|
||||
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
|
||||
public class QtLocalLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||
|
||||
@Override
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||
setTabs(new ILaunchConfigurationTab[0]);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue