Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | apply from: "${rootDir}/shared/resources.gradle" |
| 2 | |
| 3 | ext { |
| 4 | noWpiutil = true |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 5 | skipJniCheck = true |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 6 | baseId = 'wpiutil' |
| 7 | groupId = 'edu.wpi.first.wpiutil' |
| 8 | |
| 9 | nativeName = 'wpiutil' |
| 10 | devMain = 'edu.wpi.first.wpiutil.DevMain' |
| 11 | def generateTask = createGenerateResourcesTask('main', 'WPI', 'wpi', project) |
| 12 | |
| 13 | splitSetup = { |
| 14 | it.tasks.withType(CppCompile) { |
| 15 | dependsOn generateTask |
| 16 | } |
| 17 | it.sources { |
| 18 | libuvCpp(CppSourceSet) { |
| 19 | source { |
| 20 | srcDirs 'src/main/native/libuv/src' |
| 21 | include '*.cpp' |
| 22 | } |
| 23 | exportedHeaders { |
| 24 | srcDirs 'src/main/native/include', 'src/main/native/libuv/include', 'src/main/native/libuv/src' |
| 25 | } |
| 26 | } |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 27 | fmtlibCpp(CppSourceSet) { |
| 28 | source { |
| 29 | srcDirs 'src/main/native/fmtlib/src' |
| 30 | include '*.cpp' |
| 31 | } |
| 32 | exportedHeaders { |
| 33 | srcDirs 'src/main/native/fmtlib/include' |
| 34 | } |
| 35 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 36 | resourcesCpp(CppSourceSet) { |
| 37 | source { |
| 38 | srcDirs "$buildDir/generated/main/cpp", "$rootDir/shared/singlelib" |
| 39 | include '*.cpp' |
| 40 | } |
| 41 | exportedHeaders { |
| 42 | srcDirs 'src/main/native/include' |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | if (!it.targetPlatform.operatingSystem.isWindows()) { |
| 47 | it.cppCompiler.define '_GNU_SOURCE' |
| 48 | it.sources { |
| 49 | libuvUnixCpp(CppSourceSet) { |
| 50 | source { |
| 51 | srcDirs 'src/main/native/libuv/src/unix' |
| 52 | includes = [ |
| 53 | 'async.cpp', |
| 54 | 'core.cpp', |
| 55 | 'dl.cpp', |
| 56 | 'fs.cpp', |
| 57 | 'getaddrinfo.cpp', |
| 58 | 'getnameinfo.cpp', |
| 59 | 'loop-watcher.cpp', |
| 60 | 'loop.cpp', |
| 61 | 'pipe.cpp', |
| 62 | 'poll.cpp', |
| 63 | 'process.cpp', |
| 64 | 'signal.cpp', |
| 65 | 'stream.cpp', |
| 66 | 'tcp.cpp', |
| 67 | 'thread.cpp', |
| 68 | 'timer.cpp', |
| 69 | 'tty.cpp', |
| 70 | 'udp.cpp', |
| 71 | ] |
| 72 | } |
| 73 | exportedHeaders { |
| 74 | srcDirs 'src/main/native/include', 'src/main/native/libuv/include', 'src/main/native/libuv/src' |
| 75 | } |
| 76 | } |
| 77 | wpiutilUnixCpp(CppSourceSet) { |
| 78 | source { |
| 79 | srcDirs 'src/main/native/unix' |
| 80 | include '**/*.cpp' |
| 81 | } |
| 82 | exportedHeaders { |
| 83 | srcDirs 'src/main/native/include', 'src/main/native/cpp' |
| 84 | include '**/*.h' |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | if (it.targetPlatform.operatingSystem.isWindows()) { |
| 90 | if (it in SharedLibraryBinarySpec) { |
| 91 | it.cppCompiler.define 'BUILDING_UV_SHARED' |
| 92 | } |
| 93 | it.sources { |
| 94 | libuvWindowsCpp(CppSourceSet) { |
| 95 | source { |
| 96 | srcDirs 'src/main/native/libuv/src/win' |
| 97 | include '*.cpp' |
| 98 | } |
| 99 | exportedHeaders { |
| 100 | srcDirs 'src/main/native/include', 'src/main/native/libuv/include', 'src/main/native/libuv/src' |
| 101 | } |
| 102 | } |
| 103 | wpiutilWindowsCpp(CppSourceSet) { |
| 104 | source { |
| 105 | srcDirs 'src/main/native/windows' |
| 106 | include '**/*.cpp' |
| 107 | } |
| 108 | exportedHeaders { |
| 109 | srcDirs 'src/main/native/include', 'src/main/native/cpp' |
| 110 | include '**/*.h' |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } else if (it.targetPlatform.operatingSystem.isMacOsX()) { |
| 115 | it.sources { |
| 116 | libuvMacCpp(CppSourceSet) { |
| 117 | source { |
| 118 | srcDirs 'src/main/native/libuv/src/unix' |
| 119 | includes = [ |
| 120 | 'bsd-ifaddrs.cpp', |
| 121 | 'darwin.cpp', |
| 122 | 'darwin-proctitle.cpp', |
| 123 | 'fsevents.cpp', |
| 124 | 'kqueue.cpp', |
| 125 | 'proctitle.cpp' |
| 126 | ] |
| 127 | } |
| 128 | exportedHeaders { |
| 129 | srcDirs 'src/main/native/include', 'src/main/native/libuv/include', 'src/main/native/libuv/src' |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } else { |
| 134 | it.sources { |
| 135 | libuvLinuxCpp(CppSourceSet) { |
| 136 | source { |
| 137 | srcDirs 'src/main/native/libuv/src/unix' |
| 138 | includes = [ |
| 139 | 'linux-core.cpp', |
| 140 | 'linux-inotify.cpp', |
| 141 | 'linux-syscalls.cpp', |
| 142 | 'procfs-exepath.cpp', |
| 143 | 'proctitle.cpp', |
| 144 | 'sysinfo-loadavg.cpp', |
| 145 | ] |
| 146 | } |
| 147 | exportedHeaders { |
| 148 | srcDirs 'src/main/native/include', 'src/main/native/libuv/include', 'src/main/native/libuv/src' |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | def examplesMap = [:]; |
| 157 | file("$projectDir/examples").list(new FilenameFilter() { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 158 | @Override |
| 159 | public boolean accept(File current, String name) { |
| 160 | return new File(current, name).isDirectory(); |
| 161 | } |
| 162 | }).each { |
| 163 | examplesMap.put(it, []) |
| 164 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 165 | |
| 166 | apply from: "${rootDir}/shared/jni/setupBuild.gradle" |
| 167 | |
| 168 | nativeUtils.exportsConfigs { |
| 169 | wpiutil { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 170 | x86ExcludeSymbols = [ |
| 171 | '_CT??_R0?AV_System_error', |
| 172 | '_CT??_R0?AVexception', |
| 173 | '_CT??_R0?AVfailure', |
| 174 | '_CT??_R0?AVruntime_error', |
| 175 | '_CT??_R0?AVsystem_error', |
| 176 | '_CTA5?AVfailure', |
| 177 | '_TI5?AVfailure', |
| 178 | '_CT??_R0?AVout_of_range', |
| 179 | '_CTA3?AVout_of_range', |
| 180 | '_TI3?AVout_of_range', |
| 181 | '_CT??_R0?AVbad_cast' |
| 182 | ] |
| 183 | x64ExcludeSymbols = [ |
| 184 | '_CT??_R0?AV_System_error', |
| 185 | '_CT??_R0?AVexception', |
| 186 | '_CT??_R0?AVfailure', |
| 187 | '_CT??_R0?AVruntime_error', |
| 188 | '_CT??_R0?AVsystem_error', |
| 189 | '_CTA5?AVfailure', |
| 190 | '_TI5?AVfailure', |
| 191 | '_CT??_R0?AVout_of_range', |
| 192 | '_CTA3?AVout_of_range', |
| 193 | '_TI3?AVout_of_range', |
| 194 | '_CT??_R0?AVbad_cast' |
| 195 | ] |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
| 199 | cppHeadersZip { |
| 200 | from('src/main/native/libuv/include') { |
| 201 | into '/' |
| 202 | } |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 203 | from('src/main/native/fmtlib/include') { |
| 204 | into '/' |
| 205 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | model { |
| 209 | components { |
| 210 | all { |
| 211 | it.sources.each { |
| 212 | it.exportedHeaders { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 213 | srcDirs 'src/main/native/include', 'src/main/native/libuv/include', 'src/main/native/libuv/src', 'src/main/native/fmtlib/include' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | model { |
| 221 | components { |
| 222 | examplesMap.each { key, value -> |
| 223 | "${key}"(NativeExecutableSpec) { |
| 224 | targetBuildTypes 'debug' |
| 225 | binaries.all { |
| 226 | lib library: 'wpiutil', linkage: 'shared' |
| 227 | } |
| 228 | sources { |
| 229 | cpp { |
| 230 | source { |
| 231 | srcDirs 'examples/' + "${key}" |
| 232 | include '**/*.cpp' |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | netconsoleServer(NativeExecutableSpec) { |
| 239 | targetBuildTypes 'release' |
| 240 | sources { |
| 241 | cpp { |
| 242 | source { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 243 | srcDirs = [ |
| 244 | 'src/netconsoleServer/native/cpp' |
| 245 | ] |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 246 | includes = ['**/*.cpp'] |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | binaries.all { binary -> |
| 251 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'static' |
| 252 | if (binary.targetPlatform.operatingSystem.isLinux()) { |
| 253 | linker.args "-lutil" |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | netconsoleTee(NativeExecutableSpec) { |
| 258 | targetBuildTypes 'release' |
| 259 | sources { |
| 260 | cpp { |
| 261 | source { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 262 | srcDirs = [ |
| 263 | 'src/netconsoleTee/native/cpp' |
| 264 | ] |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 265 | includes = ['**/*.cpp'] |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | binaries.all { binary -> |
| 270 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'static' |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | dependencies { |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 277 | api "com.fasterxml.jackson.core:jackson-annotations:2.10.0" |
| 278 | api "com.fasterxml.jackson.core:jackson-core:2.10.0" |
| 279 | api "com.fasterxml.jackson.core:jackson-databind:2.10.0" |
| 280 | } |