Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2015-09-25 21:01:37 +0000
committerGerrit Code Review @ Eclipse.org2015-09-28 17:24:41 +0000
commit64bf3c4f69e00d4246552505d67521ce2167178c (patch)
treec25a42b9c579136a03be4c3e3eb896b040f70c9a /toolchains
parent7ba4959cf4293cbd17726f22b49d89c6bc444b04 (diff)
downloadorg.eclipse.cdt-64bf3c4f69e00d4246552505d67521ce2167178c.tar.gz
org.eclipse.cdt-64bf3c4f69e00d4246552505d67521ce2167178c.tar.xz
org.eclipse.cdt-64bf3c4f69e00d4246552505d67521ce2167178c.zip
Starting to put Qt onto the new build system and launch.
Diffstat (limited to 'toolchains')
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml7
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java62
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPackage.java65
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/LibraryIndex.java2
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java53
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoGCCToolChain.java64
6 files changed, 190 insertions, 63 deletions
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
index 170aa8240e1..ae405304997 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/plugin.xml
@@ -108,4 +108,11 @@
</adapter>
</factory>
</extension>
+ <extension
+ point="org.eclipse.cdt.core.ToolChainFactory">
+ <factory
+ class="org.eclipse.cdt.arduino.core.internal.build.ArduinoGCCToolChain$ArduinoFactory"
+ family="Arduino GCC">
+ </factory>
+ </extension>
</plugin>
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
index 030dbd88c74..e2483f6ebcd 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
@@ -208,6 +208,23 @@ public class ArduinoManager {
return null;
}
+ public ArduinoTool getLatestTool(String packageName, String toolName) {
+ for (PackageIndex index : packageIndices) {
+ ArduinoPackage pkg = index.getPackage(packageName);
+ if (pkg != null) {
+ ArduinoTool latestTool = null;
+ for (ArduinoTool tool : pkg.getTools()) {
+ if (tool.getName().equals(toolName)) {
+ if (latestTool == null || compareVersions(latestTool.getVersion(), tool.getVersion()) > 1) {
+ latestTool = tool;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
private static final String LIBRARIES = "libraries"; //$NON-NLS-1$
private IEclipsePreferences getSettings(IProject project) {
@@ -378,4 +395,49 @@ public class ArduinoManager {
return perms;
}
+ public static int compareVersions(String version1, String version2) {
+ if (version1 == null) {
+ return version2 == null ? 0 : -1;
+ }
+
+ if (version2 == null) {
+ return 1;
+ }
+
+ String[] v1 = version1.split("\\."); //$NON-NLS-1$
+ String[] v2 = version2.split("\\."); //$NON-NLS-1$
+ for (int i = 0; i < Math.max(v1.length, v2.length); ++i) {
+ if (v1.length <= i) {
+ return v2.length < i ? 0 : -1;
+ }
+
+ if (v2.length <= i) {
+ return 1;
+ }
+
+ try {
+ int vi1 = Integer.parseInt(v1[i]);
+ int vi2 = Integer.parseInt(v2[i]);
+ if (vi1 < vi2) {
+ return -1;
+ }
+
+ if (vi1 > vi2) {
+ return 1;
+ }
+ } catch (NumberFormatException e) {
+ // not numbers, do string compares
+ int c = v1[i].compareTo(v2[i]);
+ if (c < 0) {
+ return -1;
+ }
+ if (c > 0) {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+ }
+
}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPackage.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPackage.java
index 39f8329ea98..1fce5bac8af 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPackage.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPackage.java
@@ -72,7 +72,7 @@ public class ArduinoPackage {
Map<String, ArduinoPlatform> platformMap = new HashMap<>();
for (ArduinoPlatform platform : platforms) {
ArduinoPlatform p = platformMap.get(platform.getName());
- if (p == null || compareVersions(platform.getVersion(), p.getVersion()) > 0) {
+ if (p == null || ArduinoManager.compareVersions(platform.getVersion(), p.getVersion()) > 0) {
platformMap.put(platform.getName(), platform);
}
}
@@ -84,7 +84,7 @@ public class ArduinoPackage {
for (ArduinoPlatform platform : platforms) {
if (platform.isInstalled()) {
ArduinoPlatform p = platformMap.get(platform.getName());
- if (p == null || compareVersions(platform.getVersion(), p.getVersion()) > 0) {
+ if (p == null || ArduinoManager.compareVersions(platform.getVersion(), p.getVersion()) > 0) {
platformMap.put(platform.getName(), platform);
}
}
@@ -92,52 +92,6 @@ public class ArduinoPackage {
return Collections.unmodifiableCollection(platformMap.values());
}
- // TODO move somewhere.
- public static int compareVersions(String version1, String version2) {
- if (version1 == null) {
- return version2 == null ? 0 : -1;
- }
-
- if (version2 == null) {
- return 1;
- }
-
- String[] v1 = version1.split("\\."); //$NON-NLS-1$
- String[] v2 = version2.split("\\."); //$NON-NLS-1$
- for (int i = 0; i < Math.max(v1.length, v2.length); ++i) {
- if (v1.length <= i) {
- return v2.length < i ? 0 : -1;
- }
-
- if (v2.length <= i) {
- return 1;
- }
-
- try {
- int vi1 = Integer.parseInt(v1[i]);
- int vi2 = Integer.parseInt(v2[i]);
- if (vi1 < vi2) {
- return -1;
- }
-
- if (vi1 > vi2) {
- return 1;
- }
- } catch (NumberFormatException e) {
- // not numbers, do string compares
- int c = v1[i].compareTo(v2[i]);
- if (c < 0) {
- return -1;
- }
- if (c > 0) {
- return 1;
- }
- }
- }
-
- return 0;
- }
-
public ArduinoPlatform getPlatform(String name) {
ArduinoPlatform foundPlatform = null;
for (ArduinoPlatform platform : platforms) {
@@ -146,7 +100,7 @@ public class ArduinoPackage {
foundPlatform = platform;
} else {
if (platform.isInstalled()
- && compareVersions(platform.getVersion(), foundPlatform.getVersion()) > 0) {
+ && ArduinoManager.compareVersions(platform.getVersion(), foundPlatform.getVersion()) > 0) {
foundPlatform = platform;
}
}
@@ -168,6 +122,19 @@ public class ArduinoPackage {
return null;
}
+ public ArduinoTool getLatestTool(String toolName) {
+ ArduinoTool latestTool = null;
+ for (ArduinoTool tool : tools) {
+ if (tool.getName().equals(toolName)) {
+ if (latestTool == null
+ || ArduinoManager.compareVersions(tool.getVersion(), latestTool.getVersion()) > 0) {
+ latestTool = tool;
+ }
+ }
+ }
+ return latestTool;
+ }
+
@Override
public boolean equals(Object obj) {
if (obj instanceof ArduinoPackage) {
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/LibraryIndex.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/LibraryIndex.java
index a0bbef428ca..3747d1442ef 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/LibraryIndex.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/LibraryIndex.java
@@ -36,7 +36,7 @@ public class LibraryIndex {
ArduinoLibrary current = latestLibs.get(name);
if (current != null) {
- if (ArduinoPackage.compareVersions(library.getVersion(), current.getVersion()) > 0) {
+ if (ArduinoManager.compareVersions(library.getVersion(), current.getVersion()) > 0) {
latestLibs.put(name, library);
}
} else {
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
index 91ef2068ee6..7a2a1eb861e 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
@@ -10,7 +10,9 @@ package org.eclipse.cdt.arduino.core.internal.build;
import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -32,7 +34,7 @@ import org.eclipse.cdt.arduino.core.internal.board.ToolDependency;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.build.CBuildConfiguration;
import org.eclipse.cdt.core.build.CToolChain;
-import org.eclipse.cdt.core.build.GCCToolChain;
+import org.eclipse.cdt.core.build.CToolChainManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IOutputEntry;
@@ -69,16 +71,6 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration {
private ArduinoBuildConfiguration(IBuildConfiguration config) {
super(config);
-
- try {
- if (getToolChain() == null) {
- // For now, assume GCC is the toolchain,
- // not sure it's ever not.
- setToolChain(GCCToolChain.ID);
- }
- } catch (CoreException e) {
- Activator.log(e);
- }
}
private static Map<IBuildConfiguration, ArduinoBuildConfiguration> cache = new HashMap<>();
@@ -438,6 +430,41 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration {
}
}
+ @Override
+ public CToolChain getToolChain() throws CoreException {
+ CToolChain toolChain = super.getToolChain();
+ if (toolChain == null) {
+ // figure out which one it is
+ ArduinoPlatform platform = board.getPlatform();
+ String compilerPath = resolveProperty("compiler.path", platform.getPlatformProperties()); //$NON-NLS-1$
+ if (compilerPath != null) {
+ // TODO what if it is null?
+ Path path = Paths.get(compilerPath);
+ for (ToolDependency toolDep : platform.getToolsDependencies()) {
+ ArduinoTool tool = toolDep.getTool();
+ if (path.startsWith(tool.getInstallPath())) {
+ // this is it, find the matching
+ for (CToolChain tc : CToolChainManager.instance.getToolChains()) {
+ if (tc instanceof ArduinoGCCToolChain) {
+ if (((ArduinoGCCToolChain) tc).getTool().equals(tool)) {
+ setToolChain(tc);
+ toolChain = tc;
+ break;
+ }
+ }
+ }
+ // not found, create
+ toolChain = new ArduinoGCCToolChain(tool);
+ CToolChainManager.instance.addToolChain(toolChain);
+ setToolChain(toolChain);
+ break;
+ }
+ }
+ }
+ }
+ return toolChain;
+ }
+
public IScannerInfo getScannerInfo(IResource resource) throws CoreException {
IScannerInfo info = super.getScannerInfo(resource);
if (info == null) {
@@ -473,8 +500,8 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration {
}
properties.put("includes", includes); //$NON-NLS-1$
- getToolChain().scanBuildOutput(getBuildFolder(), resolveProperty(recipe, properties), true);
- info = super.getScannerInfo(resource);
+ List<String> cmd = Arrays.asList(resolveProperty(recipe, properties).split(" ")); //$NON-NLS-1$
+ info = getToolChain().getScannerInfo(getBuildFolder(), cmd);
}
return info;
}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoGCCToolChain.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoGCCToolChain.java
new file mode 100644
index 00000000000..7670e100830
--- /dev/null
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoGCCToolChain.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.arduino.core.internal.build;
+
+import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
+import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
+import org.eclipse.cdt.arduino.core.internal.board.ArduinoTool;
+import org.eclipse.cdt.core.build.CToolChain;
+import org.eclipse.cdt.core.build.IToolChainFactory;
+import org.eclipse.cdt.core.build.gcc.GCCToolChain;
+import org.osgi.service.prefs.Preferences;
+
+public class ArduinoGCCToolChain extends GCCToolChain {
+
+ private static final String PACKAGE = "arduinoPackage"; //$NON-NLS-1$
+ private static final String TOOL = "arduinoTool"; //$NON-NLS-1$
+
+ private final ArduinoTool tool;
+
+ public ArduinoGCCToolChain(String id, Preferences settings) {
+ super(id, settings);
+ ArduinoPackage pkg = ArduinoManager.instance.getPackage(settings.get(PACKAGE, "")); //$NON-NLS-1$
+ if (pkg != null) {
+ this.tool = pkg.getLatestTool(settings.get(TOOL, "")); //$NON-NLS-1$
+ } else {
+ // TODO where did it go?
+ this.tool = null;
+ }
+ }
+
+ public ArduinoGCCToolChain(ArduinoTool tool) {
+ super(tool.getName());
+ this.tool = tool;
+ }
+
+ public static class ArduinoFactory implements IToolChainFactory {
+ @Override
+ public CToolChain createToolChain(String id, Preferences settings) {
+ return new ArduinoGCCToolChain(id, settings);
+ }
+ }
+
+ @Override
+ public String getFamily() {
+ return "Arduino GCC"; //$NON-NLS-1$
+ }
+
+ public ArduinoTool getTool() {
+ return tool;
+ }
+
+ @Override
+ public void save(Preferences settings) {
+ super.save(settings);
+ settings.put(TOOL, tool.getName());
+ settings.put(PACKAGE, tool.getPackage().getName());
+ }
+
+}

Back to the top