1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Implement Qt build tab for the launch config dialog.

Make sure Core Build handles the properties set by these tabs
correctly. A bunch of string externalization too.

Change-Id: I54a61b4d2520a0952c43608169747e792826062e
This commit is contained in:
Doug Schaefer 2016-11-11 13:10:16 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent c31b45b5cc
commit 03051c91ab
38 changed files with 543 additions and 315 deletions

View file

@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.tools.templates.ui;bundle-version="1.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"
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
Bundle-Localization: plugin

View file

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.cmake.core.internal.CMakeBuildConfiguration;
import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@ -33,13 +34,13 @@ public class CMakeBuildTab extends AbstractLaunchConfigurationTab {
setControl(comp);
Label label = new Label(comp, SWT.NONE);
label.setText("Generator");
label.setText(Messages.CMakeBuildTab_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.setText(Messages.CMakeBuildTab_UnixMakefiles);
unixGenButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -48,7 +49,7 @@ public class CMakeBuildTab extends AbstractLaunchConfigurationTab {
});
ninjaGenButton = new Button(genComp, SWT.RADIO);
ninjaGenButton.setText("Ninja");
ninjaGenButton.setText(Messages.CMakeBuildTab_Ninja);
ninjaGenButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -57,21 +58,21 @@ public class CMakeBuildTab extends AbstractLaunchConfigurationTab {
});
label = new Label(comp, SWT.NONE);
label.setText("Additional CMake arguments:");
label.setText(Messages.CMakeBuildTab_CMakeArgs);
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");
label.setText(Messages.CMakeBuildTab_BuildCommand);
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");
label.setText(Messages.CMakeBuildTab_CleanCommand);
cleanCommandText = new Text(comp, SWT.BORDER);
cleanCommandText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
@ -151,17 +152,18 @@ public class CMakeBuildTab extends AbstractLaunchConfigurationTab {
properties.put(CMakeBuildConfiguration.CLEAN_COMMAND, cleanCommand);
}
String mode = getLaunchConfigurationDialog().getMode();
String buildAttribute = CoreBuildLaunchConfigDelegate
.getBuildAttributeName(getLaunchConfigurationDialog().getMode());
if (!properties.isEmpty()) {
configuration.setAttribute("COREBUILD_" + mode, properties); //$NON-NLS-1$
configuration.setAttribute(buildAttribute, properties);
} else {
configuration.removeAttribute("COREBUILD_" + mode); //$NON-NLS-1$
configuration.removeAttribute(buildAttribute);
}
}
@Override
public String getName() {
return "CMake";
return Messages.CMakeBuildTab_Cmake;
}
}

View file

@ -4,6 +4,13 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.ui.properties.messages"; //$NON-NLS-1$
public static String CMakeBuildTab_BuildCommand;
public static String CMakeBuildTab_CleanCommand;
public static String CMakeBuildTab_Cmake;
public static String CMakeBuildTab_CMakeArgs;
public static String CMakeBuildTab_Generator;
public static String CMakeBuildTab_Ninja;
public static String CMakeBuildTab_UnixMakefiles;
public static String CMakePropertyPage_FailedToStartCMakeGui_Body;
public static String CMakePropertyPage_FailedToStartCMakeGui_Title;
public static String CMakePropertyPage_LaunchCMakeGui;

View file

@ -1,3 +1,10 @@
CMakeBuildTab_BuildCommand=Build command
CMakeBuildTab_CleanCommand=Clean command
CMakeBuildTab_Cmake=CMake
CMakeBuildTab_CMakeArgs=Additional CMake arguments:
CMakeBuildTab_Generator=Generator
CMakeBuildTab_Ninja=Ninja
CMakeBuildTab_UnixMakefiles=Unix Makefiles
CMakePropertyPage_FailedToStartCMakeGui_Body=Failed to run the CMake GUI:
CMakePropertyPage_FailedToStartCMakeGui_Title=Failed to run CMake GUI
CMakePropertyPage_LaunchCMakeGui=Launch CMake GUI...

View file

@ -24,6 +24,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -48,6 +49,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IncludeExportPatterns;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.core.build.Messages;
import org.eclipse.cdt.internal.core.model.BinaryRunner;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.internal.core.parser.ParserSettings2;
@ -127,7 +129,7 @@ public abstract class CBuildConfiguration extends PlatformObject
tc = tcs.iterator().next();
} else {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
String.format("Toolchain missing for config: %s", config.getName())));
String.format(Messages.CBuildConfigurationtoolchainMissing, config.getName())));
}
}
toolChain = tc;
@ -720,8 +722,13 @@ public abstract class CBuildConfiguration extends PlatformObject
* @since 6.2
*/
@Override
public void setProperties(Map<String, String> properties) {
this.properties = properties;
public boolean setProperties(Map<String, String> properties) {
if (this.properties == null || !this.properties.equals(properties)) {
this.properties = properties;
return true;
} else {
return false;
}
}
/**
@ -729,7 +736,18 @@ public abstract class CBuildConfiguration extends PlatformObject
*/
@Override
public Map<String, String> getProperties() {
return properties != null ? properties : new HashMap<>();
if (properties == null) {
properties = getDefaultProperties();
}
return Collections.unmodifiableMap(properties);
}
/**
* @since 6.2
*/
@Override
public Map<String, String> getDefaultProperties() {
return new HashMap<>();
}
}

View file

@ -34,7 +34,7 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider {
* CDT doesn't like that the Platform default config name is an empty string.
* It needs a real name for the name of the build directory, for example.
*/
public static String DEFAULT_NAME = "default";
public static String DEFAULT_NAME = "default"; //$NON-NLS-1$
/**
* Returns the resources build configuration that this CDT build
@ -134,9 +134,11 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider {
*
* @param properties
* build properties
* @return whether the properties have changed
* @since 6.2
*/
default void setProperties(Map<String, String> properties) {
default boolean setProperties(Map<String, String> properties) {
return false;
}
/**
@ -146,6 +148,15 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider {
* @since 6.2
*/
default Map<String, String> getProperties() {
return getDefaultProperties();
}
/**
* Returns the default values for the properties.
*
* @since 6.2
*/
default Map<String, String> getDefaultProperties() {
return new HashMap<>();
}

View file

@ -7,6 +7,8 @@
*******************************************************************************/
package org.eclipse.cdt.core.build;
import java.util.Map;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@ -59,6 +61,23 @@ public interface ICBuildConfigurationManager {
ICBuildConfiguration getBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
IProgressMonitor monitor) throws CoreException;
/**
* Create a new build configuration for a given project using a toolchain
* with the given properties and that builds for a given launch mode.
*
* @param project
* project for the config
* @param properties
* properties for the toolchain to be selected
* @param launchMode
* launch mode the buld config will build for
* @return new build configuration
* @throws CoreException
* @since 6.2
*/
ICBuildConfiguration getBuildConfiguration(IProject project, Map<String, String> properties,
String launchMode, IProgressMonitor monitor) throws CoreException;
/**
* Called by providers to add new build configurations as they are created.
*

View file

@ -13,6 +13,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@ -24,6 +25,7 @@ import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
@ -229,6 +231,19 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
}
}
@Override
public ICBuildConfiguration getBuildConfiguration(IProject project, Map<String, String> properties,
String launchMode, IProgressMonitor monitor) throws CoreException {
IToolChainManager tcManager = CCorePlugin.getService(IToolChainManager.class);
Collection<IToolChain> toolchains = tcManager.getToolChainsMatching(properties);
if (toolchains.isEmpty()) {
return null;
}
IToolChain toolChain = toolchains.iterator().next();
return getBuildConfiguration(project, toolChain, launchMode, monitor);
}
@Override
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.PRE_CLOSE

View file

@ -0,0 +1,15 @@
package org.eclipse.cdt.internal.core.build;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.build.Messages"; //$NON-NLS-1$
public static String CBuildConfigurationtoolchainMissing;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1 @@
CBuildConfigurationtoolchainMissing=Toolchain missing for config: %s

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.utils.Platform;
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
@ -33,13 +33,13 @@ import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDeleg
*
* @since 8.1
*/
public abstract class CoreBuildLocalLaunchConfigDelegate extends LaunchConfigurationTargetedDelegate {
public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationTargetedDelegate {
protected ICBuildConfigurationManager configManager = CDebugCorePlugin
.getService(ICBuildConfigurationManager.class);
protected IToolChainManager toolChainManager = CDebugCorePlugin.getService(IToolChainManager.class);
protected IProject getProject(ILaunchConfiguration configuration) throws CoreException {
public static IProject getProject(ILaunchConfiguration configuration) throws CoreException {
// TODO - make sure this is really the correct project
return configuration.getMappedResources()[0].getProject();
}
@ -48,8 +48,7 @@ public abstract class CoreBuildLocalLaunchConfigDelegate extends LaunchConfigura
IProgressMonitor monitor) throws CoreException {
// Pick build config based on toolchain for target
Map<String, String> properties = new HashMap<>();
properties.put(IToolChain.ATTR_OS, Platform.getOS());
properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
properties.putAll(target.getAttributes());
Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
if (!tcs.isEmpty()) {
IToolChain toolChain = tcs.iterator().next();
@ -69,7 +68,7 @@ public abstract class CoreBuildLocalLaunchConfigDelegate extends LaunchConfigura
}
}
if (exeFile == null) {
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, "No binaries"));
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, InternalDebugCoreMessages.CoreBuildLaunchConfigDelegate_noBinaries));
}
return exeFile;
}
@ -82,6 +81,10 @@ public abstract class CoreBuildLocalLaunchConfigDelegate extends LaunchConfigura
return new IProject[] { project };
}
public static String getBuildAttributeName(String mode) {
return "COREBUILD_" + mode; //$NON-NLS-1$
}
@Override
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
IProgressMonitor monitor) throws CoreException {
@ -92,10 +95,9 @@ public abstract class CoreBuildLocalLaunchConfigDelegate extends LaunchConfigura
desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
project.setDescription(desc, monitor);
Map<String, String> buildProps = configuration.getAttribute("COREBUILD_" + mode, new HashMap<>()); //$NON-NLS-1$
if (!buildProps.isEmpty()) {
buildConfig.setProperties(buildProps);
}
Map<String, String> buildProps = configuration.getAttribute(getBuildAttributeName(mode),
buildConfig.getDefaultProperties());
buildConfig.setProperties(buildProps);
}
// proceed with the build

