Skip to content

Ghidra is a software reverse engineering (SRE) framework

changed build system to generate all external jar files used file.

ghidravore8b054814a83c
diff --git a/Ghidra/Framework/SoftwareModeling/build.gradle b/Ghidra/Framework/SoftwareModeling/build.gradle
index 07e1bef2b5..e6fcb43727 100644
--- a/Ghidra/Framework/SoftwareModeling/build.gradle
+++ b/Ghidra/Framework/SoftwareModeling/build.gradle
@@ -30,6 +30,9 @@ dependencies {
// Must specify the specific antlr implementation to use or it will default to trying to find
// version 2.7.7 (which we don't have)
antlr "org.antlr:antlr:3.5.2"
+ // need to add in the antlr dependencies for when we build from flat jar dirs
+ antlr "org.antlr:antlr-runtime:3.5.2"
+ antlr "org.antlr:ST4:4.0.8"
}
def genSrcDir = 'generated-src/antlr/main'
diff --git a/build.gradle b/build.gradle
index a26d0fbd1f..b5539e3409 100644
--- a/build.gradle
+++ b/build.gradle
@@ -292,28 +292,49 @@ String getCurrentPlatformName() {
* given project
*
*********************************************************************************/
-List<String> getExternalDependencies(Project project) {
+List<String> getExternalRuntimeDependencies(Project project) {
List<String> list = new ArrayList<String>()
- // for each dependency in the compile configuration
- Configuration runtimeConfig = project.configurations.runtime
- runtimeConfig.allDependencies.each { dep ->
+ list.addAll(getExternalDependencies(project.configurations.compile));
+ list.addAll(getExternalDependencies(project.configurations.runtime));
+
+ return list
+}
+
+List<String> getExternalDependencies(Configuration configuration) {
+ List<String> list = new ArrayList<>();
+ configuration.dependencies.each { dep ->
// if the dependency is an external jar
- if (dep.class.toString().contains("DefaultExternalModuleDependency")) {
-
+ if (dep instanceof ExternalDependency) {
+
// loop back through all the dependency files, looking for one that contains the dependency name.
- String depPath = runtimeConfig.find {
+ String depPath = configuration.find {
it.name.contains(dep.name)
}
// if we found the path, then add it to the list
- if (depPath && !depPath.contains("libsForBuild")) {
+ if (depPath) {
list.add(depPath)
}
}
}
- return list
+ return list;
+}
+
+/*********************************************************************************
+ * Returns a list of all the external library paths declared as dependencies for the
+ * given project
+ *
+ *********************************************************************************/
+Set<String> getAllExternalDependencies(Project project) {
+ Set<String> set = new HashSet<String>()
+
+ project.getConfigurations().each { config ->
+ set.addAll(getExternalDependencies(config))
+ }
+
+ return set
}
/******************************************************************************************
@@ -334,7 +355,7 @@ String generateLibraryDependencyMapping() {
libsFile.withWriter { out ->
subprojects { p ->
p.plugins.withType(JavaPlugin) {
- List<String> libs = getExternalDependencies(p);
+ List<String> libs = getExternalRuntimeDependencies(p);
if (libs != null) {
out.println "Module: $p.name"
libs.each { path ->
@@ -346,6 +367,37 @@ String generateLibraryDependencyMapping() {
}
return libsFile.absolutePath
}
+/******************************************************************************************
+ *
+ * Creates a file that lists all external jars used to build and run Ghidra
+ *
+ ******************************************************************************************/
+String generateAllExternalLibsFile() {
+ File libsFile = file("$buildDir/AllExternalLibs.txt")
+
+ // Check to make sure the build folder exists - if it doesn't, the 'libsFile.withWriter'
+ // call (below) will fail miserably.
+ def buildFolder = file ("$buildDir")
+ if (!buildFolder.exists()) {
+ buildFolder.mkdirs()
+ }
+ Set<String> allLibs = new HashSet<>();
+ subprojects { p ->
+ p.plugins.withType(JavaPlugin) {
+ Set<String> libs = getAllExternalDependencies(p);
+ if (libs != null) {
+ allLibs.addAll(libs);
+ }
+ }
+ }
+ libsFile.withWriter { out ->
+ allLibs.each { path ->
+ out.println "$path"
+ }
+ }
+ return libsFile.absolutePath
+}
+
task allSleighCompile {
}
diff --git a/gradle/distributableGhidraModule.gradle b/gradle/distributableGhidraModule.gradle
index 104a842240..3506d50080 100644
--- a/gradle/distributableGhidraModule.gradle
+++ b/gradle/distributableGhidraModule.gradle
@@ -173,7 +173,7 @@ plugins.withType(JavaPlugin) {
// External Libraries
gradle.taskGraph.whenReady { taskGraph ->
- List<String> externalPaths = getExternalDependencies(p)
+ List<String> externalPaths = getExternalRuntimeDependencies(p)
externalPaths.each { path ->
from (path) {
into {zipPath + "/lib" }
diff --git a/gradle/root/prepDev.gradle b/gradle/root/prepDev.gradle
index dc0d6f1bf9..fe46b5bca4 100644
--- a/gradle/root/prepDev.gradle
+++ b/gradle/root/prepDev.gradle
@@ -12,8 +12,22 @@ task prepDev {
// the GhidraLauncher depends on this file to build the classpath in dev mode
dependsOn { generateLibraryDependencyMapping }
+
+ // generate list of all library files used to build and run ghidra. (not strictly necessary here, but nice to have)
+ dependsOn { generateAllExternalLibsFile }
+
}
+/******************************************************************************************
+ * TASK generateAllExternalLibsFile
+ *
+ * Summary: Creates a file that lists all libraries used to build and run Ghidra
+ ******************************************************************************************/
+task generateAllExternalLibsFile {
+ doFirst{
+ generateAllExternalLibsFile()
+ }
+}
/******************************************************************************************
* TASK generateLibraryDependencyMapping
@@ -24,4 +38,5 @@ task generateLibraryDependencyMapping {
doFirst{
generateLibraryDependencyMapping()
}
-}
\ No newline at end of file
+}
+
diff --git a/gradle/support/extensionCommon.gradle b/gradle/support/extensionCommon.gradle
index bc1d3cdd5a..953fa19ba0 100644
--- a/gradle/support/extensionCommon.gradle
+++ b/gradle/support/extensionCommon.gradle
@@ -61,7 +61,7 @@ task zipExtensions (type: Zip) {
/////////////////
gradle.taskGraph.whenReady { taskGraph ->
if (project.plugins.withType(JavaPlugin)) {
- List<String> externalPaths = getExternalDependencies(p)
+ List<String> externalPaths = getExternalRuntimeDependencies(p)
externalPaths.each { path ->
from (path) {
into { getBaseProjectName(p) + "/lib" }
diff --git a/gradle/support/ip.gradle b/gradle/support/ip.gradle
index 5e6c4a8ab3..2125091554 100644
--- a/gradle/support/ip.gradle
+++ b/gradle/support/ip.gradle
@@ -82,7 +82,7 @@ def Map<String, String> getModuleManifestIp(Project project) {
*********************************************************************************/
def checkExternalLibsInMap(Map<String, String> map, Project project) {
if (project.plugins.withType(JavaPlugin)) {
- List<String> libs = getExternalDependencies(project)
+ List<String> libs = getExternalRuntimeDependencies(project)
libs.each { lib ->
String libName = new File(lib).getName() // get just the filename without the path
String relativePath = "lib/"+libName;