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

distribution
This commit is contained in:
Ryan Kurtz 2021-06-29 15:59:52 -04:00
parent 7936f89ab5
commit 524badc9d4
2 changed files with 32 additions and 10 deletions

View File

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

View File

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