mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
Factoring Library class, step 2: first try parsing library metadata
This commit is contained in:
parent
a2fc4332b9
commit
aa2d0e0c3c
@ -1044,25 +1044,17 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LibraryList getIDELibs() {
|
public LibraryList getIDELibs() {
|
||||||
LibraryList libs = new LibraryList();
|
|
||||||
if (libraries == null)
|
if (libraries == null)
|
||||||
return libs;
|
return new LibraryList();
|
||||||
for (Library lib : libraries) {
|
LibraryList res = new LibraryList(libraries);
|
||||||
if (!FileUtils.isSubDirectory(getSketchbookFolder(), lib.getRootFolder()))
|
res.removeAll(getUserLibs());
|
||||||
libs.add(lib);
|
return res;
|
||||||
}
|
|
||||||
return libs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LibraryList getUserLibs() {
|
public LibraryList getUserLibs() {
|
||||||
LibraryList libs = new LibraryList();
|
|
||||||
if (libraries == null)
|
if (libraries == null)
|
||||||
return libs;
|
return new LibraryList();
|
||||||
for (Library lib : libraries) {
|
return libraries.filterLibrariesInSubfolder(getSketchbookFolder());
|
||||||
if (FileUtils.isSubDirectory(getSketchbookFolder(), lib.getRootFolder()))
|
|
||||||
libs.add(lib);
|
|
||||||
}
|
|
||||||
return libs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebuildImportMenu(JMenu importMenu, final Editor editor) {
|
public void rebuildImportMenu(JMenu importMenu, final Editor editor) {
|
||||||
@ -1124,28 +1116,16 @@ public class Base {
|
|||||||
|
|
||||||
// Add examples from libraries
|
// Add examples from libraries
|
||||||
LibraryList ideLibs = getIDELibs();
|
LibraryList ideLibs = getIDELibs();
|
||||||
Collections.sort(ideLibs, Library.CASE_INSENSITIVE_ORDER);
|
ideLibs.sort();
|
||||||
for (Library lib : ideLibs) {
|
for (Library lib : ideLibs)
|
||||||
File folder = lib.getRootFolder();
|
addSketchesSubmenu(menu, lib, false);
|
||||||
String name = lib.getName();
|
|
||||||
addSketchesSubmenu(menu, name, folder, false);
|
|
||||||
// Allows "fat" libraries to have examples in the root folder
|
|
||||||
if (folder.getName().equals(Base.getTargetPlatform().getName()))
|
|
||||||
addSketchesSubmenu(menu, name, folder.getParentFile(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
LibraryList userLibs = getUserLibs();
|
LibraryList userLibs = getUserLibs();
|
||||||
if (userLibs.size()>0) {
|
if (userLibs.size()>0) {
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
Collections.sort(userLibs, Library.CASE_INSENSITIVE_ORDER);
|
userLibs.sort();
|
||||||
for (Library lib : userLibs) {
|
for (Library lib : userLibs)
|
||||||
File folder = lib.getRootFolder();
|
addSketchesSubmenu(menu, lib, false);
|
||||||
String name = lib.getName();
|
|
||||||
addSketchesSubmenu(menu, name, folder, false);
|
|
||||||
// Allows "fat" libraries to have examples in the root folder
|
|
||||||
if (folder.getName().equals(Base.getTargetPlatform().getName()))
|
|
||||||
addSketchesSubmenu(menu, name, folder.getParentFile(), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1155,7 +1135,7 @@ public class Base {
|
|||||||
public LibraryList scanLibraries(List<File> folders) {
|
public LibraryList scanLibraries(List<File> folders) {
|
||||||
LibraryList res = new LibraryList();
|
LibraryList res = new LibraryList();
|
||||||
for (File folder : folders)
|
for (File folder : folders)
|
||||||
res.addAll(scanLibraries(folder));
|
res.addOrReplaceAll(scanLibraries(folder));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1178,8 +1158,7 @@ public class Base {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Library lib = Library.fromFolder(subfolder, Base.getTargetPlatform().getName());
|
Library lib = Library.create(subfolder);
|
||||||
|
|
||||||
// (also replace previously found libs with the same name)
|
// (also replace previously found libs with the same name)
|
||||||
if (lib != null)
|
if (lib != null)
|
||||||
res.addOrReplace(lib);
|
res.addOrReplace(lib);
|
||||||
@ -1206,18 +1185,20 @@ public class Base {
|
|||||||
// Libraries located in the latest folders on the list can override
|
// Libraries located in the latest folders on the list can override
|
||||||
// other libraries with the same name.
|
// other libraries with the same name.
|
||||||
libraries = scanLibraries(librariesFolders);
|
libraries = scanLibraries(librariesFolders);
|
||||||
|
String currentArch = Base.getTargetPlatform().getName();
|
||||||
|
libraries = libraries.filterByArchitecture(currentArch);
|
||||||
|
|
||||||
// Populate importToLibraryTable
|
// Populate importToLibraryTable
|
||||||
importToLibraryTable = new HashMap<String, Library>();
|
importToLibraryTable = new HashMap<String, Library>();
|
||||||
for (Library lib : libraries) {
|
for (Library lib : libraries) {
|
||||||
try {
|
try {
|
||||||
String headers[] = headerListFromIncludePath(lib.getRootFolder());
|
String headers[] = headerListFromIncludePath(lib.getSrcFolder());
|
||||||
for (String header : headers) {
|
for (String header : headers) {
|
||||||
importToLibraryTable.put(header, lib);
|
importToLibraryTable.put(header, lib);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
showWarning(_("Error"), I18n
|
showWarning(_("Error"), I18n
|
||||||
.format("Unable to list header files in {0}", lib.getRootFolder()), e);
|
.format("Unable to list header files in {0}", lib.getSrcFolder()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1495,6 +1476,13 @@ public class Base {
|
|||||||
return ifound; // actually ignored, but..
|
return ifound; // actually ignored, but..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean addSketchesSubmenu(JMenu menu, Library lib,
|
||||||
|
boolean replaceExisting)
|
||||||
|
throws IOException {
|
||||||
|
return addSketchesSubmenu(menu, lib.getName(), lib.getFolder(),
|
||||||
|
replaceExisting);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean addSketchesSubmenu(JMenu menu, String name, File folder,
|
private boolean addSketchesSubmenu(JMenu menu, String name, File folder,
|
||||||
final boolean replaceExisting) throws IOException {
|
final boolean replaceExisting) throws IOException {
|
||||||
|
|
||||||
@ -1564,26 +1552,25 @@ public class Base {
|
|||||||
protected void addLibraries(JMenu menu, LibraryList libs) throws IOException {
|
protected void addLibraries(JMenu menu, LibraryList libs) throws IOException {
|
||||||
|
|
||||||
LibraryList list = new LibraryList(libs);
|
LibraryList list = new LibraryList(libs);
|
||||||
Collections.sort(list, Library.CASE_INSENSITIVE_ORDER);
|
list.sort();
|
||||||
|
|
||||||
ActionListener listener = new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent event) {
|
|
||||||
String jarPath = event.getActionCommand();
|
|
||||||
try {
|
|
||||||
activeEditor.getSketch().importLibrary(jarPath);
|
|
||||||
} catch (IOException e) {
|
|
||||||
showWarning(_("Error"), I18n.format("Unable to list header files in {0}", jarPath), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (Library lib : list) {
|
for (Library lib : list) {
|
||||||
File folder = lib.getRootFolder();
|
@SuppressWarnings("serial")
|
||||||
|
AbstractAction action = new AbstractAction(lib.getName()) {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
Library l = (Library) getValue("library");
|
||||||
|
try {
|
||||||
|
activeEditor.getSketch().importLibrary(l);
|
||||||
|
} catch (IOException e) {
|
||||||
|
showWarning(_("Error"), I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
action.putValue("library", lib);
|
||||||
|
|
||||||
// Add new element at the bottom
|
// Add new element at the bottom
|
||||||
JMenuItem item = new JMenuItem(lib.getName());
|
JMenuItem item = new JMenuItem(action);
|
||||||
item.addActionListener(listener);
|
item.putClientProperty("library", lib);
|
||||||
item.setActionCommand(folder.getAbsolutePath());
|
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
||||||
// XXX: DAM: should recurse here so that library folders can be nested
|
// XXX: DAM: should recurse here so that library folders can be nested
|
||||||
|
@ -89,12 +89,6 @@ public class Sketch {
|
|||||||
/** Class path determined during build. */
|
/** Class path determined during build. */
|
||||||
private String classPath;
|
private String classPath;
|
||||||
|
|
||||||
/**
|
|
||||||
* This is *not* the "Processing" libraries path, this is the Java libraries
|
|
||||||
* path, as in java.library.path=BlahBlah, which identifies search paths for
|
|
||||||
* DLLs or JNILIBs.
|
|
||||||
*/
|
|
||||||
private String libraryPath;
|
|
||||||
/**
|
/**
|
||||||
* List of library folders.
|
* List of library folders.
|
||||||
*/
|
*/
|
||||||
@ -1122,15 +1116,19 @@ public class Sketch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void importLibrary(Library 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 all of packages inside
|
||||||
* the specified jar file.
|
* the specified jar file.
|
||||||
*/
|
*/
|
||||||
public void importLibrary(String jarPath) throws IOException {
|
public void importLibrary(File jarPath) 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(new File(jarPath));
|
String list[] = Base.headerListFromIncludePath(jarPath);
|
||||||
|
|
||||||
// import statements into the main sketch file (code[0])
|
// import statements into the main sketch file (code[0])
|
||||||
// if the current code is a .java file, insert into current
|
// if the current code is a .java file, insert into current
|
||||||
@ -1424,8 +1422,6 @@ public class Sketch {
|
|||||||
// grab the imports from the code just preproc'd
|
// grab the imports from the code just preproc'd
|
||||||
|
|
||||||
importedLibraries = new LibraryList();
|
importedLibraries = new LibraryList();
|
||||||
//Remember to clear library path before building it.
|
|
||||||
libraryPath = "";
|
|
||||||
for (String item : preprocessor.getExtraImports()) {
|
for (String item : preprocessor.getExtraImports()) {
|
||||||
|
|
||||||
Library lib = Base.importToLibraryTable.get(item);
|
Library lib = Base.importToLibraryTable.get(item);
|
||||||
@ -1433,8 +1429,6 @@ public class Sketch {
|
|||||||
|
|
||||||
if (lib != null && !importedLibraries.contains(lib)) {
|
if (lib != null && !importedLibraries.contains(lib)) {
|
||||||
importedLibraries.add(lib);
|
importedLibraries.add(lib);
|
||||||
//classPath += Compiler.contentsToClassPath(libFolder);
|
|
||||||
libraryPath += File.pathSeparator + lib.getRootFolder().getAbsolutePath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1889,11 +1883,6 @@ public class Sketch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getLibraryPath() {
|
|
||||||
return libraryPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SketchCode[] getCode() {
|
public SketchCode[] getCode() {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
if (prefs.get("build.variant.path").length() != 0)
|
if (prefs.get("build.variant.path").length() != 0)
|
||||||
includePaths.add(prefs.get("build.variant.path"));
|
includePaths.add(prefs.get("build.variant.path"));
|
||||||
for (Library lib : sketch.getImportedLibraries())
|
for (Library lib : sketch.getImportedLibraries())
|
||||||
includePaths.add(lib.getRootFolder().getPath());
|
includePaths.add(lib.getSrcFolder().getPath());
|
||||||
|
|
||||||
// 1. compile the sketch (already in the buildPath)
|
// 1. compile the sketch (already in the buildPath)
|
||||||
sketch.setCompilingProgress(30);
|
sketch.setCompilingProgress(30);
|
||||||
@ -582,11 +582,11 @@ public class Compiler implements MessageConsumer {
|
|||||||
void compileLibraries(List<String> includePaths) throws RunnerException {
|
void compileLibraries(List<String> includePaths) throws RunnerException {
|
||||||
File outputPath = new File(prefs.get("build.path"));
|
File outputPath = new File(prefs.get("build.path"));
|
||||||
for (Library lib : sketch.getImportedLibraries()) {
|
for (Library lib : sketch.getImportedLibraries()) {
|
||||||
File libFolder = lib.getRootFolder();
|
File libFolder = lib.getSrcFolder();
|
||||||
if (lib.isNewLib()) {
|
if (lib.isPre15Lib()) {
|
||||||
recursiveCompileLibrary(outputPath, libFolder, includePaths);
|
|
||||||
} else {
|
|
||||||
compileLibrary(outputPath, libFolder, includePaths);
|
compileLibrary(outputPath, libFolder, includePaths);
|
||||||
|
} else {
|
||||||
|
recursiveCompileLibrary(outputPath, libFolder, includePaths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
app/src/processing/app/helpers/StringMatchers.java
Normal file
21
app/src/processing/app/helpers/StringMatchers.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package processing.app.helpers;
|
||||||
|
|
||||||
|
public class StringMatchers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to match <b>input</b> with <b>pattern</b>. The pattern can use the
|
||||||
|
* "*" and "?" globs to match any-char-sequence and any-char respectively.
|
||||||
|
*
|
||||||
|
* @param input
|
||||||
|
* The string to be checked
|
||||||
|
* @param pattern
|
||||||
|
* The pattern to match
|
||||||
|
* @return <b>true</b> if the <b>input</b> matches the <b>pattern</b>,
|
||||||
|
* <b>false</b> otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean wildcardMatch(String input, String pattern) {
|
||||||
|
String regex = pattern.replace("?", ".?").replace("*", ".*?");
|
||||||
|
return input.matches(regex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,64 +1,114 @@
|
|||||||
package processing.app.packages;
|
package processing.app.packages;
|
||||||
|
|
||||||
|
import static processing.app.helpers.StringMatchers.wildcardMatch;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import processing.app.helpers.PreferencesMap;
|
||||||
|
|
||||||
public class Library {
|
public class Library {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private File folder;
|
private String version;
|
||||||
|
private File folder, srcFolder;
|
||||||
private List<String> architectures;
|
private List<String> architectures;
|
||||||
private boolean oldLib = true;
|
private boolean pre15Lib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans inside a library folder to see if it contains a version suitable for
|
* Scans inside a folder and create a Library object out of it. Automatically
|
||||||
* the actual selected architecture. If a suitable version is found the folder
|
* detects pre-1.5 libraries. Automatically fills metadata from
|
||||||
* containing that version is selected, otherwise <b>null</b> is selected.<br />
|
* library.properties file if found.
|
||||||
* <br />
|
|
||||||
* If an old-style library is detected, we assume that the library is suitable
|
|
||||||
* for the current architecture and the libFolder parameter is used.<br />
|
|
||||||
*
|
*
|
||||||
* @param libFolder
|
* @param libFolder
|
||||||
* @param arch
|
|
||||||
* Currently selected architecture
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static public Library fromFolder(File libFolder, String arch) {
|
static public Library create(File libFolder) {
|
||||||
// A library is considered "new" if it contains a file called
|
// A library is considered "new" if it contains a file called
|
||||||
// "library.properties"
|
// "library.properties"
|
||||||
File libraryPropFile = new File(libFolder, "library.properties");
|
File check = new File(libFolder, "library.properties");
|
||||||
if (!libraryPropFile.exists() || !libraryPropFile.isFile()) {
|
if (!check.exists() || !check.isFile())
|
||||||
// construct an old style library
|
return createPre15Library(libFolder);
|
||||||
Library res = new Library();
|
else
|
||||||
res.folder = libFolder;
|
return createLibrary(libFolder);
|
||||||
res.name = libFolder.getName();
|
}
|
||||||
res.oldLib = true;
|
|
||||||
return res;
|
private static Library createLibrary(File libFolder) {
|
||||||
|
// Parse metadata
|
||||||
|
File propertiesFile = new File(libFolder, "library.properties");
|
||||||
|
PreferencesMap properties = new PreferencesMap();
|
||||||
|
try {
|
||||||
|
properties.load(propertiesFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for a subfolder for actual architecture, return null if not found
|
// Library sanity checks
|
||||||
File archSubfolder = new File(libFolder, arch);
|
// ---------------------
|
||||||
if (!archSubfolder.exists() || !archSubfolder.isDirectory())
|
|
||||||
|
// 1. Check mandatory properties
|
||||||
|
if (!properties.containsKey("name"))
|
||||||
|
return null;
|
||||||
|
if (!properties.containsKey("version"))
|
||||||
|
return null;
|
||||||
|
if (!properties.containsKey("architectures"))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
// 2. Check mandatory folders
|
||||||
|
File srcFolder = new File(libFolder, "src");
|
||||||
|
if (!srcFolder.exists() && !srcFolder.isDirectory())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// TODO: 3. check if root folder contains prohibited stuff
|
||||||
|
|
||||||
|
// Extract metadata info
|
||||||
|
// TODO: do for all metadata
|
||||||
|
List<String> archs = new ArrayList<String>();
|
||||||
|
for (String arch : properties.get("architectures").split(","))
|
||||||
|
archs.add(arch.trim());
|
||||||
|
|
||||||
Library res = new Library();
|
Library res = new Library();
|
||||||
res.folder = archSubfolder;
|
res.folder = libFolder;
|
||||||
res.name = libFolder.getName();
|
res.srcFolder = srcFolder;
|
||||||
res.oldLib = false;
|
res.name = properties.get("name").trim();
|
||||||
|
res.architectures = archs;
|
||||||
|
res.version = properties.get("version").trim();
|
||||||
|
res.pre15Lib = false;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getRootFolder() {
|
private static Library createPre15Library(File libFolder) {
|
||||||
return folder;
|
// construct an old style library
|
||||||
|
Library res = new Library();
|
||||||
|
res.folder = libFolder;
|
||||||
|
res.srcFolder = libFolder;
|
||||||
|
res.name = libFolder.getName();
|
||||||
|
res.architectures = Arrays.asList(new String[] { "*" });
|
||||||
|
res.pre15Lib = true;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public List<File> getSrcFolders(String reqArch) {
|
||||||
return name;
|
if (!supportsArchitecture(reqArch))
|
||||||
|
return null;
|
||||||
|
List<File> res = new ArrayList<File>();
|
||||||
|
res.add(srcFolder);
|
||||||
|
File archSpecificFolder = new File(srcFolder, reqArch);
|
||||||
|
if (archSpecificFolder.exists() && archSpecificFolder.isDirectory())
|
||||||
|
res.add(archSpecificFolder);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String _name) {
|
public boolean supportsArchitecture(String reqArch) {
|
||||||
name = _name;
|
for (String arch : architectures)
|
||||||
|
if (wildcardMatch(reqArch, arch))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Comparator<Library> CASE_INSENSITIVE_ORDER = new Comparator<Library>() {
|
public static final Comparator<Library> CASE_INSENSITIVE_ORDER = new Comparator<Library>() {
|
||||||
@ -68,12 +118,19 @@ public class Library {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public boolean isOldLib() {
|
public File getSrcFolder() {
|
||||||
return oldLib;
|
return srcFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNewLib() {
|
public String getName() {
|
||||||
return !oldLib;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPre15Lib() {
|
||||||
|
return pre15Lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFolder() {
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package processing.app.packages;
|
package processing.app.packages;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import processing.app.helpers.FileUtils;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class LibraryList extends ArrayList<Library> {
|
public class LibraryList extends ArrayList<Library> {
|
||||||
@ -27,4 +32,39 @@ public class LibraryList extends ArrayList<Library> {
|
|||||||
add(lib);
|
add(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addOrReplaceAll(Collection<? extends Library> c) {
|
||||||
|
for (Library l : c)
|
||||||
|
addOrReplace(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sort() {
|
||||||
|
Collections.sort(this, Library.CASE_INSENSITIVE_ORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Library search(String name, String arch) {
|
||||||
|
for (Library lib : this) {
|
||||||
|
if (!lib.getName().equals(name))
|
||||||
|
continue;
|
||||||
|
if (!lib.supportsArchitecture(arch))
|
||||||
|
continue;
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LibraryList filterByArchitecture(String reqArch) {
|
||||||
|
LibraryList res = new LibraryList();
|
||||||
|
for (Library lib : this)
|
||||||
|
if (lib.supportsArchitecture(reqArch))
|
||||||
|
res.add(lib);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LibraryList filterLibrariesInSubfolder(File subFolder) {
|
||||||
|
LibraryList res = new LibraryList();
|
||||||
|
for (Library lib : this)
|
||||||
|
if (FileUtils.isSubDirectory(subFolder, lib.getFolder()))
|
||||||
|
res.add(lib);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class PdeKeywords extends CTokenMarker {
|
|||||||
keywordToReference = new Hashtable();
|
keywordToReference = new Hashtable();
|
||||||
getKeywords(Base.getLibStream("keywords.txt"));
|
getKeywords(Base.getLibStream("keywords.txt"));
|
||||||
for (Library lib : Base.getLibraries()) {
|
for (Library lib : Base.getLibraries()) {
|
||||||
File keywords = new File(lib.getRootFolder(), "keywords.txt");
|
File keywords = new File(lib.getFolder(), "keywords.txt");
|
||||||
if (keywords.exists()) getKeywords(new FileInputStream(keywords));
|
if (keywords.exists()) getKeywords(new FileInputStream(keywords));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user