Skip to content

Commit 2b53d69

Browse files
committed
Added the possibility to override library compatibility check
1 parent 512925a commit 2b53d69

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

app/src/processing/app/debug/Compiler.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.FileReader;
3131
import java.io.IOException;
3232
import java.util.ArrayList;
33+
import java.util.Arrays;
3334
import java.util.List;
3435
import java.util.Map;
3536

@@ -102,14 +103,19 @@ public boolean compile(boolean _verbose) throws RunnerException {
102103
if (verbose)
103104
System.out.println();
104105

105-
String arch = Base.getTargetPlatform().getId();
106+
List<String> archs = new ArrayList<String>();
107+
archs.add(Base.getTargetPlatform().getId());
108+
if (prefs.containsKey("architecture.override_check")) {
109+
String[] overrides = prefs.get("architecture.override_check").split(",");
110+
archs.addAll(Arrays.asList(overrides));
111+
}
106112
for (Library lib : sketch.getImportedLibraries()) {
107-
if (!lib.supportsArchitecture(arch)) {
113+
if (!lib.supportsArchitecture(archs)) {
108114
System.err.println(I18n
109115
.format(_("WARNING: library {0} claims to run on {1} "
110116
+ "architecture(s) and may be incompatible with your"
111-
+ " current board which runs on [{2}] architecture."), lib
112-
.getName(), lib.getArchitectures(), arch));
117+
+ " current board which runs on {2} architecture(s)."), lib
118+
.getName(), lib.getArchitectures(), archs));
113119
System.err.println();
114120
}
115121
}

app/src/processing/app/packages/Library.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package processing.app.packages;
22

3-
import static processing.app.helpers.StringUtils.wildcardMatch;
4-
53
import java.io.File;
64
import java.io.IOException;
75
import java.util.ArrayList;
@@ -160,9 +158,30 @@ private static Library createLegacyLibrary(File libFolder) {
160158
return res;
161159
}
162160

161+
/**
162+
* Returns <b>true</b> if the library declares to support the specified
163+
* architecture (through the "architectures" property field).
164+
*
165+
* @param reqArch
166+
* @return
167+
*/
163168
public boolean supportsArchitecture(String reqArch) {
164-
for (String arch : architectures)
165-
if (wildcardMatch(reqArch, arch))
169+
return architectures.contains(reqArch) || architectures.contains("*");
170+
}
171+
172+
/**
173+
* Returns <b>true</b> if the library declares to support at least one of the
174+
* specified architectures.
175+
*
176+
* @param reqArchs
177+
* A List of architectures to check
178+
* @return
179+
*/
180+
public boolean supportsArchitecture(List<String> reqArchs) {
181+
if (reqArchs.contains("*"))
182+
return true;
183+
for (String reqArch : reqArchs)
184+
if (supportsArchitecture(reqArch))
166185
return true;
167186
return false;
168187
}

0 commit comments

Comments
 (0)