Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java')
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
new file mode 100644
index 00000000000..51f6d313f22
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.cmake.core.internal;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.build.IToolChainManager;
+import org.eclipse.core.resources.IBuildConfiguration;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+
+public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProvider {
+
+ public static final String ID = "org.eclipse.cdt.cmake.core.provider"; //$NON-NLS-1$
+
+ @Override
+ public String getId() {
+ return ID;
+ }
+
+ @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 = Activator.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 CMakeBuildConfiguration(config, name, toolChain);
+ } else {
+ // No valid combinations
+ return null;
+ }
+ } else {
+ return new CMakeBuildConfiguration(config, name);
+ }
+ }
+
+}

Back to the top