Skip to content

Ghidra is a software reverse engineering (SRE) framework

4.8 KB
Raw Blame
/* ###
 * IP: GHIDRA
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
apply from: "$rootProject.projectDir/gradle/javaProject.gradle"
apply from: "$rootProject.projectDir/gradle/helpProject.gradle"
apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle"
apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"
apply from: "$rootProject.projectDir/gradle/javadoc.gradle"
apply from: "${rootProject.projectDir}/gradle/hasPythonPackage.gradle"
apply plugin: 'eclipse'

eclipse.project.name = 'Features PyGhidra'


dependencies {
	api project(':Base')
}


// NOTE: The Python package is a "Pure Python" package. Building the wheel does not
// require any dependencies except setuptools. Installing the wheel will require
// the correct os/python version of Jpype and packaging. Installing the wheel does
// not require Ghidra.
distributePyDep("jpype1-1.5.2-cp313-cp313-win_amd64.whl")
distributePyDep("jpype1-1.5.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
distributePyDep("jpype1-1.5.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl")
distributePyDep("jpype1-1.5.2-cp313-cp313-macosx_10_13_universal2.whl")
distributePyDep("jpype1-1.5.2-cp312-cp312-win_amd64.whl")
distributePyDep("jpype1-1.5.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
distributePyDep("jpype1-1.5.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl")
distributePyDep("jpype1-1.5.2-cp312-cp312-macosx_10_9_universal2.whl")
distributePyDep("jpype1-1.5.2-cp311-cp311-win_amd64.whl")
distributePyDep("jpype1-1.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
distributePyDep("jpype1-1.5.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl")
distributePyDep("jpype1-1.5.2-cp311-cp311-macosx_10_9_universal2.whl")
distributePyDep("jpype1-1.5.2-cp310-cp310-win_amd64.whl")
distributePyDep("jpype1-1.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
distributePyDep("jpype1-1.5.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl")
distributePyDep("jpype1-1.5.2-cp310-cp310-macosx_10_9_universal2.whl")
distributePyDep("jpype1-1.5.2-cp39-cp39-win_amd64.whl")
distributePyDep("jpype1-1.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
distributePyDep("jpype1-1.5.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl")
distributePyDep("jpype1-1.5.2-cp39-cp39-macosx_10_9_x86_64.whl")
distributePyDep("jpype1-1.5.2.tar.gz")
distributePyDep("packaging-25.0-py3-none-any.whl")
distributePyDep("setuptools-80.9.0-py3-none-any.whl")
distributePyDep("wheel-0.45.1-py3-none-any.whl")
distributePyDep("typing_extensions-4.16.0-py3-none-any.whl")

// Install JPype into the development virtual environment
task installJPype(type: Exec) {
	dependsOn(":createPythonVirtualEnvironment")
	
	File depsDir = file("${rootProject.DEPS_DIR}/PyGhidra")
	File binRepoDir = file("${rootProject.BIN_REPO}/ExternalPyWheels")
	def dir = depsDir.exists() ? depsDir : binRepoDir
	
	doFirst {
		commandLine "$PYTHON3_VENV", "-m", "pip", "install", "--no-index", "-f", "$dir", "JPype1"
	}
}

// Install ghidra-stubs into the development virtual environment
task installGhidraStubs(type: Exec) {
	dependsOn(":createGhidraStubsWheel")
	dependsOn(":createPythonVirtualEnvironment")
	
	File depsDir = file("${rootProject.DEPS_DIR}/PyGhidra")
	File binRepoDir = file("${rootProject.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" 
	}
}

// Prepares PyGhidra for development by installing it in editable mode to the development virtual
// environment
task prepPyGhidra(type: Exec) {
	dependsOn("installJPype")
	dependsOn("installGhidraStubs")
	
	File depsDir = file("${rootProject.DEPS_DIR}/PyGhidra")
	File binRepoDir = file("${rootProject.BIN_REPO}/ExternalPyWheels")
	def dir = depsDir.exists() ? depsDir : binRepoDir

	doFirst {
		commandLine "$PYTHON3_VENV", "-m", "pip", "install", "-e", "src/main/py", "--no-index", "-f", "$dir"
	}
}

rootProject.assembleMarkdownToHtml {
	def p = this.project
	def zipPath = rootProject.getZipPath(p)
	
	from ("${p.projectDir}/src/main/py/README.md") {
		into { "${zipPath}/pypkg" }
	}
}