[build] Delete test folders after tests execute (#2891)

Also deletes object files.

Both of these things are only done on the build server (-PbuildServer flag).

This will remove all test folders, which removes lots of copies of dependencies.

This also fixes an issue where gtest exectubables were installed for cross builds, even though they should not have been.
This commit is contained in:
Thad House
2020-11-27 21:44:47 -08:00
committed by GitHub
parent d478ad00d0
commit e6a4254488
7 changed files with 40 additions and 8 deletions

View File

@@ -6,6 +6,8 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import org.gradle.api.tasks.Delete
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
@@ -87,6 +89,14 @@ class SingleNativeBuild implements Plugin<Project> {
subs << component
}
}
Delete deleteObjects = null
if (project.hasProperty('buildServer')) {
deleteObjects = project.tasks.create('deleteObjects', Delete)
project.tasks.named('build').configure { Task t ->
t.dependsOn deleteObjects
return
}
}
subs.each {
((NativeLibrarySpec) it).binaries.each { oBinary ->
if (oBinary.buildable == false) {
@@ -136,6 +146,10 @@ class SingleNativeBuild implements Plugin<Project> {
tree.include '**/*.o'
tree.include '**/*.obj'
link.source tree
if (project.hasProperty('buildServer')) {
deleteObjects.dependsOn link
deleteObjects.delete tree
}
} else if (binary instanceof StaticLibraryBinarySpec) {
def sBinary = (StaticLibraryBinarySpec) binary
ObjectFilesToBinary assemble = (ObjectFilesToBinary) sBinary.tasks.createStaticLib
@@ -145,6 +159,10 @@ class SingleNativeBuild implements Plugin<Project> {
tree.include '**/*.o'
tree.include '**/*.obj'
assemble.source tree
if (project.hasProperty('buildServer')) {
deleteObjects.dependsOn assemble
deleteObjects.delete tree
}
}
}
}

View File

@@ -43,8 +43,6 @@ def generateUsageReporting = tasks.register('generateUsageReporting') {
}
}
apply plugin: DisableBuildingGTest
ext {
addHalDependency = { binary, shared->
binary.tasks.withType(AbstractNativeSourceCompileTask) {

View File

@@ -45,6 +45,19 @@ model {
}
}
apply plugin: DisableBuildingGTest
if (project.hasProperty('buildServer')) {
tasks.withType(org.gradle.nativeplatform.test.tasks.RunTestExecutable) {
def exeFile = file(it.executable)
def folder = exeFile.parentFile
it.doLast {
folder.deleteDir()
}
}
}
ext.appendDebugPathToBinaries = { binaries->
binaries.withType(StaticLibraryBinarySpec) {
if (it.buildType.name.contains('debug')) {

View File

@@ -257,6 +257,15 @@ model {
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
test.dependsOn it.tasks.install
if (project.hasProperty('buildServer')) {
def folderDir = it.tasks.install.installDirectory.get().toString()
test.doLast {
def folder = file(folderDir)
folder.deleteDir()
}
}
test.systemProperty 'java.library.path', filePath
test.environment 'LD_LIBRARY_PATH', filePath
test.workingDir filePath

View File

@@ -43,8 +43,6 @@ nativeUtils.exportsConfigs {
}
}
apply plugin: DisableBuildingGTest
model {
components {}
binaries {

View File

@@ -41,8 +41,6 @@ nativeUtils.exportsConfigs {
}
}
apply plugin: DisableBuildingGTest
model {
components {}
binaries {

View File

@@ -60,8 +60,6 @@ staticGtestConfigs["${nativeName}Test"] = []
apply from: "${rootDir}/shared/googletest.gradle"
apply plugin: DisableBuildingGTest
nativeUtils.exportsConfigs {
wpilibc {
x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',