ghidra/GPL/GnuDisassembler/build.gradle

87 lines
3.4 KiB
Groovy
Raw Normal View History

2021-03-17 22:22:43 +00:00
/* ###
* 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:
//
2021-06-16 19:17:04 +00:00
// https://ftp.gnu.org/pub/gnu/binutils/binutils-2.36.tar.bz2
//
2021-06-16 19:17:04 +00:00
ext.binutils = "binutils-2.36"
ext.binutilsDistro = "${binutils}.tar.bz2"
2021-06-16 19:17:04 +00:00
// Find the GPL dir
def gplDir = null;
if (file("../utils.gradle").exists()) {
2021-06-16 19:17:04 +00:00
gplDir = file("..").getCanonicalPath()
}
else {
2021-06-16 19:17:04 +00:00
// Module lives disconnected from the GPL directory, which it will need to build.
// Find a Ghidra installation directory and use its GPL directory.
if (file("../../Extensions").exists() && file("../../../GPL/utils.gradle").exists()) {
2021-06-16 19:17:04 +00:00
// Module is installed within a Ghidra installation (i.e, ghidra/Ghidra/Extensions)
gplDir = file("../../../GPL").getCanonicalPath()
}
else {
2021-06-16 19:17:04 +00:00
// 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) {
2021-06-16 19:17:04 +00:00
ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
}
else if (project.hasProperty("GHIDRA_INSTALL_DIR")) {
2021-06-16 19:17:04 +00:00
ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
}
2021-06-16 19:17:04 +00:00
else {
throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
}
if (ghidraInstallDir.replace("\\","/").endsWith("/")) {
2021-06-16 19:17:04 +00:00
ghidraInstallDir = ghidraInstallDir.substring(0, ghidraInstallDir.length()-1)
}
2021-06-16 19:17:04 +00:00
gplDir = file("${ghidraInstallDir}/GPL")
println "Building with Ghidra installation at $ghidraInstallDir"
}
}
2021-06-16 19:17:04 +00:00
// If we see other projects, we are packaging this extension for distribution
if (findProject(':Generic') != null) {
2021-06-16 19:17:04 +00:00
// Package extension
apply from: "$rootProject.projectDir/gradle/distributableGPLExtension.gradle"
delete file("build/os"); // remove any prior build of gdis
}
else {
2021-06-16 19:17:04 +00:00
// Build GPL extension (gdis)
apply from: "${gplDir}/utils.gradle"
apply from: "${gplDir}/nativePlatforms.gradle"
2021-06-16 19:17:04 +00:00
apply from: "${gplDir}/nativeBuildProperties.gradle"
apply from: "buildGdis.gradle"
}
apply plugin: 'eclipse'
eclipse.project.name = 'Xtra GPL GnuDisassembler'