1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Make Qt toolchain selection more resilient.

On my Windows box I have lots of GCC toolchains. Make sure it selects
the one from the Qt install. And fix a few NPEs and things around that.

Change-Id: Ifeeca9271b5055ac773b3b77e372a67e07305130
This commit is contained in:
Doug Schaefer 2017-10-17 11:35:03 -04:00
parent 2198597a98
commit 736d7b5955
4 changed files with 13 additions and 9 deletions

View file

@ -81,14 +81,16 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT
// Pick the first one that matches // Pick the first one that matches
Map<String, String> properties = new HashMap<>(); Map<String, String> properties = new HashMap<>();
properties.putAll(target.getAttributes()); properties.putAll(target.getAttributes());
Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties); for (IToolChain toolChain : toolChainManager.getToolChainsMatching(properties)) {
if (!tcs.isEmpty()) { ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(project, toolChain, mode, monitor);
IToolChain toolChain = tcs.iterator().next(); if (buildConfig != null) {
return configManager.getBuildConfiguration(project, toolChain, mode, monitor); return buildConfig;
}
} }
return null; return null;
} }
protected IBinary getBinary(ICBuildConfiguration buildConfig) throws CoreException { protected IBinary getBinary(ICBuildConfiguration buildConfig) throws CoreException {
IBinary[] binaries = buildConfig.getBuildOutput(); IBinary[] binaries = buildConfig.getBuildOutput();
IBinary exeFile = null; IBinary exeFile = null;

View file

@ -10,7 +10,6 @@ package org.eclipse.cdt.internal.qt.core.build;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.build.ICBuildConfiguration; import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager; import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.ICBuildConfigurationProvider; import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
@ -24,9 +23,7 @@ import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
public class QtBuildConfigurationProvider implements ICBuildConfigurationProvider { public class QtBuildConfigurationProvider implements ICBuildConfigurationProvider {
@ -105,8 +102,7 @@ public class QtBuildConfigurationProvider implements ICBuildConfigurationProvide
configManager.addBuildConfiguration(config, qtConfig); configManager.addBuildConfiguration(config, qtConfig);
return qtConfig; return qtConfig;
} else { } else {
throw new CoreException( return null;
new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.QtBuildConfigurationProvider_NoQtInstall));
} }
} }

View file

@ -56,12 +56,14 @@ public class QtMinGWToolChainProvider implements IToolChainProvider {
IEnvironmentVariable.ENVVAR_PREPEND, File.pathSeparator) }; IEnvironmentVariable.ENVVAR_PREPEND, File.pathSeparator) };
GCCToolChain toolChain = new GCCToolChain(this, path.resolve(gcc), GCCToolChain toolChain = new GCCToolChain(this, path.resolve(gcc),
Platform.ARCH_X86, env); Platform.ARCH_X86, env);
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_WIN32);
toolChain.setProperty(IToolChain.ATTR_PACKAGE, "qt"); //$NON-NLS-1$ toolChain.setProperty(IToolChain.ATTR_PACKAGE, "qt"); //$NON-NLS-1$
manager.addToolChain(toolChain); manager.addToolChain(toolChain);
if (Platform.getOSArch().equals(Platform.ARCH_X86_64)) { if (Platform.getOSArch().equals(Platform.ARCH_X86_64)) {
toolChain = new GCCToolChain(this, path.resolve(gcc), Platform.ARCH_X86_64, toolChain = new GCCToolChain(this, path.resolve(gcc), Platform.ARCH_X86_64,
env); env);
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_WIN32);
toolChain.setProperty(IToolChain.ATTR_PACKAGE, "qt"); //$NON-NLS-1$ toolChain.setProperty(IToolChain.ATTR_PACKAGE, "qt"); //$NON-NLS-1$
manager.addToolChain(toolChain); manager.addToolChain(toolChain);
} }

View file

@ -65,6 +65,10 @@ public class QtBuildTab extends CommonBuildTab {
public void initializeFrom(ILaunchConfiguration configuration) { public void initializeFrom(ILaunchConfiguration configuration) {
try { try {
ICBuildConfiguration buildConfig = getBuildConfiguration(); ICBuildConfiguration buildConfig = getBuildConfiguration();
if (buildConfig == null) {
return;
}
// qmake command // qmake command
IToolChainManager tcManager = Activator.getService(IToolChainManager.class); IToolChainManager tcManager = Activator.getService(IToolChainManager.class);
IQtInstallManager qtManager = Activator.getService(IQtInstallManager.class); IQtInstallManager qtManager = Activator.getService(IQtInstallManager.class);