Skip to content

Commit 7fa975d

Browse files
committed
Merge branch 'import-library-meta' of https://github.com/cmaglie/Arduino
2 parents 25fe4f4 + 8f20f4d commit 7fa975d

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

app/src/processing/app/Sketch.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -917,20 +917,20 @@ public boolean addFile(File sourceFile) {
917917
}
918918

919919

920-
public void importLibrary(UserLibrary lib) throws IOException {
921-
importLibrary(lib.getSrcFolder());
922-
}
923-
924920
/**
925-
* Add import statements to the current tab for all of packages inside
926-
* the specified jar file.
921+
* Add import statements to the current tab for the specified library
927922
*/
928-
private void importLibrary(File jarPath) throws IOException {
923+
public void importLibrary(UserLibrary lib) throws IOException {
929924
// make sure the user didn't hide the sketch folder
930925
ensureExistence();
931926

932-
String list[] = Base.headerListFromIncludePath(jarPath);
933-
if (list == null || list.length == 0) {
927+
List<String> list = lib.getIncludes();
928+
if (list == null) {
929+
File srcFolder = lib.getSrcFolder();
930+
String[] headers = Base.headerListFromIncludePath(srcFolder);
931+
list = Arrays.asList(headers);
932+
}
933+
if (list.isEmpty()) {
934934
return;
935935
}
936936

arduino-core/src/processing/app/packages/UserLibrary.java

+15
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class UserLibrary extends ContributedLibrary {
5656
private List<String> types;
5757
private List<String> declaredTypes;
5858
private boolean onGoingDevelopment;
59+
private List<String> includes;
5960

6061
public static UserLibrary create(File libFolder) throws IOException {
6162
// Parse metadata
@@ -131,6 +132,13 @@ public static UserLibrary create(File libFolder) throws IOException {
131132
typesList.add(type.trim());
132133
}
133134

135+
List<String> includes = null;
136+
if (properties.containsKey("includes")) {
137+
includes = new ArrayList<>();
138+
for (String i : properties.get("includes").split(","))
139+
includes.add(i.trim());
140+
}
141+
134142
UserLibrary res = new UserLibrary();
135143
res.setInstalledFolder(libFolder);
136144
res.setInstalled(true);
@@ -147,6 +155,7 @@ public static UserLibrary create(File libFolder) throws IOException {
147155
res.layout = layout;
148156
res.declaredTypes = typesList;
149157
res.onGoingDevelopment = Files.exists(Paths.get(libFolder.getAbsolutePath(), Constants.LIBRARY_DEVELOPMENT_FLAG_FILE));
158+
res.includes = includes;
150159
return res;
151160
}
152161

@@ -247,6 +256,10 @@ public boolean onGoingDevelopment() {
247256
return onGoingDevelopment;
248257
}
249258

259+
public List<String> getIncludes() {
260+
return includes;
261+
}
262+
250263
protected enum LibraryLayout {
251264
FLAT, RECURSIVE
252265
}
@@ -278,6 +291,8 @@ public String toString() {
278291
res += " (paragraph=" + paragraph + ")\n";
279292
res += " (url=" + website + ")\n";
280293
res += " (architectures=" + architectures + ")\n";
294+
if (includes != null)
295+
res += " (includes=" + includes + ")\n";
281296
return res;
282297
}
283298

build/shared/revisions.txt

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ ARDUINO 1.6.10
33
[ide]
44
* A lot of bugfixes to builder:
55
https://github.com/arduino/arduino-builder/issues?q=milestone%3A1.3.19+is%3Aclosed
6+
* Libraries can now define the property "includes" in the library.properties to
7+
tell the IDE which `#include <...>` lines should be added to the sketch when
8+
the "Include library" command is used. See:
9+
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format
610

711
[core]
812
* fixed a small bug that caused a compile error on some 3rd party derivatives

0 commit comments

Comments
 (0)