mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
90 lines
3.6 KiB
Groovy
90 lines
3.6 KiB
Groovy
/* ###
|
|
* IP: Public Domain
|
|
*/
|
|
// If extension module does not reside within the Ghidra GPL directory, the Ghidra installation directory
|
|
// must be specified either by setting the GHIDRA_INSTALL_DIR environment variable or Gradle
|
|
// project property:
|
|
//
|
|
// > export GHIDRA_INSTALL_DIR=<Absolute path to Ghidra>
|
|
// > gradle build
|
|
//
|
|
// or
|
|
//
|
|
// > gradle -PGHIDRA_INSTALL_DIR=<Absolute path to Ghidra> build
|
|
//
|
|
// In addition, the appropriate binutils source distribution archive must be placed
|
|
// within this module's directory (see below for binutils version and archive file naming.
|
|
//
|
|
// Gradle should be invoked from the directory of the extension module to build. Please see the
|
|
// application.gradle.version property in <GHIDRA_INSTALL_DIR>/Ghidra/application.properties
|
|
// for the correction version of Gradle to use for the Ghidra installation you specify.
|
|
//
|
|
// Build Prerequisite:
|
|
// The appropriate binutils source distribution archive (see version and naming below) must be
|
|
// obtained and placed appropriately prior to building the gdis executable. If working with
|
|
// a full source distribution of Ghidra the binutils archive should be placed within the module's
|
|
// shadow directory located within ghidra.bin (ghidra.bin/GPL/GnuDisassembler/). If building within
|
|
// an unpacked distribution of Ghidra it should be placed directly within the module
|
|
// directory once the extension has been installed/unpacked by Ghidra. The binutils referenced
|
|
// by the script below may be downloaded from the following URL:
|
|
//
|
|
// https://ftp.gnu.org/pub/gnu/binutils/binutils-2.41.tar.bz2
|
|
//
|
|
|
|
ext.binutils = "binutils-2.41"
|
|
ext.binutilsDistro = "${binutils}.tar.bz2"
|
|
|
|
// Find the GPL dir
|
|
def gplDir = null;
|
|
if (file("../utils.gradle").exists()) {
|
|
gplDir = file("..").getCanonicalPath()
|
|
ext.ghidraInstallDir = file("../..").getCanonicalPath()
|
|
ext.binutilsLocation = file("${ghidraInstallDir}/../ghidra.bin/GPL/${name}").getCanonicalPath()
|
|
}
|
|
else {
|
|
// Module lives disconnected from the GPL directory, which it will need to build.
|
|
// Find a Ghidra installation directory and use its GPL directory.
|
|
ext.binutilsLocation = projectDir
|
|
if (file("../../Extensions").exists() && file("../../../GPL/utils.gradle").exists()) {
|
|
// Module is installed within a Ghidra installation (i.e, ghidra/Ghidra/Extensions)
|
|
gplDir = file("../../../GPL").getCanonicalPath()
|
|
}
|
|
else {
|
|
// Module is in an unknown location (likely outside of Ghidra).
|
|
// Rely on the GHIDRA_INSTALL_DIR property being set.
|
|
def ghidraInstallDir = null;
|
|
if (System.env.GHIDRA_INSTALL_DIR) {
|
|
ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
|
|
}
|
|
else if (project.hasProperty("GHIDRA_INSTALL_DIR")) {
|
|
ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
|
|
}
|
|
else {
|
|
throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
|
|
}
|
|
|
|
if (ghidraInstallDir.replace("\\","/").endsWith("/")) {
|
|
ghidraInstallDir = ghidraInstallDir.substring(0, ghidraInstallDir.length()-1)
|
|
}
|
|
gplDir = file("${ghidraInstallDir}/GPL")
|
|
println "Building with Ghidra installation at $ghidraInstallDir"
|
|
}
|
|
}
|
|
|
|
// If we see other projects, we are packaging this extension for distribution
|
|
if (findProject(':Generic') != null) {
|
|
// Package extension
|
|
apply from: "$rootProject.projectDir/gradle/distributableGPLExtension.gradle"
|
|
delete file("build/os"); // remove any prior build of gdis
|
|
}
|
|
else {
|
|
// Build GPL extension (gdis)
|
|
apply from: "${gplDir}/utils.gradle"
|
|
apply from: "${gplDir}/nativePlatforms.gradle"
|
|
apply from: "${gplDir}/nativeBuildProperties.gradle"
|
|
apply from: "buildGdis.gradle"
|
|
}
|
|
|
|
apply plugin: 'eclipse'
|
|
eclipse.project.name = 'Xtra GPL GnuDisassembler'
|