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
id="ghidra.ghidradev"
label="GhidraDev"
version="2.1.4.qualifier"
version="2.1.5.qualifier"
provider-name="Ghidra">
<description>

View File

@ -19,7 +19,7 @@
<h1>GhidraDev README</h1>
<p>GhidraDev provides support for developing and debugging Ghidra scripts and modules in Eclipse.
</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>
<ul>
@ -53,6 +53,8 @@ change with future releases.</p>
</ul>
<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
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

View File

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

View File

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