mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Finding external modules from the classpath instead of the
eclipse.project.dir property.
This commit is contained in:
parent
351cf56e6e
commit
3a12b5bbe2
2 changed files with 28 additions and 28 deletions
|
@ -933,18 +933,6 @@ public abstract class ProcessorEmulatorTestAdapter extends TestCase implements E
|
|||
|
||||
ResourceFile myModuleRootDirectory =
|
||||
Application.getModuleContainingClass(getClass().getName());
|
||||
if (myModuleRootDirectory == null) {
|
||||
if (!SystemUtilities.isInDevelopmentMode()) {
|
||||
Msg.warn(this, "Unable to identify pcodetest module directory!\n" +
|
||||
"Project must contain Module.manifest file, and if developing module using Eclipse\n" +
|
||||
"w/ GhidraDev the VM argument -Declipse.project.dir=<project-path> must be specified.");
|
||||
}
|
||||
else {
|
||||
Msg.warn(this,
|
||||
"Unable to identify pcodetest module directory! Project must contain Module.manifest file");
|
||||
}
|
||||
}
|
||||
|
||||
if (myModuleRootDirectory != null) {
|
||||
File myModuleRoot = myModuleRootDirectory.getFile(false);
|
||||
if (myModuleRoot != null) {
|
||||
|
@ -954,6 +942,10 @@ public abstract class ProcessorEmulatorTestAdapter extends TestCase implements E
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Msg.warn(this,
|
||||
"Unable to identify pcodetest module directory! Project must contain Module.manifest file");
|
||||
}
|
||||
|
||||
if (resourcesTestDataDir == null || !resourcesTestDataDir.isDirectory()) {
|
||||
findTestResourceDirectory(DEFAULT_PROCESSOR_TEST_MODULE);
|
||||
|
|
|
@ -22,6 +22,7 @@ import generic.jar.ResourceFile;
|
|||
import ghidra.framework.ApplicationProperties;
|
||||
import ghidra.framework.GModule;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import utilities.util.FileUtilities;
|
||||
import utility.application.ApplicationLayout;
|
||||
import utility.application.ApplicationUtilities;
|
||||
import utility.module.ModuleUtilities;
|
||||
|
@ -142,23 +143,30 @@ public class GhidraApplicationLayout extends ApplicationLayout {
|
|||
Collection<ResourceFile> moduleRootDirectories =
|
||||
ModuleUtilities.findModuleRootDirectories(applicationRootDirs, new ArrayList<>());
|
||||
|
||||
// If Ghidra was launched from our Eclipse GhidraDev plugin, we want to add the
|
||||
// Eclipse module project (and it's dependent projects) to the list of module root
|
||||
// directories so Ghidra can discover them.
|
||||
String eclipseProjectDirProperty = System.getProperty("eclipse.project.dir");
|
||||
if (eclipseProjectDirProperty != null && !eclipseProjectDirProperty.isEmpty()) {
|
||||
ResourceFile eclipseProjectDir = new ResourceFile(eclipseProjectDirProperty);
|
||||
if (ModuleUtilities.isModuleDirectory(eclipseProjectDir)) {
|
||||
moduleRootDirectories.add(eclipseProjectDir);
|
||||
// Examine the classpath to look for modules outside of the application root directories.
|
||||
// These might exist if Ghidra was launched from an Eclipse project that resides
|
||||
// external to the Ghidra installation.
|
||||
for (String entry : System.getProperty("java.class.path", "").split(File.pathSeparator)) {
|
||||
final ResourceFile classpathEntry = new ResourceFile(entry);
|
||||
|
||||
// We only care about directories (skip jars)
|
||||
if (!classpathEntry.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip classpath entries that live in an application root directory...we've already
|
||||
// found those.
|
||||
if (applicationRootDirs.stream().anyMatch(dir -> FileUtilities.isPathContainedWithin(
|
||||
dir.getFile(false), classpathEntry.getFile(false)))) {
|
||||
continue;
|
||||
}
|
||||
String eclipseProjectDependencies = System.getProperty("eclipse.project.dependencies");
|
||||
if (eclipseProjectDependencies != null && !eclipseProjectDependencies.isEmpty()) {
|
||||
for (String path : eclipseProjectDependencies.split(File.pathSeparator)) {
|
||||
ResourceFile eclipseProjectDir = new ResourceFile(path);
|
||||
if (ModuleUtilities.isModuleDirectory(eclipseProjectDir)) {
|
||||
moduleRootDirectories.add(eclipseProjectDir);
|
||||
}
|
||||
|
||||
// We are going to assume that the classpath entry is in a subdirectory of the module
|
||||
// directory (i.e., bin/), so only check parent directory for the module.
|
||||
ResourceFile classpathEntryParent = classpathEntry.getParentFile();
|
||||
if (classpathEntryParent != null &&
|
||||
ModuleUtilities.isModuleDirectory(classpathEntryParent)) {
|
||||
moduleRootDirectories.add(classpathEntryParent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue