GP-1040: Fixing GnuDisassembler build

This commit is contained in:
Ryan Kurtz 2021-06-16 15:17:04 -04:00
parent cde02a91eb
commit 8473259d06
7 changed files with 38 additions and 36 deletions

1
GPL/GnuDisassembler/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
binutils-*

View File

@ -14,6 +14,12 @@ To build this extension for Linux or Mac OS X:
If a different binutils distribution is used the build.gradle and/or buildGdis.gradle
may require modification.
The build requires the following packages to be installed:
* flex
* bison
* texinfo
* zlib1g-dev
2. Run gradle from the module's root directory (see top of build.gradle file for
specific instructions).

View File

@ -28,55 +28,56 @@
// 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.34.tar.bz2
// https://ftp.gnu.org/pub/gnu/binutils/binutils-2.36.tar.bz2
//
ext.binutils = "binutils-2.34"
ext.binutils = "binutils-2.36"
ext.binutilsDistro = "${binutils}.tar.bz2"
ext.ghidraInstallDir = null;
if (file("../gpl.gradle").exists()) {
// Module is located within the Ghidra GPL directory
ext.ghidraInstallDir = file("../..").getCanonicalPath()
ext.binutilsLocation = file("${ghidraInstallDir}/../ghidra.bin/GPL/${name}").getCanonicalPath()
apply from: file("../gpl.gradle").getCanonicalPath()
// Find the GPL dir
def gplDir = null;
if (file("../gpl.gradle").exists()) {
gplDir = file("..").getCanonicalPath()
}
else {
// various module placements for Ghidra installations
ext.binutilsLocation = projectDir
if (file("../../../GPL/gpl.gradle").exists()) {
// Handle GPL extension install within Ghidra Extensions directory
ext.ghidraInstallDir = file("../../..").getCanonicalPath()
// 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/gpl.gradle").exists()) {
// Module is installed within a Ghidra installation (i.e, ghidra/Ghidra/Extensions)
gplDir = file("../../../GPL").getCanonicalPath()
}
else {
// Handle extension install outside of Ghidra installation - must specify Ghidra install path
// 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) {
ext.ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
}
else if (project.hasProperty("GHIDRA_INSTALL_DIR")) {
ext.ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
}
}
if (ghidraInstallDir) {
else {
throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
}
if (ghidraInstallDir.replace("\\","/").endsWith("/")) {
ext.ghidraInstallDir = ghidraInstallDir.substring(0, ghidraInstallDir.length()-1)
ghidraInstallDir = ghidraInstallDir.substring(0, ghidraInstallDir.length()-1)
}
gplDir = file("${ghidraInstallDir}/GPL")
println "Building with Ghidra installation at $ghidraInstallDir"
apply from: new File(ghidraInstallDir).getCanonicalPath() + "/GPL/gpl.gradle"
}
else {
throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
}
}
// If we see other projects, we are packaging this extension for distribution
if (findProject(':Generic') != null) {
// Handle integrated Ghidra build - do not build gdis native
// Package extension
apply from: "$rootProject.projectDir/gradle/distributableGPLExtension.gradle"
delete file("build/os"); // remove any prior build of gdis
}
else {
apply from: "${ghidraInstallDir}/GPL/nativeBuildProperties.gradle"
// Build GPL extension (gdis)
apply from: "${gplDir}/gpl.gradle"
apply from: "${gplDir}/nativeBuildProperties.gradle"
apply from: "buildGdis.gradle"
}

View File

@ -1,17 +1,12 @@
/* ###
* IP: Public Domain
*/
/*******************************************************************************************
* build.gradle file that applies this script must define two properties
* 1) binutilsLocation - the folder where the original binutils.zip lives
* 2) binutilsPrebuiltPath - the folder where the custom prebuilt binutils lives or will be built to
*******************************************************************************************/
defaultTasks 'assemble'
ext.supportedPlatforms = ['osx64', 'linux64']
ext.binutilsResource = new File("${binutilsLocation}/${binutils}.tar.bz2")
ext.binutilsResource = new File("${projectDir}/${binutils}.tar.bz2")
def binutilsUnpackDir = file("${project.buildDir}/${binutils}/")
@ -19,8 +14,6 @@ def binutilsUnpackDir = file("${project.buildDir}/${binutils}/")
*
* For each supported platform build the following tasks:
* buildBinutils_<platform> builds binutils for the platform
* packageBinutilsDev_<platform> creates the built bundle of stuf we need to build gdis
* unpackBinutilsPrebuilt_<platform> unpacks the built bundle to be used to build gdis
*
******************************************************************************************/

View File

@ -1,6 +1,7 @@
##VERSION: 2.0
##MODULE IP: GPL 2
##MODULE IP: Public Domain
.gitignore||Public Domain||||END|
Module.manifest||Public Domain||||END|
README.txt||Public Domain||||END|
data/arm_test1.s||Public Domain||||END|

View File

@ -1,5 +1,5 @@
name=GnuDisassembler
description=GNU Disassembler. Extension is delivered unbuilt. See module README.txt for build instructions.
description=GNU Disassembler. Extension is delivered unbuilt. See module README.txt for build instructions. Depends on SleighDevTools.
author=Ghidra Team
createdOn=6/18/2019
version=@extversion@

View File

@ -14,7 +14,7 @@ project.ext.set("OS_NAMES", ["osx64", "win32", "win64", "linux64"])
* Establish Visual Studio configuration environment for Windows native builds
* NOTE: vsconfig.gradle path is relative to each GPL project module
****************************************************************************/
apply from: "../vsconfig.gradle"
apply from: buildscript.sourceFile.getParent() + "/vsconfig.gradle"
/*********************************************************************************
* Returns the local platform name.