blob: 1a1e3b10e0252d0ee426d129eb1ab99e94b46fd6 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001plugins {
2 id 'java'
Austin Schuh812d0d12021-11-04 20:16:48 -07003 id "org.ysb33r.doxygen" version "0.7.0"
Brian Silverman8fce7482020-01-05 13:18:21 -08004}
5
James Kuszmaulcf324122023-01-14 14:07:17 -08006evaluationDependsOn(':apriltag')
7evaluationDependsOn(':cameraserver')
Brian Silverman8fce7482020-01-05 13:18:21 -08008evaluationDependsOn(':cscore')
9evaluationDependsOn(':hal')
James Kuszmaulcf324122023-01-14 14:07:17 -080010evaluationDependsOn(':ntcore')
11evaluationDependsOn(':wpilibNewCommands')
Brian Silverman8fce7482020-01-05 13:18:21 -080012evaluationDependsOn(':wpilibc')
13evaluationDependsOn(':wpilibj')
James Kuszmaulcf324122023-01-14 14:07:17 -080014evaluationDependsOn(':wpimath')
15evaluationDependsOn(':wpinet')
James Kuszmaulb13e13f2023-11-22 20:44:04 -080016evaluationDependsOn(':wpiunits')
James Kuszmaulcf324122023-01-14 14:07:17 -080017evaluationDependsOn(':wpiutil')
Brian Silverman8fce7482020-01-05 13:18:21 -080018
19def baseArtifactIdCpp = 'documentation'
20def artifactGroupIdCpp = 'edu.wpi.first.wpilibc'
21def zipBaseNameCpp = '_GROUP_edu_wpi_first_wpilibc_ID_documentation_CLS'
22
23def baseArtifactIdJava = 'documentation'
24def artifactGroupIdJava = 'edu.wpi.first.wpilibj'
25def zipBaseNameJava = '_GROUP_edu_wpi_first_wpilibj_ID_documentation_CLS'
26
27def outputsFolder = file("$project.buildDir/outputs")
28
29def cppProjectZips = []
Austin Schuh812d0d12021-11-04 20:16:48 -070030def cppIncludeRoots = []
Brian Silverman8fce7482020-01-05 13:18:21 -080031
James Kuszmaulcf324122023-01-14 14:07:17 -080032cppProjectZips.add(project(':apriltag').cppHeadersZip)
Brian Silverman8fce7482020-01-05 13:18:21 -080033cppProjectZips.add(project(':cameraserver').cppHeadersZip)
James Kuszmaulcf324122023-01-14 14:07:17 -080034cppProjectZips.add(project(':cscore').cppHeadersZip)
35cppProjectZips.add(project(':hal').cppHeadersZip)
36cppProjectZips.add(project(':ntcore').cppHeadersZip)
Brian Silverman8fce7482020-01-05 13:18:21 -080037cppProjectZips.add(project(':wpilibNewCommands').cppHeadersZip)
James Kuszmaulcf324122023-01-14 14:07:17 -080038cppProjectZips.add(project(':wpilibc').cppHeadersZip)
39cppProjectZips.add(project(':wpimath').cppHeadersZip)
40cppProjectZips.add(project(':wpinet').cppHeadersZip)
41cppProjectZips.add(project(':wpiutil').cppHeadersZip)
Brian Silverman8fce7482020-01-05 13:18:21 -080042
43doxygen {
James Kuszmaulcf324122023-01-14 14:07:17 -080044 // Doxygen binaries are only provided for x86_64 platforms
45 // Other platforms will need to provide doxygen via their system
46 // See below maven and https://doxygen.nl/download.html for provided binaries
47
48 String arch = System.getProperty("os.arch");
49 if (arch.equals("x86_64") || arch.equals("amd64")) {
50 executables {
51 doxygen version : '1.9.4',
52 baseURI : 'https://frcmaven.wpi.edu/artifactory/generic-release-mirror/doxygen'
53 }
Austin Schuh1e69f942020-11-14 15:06:14 -080054 }
Brian Silverman8fce7482020-01-05 13:18:21 -080055}
56
57doxygen {
58 generate_html true
Austin Schuh812d0d12021-11-04 20:16:48 -070059 html_extra_stylesheet 'theme.css'
Brian Silverman8fce7482020-01-05 13:18:21 -080060
61 cppProjectZips.each {
62 dependsOn it
63 source it.source
Austin Schuh812d0d12021-11-04 20:16:48 -070064 it.ext.includeDirs.each {
65 cppIncludeRoots.add(it.absolutePath)
66 }
Brian Silverman8fce7482020-01-05 13:18:21 -080067 }
James Kuszmaulb13e13f2023-11-22 20:44:04 -080068 cppIncludeRoots << '../ntcore/build/generated/main/native/include/'
Brian Silverman8fce7482020-01-05 13:18:21 -080069
Austin Schuh812d0d12021-11-04 20:16:48 -070070 if (project.hasProperty('docWarningsAsErrors')) {
Austin Schuh812d0d12021-11-04 20:16:48 -070071 // Eigen
72 exclude 'Eigen/**'
73 exclude 'unsupported/**'
74
75 // LLVM
76 exclude 'wpi/AlignOf.h'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080077 exclude 'wpi/Casting.h'
Austin Schuh812d0d12021-11-04 20:16:48 -070078 exclude 'wpi/Chrono.h'
79 exclude 'wpi/Compiler.h'
80 exclude 'wpi/ConvertUTF.h'
81 exclude 'wpi/DenseMap.h'
82 exclude 'wpi/DenseMapInfo.h'
83 exclude 'wpi/Endian.h'
84 exclude 'wpi/EpochTracker.h'
85 exclude 'wpi/Errc.h'
86 exclude 'wpi/Errno.h'
87 exclude 'wpi/ErrorHandling.h'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080088 exclude 'wpi/bit.h'
Austin Schuh812d0d12021-11-04 20:16:48 -070089 exclude 'wpi/fs.h'
90 exclude 'wpi/FunctionExtras.h'
91 exclude 'wpi/function_ref.h'
92 exclude 'wpi/Hashing.h'
93 exclude 'wpi/iterator.h'
94 exclude 'wpi/iterator_range.h'
95 exclude 'wpi/ManagedStatic.h'
96 exclude 'wpi/MapVector.h'
97 exclude 'wpi/MathExtras.h'
98 exclude 'wpi/MemAlloc.h'
99 exclude 'wpi/PointerIntPair.h'
100 exclude 'wpi/PointerLikeTypeTraits.h'
101 exclude 'wpi/PointerUnion.h'
102 exclude 'wpi/raw_os_ostream.h'
103 exclude 'wpi/raw_ostream.h'
104 exclude 'wpi/SmallPtrSet.h'
105 exclude 'wpi/SmallSet.h'
106 exclude 'wpi/SmallString.h'
107 exclude 'wpi/SmallVector.h'
108 exclude 'wpi/StringExtras.h'
109 exclude 'wpi/StringMap.h'
110 exclude 'wpi/SwapByteOrder.h'
111 exclude 'wpi/type_traits.h'
112 exclude 'wpi/VersionTuple.h'
113 exclude 'wpi/WindowsError.h'
114
115 // fmtlib
116 exclude 'fmt/**'
117
118 // libuv
119 exclude 'uv.h'
120 exclude 'uv/**'
James Kuszmaulcf324122023-01-14 14:07:17 -0800121 exclude 'wpinet/uv/**'
Austin Schuh812d0d12021-11-04 20:16:48 -0700122
123 // json
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800124 exclude 'wpi/adl_serializer.h'
125 exclude 'wpi/byte_container_with_subtype.h'
126 exclude 'wpi/detail/**'
Austin Schuh812d0d12021-11-04 20:16:48 -0700127 exclude 'wpi/json.h'
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800128 exclude 'wpi/json_fwd.h'
129 exclude 'wpi/ordered_map.h'
130 exclude 'wpi/thirdparty/**'
Austin Schuh812d0d12021-11-04 20:16:48 -0700131
James Kuszmaulcf324122023-01-14 14:07:17 -0800132 // memory
133 exclude 'wpi/memory/**'
134
Austin Schuh812d0d12021-11-04 20:16:48 -0700135 // mpack
136 exclude 'wpi/mpack.h'
137
138 // units
139 exclude 'units/**'
140 }
141
James Kuszmaulcf324122023-01-14 14:07:17 -0800142 //TODO: building memory docs causes search to break
143 exclude 'wpi/memory/**'
144
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800145 exclude '*.pb.h'
146
James Kuszmaulcf324122023-01-14 14:07:17 -0800147 aliases 'effects=\\par <i>Effects:</i>^^',
148 'notes=\\par <i>Notes:</i>^^',
149 'requires=\\par <i>Requires:</i>^^',
150 'requiredbe=\\par <i>Required Behavior:</i>^^',
151 'concept{2}=<a href=\"md_doc_concepts.html#\1\">\2</a>',
152 'defaultbe=\\par <i>Default Behavior:</i>^^'
Austin Schuh812d0d12021-11-04 20:16:48 -0700153 case_sense_names false
Austin Schuh75263e32022-02-22 18:05:32 -0800154 extension_mapping 'inc=C++', 'no_extension=C++'
Austin Schuh812d0d12021-11-04 20:16:48 -0700155 extract_all true
Brian Silverman8fce7482020-01-05 13:18:21 -0800156 extract_static true
Austin Schuh75263e32022-02-22 18:05:32 -0800157 file_patterns '*'
Austin Schuh812d0d12021-11-04 20:16:48 -0700158 full_path_names true
159 generate_html true
160 generate_latex false
161 generate_treeview true
162 html_extra_stylesheet 'theme.css'
163 html_timestamp true
164 javadoc_autobrief true
165 project_name 'WPILibC++'
166 project_logo '../wpiutil/src/main/native/resources/wpilib-128.png'
167 project_number wpilibVersioning.version.get()
168 quiet true
169 recursive true
170 strip_code_comments false
171 strip_from_inc_path cppIncludeRoots as String[]
172 strip_from_path cppIncludeRoots as String[]
173 use_mathjax true
174 warnings false
175 warn_if_incomplete_doc true
176 warn_if_undocumented false
177 warn_no_paramdoc true
178
James Kuszmaulcf324122023-01-14 14:07:17 -0800179 //enable doxygen preprocessor expansion of WPI_DEPRECATED to fix MotorController docs
Austin Schuh812d0d12021-11-04 20:16:48 -0700180 enable_preprocessing true
181 macro_expansion true
182 expand_only_predef true
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800183 predefined "WPI_DEPRECATED(x)=[[deprecated(x)]]\"\\\n" +
184 "\"__cplusplus\"\\\n" +
185 "\"HAL_ENUM(name)=enum name : int32_t"
Austin Schuh812d0d12021-11-04 20:16:48 -0700186
187 if (project.hasProperty('docWarningsAsErrors')) {
188 warn_as_error 'FAIL_ON_WARNINGS'
189 }
Brian Silverman8fce7482020-01-05 13:18:21 -0800190}
191
192tasks.register("zipCppDocs", Zip) {
193 archiveBaseName = zipBaseNameCpp
194 destinationDirectory = outputsFolder
195 dependsOn doxygen
196 from ("$buildDir/docs/doxygen/html")
197 into '/'
198}
199
200// Java
201configurations {
202 javaSource {
203 transitive false
204 }
205}
206
207ext {
208 sharedCvConfigs = [:]
209 staticCvConfigs = [:]
210 useJava = true
211 useCpp = false
212 skipDev = true
213 useDocumentation = true
214}
215
216apply from: "${rootDir}/shared/opencv.gradle"
217
218task generateJavaDocs(type: Javadoc) {
Austin Schuh1e69f942020-11-14 15:06:14 -0800219 classpath += project(":wpimath").sourceSets.main.compileClasspath
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800220 options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
Austin Schuh812d0d12021-11-04 20:16:48 -0700221 options.addStringOption("tag", "pre:a:Pre-Condition")
222 options.addBooleanOption("Xdoclint:html,missing,reference,syntax", true)
Brian Silverman8fce7482020-01-05 13:18:21 -0800223 options.addBooleanOption('html5', true)
Austin Schuh812d0d12021-11-04 20:16:48 -0700224 options.linkSource(true)
Brian Silverman8fce7482020-01-05 13:18:21 -0800225 dependsOn project(':hal').generateUsageReporting
James Kuszmaulcf324122023-01-14 14:07:17 -0800226 dependsOn project(':ntcore').ntcoreGenerateJavaTypes
227 dependsOn project(':wpilibj').generateJavaVersion
Austin Schuh1e69f942020-11-14 15:06:14 -0800228 dependsOn project(':wpimath').generateNat
James Kuszmaulcf324122023-01-14 14:07:17 -0800229 source project(':apriltag').sourceSets.main.java
Brian Silverman8fce7482020-01-05 13:18:21 -0800230 source project(':cameraserver').sourceSets.main.java
James Kuszmaulcf324122023-01-14 14:07:17 -0800231 source project(':cscore').sourceSets.main.java
232 source project(':hal').sourceSets.main.java
233 source project(':ntcore').sourceSets.main.java
Brian Silverman8fce7482020-01-05 13:18:21 -0800234 source project(':wpilibNewCommands').sourceSets.main.java
James Kuszmaulcf324122023-01-14 14:07:17 -0800235 source project(':wpilibj').sourceSets.main.java
236 source project(':wpimath').sourceSets.main.java
237 source project(':wpinet').sourceSets.main.java
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800238 source project(':wpiunits').sourceSets.main.java
James Kuszmaulcf324122023-01-14 14:07:17 -0800239 source project(':wpiutil').sourceSets.main.java
Brian Silverman8fce7482020-01-05 13:18:21 -0800240 source configurations.javaSource.collect { zipTree(it) }
241 include '**/*.java'
242 failOnError = true
Brian Silverman8fce7482020-01-05 13:18:21 -0800243
244 title = "WPILib API ${wpilibVersioning.version.get()}"
245 ext.entryPoint = "$destinationDir/index.html"
246
Austin Schuh812d0d12021-11-04 20:16:48 -0700247 if (JavaVersion.current().isJava8Compatible() && project.hasProperty('docWarningsAsErrors')) {
248 // Treat javadoc warnings as errors.
249 //
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800250 // The second argument '-quiet' is a hack. The one parameter
Austin Schuh812d0d12021-11-04 20:16:48 -0700251 // addStringOption() doesn't work, so we add '-quiet', which is added
252 // anyway by gradle. See https://github.com/gradle/gradle/issues/2354.
253 //
254 // See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
255 // for information about the nonstandard -Xwerror option. JDK 15+ has
256 // -Werror.
257 options.addStringOption('Xwerror', '-quiet')
258 }
259
Brian Silverman8fce7482020-01-05 13:18:21 -0800260 if (JavaVersion.current().isJava11Compatible()) {
Austin Schuh1e69f942020-11-14 15:06:14 -0800261 if (!JavaVersion.current().isJava12Compatible()) {
262 options.addBooleanOption('-no-module-directories', true)
263 }
Brian Silverman8fce7482020-01-05 13:18:21 -0800264 doLast {
265 // This is a work-around for https://bugs.openjdk.java.net/browse/JDK-8211194. Can be removed once that issue is fixed on JDK's side
266 // Since JDK 11, package-list is missing from javadoc output files and superseded by element-list file, but a lot of external tools still need it
267 // Here we generate this file manually
268 new File(destinationDir, 'package-list').text = new File(destinationDir, 'element-list').text
269 }
270 }
271}
272
273tasks.register("zipJavaDocs", Zip) {
274 archiveBaseName = zipBaseNameJava
275 destinationDirectory = outputsFolder
276 dependsOn generateJavaDocs
277 from ("$buildDir/docs/javadoc")
278 into '/'
279}
280
Austin Schuh1e69f942020-11-14 15:06:14 -0800281tasks.register("zipDocs") {
282 dependsOn zipCppDocs
283 dependsOn zipJavaDocs
284}
Brian Silverman8fce7482020-01-05 13:18:21 -0800285
286apply plugin: 'maven-publish'
287
288publishing {
289 publications {
290 java(MavenPublication) {
291 artifact zipJavaDocs
292
293 artifactId = "${baseArtifactIdJava}"
294 groupId artifactGroupIdJava
295 version wpilibVersioning.version.get()
296 }
297 cpp(MavenPublication) {
298 artifact zipCppDocs
299
300 artifactId = "${baseArtifactIdCpp}"
301 groupId artifactGroupIdCpp
302 version wpilibVersioning.version.get()
303 }
304 }
305}