1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 20:15:22 +02:00

Bug 480365 - Support Arduino Zero

Made a number of bad assumptions. This get us building for the Zero
and tested to make sure Uno and ESP8266 still work.

Change-Id: Ifed78af11969c7fba65754b9254d8a2eecf335ac
This commit is contained in:
Doug Schaefer 2015-10-21 22:19:30 -04:00
parent a9034fa6e9
commit 8cc9e5f3f0
4 changed files with 59 additions and 26 deletions

View file

@ -210,12 +210,16 @@ public class ArduinoPlatform {
}
}
public Collection<String> getSources(String core) {
public Collection<String> getSources(String core, String variant) {
List<String> sources = new ArrayList<>();
Path srcPath = getInstallPath().resolve("cores").resolve(core); //$NON-NLS-1$
if (srcPath.toFile().isDirectory()) {
getSources(sources, srcPath, true);
}
Path variantPath = getInstallPath().resolve("variants").resolve(variant); //$NON-NLS-1$
if (variantPath.toFile().isDirectory()) {
getSources(sources, variantPath, true);
}
return sources;
}

View file

@ -236,11 +236,30 @@ public class ArduinoBuildConfiguration {
return board;
}
private Properties getProperties() throws CoreException {
private synchronized Properties getProperties() throws CoreException {
if (properties == null) {
ArduinoPlatform platform = board.getPlatform();
// IDE generated properties
properties = new Properties();
properties.put("runtime.platform.path", platform.getInstallPath().toString()); //$NON-NLS-1$
properties.put("runtime.ide.version", "10607"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("build.arch", platform.getArchitecture().toUpperCase()); //$NON-NLS-1$
properties.put("build.path", config.getName()); //$NON-NLS-1$
properties.put("build.variant.path", //$NON-NLS-1$
platform.getInstallPath().resolve("variants").resolve("{build.variant}").toString()); //$NON-NLS-1$ //$NON-NLS-2$
// Platform
properties.putAll(board.getPlatform().getPlatformProperties());
// Tools
for (ToolDependency toolDep : platform.getToolsDependencies()) {
properties.putAll(toolDep.getTool().getToolProperties());
}
// Board
ArduinoBoard board = getBoard();
properties = board.getBoardProperties();
properties.putAll(board.getBoardProperties());
// Menus
IEclipsePreferences settings = getSettings();
@ -253,21 +272,8 @@ public class ArduinoBuildConfiguration {
}
}
}
// Platform
ArduinoPlatform platform = board.getPlatform();
properties.putAll(board.getPlatform().getPlatformProperties());
// Tools
for (ToolDependency toolDep : platform.getToolsDependencies()) {
properties.putAll(toolDep.getTool().getToolProperties());
}
properties.put("runtime.platform.path", platform.getInstallPath().toString()); //$NON-NLS-1$
properties.put("runtime.ide.version", "10607"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("build.arch", platform.getArchitecture().toUpperCase()); //$NON-NLS-1$
properties.put("build.path", config.getName()); //$NON-NLS-1$
}
// always do this in case the project changes names
properties.put("build.project_name", config.getProject().getName()); //$NON-NLS-1$
return properties;
@ -364,7 +370,8 @@ public class ArduinoBuildConfiguration {
Path platformPath = platform.getInstallPath();
buildModel.put("platform_path", pathString(platformPath)); //$NON-NLS-1$
buildModel.put("platform_srcs", platform.getSources(properties.getProperty("build.core"))); //$NON-NLS-1$ //$NON-NLS-2$
buildModel.put("platform_srcs", //$NON-NLS-1$
platform.getSources(properties.getProperty("build.core"), properties.getProperty("build.variant"))); //$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$
@ -378,6 +385,7 @@ public class ArduinoBuildConfiguration {
buildModel.put("recipe_c_combine_pattern", resolveProperty("recipe.c.combine.pattern", properties)); //$NON-NLS-1$ //$NON-NLS-2$
buildModel.put("recipe_objcopy_eep_pattern", resolveProperty("recipe.objcopy.eep.pattern", properties)); //$NON-NLS-1$ //$NON-NLS-2$
buildModel.put("recipe_objcopy_hex_pattern", resolveProperty("recipe.objcopy.hex.pattern", properties)); //$NON-NLS-1$ //$NON-NLS-2$
buildModel.put("recipe_objcopy_bin_pattern", resolveProperty("recipe.objcopy.bin.pattern", properties)); //$NON-NLS-1$ //$NON-NLS-2$
buildModel.put("recipe_size_pattern", resolveProperty("recipe.size.pattern", properties)); //$NON-NLS-1$ //$NON-NLS-2$
ArduinoTemplateGenerator templateGen = new ArduinoTemplateGenerator();

View file

@ -26,8 +26,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* This class is responsible for generating the Makefile for the current build
* config.
* This class is responsible for generating the Makefile for the current build config.
*/
public class ArduinoBuilder extends IncrementalProjectBuilder {
@ -97,7 +96,7 @@ public class ArduinoBuilder extends IncrementalProjectBuilder {
String codeSizeRegex = config.getCodeSizeRegex();
Pattern codeSizePattern = codeSizeRegex != null ? Pattern.compile(codeSizeRegex) : null;
String dataSizeRegex = config.getDataSizeRegex();
Pattern dataSizePattern = codeSizeRegex != null ? Pattern.compile(dataSizeRegex) : null;
Pattern dataSizePattern = dataSizeRegex != null ? Pattern.compile(dataSizeRegex) : null;
if (codeSizePattern == null && dataSizePattern == null) {
return;
@ -133,11 +132,13 @@ public class ArduinoBuilder extends IncrementalProjectBuilder {
}
console.writeOutput(" bytes\n");
if (maxDataSize >= 0) {
console.writeOutput("Initial RAM usage: " + dataSize);
if (maxCodeSize > 0) {
console.writeOutput(" of maximum " + maxDataSize);
}
console.writeOutput(" bytes\n");
}
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), "Checking sizes", e));
}

View file

@ -48,14 +48,34 @@ LIBRARIES_OBJS = \
</#if>
</#list>
all: ${build_path}/${project_name}.hex ${build_path}/${project_name}.eep
TARGETS = \
<#if recipe_objcopy_hex_pattern??>
${build_path}/${project_name}.hex \
</#if>
<#if recipe_objcopy_epp_pattern??>
${build_path}/${project_name}.eep \
</#if>
<#if recipe_objcopy_bin_pattern??>
${build_path}/${project_name}.bin \
</#if>
all: $(TARGETS)
<#if recipe_objcopy_hex_pattern??>
${build_path}/${project_name}.hex: ${build_path}/${project_name}.elf
${recipe_objcopy_hex_pattern}
</#if>
<#if recipe_objcopy_epp_pattern??>
${build_path}/${project_name}.eep: ${build_path}/${project_name}.elf
${recipe_objcopy_eep_pattern}
</#if>
<#if recipe_objcopy_bin_pattern??>
${build_path}/${project_name}.bin: ${build_path}/${project_name}.elf
${recipe_objcopy_bin_pattern}
</#if>
${build_path}/${project_name}.elf: $(PROJECT_OBJS) $(LIBRARIES_OBJS) ${build_path}/core.a
${recipe_c_combine_pattern}