10000 Filter examples based on contributed libraries by architecture by facchinm · Pull Request #4828 · arduino/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Filter examples based on contributed libraries by architecture #4828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1104,6 +1105,7 @@ public LibraryList getIDELibs() {
List<UserLibrary> libs = installedLibraries.stream()
.filter(CONTRIBUTED.negate())
.filter(RETIRED.negate())
.filter(COMPATIBLE)
.collect(Collectors.toList());
return new LibraryList(libs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ private void scanLibrary(File folder, boolean isSketchbook) throws IOException {
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
Expand Down
20 changes: 15 additions & 5 deletions arduino-core/src/processing/app/packages/LibraryList.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,25 @@ public synchronized UserLibrary getByName(String name) {
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() {
Expand Down
0