diff --git a/DevGuide.md b/DevGuide.md index 9adb647995..c3c93c20a6 100644 --- a/DevGuide.md +++ b/DevGuide.md @@ -173,30 +173,29 @@ cp csframework.jar hfsx_dmglib.jar hfsx.jar iharder-base64.jar ~/flatRepo/ #### Get Dependencies for GhidraServer Building the GhidraServer requires "Yet another Java service wrapper" (yajsw) version 12.12. -Download `yajsw-stable-12.12.zip` from their project on www.sourceforge.net, and place it in a directory named: -`ghidra.bin/Ghidra/Features/GhidraServer/`. Note that `ghidra.bin` must be a sibling of `ghidra`: +Download `yajsw-stable-12.12.zip` from their project on www.sourceforge.net, and place it in: +`~/ghidra/Ghidra/Features/GhidraServer/build`: ```bash cd ~/Downloads # Or wherever curl -OL https://sourceforge.net/projects/yajsw/files/yajsw/yajsw-stable-12.12/yajsw-stable-12.12.zip -mkdir -p ~/git/ghidra/Ghidra/Features/GhidraServer/build/data/ -cp ~/Downloads/yajsw-stable-12.12.zip ~/git/ghidra/Ghidra/Features/GhidraServer/build/data/ +mkdir -p ~/git/ghidra/Ghidra/Features/GhidraServer/build/ +cp ~/Downloads/yajsw-stable-12.12.zip ~/git/ghidra/Ghidra/Features/GhidraServer/build/ ``` #### Get Dependencies for GhidraDev Building the GhidraDev plugin for Eclipse requires the CDT and PyDev plugins for Eclipse. -Download `cdt-8.6.0.zip` from The Eclipse Foundation, and place it in a directory named: -`ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/`. Note that -`ghidra.bin` must be a sibling of `ghidra`. +Download `cdt-8.6.0.zip` from The Eclipse Foundation, and place it in: +`~/git/ghidra/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/`: ```bash cd ~/Downloads # Or wherever curl -OL 'http://www.eclipse.org/downloads/download.php?r=1&protocol=https&file=/tools/cdt/releases/8.6/cdt-8.6.0.zip' curl -o 'cdt-8.6.0.zip.sha512' -L --retry 3 'http://www.eclipse.org/downloads/sums.php?type=sha512&file=/tools/cdt/releases/8.6/cdt-8.6.0.zip' -sha512sum -c 'cdt-8.6.0.zip.sha512' -mkdir -p ~/git/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/ -cp ~/Downloads/cdt-8.6.0.zip ~/git/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/ +shasum -a 512 -c 'cdt-8.6.0.zip.sha512' +mkdir -p ~/git/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/ +cp ~/Downloads/cdt-8.6.0.zip ~/git/ghidra/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/ ``` Download `PyDev 6.3.1.zip` from www.pydev.org, and place it in the same directory: @@ -204,7 +203,7 @@ Download `PyDev 6.3.1.zip` from www.pydev.org, and place it in the same director ```bash cd ~/Downloads # Or wherever curl -OL https://sourceforge.net/projects/pydev/files/pydev/PyDev%206.3.1/PyDev%206.3.1.zip -cp ~/Downloads/'PyDev 6.3.1.zip' ~/git/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/ +cp ~/Downloads/'PyDev 6.3.1.zip ~/git/ghidra/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/ ``` ## Building Ghidra diff --git a/Ghidra/Features/GhidraServer/build.gradle b/Ghidra/Features/GhidraServer/build.gradle index 8a1a8ecb0e..1f5a16c73e 100644 --- a/Ghidra/Features/GhidraServer/build.gradle +++ b/Ghidra/Features/GhidraServer/build.gradle @@ -25,7 +25,7 @@ addExports([ ]) CopySpec yajswCopySpec = copySpec { - File localFile = file("build/data/${yajswRelease}.zip") + File localFile = file("build/${yajswRelease}.zip") File binFile = file("${BIN_REPO}/Ghidra/Features/GhidraServer/${yajswRelease}.zip") // First check if the file was downloaded and dropped in locally. If not, check in the bin diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build.gradle b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build.gradle index a8fce00096..b2b80562ff 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build.gradle +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build.gradle @@ -42,22 +42,14 @@ dependencies { compileJava.enabled = false jar.enabled = false -File libraryJarDestDir = file("build/data") - -File pyDevSourceZipFile = file("${BIN_REPO}/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/PyDev 6.3.1.zip") -File cdtSourceZipFile = file("${BIN_REPO}/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/cdt-8.6.0.zip") - -File pyDevDestDir = file("build/data/buildDependencies/pydev") -File cdtDestDir = file("build/data/buildDependencies/cdt") - task utilityJar(type:Copy) { - destinationDir libraryJarDestDir + destinationDir file("build/data") from { project(':Utility').jar } // using closure to delay until all projects evaluated } task launchSupportJar(type:Copy) { - destinationDir libraryJarDestDir + destinationDir file("build/data") from { project(':LaunchSupport').jar } // using closure to delay until all projects evaluated } @@ -65,13 +57,22 @@ task launchSupportJar(type:Copy) { 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 localFile = file("build/PyDev 6.3.1.zip") + File binFile = file("${BIN_REPO}/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/PyDev 6.3.1.zip") - from zipTree(pyDevSourceZipFile) + // First check if the file was downloaded and dropped in locally. If not, check in the bin + // repo. + def pyDevZipTree = localFile.exists() ? zipTree(localFile) : zipTree(binFile) + + from pyDevZipTree exclude "**/.project", "**/.pydevproject" destinationDir pyDevDestDir @@ -80,13 +81,22 @@ task pyDevUnpack(type:Copy) { 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 localFile = file("build/cdt-8.6.0.zip") + File binFile = file("${BIN_REPO}/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/cdt-8.6.0.zip") - from zipTree(cdtSourceZipFile) + // First check if the file was downloaded and dropped in locally. If not, check in the bin + // repo. + def cdtZipTree = localFile.exists() ? zipTree(localFile) : zipTree(binFile) + + from cdtZipTree destinationDir cdtDestDir } diff --git a/gradle/init.gradle b/gradle/init.gradle index 0b6898cf3c..50a3674a28 100644 --- a/gradle/init.gradle +++ b/gradle/init.gradle @@ -68,7 +68,7 @@ ext.AXML_MD5 = '55d70be9862c2b456cc91a933c197934' ext.HFS_MD5 = 'cc1713d634d2cd1fd7f21e18ae4d5d5c' ext.YAJSW_MD5 = 'e490ea92554f0238d74d4ef6161cb2c7' ext.PYDEV_MD5 = '06263bdef4917c49d8d977d12c2d5073' -ext.CDT_MD5 = 'd41d8cd98f00b204e9800998ecf8427e' +ext.CDT_MD5 = '8e9438a6e3947d614af98e1b58e945a2' // Number of times to try and establish a connection when downloading files before // failing @@ -123,11 +123,11 @@ def createConfigFile() { repoConfigFile.write("ext.HOME = System.getProperty('user.home')") repoConfigFile.append("\nallprojects {") - repoConfigFile.append("\nrepositories {") - repoConfigFile.append("\nmavenCentral()") - repoConfigFile.append("\njcenter()") - repoConfigFile.append('\nflatDir name: "flat", dirs:["$HOME/flatRepo"]') - repoConfigFile.append("\n}") + repoConfigFile.append("\n\trepositories {") + repoConfigFile.append("\n\t\tmavenCentral()") + repoConfigFile.append("\n\t\tjcenter()") + repoConfigFile.append('\n\t\tflatDir name: "flat", dirs:["$HOME/flatRepo"]') + repoConfigFile.append("\n\t}") repoConfigFile.append("\n}") } @@ -237,46 +237,40 @@ def populateFlatRepo() { // 1. Download all the dependencies and verify their checksums. If the dependency has already // been download, do NOT download again. - File file = new File(DOWNLOADS_DIR.path, '/dex-tools-2.0.zip') - def checksum = generateChecksum(file) - if (!(file.exists() && (checksum.equals(DEX_MD5)))) { + File file = new File(DOWNLOADS_DIR, 'dex-tools-2.0.zip') + if (!DEX_MD5.equals(generateChecksum(file))) { download (DEX_ZIP, file.path) - validateChecksum(checksum, DEX_MD5); + validateChecksum(generateChecksum(file), DEX_MD5); } - file = new File(FLAT_REPO_DIR.path + '/AXMLPrinter2.jar') - checksum = generateChecksum(file) - if (!(file.exists() && (checksum.equals(AXML_MD5)))) { + file = new File(DOWNLOADS_DIR, 'AXMLPrinter2.jar') + if (!AXML_MD5.equals(generateChecksum(file))) { download (AXML_ZIP, file.path) - validateChecksum(checksum, AXML_MD5); + validateChecksum(generateChecksum(file), AXML_MD5); } - file = new File(DOWNLOADS_DIR.path + '/hfsexplorer-0_21-bin.zip') - checksum = generateChecksum(file) - if (!(file.exists() && (checksum.equals(HFS_MD5)))) { + file = new File(DOWNLOADS_DIR, 'hfsexplorer-0_21-bin.zip') + if (!HFS_MD5.equals(generateChecksum(file))) { download (HFS_ZIP, file.path) - validateChecksum(checksum, HFS_MD5); + validateChecksum(generateChecksum(file), HFS_MD5); } - file = new File(DOWNLOADS_DIR.path + '/yajsw-stable-12.12.zip') - checksum = generateChecksum(file) - if (!(file.exists() && (checksum.equals(YAJSW_MD5)))) { + file = new File(DOWNLOADS_DIR, 'yajsw-stable-12.12.zip') + if (!YAJSW_MD5.equals(generateChecksum(file))) { download (YAJSW_ZIP, file.path) - validateChecksum(checksum, YAJSW_MD5); + validateChecksum(generateChecksum(file), YAJSW_MD5); } - file = new File(DOWNLOADS_DIR.path + "/PyDev 6.3.1.zip") - checksum = generateChecksum(file) - if (!(file.exists() && (checksum.equals(PYDEV_MD5)))) { + file = new File(DOWNLOADS_DIR, 'PyDev 6.3.1.zip') + if (!PYDEV_MD5.equals(generateChecksum(file))) { download (PYDEV_ZIP, file.path) - validateChecksum(checksum, PYDEV_MD5); + validateChecksum(generateChecksum(file), PYDEV_MD5); } - file = new File(DOWNLOADS_DIR.path + '/cdt-8.6.0.zip') - checksum = generateChecksum(file) - if (!(file.exists() && (checksum.equals(CDT_MD5)))) { + file = new File(DOWNLOADS_DIR, 'cdt-8.6.0.zip') + if (!CDT_MD5.equals(generateChecksum(file))) { download (CDT_ZIP, file.path) - validateChecksum(checksum, CDT_MD5); + validateChecksum(generateChecksum(file), CDT_MD5); } // 2. Unzip the dependencies @@ -286,6 +280,7 @@ def populateFlatRepo() { // 3. Copy the necessary jars to the flatRepo directory. Yajsw, CDT, and PyDev go directly into // the source repository. copyDexTools() + copyAXML() copyHfsx() copyYajsw() copyPyDev() @@ -300,7 +295,7 @@ def populateFlatRepo() { */ def generateChecksum(file) { if (!file.exists()) { - return + return null } MessageDigest md = MessageDigest.getInstance("MD5"); md.update(Files.readAllBytes(Paths.get(file.path))); @@ -340,6 +335,13 @@ def copyDexTools() { FileUtils.copyDirectory(new File(DOWNLOADS_DIR, 'dex2jar-2.0/lib/'), FLAT_REPO_DIR, new WildcardFileFilter("dex-*")); } +/** + * Copies the AXMLPrinter2 jar to the flat repository + */ +def copyAXML() { + FileUtils.copyFile(new File(DOWNLOADS_DIR, 'AXMLPrinter2.jar'), new File(FLAT_REPO_DIR, "AXMLPrinter2.jar")); +} + /** * Copies the necessary hfsx jars to the flat repository */ @@ -354,21 +356,21 @@ def copyHfsx() { * Copies the yajswdir zip to its location in the GhidraServer project. */ def copyYajsw() { - FileUtils.copyFile(new File(DOWNLOADS_DIR, "yajsw-stable-12.12.zip"), new File(REPO_DIR, "Ghidra/Features/GhidraServer/build/data/yajsw-stable-12.12.zip")); + FileUtils.copyFile(new File(DOWNLOADS_DIR, "yajsw-stable-12.12.zip"), new File(REPO_DIR, "Ghidra/Features/GhidraServer/build/yajsw-stable-12.12.zip")); } /** * Copies the pydev zip to its bin repository location */ def copyPyDev() { - FileUtils.copyFile(new File(DOWNLOADS_DIR, 'PyDev 6.3.1.zip'), new File(REPO_DIR, "GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/data/buildDependencies/PyDev 6.3.1.zip")); + FileUtils.copyFile(new File(DOWNLOADS_DIR, 'PyDev 6.3.1.zip'), new File(REPO_DIR, "GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/PyDev 6.3.1.zip")); } /** * Copies the cdt zip to its bin repository location */ def copyCdt() { - FileUtils.copyFile(new File(DOWNLOADS_DIR, 'cdt-8.6.0.zip'), new File(REPO_DIR, "GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/data/buildDependencies/cdt-8.6.0.zip")); + FileUtils.copyFile(new File(DOWNLOADS_DIR, 'cdt-8.6.0.zip'), new File(REPO_DIR, "GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build/cdt-8.6.0.zip")); } /**