Brian Silverman | 890a32a | 2018-03-11 15:41:56 -0700 | [diff] [blame] | 1 | task javaSourceJar(type: Jar) { |
| 2 | description = 'Generates the source jar for java' |
| 3 | group = '' |
| 4 | baseName = libraryName |
| 5 | classifier = "sources" |
| 6 | duplicatesStrategy = 'exclude' |
| 7 | destinationDir = archiveReleaseDir |
| 8 | |
| 9 | dependsOn project(':arm:cpp').classes |
| 10 | from project(':arm:cpp').sourceSets.main.allJava |
| 11 | } |
| 12 | |
| 13 | task javaJavadocJar(type: Jar) { |
| 14 | description = 'Generates the javadoc jar for java' |
| 15 | group = '' |
| 16 | baseName = libraryName |
| 17 | classifier = "javadoc" |
| 18 | duplicatesStrategy = 'exclude' |
| 19 | destinationDir = archiveReleaseDir |
| 20 | |
| 21 | dependsOn project(':arm:cpp').javadoc |
| 22 | from project(':arm:cpp').javadoc.destinationDir |
| 23 | } |
| 24 | |
| 25 | task cppSources(type: Zip) { |
| 26 | description = 'Creates a zip of cpp sources.' |
| 27 | group = '' |
| 28 | destinationDir = archiveReleaseDir |
| 29 | baseName = libraryName |
| 30 | classifier = 'cppsources' |
| 31 | duplicatesStrategy = 'exclude' |
| 32 | |
| 33 | from(cppSrc) { |
| 34 | into 'src' |
| 35 | } |
| 36 | |
| 37 | from(cppInclude) { |
| 38 | into 'include' |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | task copyToEclipse(type: Copy) { |
| 43 | description = 'Creates user zip of libraries, with shared c++ libs.' |
| 44 | group = '' |
| 45 | def userDir = System.getProperty("user.home") |
| 46 | destinationDir = file("${userDir}/wpilib/user/") |
| 47 | |
| 48 | // Copy include files from cpp project |
| 49 | from(file(cppInclude)) { |
| 50 | include '**/*.h' |
| 51 | into '/cpp/include' |
| 52 | } |
| 53 | |
| 54 | // Copy static binaries from cpp project |
| 55 | project(':arm:cpp').model { |
| 56 | binaries { |
| 57 | withType(StaticLibraryBinarySpec) { binary -> |
| 58 | from(binary.staticLibraryFile) { |
| 59 | include '*.a' |
| 60 | into '/cpp/lib' |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | // copy driver include |
| 67 | from (file(driverInclude)) { |
| 68 | include '**/*.h' |
| 69 | into '/cpp/include' |
| 70 | } |
| 71 | |
| 72 | // Copy included driver library headers |
| 73 | from(file(driverLibraryInclude)) { |
| 74 | include '**/*.h' |
| 75 | into '/cpp/include' |
| 76 | } |
| 77 | |
| 78 | // Copy included driver library binaries |
| 79 | from(file(driverLibraryLib)) { |
| 80 | include '*.so*' |
| 81 | include '*.a*' |
| 82 | into '/cpp/lib' |
| 83 | } |
| 84 | |
| 85 | // Copy included driver library headers |
| 86 | from(file(cppLibraryInclude)) { |
| 87 | include '**/*.h' |
| 88 | into '/cpp/include' |
| 89 | } |
| 90 | |
| 91 | // Copy included driver library binaries |
| 92 | from(file(cppLibraryLib)) { |
| 93 | include '*.so*' |
| 94 | include '*.a*' |
| 95 | into '/cpp/lib' |
| 96 | } |
| 97 | |
| 98 | def javaProject = project(':arm:cpp') |
| 99 | dependsOn javaProject.jar |
| 100 | // Copy project java binary |
| 101 | from (file(javaProject.jar.archivePath)) { |
| 102 | into '/java/lib' |
| 103 | } |
| 104 | |
| 105 | |
| 106 | // If not embedded java, include java libs |
| 107 | if (!embedJavaLibraries) { |
| 108 | from(file(javaLibraryLoc)) { |
| 109 | include '*.jar' |
| 110 | include '*.so' |
| 111 | include '*.so.debug' |
| 112 | into '/java/lib' |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // Include java sources if set |
| 117 | if (includeJavaSources) { |
| 118 | dependsOn javaSourceJar |
| 119 | from (file(javaSourceJar.archivePath)) { |
| 120 | into '/java/lib' |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // Include java javadoc if set |
| 125 | if (includeJavaJavadoc) { |
| 126 | dependsOn javaJavadocJar |
| 127 | from (file(javaJavadocJar.archivePath)) { |
| 128 | into '/java/docs' |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | // Include cpp sources if set |
| 133 | if (includeCppSources) { |
| 134 | from(file(cppSrc)) { |
| 135 | include '**/*.cpp' |
| 136 | include '**/*.h' |
| 137 | into "/cpp/src/$libraryName" |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | // Include driver sources if set |
| 142 | if (includeDriverSources) { |
| 143 | from(file(driverSrc)) { |
| 144 | include '**/*.cpp' |
| 145 | include '**/*.h' |
| 146 | into "/cpp/src/$libraryName" |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | |
| 152 | task userStaticArtifacts(type: Copy) { |
| 153 | description = 'Creates user zip of libraries, with static c++ libs.' |
| 154 | group = '' |
| 155 | destinationDir = releaseDir |
| 156 | duplicatesStrategy = 'exclude' |
| 157 | |
| 158 | // Copy include files from cpp project |
| 159 | from(file(cppInclude)) { |
| 160 | include '**/*.h' |
| 161 | into '/cpp/include' |
| 162 | } |
| 163 | |
| 164 | // Copy static binaries from cpp project |
| 165 | project(':arm:cpp').model { |
| 166 | binaries { |
| 167 | withType(StaticLibraryBinarySpec) { binary -> |
| 168 | from(binary.staticLibraryFile) { |
| 169 | include '*.a' |
| 170 | into '/cpp/lib' |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // copy driver include |
| 177 | from (file(driverInclude)) { |
| 178 | include '**/*.h' |
| 179 | into '/cpp/include' |
| 180 | } |
| 181 | |
| 182 | // Copy included driver library headers |
| 183 | from(file(driverLibraryInclude)) { |
| 184 | include '**/*.h' |
| 185 | into '/cpp/include' |
| 186 | } |
| 187 | |
| 188 | // Copy included driver library binaries |
| 189 | from(file(driverLibraryLib)) { |
| 190 | include '*.so*' |
| 191 | include '*.a*' |
| 192 | into '/cpp/lib' |
| 193 | } |
| 194 | |
| 195 | // Copy included driver library headers |
| 196 | from(file(cppLibraryInclude)) { |
| 197 | include '**/*.h' |
| 198 | into '/cpp/include' |
| 199 | } |
| 200 | |
| 201 | // Copy included driver library binaries |
| 202 | from(file(cppLibraryLib)) { |
| 203 | include '*.so*' |
| 204 | include '*.a*' |
| 205 | into '/cpp/lib' |
| 206 | } |
| 207 | |
| 208 | def javaProject = project(':arm:cpp') |
| 209 | dependsOn javaProject.jar |
| 210 | // Copy project java binary |
| 211 | from (file(javaProject.jar.archivePath)) { |
| 212 | into '/java/lib' |
| 213 | } |
| 214 | |
| 215 | // If not embedded java, include java libs |
| 216 | if (!embedJavaLibraries) { |
| 217 | from(file(javaLibraryLoc)) { |
| 218 | include '*.jar' |
| 219 | include '*.so' |
| 220 | include '*.so.debug' |
| 221 | into '/java/lib' |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | // Include java sources if set |
| 226 | if (includeJavaSources) { |
| 227 | dependsOn javaSourceJar |
| 228 | from (file(javaSourceJar.archivePath)) { |
| 229 | into '/java/lib' |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // Include java javadoc if set |
| 234 | if (includeJavaJavadoc) { |
| 235 | dependsOn javaJavadocJar |
| 236 | from (file(javaJavadocJar.archivePath)) { |
| 237 | into '/java/docs' |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | // Include cpp sources if set |
| 242 | if (includeCppSources) { |
| 243 | from(file(cppSrc)) { |
| 244 | include '**/*.cpp' |
| 245 | include '**/*.h' |
| 246 | into "/cpp/src/$libraryName" |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // Include driver sources if set |
| 251 | if (includeDriverSources) { |
| 252 | from(file(driverSrc)) { |
| 253 | include '**/*.cpp' |
| 254 | include '**/*.h' |
| 255 | into "/cpp/src/$libraryName" |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | task doc(type: Exec){ |
| 261 | doFirst{ |
| 262 | mkdir "${releaseDir}/cpp/docs" |
| 263 | } |
| 264 | commandLine 'powershell', 'doxygen ctrlib.doxy' |
| 265 | } |
| 266 | |
| 267 | |
| 268 | project(':arm:cpp').tasks.whenTaskAdded { task -> |
| 269 | def name = task.name.toLowerCase() |
| 270 | if (name.contains("sharedlibrary") || name.contains("staticlibrary")) { |
| 271 | userStaticArtifacts.dependsOn task |
| 272 | copyToEclipse.dependsOn task |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | |
| 277 | //build.dependsOn javaSourceJar |
| 278 | //build.dependsOn javaJavadocJar |
| 279 | //build.dependsOn cppSources |
| 280 | |
| 281 | build.dependsOn userStaticArtifacts |
| 282 | build.dependsOn doc |
| 283 | |
| 284 | doc.mustRunAfter userStaticArtifacts |
| 285 | |
| 286 | if (setCopyToEclipse) { |
| 287 | build.dependsOn copyToEclipse |
| 288 | } |