1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-18 12:54:25 +01:00

Merge pull request #4828 from facchinm/issue_4762

Filter examples based on contributed libraries by architecture
This commit is contained in:
Sandeep Mistry 2016-07-19 10:00:18 -04:00
commit afe204f97f
3 changed files with 19 additions and 7 deletions

View File

@ -82,6 +82,7 @@ public class Base {
public static final Predicate<UserLibrary> CONTRIBUTED = library -> library.getTypes() == null || library.getTypes().isEmpty() || library.getTypes().contains("Contributed");
public static final Predicate<UserLibrary> RETIRED = library -> library.getTypes() != null && library.getTypes().contains("Retired");
public static final Predicate<UserLibrary> COMPATIBLE = library -> library.getArchitectures() != null && (library.getArchitectures().contains("*") || library.getArchitectures().contains(BaseNoGui.getTargetPlatform().getId()));
private static final int RECENT_SKETCHES_MAX_SIZE = 10;
@ -1104,6 +1105,7 @@ public class Base {
List<UserLibrary> libs = installedLibraries.stream()
.filter(CONTRIBUTED.negate())
.filter(RETIRED.negate())
.filter(COMPATIBLE)
.collect(Collectors.toList());
return new LibraryList(libs);
}

View File

@ -187,11 +187,11 @@ public class LibrariesIndexer {
if (headers.length == 0) {
throw new IOException(lib.getSrcFolder().getAbsolutePath());
}
installedLibraries.addOrReplace(lib);
installedLibraries.addOrReplaceArchAware(lib);
if (isSketchbook) {
installedLibrariesWithDuplicates.add(lib);
} else {
installedLibrariesWithDuplicates.addOrReplace(lib);
installedLibrariesWithDuplicates.addOrReplaceArchAware(lib);
}
// Check if we can find the same library in the index

View File

@ -57,15 +57,25 @@ public class LibraryList extends LinkedList<UserLibrary> {
return null;
}
public synchronized void addOrReplaceArchAware(UserLibrary lib) {
addOrReplace(lib, true);
}
public synchronized void addOrReplace(UserLibrary lib) {
remove(lib);
addOrReplace(lib, false);
}
public synchronized void addOrReplace(UserLibrary lib, boolean archAware) {
remove(lib, archAware);
add(lib);
}
public synchronized void remove(UserLibrary lib) {
public synchronized void remove(UserLibrary lib, boolean archAware) {
UserLibrary l = getByName(lib.getName());
if (l != null)
super.remove(l);
if (l != null) {
if (!archAware || lib.getArchitectures().contains("*") || lib.getArchitectures().containsAll(l.getArchitectures()))
super.remove(l);
}
}
public synchronized void sort() {