Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1080: Preventing native test binaries from getting built for the distribution

Ryan Kurtz524badc9d4ca
diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradle
index 36b9a07875..6ddc826059 100644
--- a/GPL/nativeBuildProperties.gradle
+++ b/GPL/nativeBuildProperties.gradle
@@ -87,6 +87,16 @@ def isNativeBinaryMakeTask(Task task, String platform) {
return false
}
+/*******************************************************************************************
+ * Returns true if the native binaries for the given task should be skipped during build.
+ *
+ * NOTE: Some native binaries are test-only and should not be built for a distribution.
+ *
+ ******************************************************************************************/
+def shouldSkipNative(task) {
+ return task.ext.has("skipNative") && task.ext.get("skipNative")
+}
+
/*******************************************************************************************
* Task Rule : builds all the natives in this module for a given platform.
*
@@ -113,6 +123,11 @@ tasks.addRule("Pattern: buildNatives_<platform name>]: build all natives for giv
myTask.dependsOn t.path
t.dependsOn CheckToolChain
}
+
+ // buildNatives task natives end up in the distribution...mark test natives as "skip"
+ if (project.findProperty("nativesTestOnly") ?: false) {
+ t.ext.set("skipNative", true)
+ }
}
// add callbacks to look for native build tasks when new tasks are added later
@@ -169,18 +184,22 @@ tasks.addRule("Pattern: prebuildNatives_<platform name>]: build all natives for
gradle.taskGraph.whenReady {
def p = this.project
p.tasks.withType(LinkExecutable).each { t ->
- File f = t.linkedFile.getAsFile().get()
- String filename = f.getName()
- NativePlatform platform = t.targetPlatform.get()
- String osName = platform.getName()
- t.linkedFile = p.file("build/os/${osName}/$filename")
+ if (!shouldSkipNative(t)) {
+ File f = t.linkedFile.getAsFile().get()
+ String filename = f.getName()
+ NativePlatform platform = t.targetPlatform.get()
+ String osName = platform.getName()
+ t.linkedFile = p.file("build/os/${osName}/$filename")
+ }
}
p.tasks.withType(LinkSharedLibrary).each { t ->
- File f = t.linkedFile.getAsFile().get()
- String filename = f.getName()
- NativePlatform platform = t.targetPlatform.get()
- String osName = platform.getName()
- t.linkedFile = p.file("build/os/${osName}/$filename")
+ if (!shouldSkipNative(t)) {
+ File f = t.linkedFile.getAsFile().get()
+ String filename = f.getName()
+ NativePlatform platform = t.targetPlatform.get()
+ String osName = platform.getName()
+ t.linkedFile = p.file("build/os/${osName}/$filename")
+ }
}
}
diff --git a/Ghidra/Debug/Framework-Debugging/build.gradle b/Ghidra/Debug/Framework-Debugging/build.gradle
index 6031083387..841b955a24 100644
--- a/Ghidra/Debug/Framework-Debugging/build.gradle
+++ b/Ghidra/Debug/Framework-Debugging/build.gradle
@@ -31,6 +31,9 @@ dependencies {
testImplementation project(path: ':Framework-AsyncComm', configuration: 'testArtifacts')
}
+// Ensure the below native test binaries don't get built for a distribution
+ext.nativesTestOnly = true
+
task testSpecimenWin64 {
dependsOn 'expCreateProcessWin64Executable'
dependsOn 'expCreateThreadExitWin64Executable'