1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-15 12:29:26 +01:00

Merge branch 'lib-1.5-rev2' into HEAD

This commit is contained in:
Cristian Maglie 2014-01-09 14:56:23 +01:00
commit 2491c16d77
130 changed files with 918 additions and 832 deletions

View File

@ -1323,8 +1323,6 @@ public class Base {
} catch (IOException e) { } catch (IOException e) {
showWarning(_("Error"), _("Error loading libraries"), e); showWarning(_("Error"), _("Error loading libraries"), e);
} }
String currentArch = Base.getTargetPlatform().getId();
libraries = libraries.filterByArchitecture(currentArch);
// Populate importToLibraryTable // Populate importToLibraryTable
importToLibraryTable = new HashMap<String, Library>(); importToLibraryTable = new HashMap<String, Library>();

View File

@ -38,7 +38,6 @@ import processing.app.preproc.*;
import processing.core.*; import processing.core.*;
import static processing.app.I18n._; import static processing.app.I18n._;
import java.awt.*;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;

View File

@ -30,6 +30,7 @@ import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -88,30 +89,46 @@ public class Compiler implements MessageConsumer {
// 0. include paths for core + all libraries // 0. include paths for core + all libraries
sketch.setCompilingProgress(20); sketch.setCompilingProgress(20);
List<String> includePaths = new ArrayList<String>(); List<File> includeFolders = new ArrayList<File>();
includePaths.add(prefs.get("build.core.path")); includeFolders.add(prefs.getFile("build.core.path"));
if (prefs.get("build.variant.path").length() != 0) if (prefs.getFile("build.variant.path") != null)
includePaths.add(prefs.get("build.variant.path")); includeFolders.add(prefs.getFile("build.variant.path"));
for (Library lib : sketch.getImportedLibraries()) { for (Library lib : sketch.getImportedLibraries()) {
if (verbose) if (verbose)
System.out.println(I18n System.out.println(I18n
.format(_("Using library {0} in folder: {1} {2}"), lib.getName(), .format(_("Using library {0} in folder: {1} {2}"), lib.getName(),
lib.getFolder(), lib.isPre15Lib() ? "(pre-1.5)" : "")); lib.getFolder(), lib.isLegacy() ? "(legacy)" : ""));
for (File folder : lib.getSrcFolders(targetArch)) includeFolders.add(lib.getSrcFolder());
includePaths.add(folder.getPath());
} }
if (verbose) if (verbose)
System.out.println(); System.out.println();
List<String> archs = new ArrayList<String>();
archs.add(Base.getTargetPlatform().getId());
if (prefs.containsKey("architecture.override_check")) {
String[] overrides = prefs.get("architecture.override_check").split(",");
archs.addAll(Arrays.asList(overrides));
}
for (Library lib : sketch.getImportedLibraries()) {
if (!lib.supportsArchitecture(archs)) {
System.err.println(I18n
.format(_("WARNING: library {0} claims to run on {1} "
+ "architecture(s) and may be incompatible with your"
+ " current board which runs on {2} architecture(s)."), lib
.getName(), lib.getArchitectures(), archs));
System.err.println();
}
}
// 1. compile the sketch (already in the buildPath) // 1. compile the sketch (already in the buildPath)
sketch.setCompilingProgress(30); sketch.setCompilingProgress(30);
compileSketch(includePaths); compileSketch(includeFolders);
sketchIsCompiled = true; sketchIsCompiled = true;
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/ // 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
// Doesn't really use configPreferences // Doesn't really use configPreferences
sketch.setCompilingProgress(40); sketch.setCompilingProgress(40);
compileLibraries(includePaths); compileLibraries(includeFolders);
// 3. compile the core, outputting .o files to <buildPath> and then // 3. compile the core, outputting .o files to <buildPath> and then
// collecting them into the core.a library file. // collecting them into the core.a library file.
@ -120,15 +137,15 @@ public class Compiler implements MessageConsumer {
// 4. link it all together into the .elf file // 4. link it all together into the .elf file
sketch.setCompilingProgress(60); sketch.setCompilingProgress(60);
compileLink(includePaths); compileLink();
// 5. extract EEPROM data (from EEMEM directive) to .eep file. // 5. extract EEPROM data (from EEMEM directive) to .eep file.
sketch.setCompilingProgress(70); sketch.setCompilingProgress(70);
compileEep(includePaths); compileEep();
// 6. build the .hex file // 6. build the .hex file
sketch.setCompilingProgress(80); sketch.setCompilingProgress(80);
compileHex(includePaths); compileHex();
sketch.setCompilingProgress(90); sketch.setCompilingProgress(90);
return true; return true;
@ -218,8 +235,8 @@ public class Compiler implements MessageConsumer {
return p; return p;
} }
private List<File> compileFiles(String outputPath, File sourcePath, private List<File> compileFiles(File outputPath, File sourcePath,
boolean recurse, List<String> includePaths) boolean recurse, List<File> includeFolders)
throws RunnerException { throws RunnerException {
List<File> sSources = findFilesInFolder(sourcePath, "S", recurse); List<File> sSources = findFilesInFolder(sourcePath, "S", recurse);
List<File> cSources = findFilesInFolder(sourcePath, "c", recurse); List<File> cSources = findFilesInFolder(sourcePath, "c", recurse);
@ -227,36 +244,29 @@ public class Compiler implements MessageConsumer {
List<File> objectPaths = new ArrayList<File>(); List<File> objectPaths = new ArrayList<File>();
for (File file : sSources) { for (File file : sSources) {
String objectPath = outputPath + File.separator + file.getName() + ".o"; File objectFile = new File(outputPath, file.getName() + ".o");
objectPaths.add(new File(objectPath)); objectPaths.add(objectFile);
String[] cmd = getCommandCompilerS(includePaths, file.getAbsolutePath(), String[] cmd = getCommandCompilerS(includeFolders, file, objectFile);
objectPath);
execAsynchronously(cmd); execAsynchronously(cmd);
} }
for (File file : cSources) { for (File file : cSources) {
String objectPath = outputPath + File.separator + file.getName() + ".o"; File objectFile = new File(outputPath, file.getName() + ".o");
String dependPath = outputPath + File.separator + file.getName() + ".d"; File dependFile = new File(outputPath, file.getName() + ".d");
File objectFile = new File(objectPath);
File dependFile = new File(dependPath);
objectPaths.add(objectFile); objectPaths.add(objectFile);
if (isAlreadyCompiled(file, objectFile, dependFile, prefs)) if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
continue; continue;
String[] cmd = getCommandCompilerC(includePaths, file.getAbsolutePath(), String[] cmd = getCommandCompilerC(includeFolders, file, objectFile);
objectPath);
execAsynchronously(cmd); execAsynchronously(cmd);
} }
for (File file : cppSources) { for (File file : cppSources) {
String objectPath = outputPath + File.separator + file.getName() + ".o"; File objectFile = new File(outputPath, file.getName() + ".o");
String dependPath = outputPath + File.separator + file.getName() + ".d"; File dependFile = new File(outputPath, file.getName() + ".d");
File objectFile = new File(objectPath);
File dependFile = new File(dependPath);
objectPaths.add(objectFile); objectPaths.add(objectFile);
if (isAlreadyCompiled(file, objectFile, dependFile, prefs)) if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
continue; continue;
String[] cmd = getCommandCompilerCPP(includePaths, String[] cmd = getCommandCompilerCPP(includeFolders, file, objectFile);
file.getAbsolutePath(), objectPath);
execAsynchronously(cmd); execAsynchronously(cmd);
} }
@ -511,15 +521,15 @@ public class Compiler implements MessageConsumer {
System.err.print(s); System.err.print(s);
} }
private String[] getCommandCompilerS(List<String> includePaths, private String[] getCommandCompilerS(List<File> includeFolders,
String sourceName, String objectName) File sourceFile, File objectFile)
throws RunnerException { throws RunnerException {
String includes = preparePaths(includePaths); String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs); PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + Base.REVISION); dict.put("ide_version", "" + Base.REVISION);
dict.put("includes", includes); dict.put("includes", includes);
dict.put("source_file", sourceName); dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectName); dict.put("object_file", objectFile.getAbsolutePath());
try { try {
String cmd = prefs.get("recipe.S.o.pattern"); String cmd = prefs.get("recipe.S.o.pattern");
@ -529,16 +539,16 @@ public class Compiler implements MessageConsumer {
} }
} }
private String[] getCommandCompilerC(List<String> includePaths, private String[] getCommandCompilerC(List<File> includeFolders,
String sourceName, String objectName) File sourceFile, File objectFile)
throws RunnerException { throws RunnerException {
String includes = preparePaths(includePaths); String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs); PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + Base.REVISION); dict.put("ide_version", "" + Base.REVISION);
dict.put("includes", includes); dict.put("includes", includes);
dict.put("source_file", sourceName); dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectName); dict.put("object_file", objectFile.getAbsolutePath());
String cmd = prefs.get("recipe.c.o.pattern"); String cmd = prefs.get("recipe.c.o.pattern");
try { try {
@ -548,16 +558,16 @@ public class Compiler implements MessageConsumer {
} }
} }
private String[] getCommandCompilerCPP(List<String> includePaths, private String[] getCommandCompilerCPP(List<File> includeFolders,
String sourceName, String objectName) File sourceFile, File objectFile)
throws RunnerException { throws RunnerException {
String includes = preparePaths(includePaths); String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs); PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + Base.REVISION); dict.put("ide_version", "" + Base.REVISION);
dict.put("includes", includes); dict.put("includes", includes);
dict.put("source_file", sourceName); dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectName); dict.put("object_file", objectFile.getAbsolutePath());
String cmd = prefs.get("recipe.cpp.o.pattern"); String cmd = prefs.get("recipe.cpp.o.pattern");
try { try {
@ -606,56 +616,58 @@ public class Compiler implements MessageConsumer {
} }
// 1. compile the sketch (already in the buildPath) // 1. compile the sketch (already in the buildPath)
void compileSketch(List<String> includePaths) throws RunnerException { void compileSketch(List<File> includeFolders) throws RunnerException {
String buildPath = prefs.get("build.path"); File buildPath = prefs.getFile("build.path");
objectFiles.addAll(compileFiles(buildPath, new File(buildPath), false, objectFiles.addAll(compileFiles(buildPath, buildPath, false, includeFolders));
includePaths));
} }
// 2. compile the libraries, outputting .o files to: // 2. compile the libraries, outputting .o files to:
// <buildPath>/<library>/ // <buildPath>/<library>/
void compileLibraries(List<String> includePaths) throws RunnerException { void compileLibraries(List<File> includeFolders) throws RunnerException {
File outputPath = new File(prefs.get("build.path"));
for (Library lib : sketch.getImportedLibraries()) { for (Library lib : sketch.getImportedLibraries()) {
for (File folder : lib.getSrcFolders(targetArch)) { compileLibrary(lib, includeFolders);
if (lib.isPre15Lib()) { }
compileLibrary(outputPath, folder, includePaths); }
private void compileLibrary(Library lib, List<File> includeFolders)
throws RunnerException {
File libFolder = lib.getSrcFolder();
File libBuildFolder = prefs.getFile(("build.path"), lib.getName());
if (lib.useRecursion()) {
// libBuildFolder == {build.path}/LibName
// libFolder == {lib.path}/src
recursiveCompileFilesInFolder(libBuildFolder, libFolder, includeFolders);
} else { } else {
recursiveCompileLibrary(outputPath, folder, includePaths); // libFolder == {lib.path}/
} // utilityFolder == {lib.path}/utility
} // libBuildFolder == {build.path}/LibName
} // utilityBuildFolder == {build.path}/LibName/utility
} File utilityFolder = new File(libFolder, "utility");
File utilityBuildFolder = new File(libBuildFolder, "utility");
private void recursiveCompileLibrary(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException { includeFolders.add(utilityFolder);
File newOutputPath = compileFilesInFolder(outputPath, libraryFolder, includePaths); compileFilesInFolder(libBuildFolder, libFolder, includeFolders);
for (File subFolder : libraryFolder.listFiles(new OnlyDirs())) { compileFilesInFolder(utilityBuildFolder, utilityFolder, includeFolders);
recursiveCompileLibrary(newOutputPath, subFolder, includePaths);
}
}
private File compileFilesInFolder(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException {
File outputFolder = new File(outputPath, libraryFolder.getName());
createFolder(outputFolder);
objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(), libraryFolder, false, includePaths));
return outputFolder;
}
private void compileLibrary(File outputPath, File libraryFolder, List<String> includePaths) throws RunnerException {
File outputFolder = new File(outputPath, libraryFolder.getName());
File utilityFolder = new File(libraryFolder, "utility");
createFolder(outputFolder);
// this library can use includes in its utility/ folder
includePaths.add(utilityFolder.getAbsolutePath());
objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(),
libraryFolder, false, includePaths));
outputFolder = new File(outputFolder, "utility");
createFolder(outputFolder);
objectFiles.addAll(compileFiles(outputFolder.getAbsolutePath(),
utilityFolder, false, includePaths));
// other libraries should not see this library's utility/ folder // other libraries should not see this library's utility/ folder
includePaths.remove(includePaths.size() - 1); includeFolders.remove(utilityFolder);
}
}
private void recursiveCompileFilesInFolder(File srcBuildFolder, File srcFolder, List<File> includeFolders) throws RunnerException {
compileFilesInFolder(srcBuildFolder, srcFolder, includeFolders);
for (File subFolder : srcFolder.listFiles(new OnlyDirs())) {
File subBuildFolder = new File(srcBuildFolder, subFolder.getName());
recursiveCompileFilesInFolder(subBuildFolder, subFolder, includeFolders);
}
}
private void compileFilesInFolder(File buildFolder, File srcFolder, List<File> includeFolders) throws RunnerException {
createFolder(buildFolder);
List<File> objects = compileFiles(buildFolder, srcFolder, false, includeFolders);
objectFiles.addAll(objects);
} }
// 3. compile the core, outputting .o files to <buildPath> and then // 3. compile the core, outputting .o files to <buildPath> and then
@ -663,22 +675,22 @@ public class Compiler implements MessageConsumer {
void compileCore() void compileCore()
throws RunnerException { throws RunnerException {
String corePath = prefs.get("build.core.path"); File coreFolder = prefs.getFile("build.core.path");
String variantPath = prefs.get("build.variant.path"); File variantFolder = prefs.getFile("build.variant.path");
String buildPath = prefs.get("build.path"); File buildFolder = prefs.getFile("build.path");
List<String> includePaths = new ArrayList<String>(); List<File> includeFolders = new ArrayList<File>();
includePaths.add(corePath); // include core path only includeFolders.add(coreFolder); // include core path only
if (variantPath.length() != 0) if (variantFolder != null)
includePaths.add(variantPath); includeFolders.add(variantFolder);
List<File> coreObjectFiles = compileFiles(buildPath, new File(corePath), List<File> objectFiles = compileFiles(buildFolder, coreFolder, true,
true, includePaths); includeFolders);
if (variantPath.length() != 0) if (variantFolder != null)
coreObjectFiles.addAll(compileFiles(buildPath, new File(variantPath), objectFiles.addAll(compileFiles(buildFolder, variantFolder, true,
true, includePaths)); includeFolders));
for (File file : coreObjectFiles) { for (File file : objectFiles) {
PreferencesMap dict = new PreferencesMap(prefs); PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + Base.REVISION); dict.put("ide_version", "" + Base.REVISION);
@ -697,7 +709,7 @@ public class Compiler implements MessageConsumer {
} }
// 4. link it all together into the .elf file // 4. link it all together into the .elf file
void compileLink(List<String> includePaths) void compileLink()
throws RunnerException { throws RunnerException {
// TODO: Make the --relax thing in configuration files. // TODO: Make the --relax thing in configuration files.
@ -731,7 +743,7 @@ public class Compiler implements MessageConsumer {
} }
// 5. extract EEPROM data (from EEMEM directive) to .eep file. // 5. extract EEPROM data (from EEMEM directive) to .eep file.
void compileEep(List<String> includePaths) throws RunnerException { void compileEep() throws RunnerException {
PreferencesMap dict = new PreferencesMap(prefs); PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + Base.REVISION); dict.put("ide_version", "" + Base.REVISION);
@ -746,7 +758,7 @@ public class Compiler implements MessageConsumer {
} }
// 6. build the .hex file // 6. build the .hex file
void compileHex(List<String> includePaths) throws RunnerException { void compileHex() throws RunnerException {
PreferencesMap dict = new PreferencesMap(prefs); PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + Base.REVISION); dict.put("ide_version", "" + Base.REVISION);
@ -760,10 +772,10 @@ public class Compiler implements MessageConsumer {
execAsynchronously(cmdArray); execAsynchronously(cmdArray);
} }
private static String preparePaths(List<String> includePaths) { private static String prepareIncludes(List<File> includeFolders) {
String res = ""; String res = "";
for (String p : includePaths) for (File p : includeFolders)
res += " \"-I" + p + '"'; res += " \"-I" + p.getAbsolutePath() + '"';
// Remove first space // Remove first space
return res.substring(1); return res.substring(1);

View File

@ -265,4 +265,37 @@ public class PreferencesMap extends LinkedHashMap<String, String> {
public String toString() { public String toString() {
return toString(""); return toString("");
} }
/**
* Creates a new File instance by converting the value of the key into an
* abstract pathname. If the the given key doesn't exists or his value is the
* empty string, the result is <b>null</b>.
*
* @param key
* @return
*/
public File getFile(String key) {
if (!containsKey(key))
return null;
String path = get(key).trim();
if (path.length() == 0)
return null;
return new File(path);
}
/**
* Creates a new File instance by converting the value of the key into an
* abstract pathname with the specified sub folder. If the the given key
* doesn't exists or his value is the empty string, the result is <b>null</b>.
*
* @param key
* @param subFolder
* @return
*/
public File getFile(String key, String subFolder) {
File file = getFile(key);
if (file == null)
return null;
return new File(file, subFolder);
}
} }

View File

@ -1,7 +1,5 @@
package processing.app.packages; package processing.app.packages;
import static processing.app.helpers.StringUtils.wildcardMatch;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,24 +15,30 @@ public class Library {
private String name; private String name;
private String version; private String version;
private String author; private String author;
private String email; private String maintainer;
private String url;
private String sentence; private String sentence;
private String paragraph; private String paragraph;
private List<String> coreDependencies; private String url;
private List<String> dependencies; private String category;
private File folder, srcFolder, archFolder; private String license;
private List<String> architectures; private List<String> architectures;
private boolean pre15Lib; private File folder;
private File srcFolder;
private boolean useRecursion;
private boolean isLegacy;
private static final List<String> MANDATORY_PROPERTIES = Arrays private static final List<String> MANDATORY_PROPERTIES = Arrays
.asList(new String[] { "architectures", "author", "core-dependencies", .asList(new String[] { "name", "version", "author", "maintainer",
"dependencies", "email", "name", "paragraph", "sentence", "url", "sentence", "paragraph", "url" });
"version" });
private static final List<String> CATEGORIES = Arrays.asList(new String[] {
"Display", "Communication", "Signal Input/Output", "Sensors",
"Device Control", "Timing", "Data Storage", "Data Processing", "Other",
"Uncategorized" });
/** /**
* Scans inside a folder and create a Library object out of it. Automatically * Scans inside a folder and create a Library object out of it. Automatically
* detects pre-1.5 libraries. Automatically fills metadata from * detects legacy libraries. Automatically fills metadata from
* library.properties file if found. * library.properties file if found.
* *
* @param libFolder * @param libFolder
@ -45,7 +49,7 @@ public class Library {
// "library.properties" // "library.properties"
File check = new File(libFolder, "library.properties"); File check = new File(libFolder, "library.properties");
if (!check.exists() || !check.isFile()) if (!check.exists() || !check.isFile())
return createPre15Library(libFolder); return createLegacyLibrary(libFolder);
else else
return createLibrary(libFolder); return createLibrary(libFolder);
} }
@ -59,17 +63,43 @@ public class Library {
// Library sanity checks // Library sanity checks
// --------------------- // ---------------------
// 1. Check mandatory properties // Compatibility with 1.5 rev.1 libraries:
// "email" field changed to "maintainer"
if (!properties.containsKey("maintainer"))
properties.put("maintainer", properties.get("email"));
// Compatibility with 1.5 rev.1 libraries:
// "arch" folder no longer supported
File archFolder = new File(libFolder, "arch");
if (archFolder.isDirectory())
throw new IOException("'arch' folder is no longer supported! See "
+ "http://goo.gl/gfFJzU for more information");
// Check mandatory properties
for (String p : MANDATORY_PROPERTIES) for (String p : MANDATORY_PROPERTIES)
if (!properties.containsKey(p)) if (!properties.containsKey(p))
throw new IOException("Missing '" + p + "' from library"); throw new IOException("Missing '" + p + "' from library");
// 2. Check mandatory folders // Check layout
boolean useRecursion;
File srcFolder = new File(libFolder, "src"); File srcFolder = new File(libFolder, "src");
if (!srcFolder.exists() || !srcFolder.isDirectory())
throw new IOException("Missing 'src' folder");
// 3. Warn if root folder contains development leftovers if (srcFolder.exists() && srcFolder.isDirectory()) {
// Layout with a single "src" folder and recursive compilation
useRecursion = true;
File utilFolder = new File(libFolder, "utility");
if (utilFolder.exists() && utilFolder.isDirectory()) {
throw new IOException(
"Library can't use both 'src' and 'utility' folders.");
}
} else {
// Layout with source code on library's root and "utility" folders
srcFolder = libFolder;
useRecursion = false;
}
// Warn if root folder contains development leftovers
for (File file : libFolder.listFiles()) { for (File file : libFolder.listFiles()) {
if (file.isDirectory()) { if (file.isDirectory()) {
if (FileUtils.isSCCSOrHiddenFile(file)) { if (FileUtils.isSCCSOrHiddenFile(file)) {
@ -81,71 +111,77 @@ public class Library {
} }
// Extract metadata info // Extract metadata info
String architectures = properties.get("architectures");
if (architectures == null)
architectures = "*"; // defaults to "any"
List<String> archs = new ArrayList<String>(); List<String> archs = new ArrayList<String>();
for (String arch : properties.get("architectures").split(",")) for (String arch : architectures.split(","))
archs.add(arch.trim()); archs.add(arch.trim());
List<String> coreDeps = new ArrayList<String>(); String category = properties.get("category");
for (String dep : properties.get("core-dependencies").split(",")) if (category == null)
coreDeps.add(dep.trim()); category = "Uncategorized";
if (!CATEGORIES.contains(category))
category = "Uncategorized";
List<String> dependencies = new ArrayList<String>(); String license = properties.get("license");
for (String dependency : properties.get("dependencies").split(",")) { if (license == null)
dependency = dependency.trim(); license = "Unspecified";
if (!dependency.equals("")) {
dependencies.add(dependency);
}
}
Library res = new Library(); Library res = new Library();
res.folder = libFolder; res.folder = libFolder;
res.srcFolder = srcFolder; res.srcFolder = srcFolder;
res.archFolder = new File(libFolder, "arch");
res.name = properties.get("name").trim(); res.name = properties.get("name").trim();
res.version = properties.get("version").trim();
res.author = properties.get("author").trim(); res.author = properties.get("author").trim();
res.email = properties.get("email").trim(); res.maintainer = properties.get("maintainer").trim();
res.sentence = properties.get("sentence").trim(); res.sentence = properties.get("sentence").trim();
res.paragraph = properties.get("paragraph").trim(); res.paragraph = properties.get("paragraph").trim();
res.url = properties.get("url").trim(); res.url = properties.get("url").trim();
res.category = category.trim();
res.license = license.trim();
res.architectures = archs; res.architectures = archs;
res.coreDependencies = coreDeps; res.useRecursion = useRecursion;
res.dependencies = dependencies; res.isLegacy = false;
res.version = properties.get("version").trim();
res.pre15Lib = false;
return res; return res;
} }
private static Library createPre15Library(File libFolder) { private static Library createLegacyLibrary(File libFolder) {
// construct an old style library // construct an old style library
Library res = new Library(); Library res = new Library();
res.folder = libFolder; res.folder = libFolder;
res.srcFolder = libFolder; res.srcFolder = libFolder;
res.useRecursion = false;
res.name = libFolder.getName(); res.name = libFolder.getName();
res.architectures = Arrays.asList("*"); res.architectures = Arrays.asList("*");
res.pre15Lib = true; res.isLegacy = true;
return res;
}
public List<File> getSrcFolders(String reqArch) {
if (!supportsArchitecture(reqArch))
return null;
List<File> res = new ArrayList<File>();
res.add(srcFolder);
File archSpecificFolder = new File(archFolder, reqArch);
if (archSpecificFolder.exists() && archSpecificFolder.isDirectory()) {
res.add(archSpecificFolder);
} else {
// If specific architecture folder is not found try with "default"
archSpecificFolder = new File(archFolder, "default");
if (archSpecificFolder.exists() && archSpecificFolder.isDirectory())
res.add(archSpecificFolder);
}
return res; return res;
} }
/**
* Returns <b>true</b> if the library declares to support the specified
* architecture (through the "architectures" property field).
*
* @param reqArch
* @return
*/
public boolean supportsArchitecture(String reqArch) { public boolean supportsArchitecture(String reqArch) {
for (String arch : architectures) return architectures.contains(reqArch) || architectures.contains("*");
if (wildcardMatch(reqArch, arch)) }
/**
* Returns <b>true</b> if the library declares to support at least one of the
* specified architectures.
*
* @param reqArchs
* A List of architectures to check
* @return
*/
public boolean supportsArchitecture(List<String> reqArchs) {
if (reqArchs.contains("*"))
return true;
for (String reqArch : reqArchs)
if (supportsArchitecture(reqArch))
return true; return true;
return false; return false;
} }
@ -157,18 +193,10 @@ public class Library {
} }
}; };
public File getSrcFolder() {
return srcFolder;
}
public String getName() { public String getName() {
return name; return name;
} }
public boolean isPre15Lib() {
return pre15Lib;
}
public File getFolder() { public File getFolder() {
return folder; return folder;
} }
@ -181,18 +209,6 @@ public class Library {
return author; return author;
} }
public List<String> getCoreDependencies() {
return coreDependencies;
}
public List<String> getDependencies() {
return dependencies;
}
public String getEmail() {
return email;
}
public String getParagraph() { public String getParagraph() {
return paragraph; return paragraph;
} }
@ -205,23 +221,49 @@ public class Library {
return url; return url;
} }
public String getCategory() {
return category;
}
public String getLicense() {
return license;
}
public static List<String> getCategories() {
return CATEGORIES;
}
public String getVersion() { public String getVersion() {
return version; return version;
} }
public String getMaintainer() {
return maintainer;
}
public boolean useRecursion() {
return useRecursion;
}
public File getSrcFolder() {
return srcFolder;
}
public boolean isLegacy() {
return isLegacy;
}
@Override @Override
public String toString() { public String toString() {
String res = "Library:"; String res = "Library:";
res += " (name=" + name + ")"; res += " (name=" + name + ")";
res += " (architectures=" + architectures + ")";
res += " (author=" + author + ")";
res += " (core-dependencies=" + coreDependencies + ")";
res += " (dependencies=" + dependencies + ")";
res += " (email=" + email + ")";
res += " (paragraph=" + paragraph + ")";
res += " (sentence=" + sentence + ")";
res += " (url=" + url + ")";
res += " (version=" + version + ")"; res += " (version=" + version + ")";
res += " (author=" + author + ")";
res += " (maintainer=" + maintainer + ")";
res += " (sentence=" + sentence + ")";
res += " (paragraph=" + paragraph + ")";
res += " (url=" + url + ")";
res += " (architectures=" + architectures + ")";
return res; return res;
} }
} }

