Skip to content

Commit 2491c16

Browse files
committed
Merge branch 'lib-1.5-rev2' into HEAD
2 parents 8595d14 + 4b73026 commit 2491c16

File tree

130 files changed

+915
-829
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+915
-829
lines changed

app/src/processing/app/Base.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,8 +1323,6 @@ public void onBoardOrPortChange() {
13231323
} catch (IOException e) {
13241324
showWarning(_("Error"), _("Error loading libraries"), e);
13251325
}
1326-
String currentArch = Base.getTargetPlatform().getId();
1327-
libraries = libraries.filterByArchitecture(currentArch);
13281326

13291327
// Populate importToLibraryTable
13301328
importToLibraryTable = new HashMap<String, Library>();

app/src/processing/app/Sketch.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import processing.core.*;
3939
import static processing.app.I18n._;
4040

41-
import java.awt.*;
4241
import java.io.*;
4342
import java.util.*;
4443
import java.util.List;

app/src/processing/app/debug/Compiler.java

Lines changed: 113 additions & 101 deletions
Large diffs are not rendered by default.

app/src/processing/app/helpers/PreferencesMap.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,37 @@ public String getOrExcept(String k) throws PreferencesMapException {
265265
public String toString() {
266266
return toString("");
267267
}
268+
269+
/**
270+
* Creates a new File instance by converting the value of the key into an
271+
* abstract pathname. If the the given key doesn't exists or his value is the
272+
* empty string, the result is <b>null</b>.
273+
*
274+
* @param key
275+
* @return
276+
*/
277+
public File getFile(String key) {
278+
if (!containsKey(key))
279+
return null;
280+
String path = get(key).trim();
281+
if (path.length() == 0)
282+
return null;
283+
return new File(path);
284+
}
285+
286+
/**
287+
* Creates a new File instance by converting the value of the key into an
288+
* abstract pathname with the specified sub folder. If the the given key
289+
* doesn't exists or his value is the empty string, the result is <b>null</b>.
290+
*
291+
* @param key
292+
* @param subFolder
293+
* @return
294+
*/
295+
public File getFile(String key, String subFolder) {
296+
File file = getFile(key);
297+
if (file == null)
298+
return null;
299+
return new File(file, subFolder);
300+
}
268301
}
Lines changed: 123 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package processing.app.packages;
22

