Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLutz Hamann2018-12-03 14:37:47 +0000
committerDoug Schaefer2018-12-06 15:30:54 +0000
commit12207e79dba630db61194df723e199d86c2728b1 (patch)
tree627b20ed4398951c73067841911255db2dbda87e
parent4c605d68c5e8af4a1e948956f6be118a86a4c865 (diff)
downloadorg.eclipse.cdt-12207e79dba630db61194df723e199d86c2728b1.tar.gz
org.eclipse.cdt-12207e79dba630db61194df723e199d86c2728b1.tar.xz
org.eclipse.cdt-12207e79dba630db61194df723e199d86c2728b1.zip
Bug 533588 - respect OS-specific override in platform.txt
HierarchicalProperties already allow for OS-specific overrides, so 1 - convert platformProperties to HierarchicalProperties 2 - change HierarchicalProperties to allow overwriting of non-empty properties. Before it would only use the platform child if the value for the entry itself was null. With this change, if a platform child exists its value is used if - it contains a property or - has an empty property and no further children. In this case the value was specifically overridden with null This change also allows proper parsing of esp32 platform.txt Change-Id: Ie13a1bee57c216f6ab37cfc0208ef7711dfc62e8 Change-Id: Ie13a1bee57c216f6ab37cfc0208ef7711dfc62e8 Signed-off-by: Lutz Hamann <lhamann@planettime.de>
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/HierarchicalProperties.java50
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPlatform.java11
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java7
3 files changed, 39 insertions, 29 deletions
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/HierarchicalProperties.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/HierarchicalProperties.java
index 54508295031..565d8405958 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/HierarchicalProperties.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/HierarchicalProperties.java
@@ -22,11 +22,24 @@ public class HierarchicalProperties {
private String value;
private Map<String, HierarchicalProperties> children;
+ private String platName;
public HierarchicalProperties() {
+ switch (Platform.getOS()) {
+ case Platform.OS_WIN32:
+ platName = "windows"; //$NON-NLS-1$
+ break;
+ case Platform.OS_MACOSX:
+ platName = "macosx"; //$NON-NLS-1$
+ break;
+ case Platform.OS_LINUX:
+ platName = "linux"; //$NON-NLS-1$
+ break;
+ }
}
public HierarchicalProperties(LinkedProperties properties) {
+ this();
for (Object keyObj : properties.orderedKeys()) {
String key = (String) keyObj;
String value = (String) properties.get(key);
@@ -81,25 +94,15 @@ public class HierarchicalProperties {
}
public String getValue() {
- if (value == null) {
- // Try a platform child
- String platName = null;
- switch (Platform.getOS()) {
- case Platform.OS_WIN32:
- platName = "windows"; //$NON-NLS-1$
- break;
- case Platform.OS_MACOSX:
- platName = "macosx"; //$NON-NLS-1$
- break;
- case Platform.OS_LINUX:
- platName = "linux"; //$NON-NLS-1$
- break;
- }
- if (platName != null) {
- HierarchicalProperties platChild = getChild(platName);
- if (platChild != null) {
- return platChild.getValue();
- }
+ // Try a platform child
+ if (platName != null && hasChild(platName)) {
+ HierarchicalProperties child = getChild(platName);
+
+ // return the child's value if
+ // - it has a property
+ // - it has no more children. In that case the value could even be null (specifically overridden)
+ if ((null != child.getValue()) || (!child.hasChildren())) {
+ return child.getValue();
}
}
return value;
@@ -113,6 +116,14 @@ public class HierarchicalProperties {
return children;
}
+ private boolean hasChildren() {
+ return (children != null && children.size() > 0);
+ }
+
+ private boolean hasChild(String key) {
+ return (children != null && children.containsKey(key));
+ }
+
public HierarchicalProperties getChild(String key) {
return children != null ? children.get(key) : null;
}
@@ -180,5 +191,4 @@ public class HierarchicalProperties {
}
}
}
-
}
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPlatform.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPlatform.java
index af2bf642a48..c0a5bccc966 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPlatform.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoPlatform.java
@@ -58,7 +58,7 @@ public class ArduinoPlatform {
private Path installPath;
private ArduinoPackage pkg;
private HierarchicalProperties boardsProperties;
- private LinkedProperties platformProperties;
+ private HierarchicalProperties platformProperties;
private HierarchicalProperties programmerProperties;
private Map<String, String> menus = new HashMap<>();
private Map<String, ArduinoLibrary> libraries;
@@ -109,7 +109,7 @@ public class ArduinoPlatform {
return size;
}
- public void setPlatformProperties(LinkedProperties platformProperties) {
+ public void setPlatformProperties(HierarchicalProperties platformProperties) {
this.platformProperties = platformProperties;
}
@@ -187,9 +187,9 @@ public class ArduinoPlatform {
return null;
}
- public LinkedProperties getPlatformProperties() throws CoreException {
+ public HierarchicalProperties getPlatformProperties() throws CoreException {
if (platformProperties == null) {
- platformProperties = new LinkedProperties();
+ LinkedProperties rawPlatformProps = new LinkedProperties();
try (BufferedReader reader = new BufferedReader(
new FileReader(getInstallPath().resolve("platform.txt").toFile()))) { //$NON-NLS-1$
// There are regex's here and need to preserve the \'s
@@ -199,11 +199,12 @@ public class ArduinoPlatform {
buffer.append('\n');
}
try (Reader reader1 = new StringReader(buffer.toString())) {
- platformProperties.load(reader1);
+ rawPlatformProps.load(reader1);
}
} catch (IOException e) {
throw Activator.coreException(e);
}
+ platformProperties = new HierarchicalProperties(rawPlatformProps);
}
return platformProperties;
}
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 38441826f54..62d0ccaa47e 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
@@ -187,13 +187,13 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
ArduinoPlatform superPlatform = manager.getInstalledPlatform(segments[0],
platform.getArchitecture());
if (superPlatform != null) {
- boardProperties.putAll(superPlatform.getPlatformProperties());
+ boardProperties.putAll(superPlatform.getPlatformProperties().flatten());
}
}
}
// Platform
- boardProperties.putAll(platform.getPlatformProperties());
+ boardProperties.putAll(platform.getPlatformProperties().flatten());
// Tools
for (ToolDependency toolDep : platform.getToolsDependencies()) {
@@ -520,8 +520,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
properties.put("config.path", "{tools." + toolName + ".config.path}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// properties for the tool flattened
- HierarchicalProperties toolsProps = new HierarchicalProperties(platform.getPlatformProperties())
- .getChild("tools"); //$NON-NLS-1$
+ HierarchicalProperties toolsProps = platform.getPlatformProperties().getChild("tools"); //$NON-NLS-1$
if (toolsProps != null) {
HierarchicalProperties toolProps = toolsProps.getChild(toolName);
if (toolProps != null) {

Back to the top