diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java index c56396acf50..eb4bea66f1b 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java @@ -93,7 +93,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { Map properties = getProperties(); String generator = properties.get(CMAKE_GENERATOR); if (generator == null) { - generator = "Unix Makefiles"; //$NON-NLS-1$ + generator = "Ninja"; //$NON-NLS-1$ } project.deleteMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); @@ -200,7 +200,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { String cleanCommand = properties.get(CLEAN_COMMAND); if (cleanCommand == null) { - if (generator != null && generator.equals("Ninja")) { //$NON-NLS-1$ + if (generator == null || generator.equals("Ninja")) { //$NON-NLS-1$ cleanCommand = "ninja clean"; //$NON-NLS-1$ } else { cleanCommand = "make clean"; //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java index b5abc40765c..7778df8d84b 100644 --- a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java +++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakeBuildTab.java @@ -122,7 +122,7 @@ public class CMakeBuildTab extends AbstractLaunchConfigurationTab { } private void updateGeneratorButtons(String generator) { - if (generator != null && generator.equals("Ninja")) { //$NON-NLS-1$ + if (generator == null || generator.equals("Ninja")) { //$NON-NLS-1$ ninjaGenButton.setSelection(true); } else { unixGenButton.setSelection(true); @@ -133,9 +133,8 @@ public class CMakeBuildTab extends AbstractLaunchConfigurationTab { public void performApply(ILaunchConfigurationWorkingCopy configuration) { Map properties = new HashMap<>(); - if (ninjaGenButton.getSelection()) { - properties.put(CMakeBuildConfiguration.CMAKE_GENERATOR, "Ninja"); //$NON-NLS-1$ - } + properties.put(CMakeBuildConfiguration.CMAKE_GENERATOR, + ninjaGenButton.getSelection() ? "Ninja" : "Unix Makefiles"); //$NON-NLS-1$ //$NON-NLS-2$ String cmakeArgs = cmakeArgsText.getText().trim(); if (!cmakeArgs.isEmpty()) { diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 3b39f4d4b15..3cbcf2208f9 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true -Bundle-Version: 6.3.1.qualifier +Bundle-Version: 6.4.0.qualifier Bundle-Activator: org.eclipse.cdt.core.CCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java index 294295319b0..a7ad619b9d4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplateInstance.java @@ -1,29 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2012, 2014 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Thomas Corbat (IFS) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.dom.ast.cpp; - -import org.eclipse.cdt.core.dom.ast.ITypedef; - -/** - * Represents an instance of an alias template (14.5.7). - * @since 5.5 - * - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface ICPPAliasTemplateInstance extends ITypedef, ICPPTemplateInstance { - /** - * Returns the alias template specialized by this instance. - */ - @Override - public ICPPAliasTemplate getTemplateDefinition(); -} +/******************************************************************************* + * Copyright (c) 2012, 2014 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast.cpp; + +import org.eclipse.cdt.core.dom.ast.ITypedef; + +/** + * Represents an instance of an alias template (14.5.7). + * @since 5.5 + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICPPAliasTemplateInstance extends ITypedef, ICPPTemplateInstance { + /** + * Returns the alias template specialized by this instance. + * + * @since 6.4 + */ + @Override + public ICPPAliasTemplate getTemplateDefinition(); +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java index 1045a84196d..0c867535003 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/CBuildConfigurationManager.java @@ -1,336 +1,342 @@ -/******************************************************************************* - * 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.core.build; - -import java.io.IOException; -import java.nio.file.FileVisitResult; -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; -import java.util.Set; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.CProjectNature; -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; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.osgi.service.prefs.BackingStoreException; -import org.osgi.service.prefs.Preferences; - -public class CBuildConfigurationManager implements ICBuildConfigurationManager, IResourceChangeListener { - - private static class Provider { - private String id; - private String natureId; - private IConfigurationElement element; - private ICBuildConfigurationProvider provider; - - public Provider(IConfigurationElement element) { - this.id = element.getAttribute("id"); //$NON-NLS-1$ - this.natureId = element.getAttribute("natureId"); //$NON-NLS-1$ - this.element = element; - } - - public String getId() { - return id; - } - - public ICBuildConfigurationProvider getProvider() { - if (provider == null) { - try { - provider = (ICBuildConfigurationProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ - } catch (CoreException e) { - CCorePlugin.log(e.getStatus()); - } - } - return provider; - } - - public boolean supports(IProject project) { - try { - if (natureId != null) { - return project.hasNature(natureId); - } - } catch (CoreException e) { - CCorePlugin.log(e.getStatus()); - } - return false; - } - } - - private Map providers; - private Map configs = new HashMap<>(); - private Set noConfigs = new HashSet<>(); - - public CBuildConfigurationManager() { - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - } - - public void dispose() { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - } - - private void initProviders() { - if (providers == null) { - providers = new HashMap<>(); - - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, - "buildConfigProvider"); //$NON-NLS-1$ - for (IConfigurationElement element : point.getConfigurationElements()) { - Provider provider = new Provider(element); - providers.put(provider.getId(), provider); - } - } - } - - private Provider getProviderDelegate(String id) { - return providers.get(id); - } - - @Override - public ICBuildConfigurationProvider getProvider(String id) { - initProviders(); - Provider provider = providers.get(id); - return provider != null ? provider.getProvider() : null; - } - - public ICBuildConfigurationProvider getProvider(String id, IProject project) { - initProviders(); - Provider provider = getProviderDelegate(id); - if (provider != null && provider.supports(project)) { - return provider.getProvider(); - } - return null; - } - - public ICBuildConfigurationProvider getProvider(IProject project) throws CoreException { - initProviders(); - for (Provider provider : providers.values()) { - if (provider.supports(project)) { - return provider.getProvider(); - } - } - return null; - } - - @Override - public IBuildConfiguration createBuildConfiguration(ICBuildConfigurationProvider provider, - IProject project, String configName, IProgressMonitor monitor) throws CoreException { - String name = provider.getId() + '/' + configName; - - Set names = new HashSet<>(); - for (IBuildConfiguration config : project.getBuildConfigs()) { - names.add(config.getName()); - } - - IProjectDescription desc = project.getDescription(); - names.add(name); - desc.setBuildConfigs(names.toArray(new String[names.size()])); - project.setDescription(desc, monitor); - - return project.getBuildConfig(name); - } - - @Override - public void addBuildConfiguration(IBuildConfiguration buildConfig, ICBuildConfiguration cConfig) { - synchronized (configs) { - configs.put(buildConfig, cConfig); - } - - // reset the binary parsers - CModelManager.getDefault().resetBinaryParser(buildConfig.getProject()); - } - - @Override - public ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException { - initProviders(); - ICBuildConfiguration config = null; - boolean resetBinaryParser = false; - synchronized (configs) { - if (!noConfigs.contains(buildConfig)) { - config = configs.get(buildConfig); - if (config == null) { - String configName = null; - ICBuildConfigurationProvider provider = null; - if (IBuildConfiguration.DEFAULT_CONFIG_NAME.equals(buildConfig.getName())) { - configName = ICBuildConfiguration.DEFAULT_NAME; - provider = getProvider(buildConfig.getProject()); - } else { - String[] segments = buildConfig.getName().split("/"); //$NON-NLS-1$ - if (segments.length == 2) { - String providerId = segments[0]; - configName = segments[1]; - Provider delegate = getProviderDelegate(providerId); - if (delegate != null && delegate.supports(buildConfig.getProject())) { - provider = delegate.getProvider(); - } - } - } - - if (provider != null) { - config = provider.getCBuildConfiguration(buildConfig, configName); - if (config != null) { - configs.put(buildConfig, config); - // Also make sure we reset the binary parser cache - // for the new config - resetBinaryParser = true; - } - } - - if (config == null) { - noConfigs.add(buildConfig); - } - } - } - } - - if (resetBinaryParser) { - // Do this outside of the synchronized block to avoid deadlock with - // BinaryRunner - CModelManager.getDefault().resetBinaryParser(buildConfig.getProject()); - } - - return config; - } - - @Override - public ICBuildConfiguration getBuildConfiguration(IProject project, IToolChain toolChain, - String launchMode, IProgressMonitor monitor) throws CoreException { - ICBuildConfigurationProvider provider = getProvider(project); - if (provider != null) { - return provider.createBuildConfiguration(project, toolChain, launchMode, monitor); - } else { - return null; - } - } - - @Override - public ICBuildConfiguration getBuildConfiguration(IProject project, Map properties, - String launchMode, IProgressMonitor monitor) throws CoreException { - IToolChainManager tcManager = CCorePlugin.getService(IToolChainManager.class); - Collection 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 - || event.getType() == IResourceChangeEvent.PRE_DELETE) { - if (event.getResource().getType() == IResource.PROJECT) { - IProject project = event.getResource().getProject(); - try { - if (!project.isOpen() || !project.hasNature(CProjectNature.C_NATURE_ID)) - return; - } catch (CoreException e) { - CCorePlugin.log(e.getStatus()); - return; - } - - // Clean up the configMap - try { - for (IBuildConfiguration buildConfig : project.getBuildConfigs()) { - configs.remove(buildConfig); - } - } catch (CoreException e) { - CCorePlugin.log(e); - } - - // Clean up the config settings - Preferences parentNode = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).node("config"); //$NON-NLS-1$ - if (parentNode != null) { - Preferences projectNode = parentNode.node(project.getName()); - if (projectNode != null) { - try { - projectNode.removeNode(); - parentNode.flush(); - } catch (BackingStoreException e) { - CCorePlugin.log(e); - } - } - } - - // Clean up the scanner info data - IPath stateLoc = CCorePlugin.getDefault().getStateLocation(); - IPath scannerInfoPath = stateLoc.append(project.getName()); - Path directory = scannerInfoPath.toFile().toPath(); - if (!Files.exists(directory)) { - return; - } - - try { - Files.walkFileTree(directory, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) - throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) - throws IOException { - Files.delete(dir); - return FileVisitResult.CONTINUE; - } - }); - } catch (IOException e) { - CCorePlugin.log(e); - } - } - } - } - - @Override - public boolean supports(IProject project) throws CoreException { - initProviders(); - - // First see if we have a build config registered - for (IBuildConfiguration config : project.getBuildConfigs()) { - if (configs.containsKey(config)) { - return true; - } - } - - // See if one of the providers supports this project - for (Provider provider : providers.values()) { - if (provider.supports(project)) { - return true; - } - } - - return false; - } - -} +/******************************************************************************* + * 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.core.build; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +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; +import java.util.Set; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.CProjectNature; +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.core.model.CoreModel; +import org.eclipse.cdt.internal.core.model.CModelManager; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +public class CBuildConfigurationManager implements ICBuildConfigurationManager, IResourceChangeListener { + + private static class Provider { + private String id; + private String natureId; + private IConfigurationElement element; + private ICBuildConfigurationProvider provider; + + public Provider(IConfigurationElement element) { + this.id = element.getAttribute("id"); //$NON-NLS-1$ + this.natureId = element.getAttribute("natureId"); //$NON-NLS-1$ + this.element = element; + } + + public String getId() { + return id; + } + + public ICBuildConfigurationProvider getProvider() { + if (provider == null) { + try { + provider = (ICBuildConfigurationProvider) element.createExecutableExtension("class"); //$NON-NLS-1$ + } catch (CoreException e) { + CCorePlugin.log(e.getStatus()); + } + } + return provider; + } + + public boolean supports(IProject project) { + try { + if (natureId != null) { + return project.hasNature(natureId); + } + } catch (CoreException e) { + CCorePlugin.log(e.getStatus()); + } + return false; + } + } + + private Map providers; + private Map configs = new HashMap<>(); + private Set noConfigs = new HashSet<>(); + + public CBuildConfigurationManager() { + ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + } + + public void dispose() { + ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); + } + + private void initProviders() { + if (providers == null) { + providers = new HashMap<>(); + + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, + "buildConfigProvider"); //$NON-NLS-1$ + for (IConfigurationElement element : point.getConfigurationElements()) { + Provider provider = new Provider(element); + providers.put(provider.getId(), provider); + } + } + } + + private Provider getProviderDelegate(String id) { + return providers.get(id); + } + + @Override + public ICBuildConfigurationProvider getProvider(String id) { + initProviders(); + Provider provider = providers.get(id); + return provider != null ? provider.getProvider() : null; + } + + public ICBuildConfigurationProvider getProvider(String id, IProject project) { + initProviders(); + Provider provider = getProviderDelegate(id); + if (provider != null && provider.supports(project)) { + return provider.getProvider(); + } + return null; + } + + public ICBuildConfigurationProvider getProvider(IProject project) throws CoreException { + initProviders(); + for (Provider provider : providers.values()) { + if (provider.supports(project)) { + return provider.getProvider(); + } + } + return null; + } + + @Override + public IBuildConfiguration createBuildConfiguration(ICBuildConfigurationProvider provider, + IProject project, String configName, IProgressMonitor monitor) throws CoreException { + String name = provider.getId() + '/' + configName; + + Set names = new HashSet<>(); + for (IBuildConfiguration config : project.getBuildConfigs()) { + names.add(config.getName()); + } + + IProjectDescription desc = project.getDescription(); + names.add(name); + desc.setBuildConfigs(names.toArray(new String[names.size()])); + project.setDescription(desc, monitor); + + return project.getBuildConfig(name); + } + + @Override + public void addBuildConfiguration(IBuildConfiguration buildConfig, ICBuildConfiguration cConfig) { + synchronized (configs) { + configs.put(buildConfig, cConfig); + } + + // reset the binary parsers + CModelManager.getDefault().resetBinaryParser(buildConfig.getProject()); + } + + @Override + public ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException { + initProviders(); + ICBuildConfiguration config = null; + boolean resetBinaryParser = false; + synchronized (configs) { + if (!noConfigs.contains(buildConfig)) { + config = configs.get(buildConfig); + if (config == null) { + String configName = null; + ICBuildConfigurationProvider provider = null; + if (IBuildConfiguration.DEFAULT_CONFIG_NAME.equals(buildConfig.getName())) { + configName = ICBuildConfiguration.DEFAULT_NAME; + provider = getProvider(buildConfig.getProject()); + } else { + String[] segments = buildConfig.getName().split("/"); //$NON-NLS-1$ + if (segments.length == 2) { + String providerId = segments[0]; + configName = segments[1]; + Provider delegate = getProviderDelegate(providerId); + if (delegate != null && delegate.supports(buildConfig.getProject())) { + provider = delegate.getProvider(); + } + } + } + + if (provider != null) { + config = provider.getCBuildConfiguration(buildConfig, configName); + if (config != null) { + configs.put(buildConfig, config); + // Also make sure we reset the binary parser cache + // for the new config + resetBinaryParser = true; + } + } + + if (config == null) { + noConfigs.add(buildConfig); + } + } + } + } + + if (resetBinaryParser) { + // Do this outside of the synchronized block to avoid deadlock with + // BinaryRunner + CModelManager.getDefault().resetBinaryParser(buildConfig.getProject()); + } + + return config; + } + + @Override + public ICBuildConfiguration getBuildConfiguration(IProject project, IToolChain toolChain, + String launchMode, IProgressMonitor monitor) throws CoreException { + ICBuildConfigurationProvider provider = getProvider(project); + if (provider != null) { + return provider.createBuildConfiguration(project, toolChain, launchMode, monitor); + } else { + return null; + } + } + + @Override + public ICBuildConfiguration getBuildConfiguration(IProject project, Map properties, + String launchMode, IProgressMonitor monitor) throws CoreException { + IToolChainManager tcManager = CCorePlugin.getService(IToolChainManager.class); + Collection 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 + || event.getType() == IResourceChangeEvent.PRE_DELETE) { + if (event.getResource().getType() == IResource.PROJECT) { + IProject project = event.getResource().getProject(); + try { + if (!project.isOpen() || !project.hasNature(CProjectNature.C_NATURE_ID)) + return; + } catch (CoreException e) { + CCorePlugin.log(e.getStatus()); + return; + } + + // Clean up the configMap + try { + for (IBuildConfiguration buildConfig : project.getBuildConfigs()) { + configs.remove(buildConfig); + } + } catch (CoreException e) { + CCorePlugin.log(e); + } + + // Clean up the config settings + Preferences parentNode = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).node("config"); //$NON-NLS-1$ + if (parentNode != null) { + Preferences projectNode = parentNode.node(project.getName()); + if (projectNode != null) { + try { + projectNode.removeNode(); + parentNode.flush(); + } catch (BackingStoreException e) { + CCorePlugin.log(e); + } + } + } + + // Clean up the scanner info data + IPath stateLoc = CCorePlugin.getDefault().getStateLocation(); + IPath scannerInfoPath = stateLoc.append(project.getName()); + Path directory = scannerInfoPath.toFile().toPath(); + if (!Files.exists(directory)) { + return; + } + + try { + Files.walkFileTree(directory, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) + throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException e) { + CCorePlugin.log(e); + } + } + } + } + + @Override + public boolean supports(IProject project) throws CoreException { + // Is this a CDT project? + if (!CoreModel.hasCNature(project)) { + return false; + } + + initProviders(); + + // First see if we have a build config registered + for (IBuildConfiguration config : project.getBuildConfigs()) { + if (configs.containsKey(config)) { + return true; + } + } + + // See if one of the providers supports this project + for (Provider provider : providers.values()) { + if (provider.supports(project)) { + return true; + } + } + + return false; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java index b6fa1aae781..7be272a5109 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java @@ -124,9 +124,12 @@ public class ToolChainManager implements IToolChainManager { for (IToolChain toolChain : toolChains.values()) { boolean matches = true; for (Map.Entry property : properties.entrySet()) { - if (!property.getValue().equals(toolChain.getProperty(property.getKey()))) { - matches = false; - break; + String tcProperty = toolChain.getProperty(property.getKey()); + if (tcProperty != null) { + if (!property.getValue().equals(tcProperty)) { + matches = false; + break; + } } } if (matches) { diff --git a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF index d3faff212bb..fc709305387 100644 --- a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true -Bundle-Version: 8.2.0.qualifier +Bundle-Version: 8.3.0.qualifier Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/debug/org.eclipse.cdt.debug.core/plugin.properties b/debug/org.eclipse.cdt.debug.core/plugin.properties index 6c5079cacbf..fc9bc5104df 100644 --- a/debug/org.eclipse.cdt.debug.core/plugin.properties +++ b/debug/org.eclipse.cdt.debug.core/plugin.properties @@ -25,6 +25,7 @@ PostMortemLaunch.name=C/C++ Postmortem Debugger RemoteApplicationLaunch.name=C/C++ Remote Application localApplicationLaunch.name=Auto C/C++ Local Application +genericLaunch.name=Auto Generic C/C++ Launch CDebugger.name=C/C++ Development Tools Core Debugger Extension BreakpointAction.name=Breakpoint Action Extension diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml index f24d8b3bd14..39e6204629e 100644 --- a/debug/org.eclipse.cdt.debug.core/plugin.xml +++ b/debug/org.eclipse.cdt.debug.core/plugin.xml @@ -471,6 +471,13 @@ public="false"> + + + + + + diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java new file mode 100644 index 00000000000..c59735f9ee2 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2017 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.debug.core.launch; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.ICBuildConfigurationManager; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.build.IToolChainManager; +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchMode; +import org.eclipse.launchbar.core.ILaunchBarListener; +import org.eclipse.launchbar.core.ILaunchBarManager; +import org.eclipse.launchbar.core.ILaunchDescriptor; +import org.eclipse.launchbar.core.target.ILaunchTarget; + +/** + * A launchbar listener that attempts to set the active build configuration on + * the project adapted from the launch descriptor that supports the given + * target. + * + * @since 8.3 + */ +public class CoreBuildLaunchBarTracker implements ILaunchBarListener { + + private final ILaunchBarManager launchBarManager = CDebugCorePlugin.getService(ILaunchBarManager.class); + private final ICBuildConfigurationManager configManager = CDebugCorePlugin + .getService(ICBuildConfigurationManager.class); + private final IToolChainManager toolChainManager = CDebugCorePlugin.getService(IToolChainManager.class); + + private final String targetTypeId; + + public CoreBuildLaunchBarTracker(String targetTypeId) { + this.targetTypeId = targetTypeId; + } + + private void setActiveBuildConfig(String mode, ILaunchDescriptor descriptor, ILaunchTarget target) + throws CoreException { + if (!targetTypeId.equals(target.getTypeId())) { + return; + } + + IProject project = descriptor.getAdapter(IProject.class); + if (project == null) { + // Can we get the project name from the config + ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor, target); + String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ + if (!projectName.isEmpty()) { + project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + } + + if (project == null) { + // Try the mapped resources + IResource[] mappedResources = configuration.getMappedResources(); + if (mappedResources != null && mappedResources.length > 0) { + project = mappedResources[0].getProject(); + } + } + } + + if (project == null || !configManager.supports(project)) { + return; + } + + // Pick build config based on toolchain for target + Map properties = new HashMap<>(); + properties.putAll(target.getAttributes()); + Collection tcs = toolChainManager.getToolChainsMatching(properties); + if (!tcs.isEmpty()) { + IToolChain toolChain = tcs.iterator().next(); + IProgressMonitor monitor = new NullProgressMonitor(); + ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(project, toolChain, mode, + new NullProgressMonitor()); + if (buildConfig != null) { + IProjectDescription desc = project.getDescription(); + desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName()); + project.setDescription(desc, monitor); + + // Copy over the build attributes from the launch config + ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor, target); + Map buildProps = configuration.getAttribute( + CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode), + buildConfig.getDefaultProperties()); + buildConfig.setProperties(buildProps); + } + } + } + + @Override + public void activeLaunchTargetChanged(ILaunchTarget target) { + try { + if (target == null || target.equals(ILaunchTarget.NULL_TARGET)) { + return; + } + + ILaunchMode launchMode = launchBarManager.getActiveLaunchMode(); + if (launchMode == null) { + return; + } + + String mode = launchMode.getIdentifier(); + ILaunchDescriptor descriptor = launchBarManager.getActiveLaunchDescriptor(); + setActiveBuildConfig(mode, descriptor, target); + } catch (CoreException e) { + CDebugCorePlugin.log(e.getStatus()); + } + } + + @Override + public void activeLaunchDescriptorChanged(ILaunchDescriptor descriptor) { + try { + if (descriptor == null) { + return; + } + + ILaunchMode launchMode = launchBarManager.getActiveLaunchMode(); + if (launchMode == null) { + return; + } + + String mode = launchMode.getIdentifier(); + ILaunchTarget target = launchBarManager.getActiveLaunchTarget(); + setActiveBuildConfig(mode, descriptor, target); + } catch (CoreException e) { + CDebugCorePlugin.log(e.getStatus()); + } + + } + + @Override + public void activeLaunchModeChanged(ILaunchMode mode) { + try { + if (mode == null) { + return; + } + + ILaunchDescriptor descriptor = launchBarManager.getActiveLaunchDescriptor(); + ILaunchTarget target = launchBarManager.getActiveLaunchTarget(); + setActiveBuildConfig(mode.getIdentifier(), descriptor, target); + } catch (CoreException e) { + CDebugCorePlugin.log(e.getStatus()); + } + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java new file mode 100644 index 00000000000..7426f213980 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2017 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.debug.core.launch; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.launchbar.core.ILaunchBarManager; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.launchbar.core.target.ILaunchTargetManager; +import org.eclipse.launchbar.core.target.ILaunchTargetProvider; +import org.eclipse.launchbar.core.target.TargetStatus; + +public class GenericTargetTypeProvider implements ILaunchTargetProvider { + + public static final String TYPE_ID = "org.eclipse.cdt.launchTargetType.generic"; //$NON-NLS-1$ + + @Override + public void init(ILaunchTargetManager targetManager) { + ILaunchBarManager launchBarManager = CDebugCorePlugin.getService(ILaunchBarManager.class); + launchBarManager.addListener(new CoreBuildLaunchBarTracker(TYPE_ID)); + } + + @Override + public TargetStatus getStatus(ILaunchTarget target) { + // Always OK + return TargetStatus.OK_STATUS; + } + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildGenericLaunchConfigProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildGenericLaunchConfigProvider.java new file mode 100644 index 00000000000..915bbb529f1 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/launch/CoreBuildGenericLaunchConfigProvider.java @@ -0,0 +1,150 @@ +package org.eclipse.cdt.debug.internal.core.launch; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.launch.GenericTargetTypeProvider; +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; + +public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider { + + private static final String TYPE_ID = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"; //$NON-NLS-1$ + private static final String ATTR_OS = CDebugCorePlugin.PLUGIN_ID + ".target_os"; //$NON-NLS-1$ + private static final String NO_OS = ""; //$NON-NLS-1$ + + private Map> configs = new HashMap<>(); + + @Override + public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { + return target.getTypeId().equals(GenericTargetTypeProvider.TYPE_ID); + } + + @Override + public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) + throws CoreException { + return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(TYPE_ID); + } + + @Override + public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) + throws CoreException { + ILaunchConfiguration config = null; + IProject project = descriptor.getAdapter(IProject.class); + if (project != null) { + Map projectConfigs = configs.get(project); + if (projectConfigs == null) { + projectConfigs = new HashMap<>(); + configs.put(project, projectConfigs); + } + + String os = target.getAttribute(ILaunchTarget.ATTR_OS, NO_OS); + config = projectConfigs.get(os); + if (config == null) { + config = createLaunchConfiguration(descriptor, target); + } + } + return config; + } + + @Override + protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target, + ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { + super.populateLaunchConfiguration(descriptor, target, workingCopy); + + // Set the project + IProject project = descriptor.getAdapter(IProject.class); + workingCopy.setMappedResources(new IResource[] { project }); + + // set the OS + String os = target.getAttribute(ILaunchTarget.ATTR_OS, NO_OS); + workingCopy.setAttribute(ATTR_OS, os); + } + + @Override + public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException { + if (ownsLaunchConfiguration(configuration)) { + IProject project = configuration.getMappedResources()[0].getProject(); + Map projectConfigs = configs.get(project); + if (projectConfigs == null) { + projectConfigs = new HashMap<>(); + configs.put(project, projectConfigs); + } + + String os = configuration.getAttribute(ATTR_OS, NO_OS); + projectConfigs.put(os, configuration); + return true; + } + return false; + } + + @Override + public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException { + for (Entry> projectEntry : configs.entrySet()) { + Map projectConfigs = projectEntry.getValue(); + for (Entry entry : projectConfigs.entrySet()) { + if (configuration.equals(entry.getValue())) { + projectConfigs.remove(entry.getKey()); + if (projectConfigs.isEmpty()) { + configs.remove(projectEntry.getKey()); + } + return true; + } + } + } + return false; + } + + @Override + public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException { + // nothing to do + return false; + } + + @Override + public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException { + IProject project = descriptor.getAdapter(IProject.class); + if (project != null) { + Map projectConfigs = configs.get(project); + if (projectConfigs != null) { + for (ILaunchConfiguration config : projectConfigs.values()) { + config.delete(); + } + } + } + } + + @Override + public void launchTargetRemoved(ILaunchTarget target) throws CoreException { + // Any other targets have the same OS? + String os = target.getAttribute(ILaunchTarget.ATTR_OS, NO_OS); + + ILaunchTargetManager targetManager = CDebugCorePlugin.getService(ILaunchTargetManager.class); + for (ILaunchTarget t : targetManager.getLaunchTargets()) { + if (!target.equals(t) && os.equals(t.getAttribute(ILaunchTarget.ATTR_OS, NO_OS))) { + // Yup, nothing to do then + return; + } + } + + for (Entry> projectEntry : configs.entrySet()) { + Map projectConfigs = projectEntry.getValue(); + ILaunchConfiguration config = projectConfigs.get(os); + if (config != null) { + config.delete(); + } + } + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF index a7ded1aa541..fa8c732c2b2 100644 --- a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.ui; singleton:=true -Bundle-Version: 8.2.0.qualifier +Bundle-Version: 8.3.0.qualifier Bundle-Activator: org.eclipse.cdt.debug.ui.CDebugUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/cdt_logo_16.png b/debug/org.eclipse.cdt.debug.ui/icons/obj16/cdt_logo_16.png new file mode 100644 index 00000000000..fb343a10650 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/obj16/cdt_logo_16.png differ diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 50578110b97..e2cdd03b20d 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -277,3 +277,5 @@ popup.stepIntoSelection.name=Step Into Selection # Debugger console view DebuggerConsoleView.name=Debugger Console + +GenericTarget.name=Generic Target diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 5cdde0e680b..30dd0676ed3 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -2579,5 +2579,18 @@ id="org.eclipse.cdt.debug.ui.localLaunchConfigurationTypeImage"> + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index 3e6f66031e4..f978c314a72 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -113,6 +113,7 @@ public class CDebugImages { public static final String IMG_OBJS_COMMON_TAB = NAME_PREFIX + "common_tab.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ARRAY_PARTITION = NAME_PREFIX + "arraypartition_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_C_APP = NAME_PREFIX + "c_app.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_CDT_LOGO = NAME_PREFIX + "cdt_logo_16.png"; //$NON-NLS-1$ public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$ public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$ @@ -208,6 +209,7 @@ public class CDebugImages { public static final ImageDescriptor DESC_OBJS_ARRAY_PARTITION = createManaged(T_OBJ, IMG_OBJS_ARRAY_PARTITION); public static final ImageDescriptor DESC_OBJS_DEBUGGER_CONSOLE_SELECT = createManaged(T_OBJ, IMG_DEBUGGER_CONSOLE_SELECT); public static final ImageDescriptor DESC_OBJS_C_APP = createManaged(T_OBJ, IMG_OBJS_C_APP); + public static final ImageDescriptor DESC_OBJS_CDT_LOGO = createManaged(T_OBJ, IMG_OBJS_CDT_LOGO); public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE = createManaged(T_WIZBAN, IMG_WIZBAN_ADD_SOURCE); public static final ImageDescriptor DESC_WIZBAN_PATH_MAPPING = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAPPING); public static final ImageDescriptor DESC_WIZBAN_PATH_MAP_ENTRY = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAP_ENTRY); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetLabelProvider.java new file mode 100644 index 00000000000..f681510e815 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetLabelProvider.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2017 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.debug.internal.ui.launch; + +import org.eclipse.cdt.debug.internal.ui.CDebugImages; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.swt.graphics.Image; + +public class GenericTargetLabelProvider extends LabelProvider { + + @Override + public String getText(Object element) { + if (element instanceof ILaunchTarget) { + return ((ILaunchTarget) element).getId(); + } + return super.getText(element); + } + + @Override + public Image getImage(Object element) { + return CDebugImages.get(CDebugImages.IMG_OBJS_CDT_LOGO); + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java new file mode 100644 index 00000000000..bc5f6fd6892 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java @@ -0,0 +1,51 @@ +package org.eclipse.cdt.debug.internal.ui.launch; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class GenericTargetPropertiesBlock extends Composite { + + private Text nameText; + private Text osText; + private Text archText; + + public GenericTargetPropertiesBlock(Composite parent, int style) { + super(parent, style); + setLayout(new GridLayout(2, false)); + + Label label = new Label(this, SWT.NONE); + label.setText("Name:"); + + nameText = new Text(this, SWT.BORDER); + nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + label = new Label(this, SWT.NONE); + label.setText("Operating System:"); + + osText = new Text(this, SWT.BORDER); + osText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + label = new Label(this, SWT.NONE); + label.setText("CPU Architecture:"); + + archText = new Text(this, SWT.BORDER); + archText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + } + + public String getTargetName() { + return nameText.getText(); + } + + public String getOS() { + return osText.getText(); + } + + public String getArch() { + return archText.getText(); + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java new file mode 100644 index 00000000000..a8f982dc916 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2017 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.debug.internal.ui.launch; + +import org.eclipse.cdt.debug.core.launch.GenericTargetTypeProvider; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.launchbar.core.target.ILaunchTarget; +import org.eclipse.launchbar.core.target.ILaunchTargetManager; +import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; + +public class NewGenericTargetWizard extends Wizard implements INewWizard { + + private NewGenericTargetWizardPage page; + + public NewGenericTargetWizard() { + setWindowTitle("New Generic Target"); + } + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + // nothing + } + + @Override + public void addPages() { + super.addPages(); + + page = new NewGenericTargetWizardPage(); + addPage(page); + } + + @Override + public boolean performFinish() { + ILaunchTargetManager manager = CDebugUIPlugin.getService(ILaunchTargetManager.class); + String typeId = GenericTargetTypeProvider.TYPE_ID; + String id = page.getTargetName(); + + ILaunchTarget target = manager.addLaunchTarget(typeId, id); + ILaunchTargetWorkingCopy wc = target.getWorkingCopy(); + wc.setAttribute(ILaunchTarget.ATTR_OS, page.getOS()); + wc.setAttribute(ILaunchTarget.ATTR_ARCH, page.getArch()); + wc.save(); + + return true; + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java new file mode 100644 index 00000000000..9f3f557d4f0 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2017 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.debug.internal.ui.launch; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +public class NewGenericTargetWizardPage extends WizardPage { + + private GenericTargetPropertiesBlock propertiesBlock; + + public NewGenericTargetWizardPage() { + super(NewGenericTargetWizardPage.class.getName()); + setTitle("Generic Target"); + setDescription("Enter name and properties for the target."); + } + + @Override + public void createControl(Composite parent) { + propertiesBlock = new GenericTargetPropertiesBlock(parent, SWT.NONE); + setControl(propertiesBlock); + } + + public String getTargetName() { + return propertiesBlock.getTargetName(); + } + + public String getOS() { + return propertiesBlock.getOS(); + } + + public String getArch() { + return propertiesBlock.getArch(); + } + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java index 5c6f93bfc81..6201198ce81 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java @@ -61,6 +61,7 @@ import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.progress.WorkbenchJob; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; /** * The main plugin class to be used in the desktop. @@ -408,4 +409,12 @@ public class CDebugUIPlugin extends AbstractUIPlugin { public static IDebuggerConsoleManager getDebuggerConsoleManager() { return fDebuggerConsoleManager; } + + /** @since 8.3 */ + public static T getService(Class service) { + BundleContext context = plugin.getBundle().getBundleContext(); + ServiceReference ref = context.getServiceReference(service); + return ref != null ? context.getService(ref) : null; + } + } diff --git a/launch/org.eclipse.cdt.launch/icons/view16/core_build_tab.png b/launch/org.eclipse.cdt.launch/icons/view16/core_build_tab.png new file mode 100644 index 00000000000..c0272bb5d88 Binary files /dev/null and b/launch/org.eclipse.cdt.launch/icons/view16/core_build_tab.png differ diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index 9b298b82b29..efb162da337 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -155,4 +155,12 @@ type="org.eclipse.cdt.debug.core.localCoreBuildLaunchConfigType"> + + + + diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/CoreBuildTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/CoreBuildTabGroup.java new file mode 100644 index 00000000000..ba4db574284 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/corebuild/CoreBuildTabGroup.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2017 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.internal.corebuild; + +import org.eclipse.cdt.launch.ui.corebuild.CoreBuildTab; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; +import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.debug.ui.ILaunchConfigurationTabGroup; + +public class CoreBuildTabGroup extends AbstractLaunchConfigurationTabGroup implements ILaunchConfigurationTabGroup { + + @Override + public void createTabs(ILaunchConfigurationDialog dialog, String mode) { + setTabs(new ILaunchConfigurationTab[] { new CoreBuildTab() }); + } + +} diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java index 4bf684f22d9..be4e198fe8e 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchImages.java @@ -39,12 +39,14 @@ public class LaunchImages { public static String IMG_VIEW_ENVIRONMENT_TAB = NAME_PREFIX + "environment_tab.gif"; //$NON-NLS-1$ public static String IMG_VIEW_DEBUGGER_TAB = NAME_PREFIX + "debugger_tab.gif"; //$NON-NLS-1$ public static String IMG_VIEW_SOURCE_TAB = NAME_PREFIX + "source_tab.gif"; //$NON-NLS-1$ + public static String IMG_VIEW_CORE_BUILD_TAB = NAME_PREFIX + "core_build_tab.png"; //$NON-NLS-1$ public static final ImageDescriptor DESC_TAB_MAIN= createManaged(T_TABS, IMG_VIEW_MAIN_TAB); public static final ImageDescriptor DESC_TAB_ARGUMENTS = createManaged(T_TABS, IMG_VIEW_ARGUMENTS_TAB); public static final ImageDescriptor DESC_TAB_ENVIRONMENT = createManaged(T_TABS, IMG_VIEW_ENVIRONMENT_TAB); public static final ImageDescriptor DESC_TAB_DEBUGGER = createManaged(T_TABS, IMG_VIEW_DEBUGGER_TAB); public static final ImageDescriptor DESC_TAB_SOURCE = createManaged(T_TABS, IMG_VIEW_SOURCE_TAB); + public static final ImageDescriptor DESC_TAB_CORE_BUILD = createManaged(T_TABS, IMG_VIEW_CORE_BUILD_TAB); public static String IMG_OBJS_EXEC= NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$ public static final ImageDescriptor DESC_OBJS_EXEC = createManaged(T_OBJS, IMG_OBJS_EXEC); diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties index ef0d62cea5c..e287e387bf4 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties @@ -49,7 +49,7 @@ 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_Build=Build Settings CoreBuildTab_NoOptions=No build options required. CoreFileLaunchDelegate_Launching_postmortem_debugger=Launching postmortem debugger CoreFileLaunchDelegate_No_Corefile_selected=No Corefile selected diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java index af286f2faf1..d569a61c4bb 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/corebuild/CoreBuildTab.java @@ -7,6 +7,7 @@ *******************************************************************************/ package org.eclipse.cdt.launch.ui.corebuild; +import org.eclipse.cdt.launch.internal.ui.LaunchImages; import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.core.resources.IProject; @@ -21,6 +22,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -94,6 +96,11 @@ public class CoreBuildTab extends AbstractLaunchConfigurationTab { return LaunchMessages.CoreBuildTab_Build; } + @Override + public Image getImage() { + return LaunchImages.get(LaunchImages.IMG_VIEW_CORE_BUILD_TAB); + } + private IProject getProject(ILaunchConfiguration configuration) { try { for (IResource resource : configuration.getMappedResources()) { diff --git a/releng/org.eclipse.cdt.target/cdt-baseline.target b/releng/org.eclipse.cdt.target/cdt-baseline.target index ceabd52bca8..aeb4607cdf9 100644 --- a/releng/org.eclipse.cdt.target/cdt-baseline.target +++ b/releng/org.eclipse.cdt.target/cdt-baseline.target @@ -7,16 +7,13 @@ - - - @@ -34,7 +31,6 @@ - @@ -50,13 +46,15 @@ - + - + + + - +