mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-1981 - Support Tool - initial support tool fixes; updates to module
discovery to use the classpath in dev mode for filtering
This commit is contained in:
parent
25f7df2aa7
commit
38d18751a3
8 changed files with 84 additions and 9 deletions
|
@ -37,4 +37,6 @@ color.palette.white = white
|
|||
|
||||
// TODO replace values above with dark values
|
||||
#color.palette.black = lightgray
|
||||
#color.palette.yellow = rgb(191, 191, 64) // olive
|
||||
#color.palette.yellow = rgb(191, 191, 64) // olive
|
||||
|
||||
color.palette.cyan = #00CCCC // less harsh
|
|
@ -51,7 +51,7 @@ color.bg.fieldpanel.selection = color.bg.selection
|
|||
color.bg.fieldpanel.highlight = color.bg.highlight
|
||||
color.bg.fieldpanel.selection-highlight = green
|
||||
|
||||
// Icons file
|
||||
// Icons files
|
||||
icon.empty = images/EmptyIcon16.gif
|
||||
icon.help = images/help-browser.png
|
||||
icon.add = images/Plus2.png
|
||||
|
|
|
@ -15,12 +15,16 @@
|
|||
*/
|
||||
package docking.framework;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.framework.ApplicationProperties;
|
||||
import ghidra.framework.GModule;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import util.CollectionUtils;
|
||||
import utility.application.ApplicationLayout;
|
||||
|
@ -36,6 +40,10 @@ public class DockingApplicationLayout extends ApplicationLayout {
|
|||
|
||||
private static final String NO_RELEASE_NAME = "NO_RELEASE";
|
||||
|
||||
/** Dev mode main source bin dir pattern */
|
||||
private static final Pattern CLASS_PATH_MODULE_NAME_PATTERN =
|
||||
Pattern.compile(".*/(\\w+)/bin/main");
|
||||
|
||||
/**
|
||||
* Constructs a new docking application layout object with the given name and version.
|
||||
*
|
||||
|
@ -64,7 +72,11 @@ public class DockingApplicationLayout extends ApplicationLayout {
|
|||
* properties.
|
||||
*
|
||||
* @param applicationRootDirs list of application root directories which should be
|
||||
<<<<<<< Upstream, based on origin/master
|
||||
* used to identify modules and resources. The first entry will be treated as the
|
||||
=======
|
||||
* used to identify modules and resources. The first entry will be treated as the
|
||||
>>>>>>> 4485b75 GP-1981 - Support Tool - initial support tool fixes; updates to module discovery to use the classpath in dev mode for filtering
|
||||
* installation root.
|
||||
* @param applicationProperties The properties object that will be read system properties.
|
||||
* @throws FileNotFoundException if there was a problem getting a user directory.
|
||||
|
@ -74,6 +86,7 @@ public class DockingApplicationLayout extends ApplicationLayout {
|
|||
|
||||
this.applicationProperties = Objects.requireNonNull(applicationProperties);
|
||||
this.applicationRootDirs = applicationRootDirs;
|
||||
applicationRootDirs.addAll(getAdditionalApplicationRootDirs(applicationRootDirs));
|
||||
|
||||
// Application installation directory
|
||||
applicationInstallationDir = applicationRootDirs.iterator().next().getParentFile();
|
||||
|
@ -102,6 +115,53 @@ public class DockingApplicationLayout extends ApplicationLayout {
|
|||
applicationInstallationDir);
|
||||
}
|
||||
|
||||
protected Collection<ResourceFile> getAdditionalApplicationRootDirs(
|
||||
Collection<ResourceFile> roots) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected Map<String, GModule> findModules() {
|
||||
if (!SystemUtilities.isInDevelopmentMode()) {
|
||||
// in release mode we only have one application root, so no need to find all others
|
||||
return ModuleUtilities.findModules(applicationRootDirs, applicationRootDirs);
|
||||
}
|
||||
|
||||
// In development mode we may have multiple module root directories under which modules may
|
||||
// be found. Search all roots for modules.
|
||||
Collection<ResourceFile> roots =
|
||||
ModuleUtilities.findModuleRootDirectories(applicationRootDirs, new ArrayList<>());
|
||||
Map<String, GModule> allModules = ModuleUtilities.findModules(applicationRootDirs, roots);
|
||||
|
||||
// Filter any modules found to ensure that we only include those that are listed on the
|
||||
// classpath. (Due to the nature of how the development classpath is created, not all
|
||||
// found modules may match the classpath entries.)
|
||||
Set<String> cpNames = getClassPathModuleNames();
|
||||
Map<String, GModule> filteredModules = new HashMap<>();
|
||||
Set<Entry<String, GModule>> entrySet = allModules.entrySet();
|
||||
for (Entry<String, GModule> entry : entrySet) {
|
||||
GModule module = entry.getValue();
|
||||
if (cpNames.contains(module.getName())) {
|
||||
filteredModules.put(entry.getKey(), module);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredModules;
|
||||
}
|
||||
|
||||
private Set<String> getClassPathModuleNames() {
|
||||
String cp = System.getProperty("java.class.path");
|
||||
String[] pathParts = cp.split(File.pathSeparator);
|
||||
Set<String> paths = new HashSet<>(Arrays.asList(pathParts));
|
||||
Set<String> cpNames = new HashSet<>();
|
||||
for (String cpEntry : paths) {
|
||||
Matcher matcher = CLASS_PATH_MODULE_NAME_PATTERN.matcher(cpEntry);
|
||||
if (matcher.matches()) {
|
||||
cpNames.add(matcher.group(1));
|
||||
}
|
||||
}
|
||||
return cpNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default list of Application directories. In repo-based
|
||||
* development mode this includes the root Ghidra directory within each repo.
|
||||
|
|
|
@ -128,6 +128,7 @@ public class ThemeIconTableModel extends GDynamicColumnTableModel<IconValue, Obj
|
|||
return renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparator<ResolvedIcon> getComparator() {
|
||||
return (v1, v2) -> {
|
||||
if (v1 == null && v2 == null) {
|
||||
|
@ -210,7 +211,8 @@ public class ThemeIconTableModel extends GDynamicColumnTableModel<IconValue, Obj
|
|||
|
||||
}
|
||||
|
||||
record ResolvedIcon(String id, String refId, Icon icon) {/**/}
|
||||
record ResolvedIcon(String id, String refId, Icon icon) {
|
||||
/**/}
|
||||
|
||||
public void reloadCurrent() {
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ public class GTreeRenderer extends DefaultTreeCellRenderer implements GComponent
|
|||
paintDropTarget = (value == dropTarget);
|
||||
|
||||
setBackground(selected1 ? getBackgroundSelectionColor() : getBackgroundNonSelectionColor());
|
||||
|
||||
if (!(value instanceof GTreeNode)) {
|
||||
// not a GTree
|
||||
return this;
|
||||
|
@ -99,6 +100,7 @@ public class GTreeRenderer extends DefaultTreeCellRenderer implements GComponent
|
|||
* method.
|
||||
*
|
||||
* @param c the source color
|
||||
* @param defaultKey the GColor key to use if the given color is a ColorUIResource
|
||||
* @return the new color
|
||||
*/
|
||||
protected Color fromUiResource(Color c, String defaultKey) {
|
||||
|
|
|
@ -44,6 +44,8 @@ public class GThemeDefaults {
|
|||
// generic color concepts
|
||||
//@formatter:off
|
||||
public static final GColor BACKGROUND = new GColor("color.bg");
|
||||
public static final GColor ERROR = new GColor("color.fg.error");
|
||||
public static final GColor FOREGROUND = new GColor("color.fg");
|
||||
public static final GColor TOOLTIP_BACKGROUND = new GColor("color.bg.tooltip");
|
||||
//@formatter:on
|
||||
|
||||
|
|
|
@ -245,8 +245,8 @@ public class Gui {
|
|||
|
||||
if (color == null) {
|
||||
if (validate && isInitialized) {
|
||||
// Throwable t = getFilteredTrace();
|
||||
Msg.error(Gui.class, "No color value registered for: " + id);
|
||||
Throwable t = getFilteredTrace();
|
||||
Msg.error(Gui.class, "No color value registered for: " + id, t);
|
||||
}
|
||||
return Color.CYAN;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package ghidra.framework;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -22,6 +23,12 @@ import generic.jar.ResourceFile;
|
|||
import ghidra.util.Msg;
|
||||
import utility.module.ModuleManifestFile;
|
||||
|
||||
/**
|
||||
* Represents a module in universe of repos. This class has the notion of 'shadow' modules, which
|
||||
* are those modules that live under a repo other than the module root directory, but in the same
|
||||
* path structure. This allows for optional repos to be used, adding content to the module when
|
||||
* that repo is present.
|
||||
*/
|
||||
public class GModule {
|
||||
private final String BUILD_OUTPUT_DIR = "build";
|
||||
private static final HashSet<String> EXCLUDED_DIRECTORY_NAMES = new HashSet<>();
|
||||
|
@ -99,7 +106,7 @@ public class GModule {
|
|||
String moduleRootPath = moduleRoot.getAbsolutePath();
|
||||
|
||||
for (ResourceFile appRoot : appRoots) {
|
||||
String appRootPath = appRoot.getAbsolutePath();
|
||||
String appRootPath = appRoot.getAbsolutePath() + File.separator;
|
||||
|
||||
if (moduleRootPath.equals(appRootPath)) {
|
||||
// The module root is an appRoot; it doesn't support nested modules
|
||||
|
@ -107,7 +114,7 @@ public class GModule {
|
|||
}
|
||||
|
||||
if (moduleRootPath.startsWith(appRootPath)) {
|
||||
return moduleRootPath.substring(appRootPath.length() + 1);
|
||||
return moduleRootPath.substring(appRootPath.length());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue