Merge branch 'GP-0_ryanmkurtz_lib' (Closes #5709)

This commit is contained in:
Ryan Kurtz
2023-09-20 09:43:03 -04:00

View File

@@ -475,6 +475,8 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
createUnprocessedQueue(libraryNameList, getLibraryLoadDepth(options));
boolean loadLocalLibraries = isLoadLocalLibraries(options);
boolean loadSystemLibraries = isLoadSystemLibraries(options);
List<FileSystemSearchPath> customSearchPaths =
getCustomLibrarySearchPaths(provider, options, log, monitor);
List<FileSystemSearchPath> localSearchPaths =
getLocalLibrarySearchPaths(provider, options, log, monitor);
List<FileSystemSearchPath> systemSearchPaths =
@@ -509,25 +511,34 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
// options turned off (if shouldSearchAllPaths() is overridden to return true).
// In this case, we still want to process those libraries, but we
// do not want to save them, so they can be released.
boolean loadedLocal = false;
if (!localSearchPaths.isEmpty()) {
Loaded<Program> loadedLibrary = loadLibraryFromSearchPaths(
libraryName, provider, localSearchPaths, libraryDestFolderPath,
unprocessed, depth, desiredLoadSpec, options, log, consumer, monitor);
boolean loaded = false;
if (!customSearchPaths.isEmpty()) {
Loaded<Program> loadedLibrary = loadLibraryFromSearchPaths(libraryName,
provider, customSearchPaths, libraryDestFolderPath, unprocessed, depth,
desiredLoadSpec, options, log, consumer, monitor);
if (loadedLibrary != null) {
loadedPrograms.add(loadedLibrary);
loaded = true;
}
}
if (!loaded && !localSearchPaths.isEmpty()) {
Loaded<Program> loadedLibrary = loadLibraryFromSearchPaths(libraryName,
provider, localSearchPaths, libraryDestFolderPath, unprocessed, depth,
desiredLoadSpec, options, log, consumer, monitor);
if (loadedLibrary != null) {
if (loadLocalLibraries) {
loadedPrograms.add(loadedLibrary);
loadedLocal = true;
loaded = true;
}
else {
loadedLibrary.release(consumer);
}
}
}
if (!loadedLocal && !systemSearchPaths.isEmpty()) {
Loaded<Program> loadedLibrary = loadLibraryFromSearchPaths(
libraryName, provider, systemSearchPaths, libraryDestFolderPath,
unprocessed, depth, desiredLoadSpec, options, log, consumer, monitor);
if (!loaded && !systemSearchPaths.isEmpty()) {
Loaded<Program> loadedLibrary = loadLibraryFromSearchPaths(libraryName,
provider, systemSearchPaths, libraryDestFolderPath, unprocessed, depth,
desiredLoadSpec, options, log, consumer, monitor);
if (loadedLibrary != null) {
if (loadSystemLibraries) {
loadedPrograms.add(loadedLibrary);
@@ -1013,6 +1024,23 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
*/
private record FileSystemSearchPath(FileSystemRef fsRef, Path fsPath) {}
/**
* Gets a {@link List} of priority-ordered custom {@link FileSystemSearchPath}s used to search
* for libraries. The default implementation of this method returns an empty {@link List}.
* Subclasses can override it as needed.
*
* @param provider The {@link ByteProvider} of the program being loaded
* @param options The options
* @param log The log
* @param monitor A cancelable task monitor
* @return A {@link List} of priority-ordered custom {@link FileSystemSearchPath}s used to
* search for libraries
*/
protected List<FileSystemSearchPath> getCustomLibrarySearchPaths(ByteProvider provider,
List<Option> options, MessageLog log, TaskMonitor monitor) {
return List.of();
}
/**
* Gets a {@link List} of priority-ordered local {@link FileSystemSearchPath}s used to search
* for libraries
@@ -1021,7 +1049,7 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
* @param options The options
* @param log The log
* @param monitor A cancelable task monitor
* @return A {@link List} of priority-ordered local {@link FileSystemSearchPath}s used to s
* @return A {@link List} of priority-ordered local {@link FileSystemSearchPath}s used to
* search for libraries
*/
private List<FileSystemSearchPath> getLocalLibrarySearchPaths(ByteProvider provider,