diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java index 81c7bae29ee..9a318d5c8ce 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java @@ -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 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); }