GP-3490: GhidraDev run config fixes

This commit is contained in:
Ryan Kurtz 2024-08-27 11:11:53 -04:00
parent 8625a21892
commit 67a2f88803
2 changed files with 16 additions and 7 deletions

View file

@ -29,7 +29,7 @@ import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.launching.*; import org.eclipse.jdt.launching.*;
import ghidra.GhidraLauncher; import ghidra.Ghidra;
/** /**
* Utility methods for working with Ghidra launchers in Eclipse. * Utility methods for working with Ghidra launchers in Eclipse.
@ -134,10 +134,7 @@ public class GhidraLaunchUtils {
/** /**
* Sets the main type name attribute in the provided working copy. For Ghidra projects, this * Sets the main type name attribute in the provided working copy. For Ghidra projects, this
* should be {@link GhidraLauncher}. * should be {@link Ghidra}.
* <p>
* TODO: {@link GhidraLauncher#main(String[])} is deprecated. Fix in future version of
* GhidraDev when we are ready to break backwards compatibility with Ghidra.
* *
* @param wc The launch configuration working copy to modify. * @param wc The launch configuration working copy to modify.
* @return The modified working copy. * @return The modified working copy.
@ -145,7 +142,7 @@ public class GhidraLaunchUtils {
public static ILaunchConfigurationWorkingCopy setMainTypeName( public static ILaunchConfigurationWorkingCopy setMainTypeName(
ILaunchConfigurationWorkingCopy wc) { ILaunchConfigurationWorkingCopy wc) {
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
GhidraLauncher.class.getName()); Ghidra.class.getName());
return wc; return wc;
} }
@ -216,6 +213,18 @@ public class GhidraLaunchUtils {
List<String> newList = new ArrayList<>(); List<String> newList = new ArrayList<>();
IJavaProject javaProject = JavaRuntime.getJavaProject(wc); IJavaProject javaProject = JavaRuntime.getJavaProject(wc);
if (javaProject != null) { if (javaProject != null) {
// Add current project (might need to add dependent projects later)
newList.add(JavaRuntime.newProjectRuntimeClasspathEntry(javaProject).getMemento());
// Add JDK
newList.add(JavaRuntime
.newRuntimeContainerClasspathEntry(
JavaRuntime.newJREContainerPath(JavaRuntime.getVMInstall(javaProject)),
IRuntimeClasspathEntry.STANDARD_CLASSES)
.getMemento());
// Add Ghidra jar source
for (IClasspathEntry entry : javaProject.getRawClasspath()) { for (IClasspathEntry entry : javaProject.getRawClasspath()) {
IPath sourcePath = entry.getSourceAttachmentPath(); IPath sourcePath = entry.getSourceAttachmentPath();
if (sourcePath != null) { if (sourcePath != null) {

View file

@ -110,7 +110,7 @@ public class GhidraModuleUtils {
sourceFolderInfos.add(new SourceFolderInfo(project.getFolder("ghidra_scripts"), sourceFolderInfos.add(new SourceFolderInfo(project.getFolder("ghidra_scripts"),
project.getFolder("bin/scripts"))); project.getFolder("bin/scripts")));
for (SourceFolderInfo sourceFolderInfo : sourceFolderInfos) { for (SourceFolderInfo sourceFolderInfo : sourceFolderInfos) {
GhidraProjectUtils.createFolder(sourceFolderInfo.outputFolder(), monitor); GhidraProjectUtils.createFolder(sourceFolderInfo.sourceFolder(), monitor);
} }
// Put the source directories in the project's classpath // Put the source directories in the project's classpath