View file

@ -27,6 +27,8 @@ public class InternalDebugCoreMessages extends NLS {
public static String CDebugAdapter_0;
public static String CDebugAdapter_1;
public static String CDebugAdapter_Program_file_not_specified;
public static String CoreBuildLaunchConfigDelegate_noBinaries;
public static String CoreBuildLocalRunLaunchDelegate_ErrorLaunching;
public static String CRegisterManager_0;
public static String CRegisterManager_1;
public static String StringSubstitutionEngine_undefined_variable;

View file

@ -21,6 +21,8 @@ DebugConfiguration_0=This debugger no longer supports this operation
CDebugAdapter_0=This debugger does not support debugging external files
CDebugAdapter_1=Debugger Process
CDebugAdapter_Program_file_not_specified=Program file not specified
CoreBuildLaunchConfigDelegate_noBinaries=No binaries
CoreBuildLocalRunLaunchDelegate_ErrorLaunching=Error launching
CRegisterManager_0=Unable to restore register groups - invalid memento.
CRegisterManager_1=Unable to restore register groups - expecting register group list element.
StringSubstitutionEngine_undefined_variable=Reference to undefined variable {0}

View file

@ -13,7 +13,8 @@ import java.nio.file.Paths;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.launch.CoreBuildLocalLaunchConfigDelegate;
import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@ -25,7 +26,7 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLocalLaunchConfigDelegate {
public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLaunchConfigDelegate {
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
@ -42,7 +43,7 @@ public class CoreBuildLocalRunLaunchDelegate extends CoreBuildLocalLaunchConfigD
Process process = builder.start();
DebugPlugin.newProcess(launch, process, exeFile.getPath().lastSegment());
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, "Error launching", e));
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, InternalDebugCoreMessages.CoreBuildLocalRunLaunchDelegate_ErrorLaunching, e));
}
}

View file

@ -16,6 +16,10 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
public static String CoreBuildLocalDebugLaunchDelegate_FailureLaunching;
public static String CoreBuildLocalDebugLaunchDelegate_FailureStart;
public static String CustomTimeoutsMap_Error_initializing_custom_timeouts;
public static String CustomTimeoutsMap_Invalid_custom_timeout_data;

View file

@ -9,7 +9,8 @@
# Mentor Graphics - Initial API and implementation
# Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection
#######################################################################################
CoreBuildLocalDebugLaunchDelegate_FailureStart=Failure to start debug session
CoreBuildLocalDebugLaunchDelegate_FailureLaunching=Failure launching with gdb
CustomTimeoutsMap_Error_initializing_custom_timeouts=Error initializing custom timeouts
CustomTimeoutsMap_Invalid_custom_timeout_data=Invalid custom timeout data.
CustomTimeoutsMap_Invalid_custom_timeout_value=Invalid custom timeout value for '%s'.

View file

@ -16,13 +16,14 @@ import java.util.concurrent.ExecutionException;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.debug.core.launch.CoreBuildLocalLaunchConfigDelegate;
import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
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.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.internal.Messages;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.launching.GdbSourceLookupDirector;
import org.eclipse.cdt.dsf.gdb.launching.ServicesLaunchSequence;
@ -40,7 +41,7 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLocalLaunchConfigDelegate {
public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLaunchConfigDelegate {
@Override
public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
@ -76,7 +77,8 @@ public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLocalLaunchConfi
gdbLaunch.setInitialEnvironment(envProps);
IToolChain toolChain = buildConfig.getToolChain();
gdbLaunch.setGDBPath(toolChain.getCommandPath(Paths.get("gdb")).toString()); //$NON-NLS-1$
Path gdbPath = toolChain.getCommandPath(Paths.get("gdb")); //$NON-NLS-1$
gdbLaunch.setGDBPath(gdbPath != null ? gdbPath.toString() : "gdb"); //$NON-NLS-1$
String gdbVersion = gdbLaunch.getGDBVersion();
Path exeFile = Paths.get(getBinary(buildConfig).getLocationURI());
@ -89,7 +91,7 @@ public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLocalLaunchConfi
try {
servicesLaunchSequence.get();
} catch (InterruptedException | ExecutionException e) {
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Failure launching with gdb", e));
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, Messages.CoreBuildLocalDebugLaunchDelegate_FailureLaunching, e));
}
gdbLaunch.initializeControl();
@ -123,7 +125,7 @@ public class CoreBuildLocalDebugLaunchDelegate extends CoreBuildLocalLaunchConfi
try {
ready.get();
} catch (ExecutionException | InterruptedException e) {
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Failure to start debug session", e));
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, Messages.CoreBuildLocalDebugLaunchDelegate_FailureStart, e));
}
}

View file

@ -8,9 +8,11 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.launch,
org.eclipse.cdt.launch.internal;x-internal:=true,
org.eclipse.cdt.launch.internal.corebuild;x-internal:=true,
org.eclipse.cdt.launch.internal.refactoring;x-internal:=true,
org.eclipse.cdt.launch.internal.ui;x-friends:="org.eclipse.cdt.debug.edc.ui",
org.eclipse.cdt.launch.ui
org.eclipse.cdt.launch.ui,
org.eclipse.cdt.launch.ui.corebuild
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
@ -23,7 +25,9 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.cdt.debug.ui;bundle-version="[7.0.0,9.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)"
org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)",
org.eclipse.launchbar.ui;bundle-version="2.1.0",
org.eclipse.launchbar.core;bundle-version="2.1.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.ibm.icu.text

View file

@ -147,7 +147,7 @@
<launchConfigurationTabGroup
class="org.eclipse.cdt.launch.internal.corebuild.LocalLaunchConfigurationTabGroup"
id="org.eclipse.cdt.launch.launchConfigurationTabGroup.local"
type="org.eclipse.cdt.debug.core.localLaunchConfigurationType">
type="org.eclipse.cdt.debug.core.localCoreBuildLaunchConfigType">
</launchConfigurationTabGroup>
</extension>
</plugin>

View file

@ -46,6 +46,8 @@ public class LaunchMessages extends NLS {
public static String LocalAttachLaunchDelegate_Platform_cannot_list_processes;
public static String LocalAttachLaunchDelegate_Select_Process_to_attach_debugger_to;
public static String LocalAttachLaunchDelegate_CDT_Launch_Error;
public static String CoreBuildTab_Build;
public static String CoreBuildTab_NoOptions;
public static String CoreFileLaunchDelegate_Launching_postmortem_debugger;
public static String CoreFileLaunchDelegate_No_Corefile_selected;
public static String CoreFileLaunchDelegate_No_Shell_available_in_Launch;

View file

@ -49,6 +49,8 @@ LocalAttachLaunchDelegate_Platform_cannot_list_processes=Current platform does n
LocalAttachLaunchDelegate_Select_Process_to_attach_debugger_to=Select a Process to attach debugger to:
LocalAttachLaunchDelegate_CDT_Launch_Error=CDT Launch Error
CoreBuildTab_Build=Build
CoreBuildTab_NoOptions=No build options required.
CoreFileLaunchDelegate_Launching_postmortem_debugger=Launching postmortem debugger
CoreFileLaunchDelegate_No_Corefile_selected=No Corefile selected
CoreFileLaunchDelegate_No_Shell_available_in_Launch=No Shell available in Launch

View file

@ -23,6 +23,7 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class LaunchUIPlugin extends AbstractUIPlugin implements ILaunchesListener2 {
@ -226,4 +227,11 @@ public class LaunchUIPlugin extends AbstractUIPlugin implements ILaunchesListene
}
}
}
public static <T> T getService(Class<T> service) {
BundleContext context = fgPlugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
}

View file

@ -0,0 +1,55 @@
/*******************************************************************************
* 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 java.util.Map;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchConfigDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.ui.ILaunchBarLaunchConfigDialog;
/**
* Common utilities for Core Build launch configuration tabs.
*
* @since 9.1
*/
public abstract class CommonBuildTab extends AbstractLaunchConfigurationTab {
public ILaunchBarLaunchConfigDialog getLaunchBarLaunchConfigDialog() {
ILaunchConfigurationDialog dialog = getLaunchConfigurationDialog();
return dialog instanceof ILaunchBarLaunchConfigDialog ? (ILaunchBarLaunchConfigDialog) dialog : null;
}
public ILaunchTarget getLaunchTarget() {
ILaunchBarLaunchConfigDialog dialog = getLaunchBarLaunchConfigDialog();
return dialog != null ? dialog.getLaunchTarget() : null;
}
public ICBuildConfiguration getBuildConfiguration(ILaunchConfiguration configuration) throws CoreException {
String mode = getLaunchConfigurationDialog().getMode();
ILaunchTarget target = getLaunchTarget();
if (target == null) {
return null;
}
ICBuildConfigurationManager bcManager = LaunchUIPlugin.getService(ICBuildConfigurationManager.class);
IProject project = CoreBuildLaunchConfigDelegate.getProject(configuration);
Map<String, String> properties = target.getAttributes();
return bcManager.getBuildConfiguration(project, properties, mode, new NullProgressMonitor());
}
}

View file

@ -7,6 +7,7 @@
*******************************************************************************/
package org.eclipse.cdt.launch.ui.corebuild;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -26,6 +27,12 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
/**
* Launch configuration tab for adjusting Core Build settings. Contents of tab depends on the nature
* of the project which determines what build system is being used.
*
* @since 9.1
*/
public class CoreBuildTab extends AbstractLaunchConfigurationTab {
private Composite container;
@ -84,7 +91,7 @@ public class CoreBuildTab extends AbstractLaunchConfigurationTab {
@Override
public String getName() {
return "Build";
return LaunchMessages.CoreBuildTab_Build;
}
private IProject getProject(ILaunchConfiguration configuration) {
@ -111,7 +118,7 @@ public class CoreBuildTab extends AbstractLaunchConfigurationTab {
comp.setLayout(new GridLayout());
Label label = new Label(comp, SWT.NONE);
label.setText("No build options required.");
label.setText(LaunchMessages.CoreBuildTab_NoOptions);
activeTab = null;
}

View file

@ -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,

View file

@ -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>

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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));
}
}
}

View file

@ -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

View file

@ -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();
}

View file

@ -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())));
}
}

View file

@ -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",

View file

@ -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>

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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