Merge remote-tracking branch

'origin/GP-1338_ryanmkurtz_PR-3454_zZeck_pydevLocateFix' (Closes #3453,
Closes #3454)
This commit is contained in:
Ryan Kurtz 2021-09-30 07:27:31 -04:00
commit 45cd8dc795
4 changed files with 28 additions and 29 deletions

View File

@ -2,7 +2,7 @@
<feature <feature
id="ghidra.ghidradev" id="ghidra.ghidradev"
label="GhidraDev" label="GhidraDev"
version="2.1.4.qualifier" version="2.1.5.qualifier"
provider-name="Ghidra"> provider-name="Ghidra">
<description> <description>

View File

@ -19,7 +19,7 @@
<h1>GhidraDev README</h1> <h1>GhidraDev README</h1>
<p>GhidraDev provides support for developing and debugging Ghidra scripts and modules in Eclipse. <p>GhidraDev provides support for developing and debugging Ghidra scripts and modules in Eclipse.
</p> </p>
<p>The information provided in this document is effective as of GhidraDev 2.1.4 and is subject to <p>The information provided in this document is effective as of GhidraDev 2.1.5 and is subject to
change with future releases.</p> change with future releases.</p>
<ul> <ul>
@ -53,6 +53,8 @@ change with future releases.</p>
</ul> </ul>
<h2><a name="ChangeHistory"></a>Change History</h2> <h2><a name="ChangeHistory"></a>Change History</h2>
<p><u><b>2.1.5</b>:</u> Eclipse Python breakpoints now work when Eclipse installs PyDev in .p2
bundle pool directory.</p>
<p><u><b>2.1.4</b>:</u> Fixed exception that occurred when performing a "Link Ghidra" on projects <p><u><b>2.1.4</b>:</u> Fixed exception that occurred when performing a "Link Ghidra" on projects
that use a Gradle classpath container.</p> that use a Gradle classpath container.</p>
<p><u><b>2.1.3</b>:</u> Fixed a bug that prevented Ghidra projects from recognizing extensions <p><u><b>2.1.3</b>:</u> Fixed a bug that prevented Ghidra projects from recognizing extensions

View File

@ -3,7 +3,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: GhidraDev Bundle-Name: GhidraDev
Bundle-SymbolicName: ghidra.ghidradev;singleton:=true Bundle-SymbolicName: ghidra.ghidradev;singleton:=true
Bundle-Version: 2.1.4.qualifier Bundle-Version: 2.1.5.qualifier
Bundle-Activator: ghidradev.Activator Bundle-Activator: ghidradev.Activator
Require-Bundle: org.eclipse.ant.core;bundle-version="3.5.200", Require-Bundle: org.eclipse.ant.core;bundle-version="3.5.200",
org.eclipse.buildship.core;bundle-version="3.0.0", org.eclipse.buildship.core;bundle-version="3.0.0",

View File

@ -16,24 +16,21 @@
package ghidradev.ghidraprojectcreator.utils; package ghidradev.ghidraprojectcreator.utils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.net.URI;
import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.naming.OperationNotSupportedException; import javax.naming.OperationNotSupportedException;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IJavaProject;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import ghidradev.Activator; import ghidradev.Activator;
@ -158,30 +155,30 @@ public class PyDevUtils {
* @throws CoreException if there was a problem searching for the PyDev source directory. * @throws CoreException if there was a problem searching for the PyDev source directory.
*/ */
public static File getPyDevSrcDir() throws CoreException { public static File getPyDevSrcDir() throws CoreException {
String eclipsePath = Platform.getInstallLocation().getURL().getFile(); Bundle[] bundles =
FrameworkUtil.getBundle(PyDevUtilsInternal.class).getBundleContext().getBundles();
List<File> searchDirs = new ArrayList<>();
searchDirs.add(new File(eclipsePath, "plugins")); Bundle pydevCoreBundle = Stream.of(bundles)
searchDirs.add(new File(eclipsePath, "dropins")); .filter(bundle -> bundle.getSymbolicName().contains("org.python.pydev.core"))
.findFirst()
for (File searchRoot : searchDirs) { .orElse(null);
try (Stream<Path> paths = Files.walk(Paths.get(searchRoot.toURI()))) {
Optional<File> pysrcDir = paths.filter( if (pydevCoreBundle != null) {
Files::isDirectory) try {
.filter(p -> p.endsWith("pysrc")) URL pydevDirUrl = FileLocator.toFileURL(pydevCoreBundle.getEntry("/"));
.map(p -> p.toFile()) URI pydevDirUri =
.filter(f -> f.getParentFile().getName().startsWith("org.python.pydev")) new URI(pydevDirUrl.getProtocol(), pydevDirUrl.getPath(), null).normalize();
.findFirst(); Path pysrcDir = Paths.get(pydevDirUri).resolve("pysrc");
if (pysrcDir.isPresent()) { if (Files.exists(pysrcDir)) {
return pysrcDir.get(); return pysrcDir.toFile();
} }
} }
catch (IOException e) { catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
IStatus.ERROR, "Problem searching for PyDev source directory", e)); IStatus.ERROR, "Problem searching for PyDev source directory", e));
} }
} }
return null; return null;
} }
} }