diff options
Diffstat (limited to 'build/org.eclipse.cdt.cmake.core/src/org/eclipse')
5 files changed, 1 insertions, 289 deletions
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 9db982f7ce4..1b684999dad 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 @@ -28,13 +28,10 @@ import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.core.resources.IBuildConfiguration; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; @@ -50,11 +47,11 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { public CMakeBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { super(config, name); + ICMakeToolChainManager manager = Activator.getService(ICMakeToolChainManager.class); Preferences settings = getSettings(); String pathStr = settings.get(TOOLCHAIN_FILE, ""); //$NON-NLS-1$ if (!pathStr.isEmpty()) { Path path = Paths.get(pathStr); - ICMakeToolChainManager manager = Activator.getService(ICMakeToolChainManager.class); toolChainFile = manager.getToolChainFile(path); } } diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java deleted file mode 100644 index a2a5435d23f..00000000000 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationDelegate.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.eclipse.cdt.cmake.core.internal; - -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.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; -import org.eclipse.launchbar.core.target.ILaunchTarget; -import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate; - -public class CMakeLaunchConfigurationDelegate extends LaunchConfigurationTargetedDelegate - implements ILaunchConfigurationDelegate { - - public static final String TYPE_ID = "org.eclipse.cdt.cmake.core.launchConfigurationType"; //$NON-NLS-1$ - - private ICBuildConfigurationManager configManager = Activator.getService(ICBuildConfigurationManager.class); - private IToolChainManager tcManager = Activator.getService(IToolChainManager.class); - - private IProject getProject(ILaunchConfiguration configuration) throws CoreException { - return configuration.getMappedResources()[0].getProject(); - } - - @Override - public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target, - IProgressMonitor monitor) throws CoreException { - // Set active build config based on toolchain for target - Map<String, String> properties = new HashMap<>(); - String os = target.getAttribute(ILaunchTarget.ATTR_OS, ""); //$NON-NLS-1$ - if (!os.isEmpty()) { - properties.put(IToolChain.ATTR_OS, os); - } - String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, ""); //$NON-NLS-1$ - if (!arch.isEmpty()) { - properties.put(IToolChain.ATTR_ARCH, arch); - } - Collection<IToolChain> tcs = tcManager.getToolChainsMatching(properties); - if (!tcs.isEmpty()) { - IToolChain toolChain = tcs.iterator().next(); - - IProject project = getProject(configuration); - ICBuildConfiguration config = configManager.getBuildConfiguration(project, toolChain, "run", monitor); //$NON-NLS-1$ - - if (config != null) { - IProjectDescription desc = project.getDescription(); - desc.setActiveBuildConfig(config.getBuildConfiguration().getName()); - project.setDescription(desc, monitor); - } - } - - // proceed with the build - return superBuildForLaunch(configuration, mode, monitor); - } - - @Override - public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) - throws CoreException { - // TODO need to find the binary and launch it. - // Though, more likely, need to have launch configs per binary. - } - - @Override - protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException { - // 1. Extract project from configuration - // TODO dependencies too. - IProject project = getProject(configuration); - return new IProject[] { project }; - } - -} diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java deleted file mode 100644 index adf1bb8d358..00000000000 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchConfigurationProvider.java +++ /dev/null @@ -1,111 +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.cmake.core.internal; - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.cdt.cmake.core.ICMakeToolChainManager; -import org.eclipse.cdt.core.build.IToolChain; -import org.eclipse.cdt.core.build.IToolChainManager; -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 CMakeLaunchConfigurationProvider extends AbstractLaunchConfigProvider { - - private Map<IProject, ILaunchConfiguration> configs = new HashMap<>(); - - @Override - public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { - return ILaunchTargetManager.localLaunchTargetTypeId.equals(target.getTypeId()); - } - - @Override - public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) - throws CoreException { - return DebugPlugin.getDefault().getLaunchManager() - .getLaunchConfigurationType(CMakeLaunchConfigurationDelegate.TYPE_ID); - } - - @Override - public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) - throws CoreException { - ILaunchConfiguration config = null; - IProject project = descriptor.getAdapter(IProject.class); - if (project != null) { - config = configs.get(project); - if (config == null) { - config = createLaunchConfiguration(descriptor, target); - // launch config added will get called below to add it to the - // configs map - } - } - return config; - } - - @Override - protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target, - ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { - super.populateLaunchConfiguration(descriptor, target, workingCopy); - - // Set the project and the connection - CMakeLaunchDescriptor qtDesc = (CMakeLaunchDescriptor) descriptor; - workingCopy.setMappedResources(new IResource[] { qtDesc.getProject() }); - } - - @Override - public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException { - if (ownsLaunchConfiguration(configuration)) { - IProject project = configuration.getMappedResources()[0].getProject(); - configs.put(project, configuration); - return true; - } - return false; - } - - @Override - public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException { - for (Entry<IProject, ILaunchConfiguration> entry : configs.entrySet()) { - if (configuration.equals(entry.getValue())) { - configs.remove(entry.getKey()); - return true; - } - } - return false; - } - - @Override - public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException { - // TODO not sure I care - return false; - } - - @Override - public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException { - IProject project = descriptor.getAdapter(IProject.class); - if (project != null) { - configs.remove(project); - } - } - - @Override - public void launchTargetRemoved(ILaunchTarget target) throws CoreException { - // nothing to do since the Local connection can't be removed - } - -} diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchDescriptor.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchDescriptor.java deleted file mode 100644 index cd1cff81eee..00000000000 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchDescriptor.java +++ /dev/null @@ -1,49 +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.cmake.core.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.ILaunchDescriptorType; - -public class CMakeLaunchDescriptor extends PlatformObject implements ILaunchDescriptor { - - private final CMakeLaunchDescriptorType type; - private final IProject project; - - public CMakeLaunchDescriptor(CMakeLaunchDescriptorType type, IProject project) { - this.type = type; - this.project = project; - } - - @Override - public String getName() { - return project.getName(); - } - - @Override - public ILaunchDescriptorType getType() { - return type; - } - - public IProject getProject() { - return project; - } - - @SuppressWarnings("unchecked") - @Override - public <T> T getAdapter(Class<T> adapter) { - if (adapter.equals(IProject.class)) { - return (T) project; - } else { - return super.getAdapter(adapter); - } - } - -} diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchDescriptorType.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchDescriptorType.java deleted file mode 100644 index 944084338af..00000000000 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeLaunchDescriptorType.java +++ /dev/null @@ -1,39 +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.cmake.core.internal; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.cdt.cmake.core.CMakeNature; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.ILaunchDescriptorType; - -public class CMakeLaunchDescriptorType implements ILaunchDescriptorType { - - private Map<IProject, CMakeLaunchDescriptor> descriptors = new HashMap<>(); - - @Override - public ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException { - if (launchObject instanceof IProject) { - IProject project = (IProject) launchObject; - if (project.hasNature(CMakeNature.ID)) { - CMakeLaunchDescriptor desc = descriptors.get(project); - if (desc == null) { - desc = new CMakeLaunchDescriptor(this, project); - descriptors.put(project, desc); - } - return desc; - } - } - return null; - } - -} |