mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +02:00
Bug 492006 - Get ATtinyCore building.
These boards don't have variants so now handle when they're missing. Includes change to order the properties so that the default menu selections are the same as in the Arduino IDE. Change-Id: Ibcc69e2399a92f513964ef6500c1b1766021cd39
This commit is contained in:
parent
7f494ba112
commit
2d87281d09
7 changed files with 189 additions and 115 deletions
|
@ -14,10 +14,12 @@ import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||||
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
||||||
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectGenerator;
|
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectGenerator;
|
||||||
|
import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
|
||||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
|
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
|
||||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
|
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
|
||||||
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
|
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
|
||||||
|
@ -38,108 +40,92 @@ import org.eclipse.remote.core.IRemoteConnection;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
|
@RunWith(Parameterized.class)
|
||||||
public class FullIntegration {
|
public class FullIntegration {
|
||||||
|
|
||||||
private static final ArduinoManager arduinoManager = Activator.getService(ArduinoManager.class);
|
private static final ArduinoManager arduinoManager = Activator.getService(ArduinoManager.class);
|
||||||
private static final IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
|
private static final IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
|
||||||
private static final ICBuildConfigurationManager buildConfigManager = Activator
|
private static final ICBuildConfigurationManager buildConfigManager = Activator
|
||||||
.getService(ICBuildConfigurationManager.class);
|
.getService(ICBuildConfigurationManager.class);
|
||||||
|
private static final IProgressMonitor monitor = new SysoutProgressMonitor();
|
||||||
|
|
||||||
private void setBoardUrls() throws Exception {
|
private static Set<ArduinoBoard> skipBuild;
|
||||||
|
private static Set<ArduinoBoard> skipUpload;
|
||||||
|
private static IProject project;
|
||||||
|
|
||||||
|
private ArduinoBoard board;
|
||||||
|
|
||||||
|
private static void setPreferences() throws Exception {
|
||||||
URL[] urls = new URL[] { new URL("http://downloads.arduino.cc/packages/package_index.json"),
|
URL[] urls = new URL[] { new URL("http://downloads.arduino.cc/packages/package_index.json"),
|
||||||
new URL("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json") };
|
new URL("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"),
|
||||||
|
new URL("http://drazzy.com/package_drazzy.com_index.json") };
|
||||||
ArduinoPreferences.setBoardUrlList(urls);
|
ArduinoPreferences.setBoardUrlList(urls);
|
||||||
}
|
|
||||||
|
|
||||||
private Set<ArduinoBoard> getSkipBuild() throws Exception {
|
|
||||||
Set<ArduinoBoard> boards = new HashSet<>();
|
|
||||||
|
|
||||||
// Fails in arduino too
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "robotControl"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "robotMotor"));
|
|
||||||
boards.add(arduinoManager.getBoard("adafruit", "avr", "adafruit32u4"));
|
|
||||||
|
|
||||||
// What is Microsoft doing?
|
|
||||||
boards.add(arduinoManager.getBoard("Microsoft", "win10", "w10iotcore"));
|
|
||||||
|
|
||||||
// TODO Need to add support for menu specific build properties
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "mini"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "lilypad"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "diecimila"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "pro"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "atmegang"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "bt"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "mega"));
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "nano"));
|
|
||||||
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "CirPlayTeensyCore"));
|
|
||||||
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "FloraTeensyCore"));
|
|
||||||
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "TeeOnArdu"));
|
|
||||||
|
|
||||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
|
||||||
// tool chain incorrect?
|
|
||||||
boards.add(arduinoManager.getBoard("Intel", "i586", "izmir_fd"));
|
|
||||||
boards.add(arduinoManager.getBoard("Intel", "i586", "izmir_fg"));
|
|
||||||
boards.add(arduinoManager.getBoard("Intel", "i686", "izmir_ec"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Platform.getOS().equals(Platform.OS_LINUX)) {
|
|
||||||
// i586/pokysdk missing
|
|
||||||
boards.add(arduinoManager.getBoard("Intel", "i586", "izmir_fd"));
|
|
||||||
boards.add(arduinoManager.getBoard("Intel", "i586", "izmir_fg"));
|
|
||||||
boards.add(arduinoManager.getBoard("Intel", "i686", "izmir_ec"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return boards;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<ArduinoBoard> getSkipUpload() throws Exception {
|
|
||||||
Set<ArduinoBoard> boards = new HashSet<>();
|
|
||||||
|
|
||||||
// missing upload.protocol
|
|
||||||
boards.add(arduinoManager.getBoard("arduino", "avr", "gemma"));
|
|
||||||
boards.add(arduinoManager.getBoard("adafruit", "avr", "gemma"));
|
|
||||||
boards.add(arduinoManager.getBoard("adafruit", "avr", "trinket5"));
|
|
||||||
boards.add(arduinoManager.getBoard("adafruit", "avr", "trinket3"));
|
|
||||||
|
|
||||||
// usbtiny missing
|
|
||||||
boards.add(arduinoManager.getBoard("adafruit", "avr", "protrinket3"));
|
|
||||||
boards.add(arduinoManager.getBoard("adafruit", "avr", "protrinket5"));
|
|
||||||
|
|
||||||
return boards;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() throws Exception {
|
|
||||||
IProgressMonitor monitor = new SysoutProgressMonitor();
|
|
||||||
|
|
||||||
setArduinoHome();
|
|
||||||
setBoardUrls();
|
|
||||||
loadPlatforms(monitor);
|
|
||||||
|
|
||||||
Set<ArduinoBoard> skipBuild = getSkipBuild();
|
|
||||||
Set<ArduinoBoard> skipUpload = getSkipUpload();
|
|
||||||
IProject project = createProject(monitor);
|
|
||||||
for (ArduinoBoard board : arduinoManager.getInstalledBoards()) {
|
|
||||||
if (!skipBuild.contains(board)) {
|
|
||||||
buildBoard(project, board, !skipUpload.contains(board), monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setArduinoHome() throws Exception {
|
|
||||||
Path workspace = Paths.get(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
|
Path workspace = Paths.get(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
|
||||||
ArduinoPreferences.setArduinoHome(workspace.resolve(".arduinocdt"));
|
ArduinoPreferences.setArduinoHome(workspace.resolve(".arduinocdt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadPlatforms(IProgressMonitor monitor) throws Exception {
|
private static void setupSkipBuild() throws Exception {
|
||||||
Collection<ArduinoPlatform> plats = arduinoManager.getAvailablePlatforms(monitor);
|
skipBuild = new HashSet<>();
|
||||||
arduinoManager.installPlatforms(plats, monitor);
|
|
||||||
|
// Fails in arduino too
|
||||||
|
skipBuild.add(arduinoManager.getBoard("arduino", "avr", "robotControl"));
|
||||||
|
skipBuild.add(arduinoManager.getBoard("arduino", "avr", "robotMotor"));
|
||||||
|
skipBuild.add(arduinoManager.getBoard("adafruit", "avr", "adafruit32u4"));
|
||||||
|
|
||||||
|
// What is Microsoft doing?
|
||||||
|
skipBuild.add(arduinoManager.getBoard("Microsoft", "win10", "w10iotcore"));
|
||||||
|
|
||||||
|
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||||
|
// tool chain incorrect?
|
||||||
|
skipBuild.add(arduinoManager.getBoard("Intel", "i586", "izmir_fd"));
|
||||||
|
skipBuild.add(arduinoManager.getBoard("Intel", "i586", "izmir_fg"));
|
||||||
|
skipBuild.add(arduinoManager.getBoard("Intel", "i686", "izmir_ec"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Platform.getOS().equals(Platform.OS_LINUX)) {
|
||||||
|
// i586/pokysdk missing
|
||||||
|
skipBuild.add(arduinoManager.getBoard("Intel", "i586", "izmir_fd"));
|
||||||
|
skipBuild.add(arduinoManager.getBoard("Intel", "i586", "izmir_fg"));
|
||||||
|
skipBuild.add(arduinoManager.getBoard("Intel", "i686", "izmir_ec"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IProject createProject(IProgressMonitor monitor) throws Exception {
|
private static void setupSkipUpload() throws Exception {
|
||||||
|
skipUpload = new HashSet<>();
|
||||||
|
|
||||||
|
// missing upload.protocol
|
||||||
|
skipUpload.add(arduinoManager.getBoard("arduino", "avr", "gemma"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("adafruit", "avr", "gemma"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("adafruit", "avr", "trinket5"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("adafruit", "avr", "trinket3"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attinyx7"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attinyx61"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attinyx8"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attiny1634"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attinyx313"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attinyx5"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attinyx4"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attinyx41"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("ATTinyCore", "avr", "attiny828"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("arduino-tiny-841", "avr", "attiny1634"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("arduino-tiny-841", "avr", "attinyx41"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("arduino-tiny-841", "avr", "attiny828"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("arduino-tiny-841", "avr", "attiny828"));
|
||||||
|
|
||||||
|
// usbtiny missing
|
||||||
|
skipUpload.add(arduinoManager.getBoard("adafruit", "avr", "protrinket3"));
|
||||||
|
skipUpload.add(arduinoManager.getBoard("adafruit", "avr", "protrinket5"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createProject() throws Exception {
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
String projectName = "ArduinoTest";
|
String projectName = "ArduinoTest";
|
||||||
ArduinoProjectGenerator generator = new ArduinoProjectGenerator("templates/cppsketch/manifest.xml"); //$NON-NLS-1$
|
ArduinoProjectGenerator generator = new ArduinoProjectGenerator("templates/cppsketch/manifest.xml"); //$NON-NLS-1$
|
||||||
|
@ -165,10 +151,36 @@ public class FullIntegration {
|
||||||
job.schedule();
|
job.schedule();
|
||||||
job.join();
|
job.join();
|
||||||
|
|
||||||
return generator.getProject();
|
project = generator.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildBoard(IProject project, ArduinoBoard board, boolean upload, IProgressMonitor monitor) throws Exception {
|
@BeforeClass
|
||||||
|
public static void setup() throws Exception {
|
||||||
|
setupSkipBuild();
|
||||||
|
setupSkipUpload();
|
||||||
|
createProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parameters(name = "{0}")
|
||||||
|
public static Collection<ArduinoBoard> getBoards() throws Exception {
|
||||||
|
setPreferences();
|
||||||
|
Collection<ArduinoPlatform> plats = arduinoManager.getAvailablePlatforms(monitor);
|
||||||
|
arduinoManager.installPlatforms(plats, monitor);
|
||||||
|
return arduinoManager.getInstalledBoards();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FullIntegration(ArduinoBoard board) {
|
||||||
|
this.board = board;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void runTest() throws Exception {
|
||||||
|
if (!skipBuild.contains(board)) {
|
||||||
|
buildBoard(project, board, !skipUpload.contains(board));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildBoard(IProject project, ArduinoBoard board, boolean upload) throws Exception {
|
||||||
ArduinoRemoteConnection arduinoTarget = createTarget(board);
|
ArduinoRemoteConnection arduinoTarget = createTarget(board);
|
||||||
ArduinoBuildConfigurationProvider provider = (ArduinoBuildConfigurationProvider) buildConfigManager
|
ArduinoBuildConfigurationProvider provider = (ArduinoBuildConfigurationProvider) buildConfigManager
|
||||||
.getProvider(ArduinoBuildConfigurationProvider.ID);
|
.getProvider(ArduinoBuildConfigurationProvider.ID);
|
||||||
|
@ -203,6 +215,20 @@ public class FullIntegration {
|
||||||
IRemoteConnectionWorkingCopy workingCopy = type.newConnection(board.getName());
|
IRemoteConnectionWorkingCopy workingCopy = type.newConnection(board.getName());
|
||||||
ArduinoRemoteConnection.setBoardId(workingCopy, board);
|
ArduinoRemoteConnection.setBoardId(workingCopy, board);
|
||||||
ArduinoRemoteConnection.setPortName(workingCopy, "port1");
|
ArduinoRemoteConnection.setPortName(workingCopy, "port1");
|
||||||
|
|
||||||
|
HierarchicalProperties menus = board.getMenus();
|
||||||
|
if (menus != null) {
|
||||||
|
for (Entry<String, HierarchicalProperties> menuEntry : menus.getChildren().entrySet()) {
|
||||||
|
String key = menuEntry.getKey();
|
||||||
|
|
||||||
|
for (Entry<String, HierarchicalProperties> valueEntry : menuEntry.getValue().getChildren().entrySet()) {
|
||||||
|
String value = valueEntry.getKey();
|
||||||
|
ArduinoRemoteConnection.setMenuValue(workingCopy, key, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connection = workingCopy.save();
|
connection = workingCopy.save();
|
||||||
|
|
||||||
return connection.getService(ArduinoRemoteConnection.class);
|
return connection.getService(ArduinoRemoteConnection.class);
|
||||||
|
|
|
@ -23,10 +23,10 @@ public class HierarchicalProperties {
|
||||||
public HierarchicalProperties() {
|
public HierarchicalProperties() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public HierarchicalProperties(Properties properties) {
|
public HierarchicalProperties(LinkedProperties properties) {
|
||||||
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
|
for (Object keyObj : properties.orderedKeys()) {
|
||||||
String key = (String) entry.getKey();
|
String key = (String) keyObj;
|
||||||
String value = (String) entry.getValue();
|
String value = (String) properties.get(key);
|
||||||
putProperty(key, value);
|
putProperty(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.arduino.core.internal;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class LinkedProperties extends Properties {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final HashSet<Object> keys = new LinkedHashSet<Object>();
|
||||||
|
|
||||||
|
public Iterable<Object> orderedKeys() {
|
||||||
|
return Collections.list(keys());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Enumeration<Object> keys() {
|
||||||
|
return Collections.<Object>enumeration(keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object put(Object key, Object value) {
|
||||||
|
keys.add(key);
|
||||||
|
return super.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -93,4 +93,11 @@ public class ArduinoBoard {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String arch = getPlatform().getArchitecture();
|
||||||
|
String pkg = getPlatform().getPackage().getName();
|
||||||
|
return pkg + ',' + arch + ',' + id + ',' + name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,10 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||||
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
||||||
|
import org.eclipse.cdt.arduino.core.internal.LinkedProperties;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class ArduinoPackage {
|
public class ArduinoPackage {
|
||||||
|
@ -92,12 +92,12 @@ public class ArduinoPackage {
|
||||||
if (Files.isDirectory(getInstallPath())) {
|
if (Files.isDirectory(getInstallPath())) {
|
||||||
Path platformTxt = Paths.get("platform.txt"); //$NON-NLS-1$
|
Path platformTxt = Paths.get("platform.txt"); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
Path hardware = getInstallPath().resolve("hardware");
|
Path hardware = getInstallPath().resolve("hardware"); //$NON-NLS-1$
|
||||||
if (Files.exists(hardware)) {
|
if (Files.exists(hardware)) {
|
||||||
Files.find(hardware, 2, // $NON-NLS-1$
|
Files.find(hardware, 2, // $NON-NLS-1$
|
||||||
(path, attrs) -> path.getFileName().equals(platformTxt)).forEach(path -> {
|
(path, attrs) -> path.getFileName().equals(platformTxt)).forEach(path -> {
|
||||||
try (FileReader reader = new FileReader(path.toFile())) {
|
try (FileReader reader = new FileReader(path.toFile())) {
|
||||||
Properties platformProperties = new Properties();
|
LinkedProperties platformProperties = new LinkedProperties();
|
||||||
platformProperties.load(reader);
|
platformProperties.load(reader);
|
||||||
String arch = path.getName(path.getNameCount() - 2).toString();
|
String arch = path.getName(path.getNameCount() - 2).toString();
|
||||||
String version = platformProperties.getProperty("version"); //$NON-NLS-1$
|
String version = platformProperties.getProperty("version"); //$NON-NLS-1$
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Properties;
|
||||||
import org.eclipse.cdt.arduino.core.internal.Activator;
|
import org.eclipse.cdt.arduino.core.internal.Activator;
|
||||||
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
|
||||||
import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
|
import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
|
||||||
|
import org.eclipse.cdt.arduino.core.internal.LinkedProperties;
|
||||||
import org.eclipse.cdt.arduino.core.internal.Messages;
|
import org.eclipse.cdt.arduino.core.internal.Messages;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -54,7 +55,7 @@ public class ArduinoPlatform {
|
||||||
|
|
||||||
private ArduinoPackage pkg;
|
private ArduinoPackage pkg;
|
||||||
private HierarchicalProperties boardsProperties;
|
private HierarchicalProperties boardsProperties;
|
||||||
private Properties platformProperties;
|
private LinkedProperties platformProperties;
|
||||||
private Map<String, String> menus = new HashMap<>();
|
private Map<String, String> menus = new HashMap<>();
|
||||||
private Map<String, ArduinoLibrary> libraries;
|
private Map<String, ArduinoLibrary> libraries;
|
||||||
|
|
||||||
|
@ -104,13 +105,13 @@ public class ArduinoPlatform {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlatformProperties(Properties platformProperties) {
|
public void setPlatformProperties(LinkedProperties platformProperties) {
|
||||||
this.platformProperties = platformProperties;
|
this.platformProperties = platformProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ArduinoBoard> getBoards() {
|
public List<ArduinoBoard> getBoards() {
|
||||||
if (boardsProperties == null) {
|
if (boardsProperties == null) {
|
||||||
Properties boardProps = new Properties();
|
LinkedProperties boardProps = new LinkedProperties();
|
||||||
|
|
||||||
if (Files.exists(getInstallPath())) {
|
if (Files.exists(getInstallPath())) {
|
||||||
try (InputStream is = new FileInputStream(getInstallPath().resolve("boards.txt").toFile()); //$NON-NLS-1$
|
try (InputStream is = new FileInputStream(getInstallPath().resolve("boards.txt").toFile()); //$NON-NLS-1$
|
||||||
|
@ -182,9 +183,9 @@ public class ArduinoPlatform {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Properties getPlatformProperties() throws CoreException {
|
public LinkedProperties getPlatformProperties() throws CoreException {
|
||||||
if (platformProperties == null) {
|
if (platformProperties == null) {
|
||||||
platformProperties = new Properties();
|
platformProperties = new LinkedProperties();
|
||||||
try (BufferedReader reader = new BufferedReader(
|
try (BufferedReader reader = new BufferedReader(
|
||||||
new FileReader(getInstallPath().resolve("platform.txt").toFile()))) { //$NON-NLS-1$
|
new FileReader(getInstallPath().resolve("platform.txt").toFile()))) { //$NON-NLS-1$
|
||||||
// There are regex's here and need to preserve the \'s
|
// There are regex's here and need to preserve the \'s
|
||||||
|
|
|
@ -358,21 +358,23 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
|
||||||
getSources(coreSources, corePath, true);
|
getSources(coreSources, corePath, true);
|
||||||
buildModel.put("platform_core_srcs", coreSources); //$NON-NLS-1$
|
buildModel.put("platform_core_srcs", coreSources); //$NON-NLS-1$
|
||||||
|
|
||||||
ArduinoPlatform variantPlatform = platform;
|
|
||||||
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
|
|
||||||
if (variant.contains(":")) { //$NON-NLS-1$
|
|
||||||
String[] segments = variant.split(":"); //$NON-NLS-1$
|
|
||||||
if (segments.length == 2) {
|
|
||||||
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
|
|
||||||
variant = segments[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Path variantPath = variantPlatform.getInstallPath().resolve("variants").resolve(variant); //$NON-NLS-1$
|
|
||||||
buildModel.put("platform_variant_path", pathString(variantPath)); //$NON-NLS-1$
|
|
||||||
List<String> variantSources = new ArrayList<>();
|
List<String> variantSources = new ArrayList<>();
|
||||||
getSources(variantSources, variantPath, true);
|
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
|
||||||
|
if (variant != null) {
|
||||||
|
ArduinoPlatform variantPlatform = platform;
|
||||||
|
if (variant.contains(":")) { //$NON-NLS-1$
|
||||||
|
String[] segments = variant.split(":"); //$NON-NLS-1$
|
||||||
|
if (segments.length == 2) {
|
||||||
|
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
|
||||||
|
variant = segments[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Path variantPath = variantPlatform.getInstallPath().resolve("variants").resolve(variant); //$NON-NLS-1$
|
||||||
|
buildModel.put("platform_variant_path", pathString(variantPath)); //$NON-NLS-1$
|
||||||
|
getSources(variantSources, variantPath, true);
|
||||||
|
}
|
||||||
buildModel.put("platform_variant_srcs", variantSources); //$NON-NLS-1$
|
buildModel.put("platform_variant_srcs", variantSources); //$NON-NLS-1$
|
||||||
|
|
||||||
properties.put("object_file", "$@"); //$NON-NLS-1$ //$NON-NLS-2$
|
properties.put("object_file", "$@"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
properties.put("source_file", "$<"); //$NON-NLS-1$ //$NON-NLS-2$
|
properties.put("source_file", "$<"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
properties.put("archive_file", "core.a"); //$NON-NLS-1$ //$NON-NLS-2$
|
properties.put("archive_file", "core.a"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -608,12 +610,16 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
|
||||||
|
|
||||||
ArduinoPlatform variantPlatform = platform;
|
ArduinoPlatform variantPlatform = platform;
|
||||||
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
|
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
|
||||||
if (variant.contains(":")) { //$NON-NLS-1$
|
if (variant != null) {
|
||||||
String[] segments = variant.split(":"); //$NON-NLS-1$
|
if (variant.contains(":")) { //$NON-NLS-1$
|
||||||
if (segments.length == 2) {
|
String[] segments = variant.split(":"); //$NON-NLS-1$
|
||||||
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
|
if (segments.length == 2) {
|
||||||
variant = segments[1];
|
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
|
||||||
|
variant = segments[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Arrays.asList(corePlatform.getInstallPath().resolve("cores").resolve(core)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.asList(corePlatform.getInstallPath().resolve("cores").resolve(core), //$NON-NLS-1$
|
return Arrays.asList(corePlatform.getInstallPath().resolve("cores").resolve(core), //$NON-NLS-1$
|
||||||
|
|
Loading…
Add table
Reference in a new issue