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

This commit is contained in:
ghidravore 2020-12-08 13:03:36 -05:00 committed by ghidra1
parent fb4380155e
commit 8b054814a8
6 changed files with 84 additions and 14 deletions

View file

@ -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'

View file

@ -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 {
}

View file

@ -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" }

View file

@ -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()
}
}
}

View file

@ -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" }

View file

@ -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;