3-
import static processing.app.helpers.StringUtils.wildcardMatch;
4-
53
import java.io.File;
64
import java.io.IOException;
75
import java.util.ArrayList;
@@ -17,24 +15,30 @@ public class Library {
1715
private String name;
1816
private String version;
1917
private String author;
20-
private String email;
21-
private String url;
18+
private String maintainer;
2219
private String sentence;
2320
private String paragraph;
24-
private List<String> coreDependencies;
25-
private List<String> dependencies;
26-
private File folder, srcFolder, archFolder;
21+
private String url;
22+
private String category;
23+
private String license;
2724
private List<String> architectures;
28-
private boolean pre15Lib;
25+
private File folder;
26+
private File srcFolder;
27+
private boolean useRecursion;
28+
private boolean isLegacy;
2929

3030
private static final List<String> MANDATORY_PROPERTIES = Arrays
31-
.asList(new String[] { "architectures", "author", "core-dependencies",
32-
"dependencies", "email", "name", "paragraph", "sentence", "url",
33-
"version" });
31+
.asList(new String[] { "name", "version", "author", "maintainer",
32+
"sentence", "paragraph", "url" });
33+
34+
private static final List<String> CATEGORIES = Arrays.asList(new String[] {
35+
"Display", "Communication", "Signal Input/Output", "Sensors",
36+
"Device Control", "Timing", "Data Storage", "Data Processing", "Other",
37+
"Uncategorized" });
3438

3539
/**
3640
* Scans inside a folder and create a Library object out of it. Automatically
37-
* detects pre-1.5 libraries. Automatically fills metadata from
41+
* detects legacy libraries. Automatically fills metadata from
3842
* library.properties file if found.
3943
*
4044
* @param libFolder
@@ -45,7 +49,7 @@ static public Library create(File libFolder) throws IOException {
4549
// "library.properties"
4650
File check = new File(libFolder, "library.properties");
4751
if (!check.exists() || !check.isFile())
48-
return createPre15Library(libFolder);
52+
return createLegacyLibrary(libFolder);
4953
else
5054
return createLibrary(libFolder);
5155
}
@@ -59,17 +63,43 @@ private static Library createLibrary(File libFolder) throws IOException {
5963
// Library sanity checks
6064
// ---------------------
6165

62-
// 1. Check mandatory properties
66+
// Compatibility with 1.5 rev.1 libraries:
67+
// "email" field changed to "maintainer"
68+
if (!properties.containsKey("maintainer"))
69+
properties.put("maintainer", properties.get("email"));
70+
71+
// Compatibility with 1.5 rev.1 libraries:
72+
// "arch" folder no longer supported
73+
File archFolder = new File(libFolder, "arch");
74+
if (archFolder.isDirectory())
75+
throw new IOException("'arch' folder is no longer supported! See "
76+
+ "http://goo.gl/gfFJzU for more information");
77+
78+
// Check mandatory properties
6379
for (String p : MANDATORY_PROPERTIES)
6480
if (!properties.containsKey(p))
6581
throw new IOException("Missing '" + p + "' from library");
6682

67-
// 2. Check mandatory folders
83+
// Check layout
84+
boolean useRecursion;
6885
File srcFolder = new File(libFolder, "src");
69-
if (!srcFolder.exists() || !srcFolder.isDirectory())
70-
throw new IOException("Missing 'src' folder");
7186

72-
// 3. Warn if root folder contains development leftovers
87+
if (srcFolder.exists() && srcFolder.isDirectory()) {
88+
// Layout with a single "src" folder and recursive compilation
89+
useRecursion = true;
90+
91+
File utilFolder = new File(libFolder, "utility");
92+
if (utilFolder.exists() && utilFolder.isDirectory()) {
93+
throw new IOException(
94+
"Library can't use both 'src' and 'utility' folders.");
95+
}
96+
} else {
97+
// Layout with source code on library's root and "utility" folders
98+
srcFolder = libFolder;
99+
useRecursion = false;
100+
}
101+
102+
// Warn if root folder contains development leftovers
73103
for (File file : libFolder.listFiles()) {
74104
if (file.isDirectory()) {
75105
if (FileUtils.isSCCSOrHiddenFile(file)) {
@@ -81,71 +111,77 @@ private static Library createLibrary(File libFolder) throws IOException {
81111
}
82112

83113
// Extract metadata info
114+
String architectures = properties.get("architectures");
115+
if (architectures == null)
116+
architectures = "*"; // defaults to "any"
84117
List<String> archs = new ArrayList<String>();
85-
for (String arch : properties.get("architectures").split(","))
118+
for (String arch : architectures.split(","))
86119
archs.add(arch.trim());
87120

88-
List<String> coreDeps = new ArrayList<String>();
89-
for (String dep : properties.get("core-dependencies").split(","))
90-
coreDeps.add(dep.trim());
121+
String category = properties.get("category");
122+
if (category == null)
123+
category = "Uncategorized";
124+
if (!CATEGORIES.contains(category))
125+
category = "Uncategorized";
91126

92-
List<String> dependencies = new ArrayList<String>();
93-
for (String dependency : properties.get("dependencies").split(",")) {
94-
dependency = dependency.trim();
95-
if (!dependency.equals("")) {
96-
dependencies.add(dependency);
97-
}
98-
}
127+
String license = properties.get("license");
128+
if (license == null)
129+
license = "Unspecified";
99130

100131
Library res = new Library();
101132
res.folder = libFolder;
102133
res.srcFolder = srcFolder;
103-
res.archFolder = new File(libFolder, "arch");
104134
res.name = properties.get("name").trim();
135+
res.version = properties.get("version").trim();
105136
res.author = properties.get("author").trim();
106-
res.email = properties.get("email").trim();
137+
res.maintainer = properties.get("maintainer").trim();
107138
res.sentence = properties.get("sentence").trim();
108139
res.paragraph = properties.get("paragraph").trim();
109140
res.url = properties.get("url").trim();
141+
res.category = category.trim();
142+
res.license = license.trim();
110143
res.architectures = archs;
111-
res.coreDependencies = coreDeps;
112-
res.dependencies = dependencies;
113-
res.version = properties.get("version").trim();
114-
res.pre15Lib = false;
144+
res.useRecursion = useRecursion;
145+
res.isLegacy = false;
115146
return res;
116147
}
117148

118-
private static Library createPre15Library(File libFolder) {
149+
private static Library createLegacyLibrary(File libFolder) {
119150
// construct an old style library
120151
Library res = new Library();
121152
res.folder = libFolder;
122153
res.srcFolder = libFolder;
154+
res.useRecursion = false;
123155
res.name = libFolder.getName();
124156
res.architectures = Arrays.asList("*");
125-
res.pre15Lib = true;
157+
res.isLegacy = true;
126158
return res;
127159
}
128160

129-
public List<File> getSrcFolders(String reqArch) {
130-
if (!supportsArchitecture(reqArch))
131-
return null;
132-
List<File> res = new ArrayList<File>();
133-
res.add(srcFolder);
134-
File archSpecificFolder = new File(archFolder, reqArch);
135-
if (archSpecificFolder.exists() && archSpecificFolder.isDirectory()) {
136-
res.add(archSpecificFolder);
137-
} else {
138-
// If specific architecture folder is not found try with "default"
139-
archSpecificFolder = new File(archFolder, "default");
140-
if (archSpecificFolder.exists() && archSpecificFolder.isDirectory())
141-
res.add(archSpecificFolder);
142-
}
143-
return res;
161+
/**
162+
* Returns <b>true</b> if the library declares to support the specified
163+
* architecture (through the "architectures" property field).
164+
*
165+
* @param reqArch
166+
* @return
167+
*/
168+
public boolean supportsArchitecture(String reqArch) {
169+
return architectures.contains(reqArch) || architectures.contains("*");
144170
}
145171

146-
public boolean supportsArchitecture(String reqArch) {
147-
for (String arch : architectures)
148-
if (wildcardMatch(reqArch, arch))
172+
/**
173+
* Returns <b>true</b> if the library declares to support at least one of the
174+
* specified architectures.
175+
*
176+
* @param reqArchs
177+
* A List of architectures to check
178+
* @return
179+
*/
180+
public boolean supportsArchitecture(List<String> reqArchs) {
181+
if (reqArchs.contains("*"))
182+
return true;
183+
for (String reqArch : reqArchs)
184+
if (supportsArchitecture(reqArch))
149185
return true;
150186
return false;
151187
}
@@ -157,18 +193,10 @@ public int compare(Library o1, Library o2) {
157193
}
158194
};
159195

160-
public File getSrcFolder() {
161-
return srcFolder;
162-
}
163-
164196
public String getName() {
165197
return name;
166198
}
167199

168-
public boolean isPre15Lib() {
169-
return pre15Lib;
170-
}
171-
172200
public File getFolder() {
173201
return folder;
174202
}
@@ -181,18 +209,6 @@ public String getAuthor() {
181209
return author;
182210
}
183211

184-
public List<String> getCoreDependencies() {
185-
return coreDependencies;
186-
}
187-
188-
public List<String> getDependencies() {
189-
return dependencies;
190-
}
191-
192-
public String getEmail() {
193-
return email;
194-
}
195-
196212
public String getParagraph() {
197213
return paragraph;
198214
}
@@ -205,23 +221,49 @@ public String getUrl() {
205221
return url;
206222
}
207223

224+
public String getCategory() {
225+
return category;
226+
}
227+
228+
public String getLicense() {
229+
return license;
230+
}
231+
232+
public static List<String> getCategories() {
233+
return CATEGORIES;
234+
}
235+
208236
public String getVersion() {
209237
return version;
210238
}
211239

240+
public String getMaintainer() {
241+
return maintainer;
242+
}
243+
244+
public boolean useRecursion() {
245+
return useRecursion;
246+
}
247+
248+
public File getSrcFolder() {
249+
return srcFolder;
250+
}
251+
252+
public boolean isLegacy() {
253+
return isLegacy;
254+
}
255+
212256
@Override
213257
public String toString() {
214258
String res = "Library:";
215259
res += " (name=" + name + ")";
216-
res += " (architectures=" + architectures + ")";
260+
res += " (version=" + version + ")";
217261
res += " (author=" + author + ")";
218-
res += " (core-dependencies=" + coreDependencies + ")";
219-
res += " (dependencies=" + dependencies + ")";
220-
res += " (email=" + email + ")";
221-
res += " (paragraph=" + paragraph + ")";
262+
res += " (maintainer=" + maintainer + ")";
222263
res += " (sentence=" + sentence + ")";
264+
res += " (paragraph=" + paragraph + ")";
223265
res += " (url=" + url + ")";
224-
res += " (version=" + version + ")";
266+
res += " (architectures=" + architectures + ")";
225267
return res;
226268
}
227269
}

build/shared/revisions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
ARDUINO 1.5.6 BETA
33

44
[ide]
5+
* Implemented 1.5 library specification Rev.2
6+
(https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification)
57
* Improved command-line parsing (Matthijs Kooijman)
68

79
[libraries]

libraries/Audio/library.properties

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
name=Audio
2-
author=cmaglie
3-
email=Cristian Maglie <c.maglie@bug.st>
4-
sentence=Play audio files through the DAC outputs of the Arduino Due.
5-
paragraph=With this library you can use the Arduino Due DAC outputs to play audio files.<br />The audio files must be in the raw .wav format.
6-
url=http://arduino.cc/en/Reference/Audio
7-
architectures=sam
8-
version=1.0
9-
dependencies=
10-
core-dependencies=arduino (>=1.5.0)
1+
name=Audio
2+
version=1.0
3+
author=Arduino
4+
maintainer=Arduino <info@arduino.cc>
5+
sentence=Play audio files through the DAC outputs of the Arduino Due.
6+
paragraph=With this library you can use the Arduino Due DAC outputs to play audio files.<br />The audio files must be in the raw .wav format.
7+
url=http://arduino.cc/en/Reference/Audio
8+
architectures=sam
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)