mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-12-03 09:31:35 +00:00
GP-5133: Improvements to how we use python type stubs
This commit is contained in:
parent
32c39f3518
commit
1df4527dd3
@ -136,6 +136,9 @@ public class VSCodeProjectScript extends GhidraScript {
|
||||
.filter(e -> e.getValue() != null)
|
||||
.forEach(e -> sourcesObject.addProperty(e.getKey(), e.getValue()));
|
||||
|
||||
json.addProperty("python.analysis.stubPath",
|
||||
new File(installDir, "docs/ghidra_stubs/typestubs").getAbsolutePath());
|
||||
|
||||
// Write settings json object
|
||||
if (!FileUtilities.mkdirs(settingsFile.getParentFile())) {
|
||||
throw new IOException("Failed to create: " + settingsFile.getParentFile());
|
||||
|
@ -62,9 +62,23 @@ task installJPype(type: Exec) {
|
||||
}
|
||||
}
|
||||
|
||||
// Install ghidra-stubs into the development virtual environment
|
||||
task installGhidraStubs(type: Exec) {
|
||||
dependsOn(":createGhidraStubsWheel")
|
||||
|
||||
File depsDir = file("${DEPS_DIR}/PyGhidra")
|
||||
File binRepoDir = file("${BIN_REPO}/ExternalPyWheels")
|
||||
def dir = depsDir.exists() ? depsDir : binRepoDir
|
||||
|
||||
doFirst {
|
||||
commandLine "$PYTHON3_VENV", "-m", "pip", "install", "--no-index", "-f", "${ROOT_PROJECT_DIR}/build/typestubs/dist", "ghidra-stubs"
|
||||
}
|
||||
}
|
||||
|
||||
// Install PyGhidra in editable mode to the development virtual environment
|
||||
task installEditablePyGhidra(type: Exec) {
|
||||
dependsOn("installJPype")
|
||||
dependsOn("installGhidraStubs")
|
||||
|
||||
File depsDir = file("${DEPS_DIR}/PyGhidra")
|
||||
File binRepoDir = file("${BIN_REPO}/ExternalPyWheels")
|
||||
|
@ -236,23 +236,21 @@ task createGhidraStubsWheel {
|
||||
|
||||
dependsOn("createPythonTypeStubs")
|
||||
|
||||
String ROOT_PROJECT_DIR = rootProject.projectDir.toString()
|
||||
def typestubsDir = file("${ROOT_PROJECT_DIR}/build/typestubs").getAbsolutePath()
|
||||
def distDir = file("${typestubsDir}/dist").getAbsolutePath()
|
||||
|
||||
def cwd = file(ROOT_PROJECT_DIR + "/build/typestubs")
|
||||
def destinationDir = file(cwd.toString() + "/dist")
|
||||
|
||||
it.outputs.file(destinationDir.toString() + "/ghidra_stubs-${project.version}-py3-none-any.whl")
|
||||
it.outputs.file("${distDir}/ghidra_stubs-${project.version}-py3-none-any.whl")
|
||||
|
||||
doFirst {
|
||||
copy {
|
||||
from(file(ROOT_PROJECT_DIR + "/LICENSE"))
|
||||
into cwd
|
||||
from(file("${ROOT_PROJECT_DIR}/LICENSE"))
|
||||
into typestubsDir
|
||||
}
|
||||
|
||||
def manifest = file(cwd.toString() + "/MANIFEST.in" )
|
||||
def manifest = file("${typestubsDir}/MANIFEST.in")
|
||||
manifest.write("graft src\n")
|
||||
|
||||
def pyproject = file(cwd.toString() + "/pyproject.toml" )
|
||||
def pyproject = file("${typestubsDir}/pyproject.toml" )
|
||||
pyproject.write("""\
|
||||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
@ -272,14 +270,14 @@ task createGhidraStubsWheel {
|
||||
doLast {
|
||||
File setuptools = project(":Debugger-rmi-trace").findPyDep(".")
|
||||
|
||||
if (rootProject.PYTHON3 == null) {
|
||||
if (PYTHON3 == null) {
|
||||
throw new GradleException("A supported version of Python ${SUPPORTED_PY_VERSIONS} was not found!")
|
||||
}
|
||||
|
||||
exec {
|
||||
workingDir { cwd.toString() }
|
||||
commandLine rootProject.PYTHON3
|
||||
args "-m", "pip", "wheel", "-w", destinationDir.toString(), "--no-index", "-f", setuptools, "."
|
||||
workingDir { typestubsDir }
|
||||
commandLine PYTHON3
|
||||
args "-m", "pip", "wheel", "-w", distDir, "--no-index", "-f", setuptools, "."
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -431,8 +429,11 @@ task assembleDistribution (type: Copy) {
|
||||
////////////////////////////
|
||||
// Ghidra Python type stubs
|
||||
////////////////////////////
|
||||
from ("${ROOT_PROJECT_DIR}/build/typestubs/src") {
|
||||
into 'docs/ghidra_stubs/typestubs'
|
||||
}
|
||||
from (createGhidraStubsWheel) {
|
||||
into 'docs'
|
||||
into 'docs/ghidra_stubs'
|
||||
}
|
||||
|
||||
////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user