Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 1 | apply plugin: 'cpp' |
| 2 | apply plugin: 'google-test-test-suite' |
| 3 | apply plugin: 'visual-studio' |
| 4 | apply plugin: 'edu.wpi.first.NativeUtils' |
| 5 | apply plugin: SingleNativeBuild |
| 6 | apply plugin: ExtraTasks |
| 7 | |
| 8 | |
| 9 | ext { |
| 10 | nativeName = 'lowfi_sim' |
| 11 | } |
| 12 | |
| 13 | apply from: "${rootDir}/shared/config.gradle" |
| 14 | |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 15 | if (!project.hasProperty('onlylinuxathena')) { |
| 16 | ext.skiplinuxathena = true |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 17 | ext { |
| 18 | sharedCvConfigs = [lowfi_simTest: []] |
| 19 | staticCvConfigs = [:] |
| 20 | useJava = false |
| 21 | useCpp = true |
| 22 | } |
| 23 | apply from: "${rootDir}/shared/opencv.gradle" |
| 24 | |
| 25 | ext { |
| 26 | staticGtestConfigs = [:] |
| 27 | } |
| 28 | staticGtestConfigs["${nativeName}Test"] = [] |
| 29 | apply from: "${rootDir}/shared/googletest.gradle" |
| 30 | |
| 31 | project(':').libraryBuild.dependsOn build |
| 32 | |
| 33 | ext { |
| 34 | chipObjectComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(), |
| 35 | "${nativeName}Test".toString()] |
| 36 | netCommComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(), |
| 37 | "${nativeName}Test".toString()] |
| 38 | useNiJava = false |
| 39 | } |
| 40 | |
| 41 | apply from: "${rootDir}/shared/nilibraries.gradle" |
| 42 | |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 43 | nativeUtils.exportsConfigs { |
| 44 | lowfi_sim { |
| 45 | x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', |
| 46 | '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', |
| 47 | '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', |
| 48 | '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] |
| 49 | x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', |
| 50 | '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', |
| 51 | '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', |
| 52 | '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast'] |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 53 | } |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 54 | } |
| 55 | |
| 56 | model { |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 57 | components { |
| 58 | "${nativeName}Base"(NativeLibrarySpec) { |
| 59 | sources { |
| 60 | cpp { |
| 61 | source { |
| 62 | srcDirs = ['src/main/native/cpp'] |
| 63 | include '**/*.cpp' |
| 64 | } |
| 65 | exportedHeaders { |
| 66 | srcDirs 'src/main/native/include' |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | binaries.all { |
| 71 | if (it instanceof SharedLibraryBinarySpec) { |
| 72 | it.buildable = false |
| 73 | return |
| 74 | } |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 75 | if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 76 | it.buildable = false |
| 77 | return |
| 78 | } |
| 79 | project(':hal').addHalDependency(it, 'shared') |
| 80 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | "${nativeName}"(NativeLibrarySpec) { |
| 84 | sources { |
| 85 | cpp { |
| 86 | source { |
| 87 | srcDirs "${rootDir}/shared/singlelib" |
| 88 | include '**/*.cpp' |
| 89 | } |
| 90 | exportedHeaders { |
| 91 | srcDirs 'src/main/native/include' |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | binaries.all { |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 96 | if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 97 | it.buildable = false |
| 98 | return |
| 99 | } |
| 100 | project(':hal').addHalDependency(it, 'shared') |
| 101 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | // By default, a development executable will be generated. This is to help the case of |
| 105 | // testing specific functionality of the library. |
| 106 | "${nativeName}Dev"(NativeExecutableSpec) { |
| 107 | targetBuildTypes 'debug' |
| 108 | sources { |
| 109 | cpp { |
| 110 | source { |
| 111 | srcDirs 'src/dev/native/cpp' |
| 112 | include '**/*.cpp' |
| 113 | lib library: "${nativeName}" |
| 114 | } |
| 115 | exportedHeaders { |
| 116 | srcDirs 'src/dev/native/include' |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | binaries.all { |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 121 | if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 122 | it.buildable = false |
| 123 | return |
| 124 | } |
| 125 | project(':hal').addHalDependency(it, 'shared') |
| 126 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 127 | lib library: nativeName, linkage: 'shared' |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | binaries { |
| 132 | withType(GoogleTestTestSuiteBinarySpec) { |
| 133 | lib project: ':ntcore', library: 'ntcore', linkage: 'shared' |
| 134 | lib project: ':cscore', library: 'cscore', linkage: 'shared' |
| 135 | project(':hal').addHalDependency(it, 'shared') |
| 136 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
| 137 | lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' |
| 138 | lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared' |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 139 | lib library: nativeName, linkage: 'shared' |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | apply from: "publish.gradle" |
| 145 | } |
| 146 | |
| 147 | model { |
| 148 | |
| 149 | testSuites { |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 150 | if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) { |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 151 | "${nativeName}Test"(GoogleTestTestSuiteSpec) { |
| 152 | for(NativeComponentSpec c : $.components) { |
| 153 | if (c.name == nativeName) { |
| 154 | testing c |
| 155 | break |
| 156 | } |
| 157 | } |
| 158 | sources { |
| 159 | cpp { |
| 160 | source { |
| 161 | srcDirs 'src/test/native/cpp' |
| 162 | include '**/*.cpp' |
| 163 | } |
| 164 | exportedHeaders { |
| 165 | srcDirs 'src/test/native/include', 'src/main/native/cpp' |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | tasks { |
| 173 | def c = $.components |
| 174 | project.tasks.create('runCpp', Exec) { |
| 175 | def found = false |
| 176 | c.each { |
| 177 | if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") { |
| 178 | it.binaries.each { |
| 179 | if (!found) { |
| 180 | def arch = it.targetPlatform.architecture.name |
| 181 | if (arch == 'x86-64' || arch == 'x86') { |
| 182 | dependsOn it.tasks.install |
| 183 | commandLine it.tasks.install.runScriptFile.get().asFile.toString() |
| 184 | |
| 185 | found = true |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | tasks.withType(RunTestExecutable) { |
| 196 | args "--gtest_output=xml:test_detail.xml" |
| 197 | outputs.dir outputDir |
| 198 | } |