Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | import edu.wpi.first.toolchain.NativePlatforms |
| 2 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 3 | apply plugin: 'java' |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 4 | apply plugin: 'jacoco' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 5 | |
| 6 | ext { |
| 7 | useJava = true |
| 8 | useCpp = false |
| 9 | skipDev = true |
| 10 | } |
| 11 | |
| 12 | apply from: "${rootDir}/shared/opencv.gradle" |
| 13 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 14 | test { |
| 15 | useJUnitPlatform() |
| 16 | systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' |
| 17 | testLogging { |
| 18 | events "failed" |
| 19 | exceptionFormat "full" |
| 20 | } |
| 21 | finalizedBy jacocoTestReport |
| 22 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 23 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 24 | if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64')) { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 25 | test.enabled = false |
| 26 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 27 | |
| 28 | dependencies { |
| 29 | implementation project(':wpilibj') |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 30 | implementation project(':apriltag') |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 31 | implementation project(':wpimath') |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 32 | implementation project(':hal') |
| 33 | implementation project(':wpiutil') |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 34 | implementation project(':wpinet') |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 35 | implementation project(':ntcore') |
| 36 | implementation project(':cscore') |
| 37 | implementation project(':cameraserver') |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 38 | implementation project(':wpilibNewCommands') |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 39 | |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 40 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' |
| 41 | testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2' |
| 42 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 43 | } |
| 44 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 45 | jacoco { |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 46 | toolVersion = "0.8.8" |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | jacocoTestReport { |
| 50 | reports { |
| 51 | xml.required = true |
| 52 | html.required = true |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | if (!project.hasProperty('skipJavaFormat')) { |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 57 | apply plugin: 'pmd' |
| 58 | |
| 59 | pmd { |
| 60 | consoleOutput = true |
| 61 | reportsDir = file("$project.buildDir/reports/pmd") |
| 62 | ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml")) |
| 63 | ruleSets = [] |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | gradle.projectsEvaluated { |
| 68 | tasks.withType(JavaCompile) { |
| 69 | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Werror" |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | tasks.register('buildDesktopJava') { |
| 74 | it.dependsOn tasks.withType(JavaCompile) |
| 75 | } |
| 76 | |
| 77 | apply from: 'publish.gradle' |
| 78 | |
| 79 | ext { |
| 80 | templateDirectory = new File("$projectDir/src/main/java/edu/wpi/first/wpilibj/templates/") |
| 81 | templateFile = new File("$projectDir/src/main/java/edu/wpi/first/wpilibj/templates/templates.json") |
| 82 | exampleDirectory = new File("$projectDir/src/main/java/edu/wpi/first/wpilibj/examples/") |
| 83 | exampleFile = new File("$projectDir/src/main/java/edu/wpi/first/wpilibj/examples/examples.json") |
| 84 | commandDirectory = new File("$projectDir/src/main/java/edu/wpi/first/wpilibj/commands/") |
| 85 | commandFile = new File("$projectDir/src/main/java/edu/wpi/first/wpilibj/commands/commands.json") |
| 86 | } |
| 87 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 88 | apply plugin: 'cpp' |
| 89 | apply plugin: 'edu.wpi.first.NativeUtils' |
| 90 | |
| 91 | apply from: '../shared/config.gradle' |
| 92 | |
| 93 | |
| 94 | model { |
| 95 | components { |
| 96 | wpilibjExamplesDev(NativeExecutableSpec) { |
| 97 | targetBuildTypes 'debug' |
| 98 | sources { |
| 99 | cpp { |
| 100 | source { |
| 101 | srcDirs 'src/dev/native/cpp' |
| 102 | include '**/*.cpp' |
| 103 | } |
| 104 | exportedHeaders { |
| 105 | srcDirs 'src/dev/native/include' |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | binaries.all { binary -> |
| 110 | lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared' |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 111 | lib project: ':apriltag', library: 'apriltag', linkage: 'shared' |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 112 | lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' |
| 113 | lib project: ':wpimath', library: 'wpimath', linkage: 'shared' |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 114 | lib project: ':wpimath', library: 'wpimathJNIShared', linkage: 'shared' |
| 115 | project(':ntcore').addNtcoreDependency(binary, 'shared') |
| 116 | project(':ntcore').addNtcoreJniDependency(binary) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 117 | lib project: ':cscore', library: 'cscore', linkage: 'shared' |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 118 | lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared' |
| 119 | project(':hal').addHalDependency(binary, 'shared') |
| 120 | project(':hal').addHalJniDependency(binary) |
| 121 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 122 | lib project: ':wpiutil', library: 'wpiutilJNIShared', linkage: 'shared' |
| 123 | lib project: ':wpinet', library: 'wpinet', linkage: 'shared' |
| 124 | lib project: ':wpinet', library: 'wpinetJNIShared', linkage: 'shared' |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 125 | lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' |
| 126 | if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
| 127 | nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries') |
| 128 | } else { |
| 129 | def systemArch = getCurrentArch() |
| 130 | if (binary.targetPlatform.name == systemArch) { |
| 131 | lib project: ":simulation:halsim_gui", library: 'halsim_gui', linkage: 'shared' |
| 132 | } |
| 133 | } |
| 134 | nativeUtils.useRequiredLibrary(binary, 'opencv_shared') |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | tasks { |
| 139 | def c = $.components |
| 140 | def found = false |
| 141 | c.each { |
| 142 | if (it in NativeExecutableSpec && it.name == "wpilibjExamplesDev") { |
| 143 | it.binaries.each { |
| 144 | if (!found) { |
| 145 | def arch = it.targetPlatform.name |
| 146 | if (arch == NativePlatforms.desktop) { |
| 147 | found = true |
| 148 | def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib' |
| 149 | |
| 150 | def doFirstTask = { task -> |
| 151 | def extensions = '' |
| 152 | it.tasks.install.installDirectory.get().getAsFile().eachFileRecurse { |
| 153 | def name = it.name |
| 154 | if (!(name.endsWith('.dll') || name.endsWith('.so') || name.endsWith('.dylib'))) { |
| 155 | return |
| 156 | } |
| 157 | def file = it |
| 158 | if (name.startsWith("halsim_gui") || name.startsWith("libhalsim_gui".toString())) { |
| 159 | extensions += file.absolutePath + File.pathSeparator |
| 160 | } |
| 161 | } |
| 162 | if (extensions != '') { |
| 163 | task.environment 'HALSIM_EXTENSIONS', extensions |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | project.tasks.create("runCpp", Exec) { task -> |
| 168 | dependsOn it.tasks.install |
| 169 | commandLine it.tasks.install.runScriptFile.get().asFile.toString() |
| 170 | test.dependsOn it.tasks.install |
| 171 | test.systemProperty 'java.library.path', filePath |
| 172 | test.environment 'LD_LIBRARY_PATH', filePath |
| 173 | test.workingDir filePath |
| 174 | } |
| 175 | |
| 176 | new groovy.json.JsonSlurper().parseText(exampleFile.text).each { entry -> |
| 177 | project.tasks.create("run${entry.foldername}", JavaExec) { run -> |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 178 | run.group "run examples" |
| 179 | run.mainClass = "edu.wpi.first.wpilibj.examples." + entry.foldername + "." + entry.mainclass |
| 180 | run.classpath = sourceSets.main.runtimeClasspath |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 181 | run.dependsOn it.tasks.install |
| 182 | run.systemProperty 'java.library.path', filePath |
| 183 | run.environment 'LD_LIBRARY_PATH', filePath |
| 184 | run.workingDir filePath |
| 185 | doFirst { doFirstTask(run) } |
| 186 | |
| 187 | if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) { |
| 188 | run.jvmArgs = ['-XstartOnFirstThread'] |
| 189 | } |
| 190 | } |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 191 | project.tasks.create("test${entry.foldername}", Test) { testTask -> |
| 192 | testTask.group "verification" |
| 193 | testTask.useJUnitPlatform() |
| 194 | testTask.filter { |
| 195 | includeTestsMatching("edu.wpi.first.wpilibj.examples.${entry.foldername}.*") |
| 196 | setFailOnNoMatchingTests(false) |
| 197 | } |
| 198 | testTask.classpath = sourceSets.test.runtimeClasspath |
| 199 | testTask.dependsOn it.tasks.install |
| 200 | |
| 201 | testTask.systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' |
| 202 | testTask.testLogging { |
| 203 | events "failed" |
| 204 | exceptionFormat "full" |
| 205 | } |
| 206 | testTask.systemProperty 'java.library.path', filePath |
| 207 | testTask.environment 'LD_LIBRARY_PATH', filePath |
| 208 | testTask.workingDir filePath |
| 209 | } |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | found = true |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 221 | ext { |
| 222 | isCppCommands = false |
| 223 | } |
| 224 | apply from: "${rootDir}/shared/examplecheck.gradle" |