Add docs and lifecycle tasks for faster dev builds (#2182)

This commit is contained in:
Thad House
2019-12-20 13:48:26 -08:00
committed by Peter Johnson
parent ea4d1a39e1
commit 5e08bb28f8
9 changed files with 74 additions and 0 deletions

15
FasterBuilds.md Normal file
View File

@@ -0,0 +1,15 @@
# Faster Builds for Developers
When you run `./gradlew build`, it builds EVERYTHING. This means debug and release builds for desktop and all installed cross compilers. For many developers, this is way too much, and causes much developer pain.
To help with some of these things, common tasks have shortcuts to only build necessary things for common development and testing tasks.
## Development (Desktop)
For projects `wpiutil`, `ntcore`, `cscore`, `hal` `wpilibOldCommands`, `wpilibNewCommands` and `cameraserver`, a `testDesktopJava` and a `testDesktopCpp` task exists. These can be ran with `./gradlew :projectName:task`, and will only build the minimum things required to run those tests.
For `wpilibc`, a `testDesktopCpp` task exists. For `wpilibj`, a `testDesktopJava` task exists.
For `wpilibcExamples`, a `buildDesktopCpp` task exists (These can't be ran, but they can compile).
For `wpilibjExamples`, a `buildDesktopJava` task exists.

View File

@@ -0,0 +1,21 @@
model {
tasks {
def ts = $.testSuites
project.tasks.register('testDesktopCpp') { testTask->
def systemArch = getCurrentArch()
def found = false
ts.each {
if (it in GoogleTestTestSuiteSpec && it.name == "${nativeName}Test") {
it.binaries.each {
if (found) return
def arch = it.targetPlatform.name
if (arch == systemArch && it.buildType.name == 'debug') {
testTask.dependsOn it.tasks.run
found = true
}
}
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
tasks.register('testDesktopJava') {
dependsOn test
}

View File

@@ -141,6 +141,9 @@ model {
}
}
apply from: "${rootDir}/shared/cppDesktopTestTask.gradle"
apply from: "${rootDir}/shared/javaDesktopTestTask.gradle"
tasks.withType(RunTestExecutable) {
args "--gtest_output=xml:test_detail.xml"
outputs.dir outputDir

View File

@@ -275,6 +275,9 @@ model {
}
}
apply from: "${rootDir}/shared/cppDesktopTestTask.gradle"
apply from: "${rootDir}/shared/javaDesktopTestTask.gradle"
ext.getJniSpecClass = {
return JniNativeLibrarySpec
}

View File

@@ -231,6 +231,8 @@ model {
}
}
apply from: "${rootDir}/shared/cppDesktopTestTask.gradle"
tasks.withType(RunTestExecutable) {
args "--gtest_output=xml:test_detail.xml"
outputs.dir outputDir

View File

@@ -6,6 +6,8 @@ apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
apply plugin: ExtraTasks
evaluationDependsOn(':hal')
apply from: '../shared/config.gradle'
ext.examplesMap = [:]
@@ -222,6 +224,25 @@ model {
}
apply from: 'publish.gradle'
model {
tasks {
def c = $.components
project.tasks.register('buildDesktopCpp') { compileTask->
def systemArch = getCurrentArch()
c.each {
if (it in NativeExecutableSpec && it.name) {
it.binaries.each {
def arch = it.targetPlatform.name
if (arch == systemArch && it.buildType.name == 'debug') {
compileTask.dependsOn it.tasks.link
}
}
}
}
}
}
}
ext {
templateDirectory = new File("$projectDir/src/main/cpp/templates/")
templateFile = new File("$projectDir/src/main/cpp/templates/templates.json")

View File

@@ -170,3 +170,5 @@ test {
showStandardStreams = true
}
}
apply from: "${rootDir}/shared/javaDesktopTestTask.gradle"

View File

@@ -39,6 +39,10 @@ gradle.projectsEvaluated {
}
}
tasks.register('buildDesktopJava') {
it.dependsOn tasks.withType(JavaCompile)
}
apply from: 'publish.gradle'
ext {