View File

@ -2,6 +2,8 @@
ARDUINO 1.5.6 BETA ARDUINO 1.5.6 BETA
[ide] [ide]
* Implemented 1.5 library specification Rev.2
(https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification)
* Improved command-line parsing (Matthijs Kooijman) * Improved command-line parsing (Matthijs Kooijman)
[libraries] [libraries]

View File

@ -1,10 +1,8 @@
name=Audio name=Audio
author=cmaglie version=1.0
email=Cristian Maglie <c.maglie@bug.st> author=Arduino
maintainer=Arduino <info@arduino.cc>
sentence=Play audio files through the DAC outputs of the Arduino Due. sentence=Play audio files through the DAC outputs of the Arduino Due.
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. 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.
url=http://arduino.cc/en/Reference/Audio url=http://arduino.cc/en/Reference/Audio
architectures=sam architectures=sam
version=1.0
dependencies=
core-dependencies=arduino (>=1.5.0)

View File

@ -1,10 +1,8 @@
name=GSM name=GSM
author=Arduino author=Arduino
email=info@arduino.cc maintainer=Arduino <info@arduino.cc>
sentence=With this library you can use the Arduino GSM shield to connect on GSM and GPRS networks sentence=With this library you can use the Arduino GSM shield to connect on GSM and GPRS networks
paragraph=Use this library to make/receive voice calls, to send and receive SMS with the Quectel M10 GSM module.</br>This library also allows you to connect to internet through the GPRS networks. You can either use web Clients and Servers.</br> paragraph=Use this library to make/receive voice calls, to send and receive SMS with the Quectel M10 GSM module.</br>This library also allows you to connect to internet through the GPRS networks. You can either use web Clients and Servers.</br>
url=http://arduino.cc/en/Reference/GSM url=http://arduino.cc/en/Reference/GSM
architectures=avr architectures=avr
version=1.0 version=1.0
dependencies=SoftwareSerial
core-dependencies=arduino (>=1.5.0)

View File

@ -1,10 +1,8 @@
name=Robot Control name=Robot Control
version=1.0
author=Arduino author=Arduino
email=info@arduino.cc maintainer=Arduino <info@arduino.cc>
sentence=This is the library for programming the Control Board of the Arduino Robot. sentence=This is the library for programming the Control Board of the Arduino Robot.
paragraph=The Arduino robot is made by two independent boards. The Control Board is the top board of the Arduino Robot, with this library you can easily write sketches to control the robot. paragraph=The Arduino robot is made by two independent boards. The Control Board is the top board of the Arduino Robot, with this library you can easily write sketches to control the robot.
url=http://arduino.cc/en/Reference/RobotLibrary url=http://arduino.cc/en/Reference/RobotLibrary
architectures=avr architectures=avr
version=1.0
dependencies=
core-dependencies=arduino (>=1.5.0)

Some files were not shown because too many files have changed in this diff Show More