Skip to content

Ghidra is a software reverse engineering (SRE) framework

4.2 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 plugin: 'java-library'

java {
	sourceCompatibility = "${rootProject.JAVA_COMPILER}"
	targetCompatibility = "${rootProject.JAVA_COMPILER}"
}

//This project requires the eclpse PDE plugin. To create eclipse files for this project, run 
//	"gradle eclipse -PeclipsePDE" 
if (hasProperty("eclipsePDE")) {
	apply plugin: 'eclipse'
	eclipse {
		project {
			name = 'Eclipse GhidraDevPlugin'
			buildCommand 'org.eclipse.pde.ManifestBuilder'
			buildCommand 'org.eclipse.pde.SchemaBuilder'
			natures 'org.eclipse.pde.PluginNature'
			classpath.file {
				def requiredPlugins = 'org.eclipse.pde.core.requiredPlugins'
				beforeMerged { classpath ->
					classpath.entries.removeAll { entry ->
						entry.path == requiredPlugins
					}
				}
				whenMerged { classpath ->
					withXml {
						def node = it.asNode()
						node.appendNode('classpathentry', [kind: 'con', path: requiredPlugins])
					}
				}
			}
		}
	}
}

dependencies {
	api project(':Utility')
	api project(':LaunchSupport')
}

// We are currently building this with Eclipse, so prevent gradle from trying.
// See build_README.txt for instructions on how to build from Eclipse.
compileJava.enabled = false
jar.enabled = false

task utilityJar(type:Copy) {
	destinationDir = file("build/data")

	def utilityProject = project(':Utility')

	from { utilityProject.jar } // using closure to delay until all projects evaluated
}

task launchSupportJar(type:Copy) {
	destinationDir = file("build/data")

	def launchSupportProject = project(':LaunchSupport')

	from { launchSupportProject.jar } // using closure to delay until all projects evaluated
}

task pyDevUnpack(type:Copy) {
	description = "Unpack PyDev plugin archive for development use"
	group = "Development Preparation"
	
	File pyDevDestDir = file("build/data/buildDependencies/pydev")

	// Without this, the copyTask will unzip the file to check for "up to date"
	onlyIf {
		!pyDevDestDir.exists()
	}
	
	File depsFile = file("${rootProject.DEPS_DIR}/GhidraDev/PyDev 9.3.0.zip")
	File binRepoFile = file("${rootProject.BIN_REPO}/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/PyDev 9.3.0.zip")

	// First check if the file is in the dependencies repo.  If not, check in the bin repo.
	def pyDevZipTree = depsFile.exists() ? zipTree(depsFile) : zipTree(binRepoFile)

	from pyDevZipTree
	exclude "**/.project", "**/.pydevproject"

	destinationDir = pyDevDestDir
}

task cdtUnpack(type:Copy) {
	description = "Unpack CDT plugin archive for development use"
	group = "Development Preparation"
	
	File cdtDestDir = file("build/data/buildDependencies/cdt")

	// Without this, the copyTask will unzip the file to check for "up to date"
	onlyIf {
		!cdtDestDir.exists()
	}
	
	File depsFile = file("${rootProject.DEPS_DIR}/GhidraDev/cdt-8.6.0.zip")
	File binRepoFile = file("${rootProject.BIN_REPO}/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/cdt-8.6.0.zip")

	// First check if the file is in the dependencies repo.  If not, check in the bin repo.
	def cdtZipTree = depsFile.exists() ? zipTree(depsFile) : zipTree(binRepoFile)

	from cdtZipTree

	destinationDir = cdtDestDir
}

task prepGhidraDev {
	dependsOn("utilityJar")
	dependsOn("launchSupportJar")
	dependsOn("pyDevUnpack")
	dependsOn("cdtUnpack")
}

// We do not currently build GhidraDev plugin at Ghidra build time so we must 
// copy the prebuilt zip file from the BIN_REPO
rootProject.assembleDistribution {
	from ("${rootProject.BIN_REPO}/GhidraBuild/EclipsePlugins/GhidraDev") {
		include 'GhidraDev*.zip'
		into "Extensions/Eclipse/GhidraDev/"
	}
}

rootProject.assembleMarkdownToHtml {
	from ("${this.projectDir}/README.md") {
		into "Extensions/Eclipse/GhidraDev/"
	}
}