mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 541709 Figure out toolchain for Makefile projects.
The config is not valid without this. Using the same algorithm CMake projects do to find the default toolchain. Change-Id: I871da3019b7d440fbd6c1b2a4935d424f084a603
This commit is contained in:
parent
2f678054ff
commit
62143e2bd7
1 changed files with 33 additions and 0 deletions
|
@ -10,15 +10,20 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.core;
|
||||
|
||||
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.ICBuildConfigurationProvider;
|
||||
import org.eclipse.cdt.core.build.IToolChain;
|
||||
import org.eclipse.cdt.core.build.IToolChainManager;
|
||||
import org.eclipse.cdt.core.build.StandardBuildConfiguration;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* @since 7.4
|
||||
|
@ -34,6 +39,34 @@ public class MakefileBuildConfigurationProvider implements ICBuildConfigurationP
|
|||
|
||||
@Override
|
||||
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
|
||||
if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
|
||||
IToolChain toolChain = null;
|
||||
|
||||
// try the toolchain for the local target
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put(IToolChain.ATTR_OS, Platform.getOS());
|
||||
properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
|
||||
IToolChainManager toolChainManager = MakeCorePlugin.getService(IToolChainManager.class);
|
||||
for (IToolChain tc : toolChainManager.getToolChainsMatching(properties)) {
|
||||
toolChain = tc;
|
||||
break;
|
||||
}
|
||||
|
||||
// local didn't work, try and find one that does
|
||||
if (toolChain == null) {
|
||||
for (IToolChain tc : toolChainManager.getToolChainsMatching(new HashMap<>())) {
|
||||
toolChain = tc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (toolChain != null) {
|
||||
return new StandardBuildConfiguration(config, name, toolChain, "run"); //$NON-NLS-1$
|
||||
} else {
|
||||
// No valid combinations
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new StandardBuildConfiguration(config, name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue