blob: 2b97416e5417a49a752a673660c4108690c51c05 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001apply plugin: 'cpp'
2apply plugin: 'google-test-test-suite'
3apply plugin: 'visual-studio'
4apply plugin: 'edu.wpi.first.NativeUtils'
5apply plugin: SingleNativeBuild
6apply plugin: ExtraTasks
7
8
9ext {
10 nativeName = 'lowfi_sim'
11}
12
13apply from: "${rootDir}/shared/config.gradle"
14
15if (!project.hasProperty('onlyAthena')) {
16
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
43 model {
44 exportsConfigs {
45 lowfi_sim(ExportsConfig) {
46 x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
47 '_CT??_R0?AVbad_cast',
48 '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
49 '_TI5?AVfailure']
50 x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
51 '_CT??_R0?AVbad_cast',
52 '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
53 '_TI5?AVfailure']
54 }
55 }
56 components {
57 "${nativeName}Base"(NativeLibrarySpec) {
58 sources {
59 cpp {
60 source {
61 srcDirs = ['src/main/native/cpp']
62 include '**/*.cpp'
63 }
64 exportedHeaders {
65 srcDirs 'src/main/native/include'
66 }
67 }
68 }
69 binaries.all {
70 if (it instanceof SharedLibraryBinarySpec) {
71 it.buildable = false
72 return
73 }
74 if (it.targetPlatform.architecture.name == 'athena') {
75 it.buildable = false
76 return
77 }
78 project(':hal').addHalDependency(it, 'shared')
79 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
80 lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared'
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 {
96 if (it.targetPlatform.architecture.name == 'athena') {
97 it.buildable = false
98 return
99 }
100 project(':hal').addHalDependency(it, 'shared')
101 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
102 lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared'
103 }
104 }
105 // By default, a development executable will be generated. This is to help the case of
106 // testing specific functionality of the library.
107 "${nativeName}Dev"(NativeExecutableSpec) {
108 targetBuildTypes 'debug'
109 sources {
110 cpp {
111 source {
112 srcDirs 'src/dev/native/cpp'
113 include '**/*.cpp'
114 lib library: "${nativeName}"
115 }
116 exportedHeaders {
117 srcDirs 'src/dev/native/include'
118 }
119 }
120 }
121 binaries.all {
122 if (it.targetPlatform.architecture.name == 'athena') {
123 it.buildable = false
124 return
125 }
126 project(':hal').addHalDependency(it, 'shared')
127 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
128 lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared'
129 lib library: nativeName, linkage: 'shared'
130 }
131 }
132 }
133 binaries {
134 withType(GoogleTestTestSuiteBinarySpec) {
135 lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
136 lib project: ':cscore', library: 'cscore', linkage: 'shared'
137 project(':hal').addHalDependency(it, 'shared')
138 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
139 lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
140 lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
141 lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared'
142 lib library: nativeName, linkage: 'shared'
143 }
144 }
145 }
146
147 apply from: "publish.gradle"
148}
149
150model {
151
152 testSuites {
153 if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) {
154 "${nativeName}Test"(GoogleTestTestSuiteSpec) {
155 for(NativeComponentSpec c : $.components) {
156 if (c.name == nativeName) {
157 testing c
158 break
159 }
160 }
161 sources {
162 cpp {
163 source {
164 srcDirs 'src/test/native/cpp'
165 include '**/*.cpp'
166 }
167 exportedHeaders {
168 srcDirs 'src/test/native/include', 'src/main/native/cpp'
169 }
170 }
171 }
172 }
173 }
174 }
175 tasks {
176 def c = $.components
177 project.tasks.create('runCpp', Exec) {
178 def found = false
179 c.each {
180 if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") {
181 it.binaries.each {
182 if (!found) {
183 def arch = it.targetPlatform.architecture.name
184 if (arch == 'x86-64' || arch == 'x86') {
185 dependsOn it.tasks.install
186 commandLine it.tasks.install.runScriptFile.get().asFile.toString()
187
188 found = true
189 }
190 }
191 }
192 }
193 }
194 }
195 }
196}
197
198tasks.withType(RunTestExecutable) {
199 args "--gtest_output=xml:test_detail.xml"
200 outputs.dir outputDir
201}