blob: e6e81430bcb98b8a58324dba24db7f98e8fff46d [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -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('onlylinuxathena')) {
16 ext.skiplinuxathena = true
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 nativeUtils.exportsConfigs {
34 lowfi_sim {
35 x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
36 '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
37 '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range',
38 '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast']
39 x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
40 '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
41 '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range',
42 '_TI3?AVout_of_range', '_CT??_R0?AVbad_cast']
43 }
44 }
45
46 model {
47 components {
48 "${nativeName}Base"(NativeLibrarySpec) {
49 sources {
50 cpp {
51 source {
52 srcDirs = ['src/main/native/cpp']
53 include '**/*.cpp'
54 }
55 exportedHeaders {
56 srcDirs 'src/main/native/include'
57 }
58 }
59 }
60 binaries.all {
61 if (it instanceof SharedLibraryBinarySpec) {
62 it.buildable = false
63 return
64 }
65 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
66 it.buildable = false
67 return
68 }
69 project(':hal').addHalDependency(it, 'shared')
70 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
71 }
72 }
73 "${nativeName}"(NativeLibrarySpec) {
74 sources {
75 cpp {
76 source {
77 srcDirs "${rootDir}/shared/singlelib"
78 include '**/*.cpp'
79 }
80 exportedHeaders {
81 srcDirs 'src/main/native/include'
82 }
83 }
84 }
85 binaries.all {
86 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
87 it.buildable = false
88 return
89 }
90 project(':hal').addHalDependency(it, 'shared')
91 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
92 }
93 }
94 // By default, a development executable will be generated. This is to help the case of
95 // testing specific functionality of the library.
96 "${nativeName}Dev"(NativeExecutableSpec) {
97 targetBuildTypes 'debug'
98 sources {
99 cpp {
100 source {
101 srcDirs 'src/dev/native/cpp'
102 include '**/*.cpp'
103 lib library: "${nativeName}"
104 }
105 exportedHeaders {
106 srcDirs 'src/dev/native/include'
107 }
108 }
109 }
110 binaries.all {
111 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
112 it.buildable = false
113 return
114 }
115 project(':hal').addHalDependency(it, 'shared')
116 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
117 lib library: nativeName, linkage: 'shared'
118 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
119 nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
120 }
121 }
122 }
123 }
124 binaries {
125 withType(GoogleTestTestSuiteBinarySpec) {
126 lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
127 lib project: ':cscore', library: 'cscore', linkage: 'shared'
128 project(':hal').addHalDependency(it, 'shared')
129 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
130 lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
131 lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
132 lib library: nativeName, linkage: 'shared'
133 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
134 nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
135 }
136 }
137 }
138 }
139
140 apply from: "publish.gradle"
141}
142
143model {
144
145 testSuites {
146 if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
147 "${nativeName}Test"(GoogleTestTestSuiteSpec) {
148 for(NativeComponentSpec c : $.components) {
149 if (c.name == nativeName) {
150 testing c
151 break
152 }
153 }
154 sources {
155 cpp {
156 source {
157 srcDirs 'src/test/native/cpp'
158 include '**/*.cpp'
159 }
160 exportedHeaders {
161 srcDirs 'src/test/native/include', 'src/main/native/cpp'
162 }
163 }
164 }
165 }
166 }
167 }
168 tasks {
169 def c = $.components
170 project.tasks.create('runCpp', Exec) {
171 def found = false
172 c.each {
173 if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") {
174 it.binaries.each {
175 if (!found) {
176 def arch = it.targetPlatform.architecture.name
177 if (arch == 'x86-64' || arch == 'x86') {
178 dependsOn it.tasks.install
179 commandLine it.tasks.install.runScriptFile.get().asFile.toString()
180
181 found = true
182 }
183 }
184 }
185 }
186 }
187 }
188 }
189}
190
191tasks.withType(RunTestExecutable) {
192 args "--gtest_output=xml:test_detail.xml"
193 outputs.dir outputDir
194}