1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-30 19:52:13 +01:00

Merge branch 'import-library-meta' of https://github.com/cmaglie/Arduino

This commit is contained in:
Cristian Maglie 2016-07-01 15:04:21 +02:00
commit 7fa975df4f
3 changed files with 28 additions and 9 deletions

View File

@ -917,20 +917,20 @@ public class Sketch {
} }
public void importLibrary(UserLibrary lib) throws IOException {
importLibrary(lib.getSrcFolder());
}
/** /**
* Add import statements to the current tab for all of packages inside * Add import statements to the current tab for the specified library
* the specified jar file.
*/ */
private void importLibrary(File jarPath) throws IOException { public void importLibrary(UserLibrary lib) throws IOException {
// make sure the user didn't hide the sketch folder // make sure the user didn't hide the sketch folder
ensureExistence(); ensureExistence();
String list[] = Base.headerListFromIncludePath(jarPath); List<String> list = lib.getIncludes();
if (list == null || list.length == 0) { if (list == null) {
File srcFolder = lib.getSrcFolder();
String[] headers = Base.headerListFromIncludePath(srcFolder);
list = Arrays.asList(headers);
}
if (list.isEmpty()) {
return; return;
} }

View File

@ -56,6 +56,7 @@ public class UserLibrary extends ContributedLibrary {
private List<String> types; private List<String> types;
private List<String> declaredTypes; private List<String> declaredTypes;
private boolean onGoingDevelopment; private boolean onGoingDevelopment;
private List<String> includes;
public static UserLibrary create(File libFolder) throws IOException { public static UserLibrary create(File libFolder) throws IOException {
// Parse metadata // Parse metadata
@ -131,6 +132,13 @@ public class UserLibrary extends ContributedLibrary {
typesList.add(type.trim()); 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(); UserLibrary res = new UserLibrary();
res.setInstalledFolder(libFolder); res.setInstalledFolder(libFolder);
res.setInstalled(true); res.setInstalled(true);
@ -147,6 +155,7 @@ public class UserLibrary extends ContributedLibrary {
res.layout = layout; res.layout = layout;
res.declaredTypes = typesList; res.declaredTypes = typesList;
res.onGoingDevelopment = Files.exists(Paths.get(libFolder.getAbsolutePath(), Constants.LIBRARY_DEVELOPMENT_FLAG_FILE)); res.onGoingDevelopment = Files.exists(Paths.get(libFolder.getAbsolutePath(), Constants.LIBRARY_DEVELOPMENT_FLAG_FILE));
res.includes = includes;
return res; return res;
} }
@ -247,6 +256,10 @@ public class UserLibrary extends ContributedLibrary {
return onGoingDevelopment; return onGoingDevelopment;
} }
public List<String> getIncludes() {
return includes;
}
protected enum LibraryLayout { protected enum LibraryLayout {
FLAT, RECURSIVE FLAT, RECURSIVE
} }
@ -278,6 +291,8 @@ public class UserLibrary extends ContributedLibrary {
res += " (paragraph=" + paragraph + ")\n"; res += " (paragraph=" + paragraph + ")\n";
res += " (url=" + website + ")\n"; res += " (url=" + website + ")\n";
res += " (architectures=" + architectures + ")\n"; res += " (architectures=" + architectures + ")\n";
if (includes != null)
res += " (includes=" + includes + ")\n";
return res; return res;
} }

View File

@ -3,6 +3,10 @@ ARDUINO 1.6.10
[ide] [ide]
* A lot of bugfixes to builder: * A lot of bugfixes to builder:
https://github.com/arduino/arduino-builder/issues?q=milestone%3A1.3.19+is%3Aclosed https://github.com/arduino/arduino-builder/issues?q=milestone%3A1.3.19+is%3Aclosed
* Libraries can now define the property "includes" in the library.properties to
tell the IDE which `#include <...>` lines should be added to the sketch when
the "Include library" command is used. See:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format
[core] [core]
* fixed a small bug that caused a compile error on some 3rd party derivatives * fixed a small bug that caused a compile error on some 3rd party derivatives