Skip to content

"Include library" now checks for includes property #5066

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 1, 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
18 changes: 9 additions & 9 deletions app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -917,20 +917,20 @@ public boolean addFile(File sourceFile) {
}


public void importLibrary(UserLibrary lib) throws IOException {
importLibrary(lib.getSrcFolder());
}

/**
* Add import statements to the current tab for all of packages inside
* the specified jar file.
* Add import statements to the current tab for the specified library
*/
private void importLibrary(File jarPath) throws IOException {
public void importLibrary(UserLibrary lib) throws IOException {
// make sure the user didn't hide the sketch folder
ensureExistence();

String list[] = Base.headerListFromIncludePath(jarPath);
if (list == null || list.length == 0) {
List<String> list = lib.getIncludes();
if (list == null) {
File srcFolder = lib.getSrcFolder();
String[] headers = Base.headerListFromIncludePath(srcFolder);
list = Arrays.asList(headers);
}
if (list.isEmpty()) {
return;
}

Expand Down
15 changes: 15 additions & 0 deletions arduino-core/src/processing/app/packages/UserLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class UserLibrary extends ContributedLibrary {
private List<String> types;
private List<String> declaredTypes;
private boolean onGoingDevelopment;
private List<String> includes;

public static UserLibrary create(File libFolder) throws IOException {
// Parse metadata
Expand Down Expand Up @@ -131,6 +132,13 @@ public static UserLibrary create(File libFolder) throws IOException {
typesList.add(type.trim());
}

List<String> includes = null;
if (properties.containsKey("includes")) {
includes = new ArrayList<>();
for (String i : properties.get("includes").split(","))
includes.add(i.trim());
}

UserLibrary res = new UserLibrary();
res.setInstalledFolder(libFolder);
res.setInstalled(true);
Expand All @@ -147,6 +155,7 @@ public static UserLibrary create(File libFolder) throws IOException {
res.layout = layout;
res.declaredTypes = typesList;
res.onGoingDevelopment = Files.exists(Paths.get(libFolder.getAbsolutePath(), Constants.LIBRARY_DEVELOPMENT_FLAG_FILE));
res.includes = includes;
return res;
}

Expand Down Expand Up @@ -247,6 +256,10 @@ public boolean onGoingDevelopment() {
return onGoingDevelopment;
}

public List<String> getIncludes() {
return includes;
}

protected enum LibraryLayout {
FLAT, RECURSIVE
}
Expand Down Expand Up @@ -278,6 +291,8 @@ public String toString() {
res += " (paragraph=" + paragraph + ")\n";
res += " (url=" + website + ")\n";
res += " (architectures=" + architectures + ")\n";
if (includes != null)
res += " (includes=" + includes + ")\n";
return res;
}

Expand Down