blob: d2f11947f64c7e584da5a84da83f5e451e752249 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001import jaci.gradle.toolchains.*
2import jaci.gradle.nativedeps.*
3
4plugins {
5 id 'java'
6 id 'application'
7 id 'cpp'
8 id 'visual-studio'
9}
10
11apply plugin: 'edu.wpi.first.NativeUtils'
12apply plugin: 'jaci.gradle.EmbeddedTools'
13
14apply from: '../shared/config.gradle'
15
16ext {
17 sharedCvConfigs = [myRobotCpp: []]
18 staticCvConfigs = [myRobotCppStatic: []]
19 useJava = true
20 useCpp = true
21 skipDev = true
22}
23
24apply from: "${rootDir}/shared/opencv.gradle"
25
26deploy {
27 targets {
28 target('roborio') {
29 directory = '/home/admin'
30 maxChannels = 4
31 locations {
32 ssh {
33 address = "172.22.11.2"
34 user = 'admin'
35 password = ''
36 ipv6 = false
37 }
38 }
39 }
40 }
41 artifacts {
42 all {
43 targets << 'roborio'
44 predeploy << { ctx ->
45 ctx.execute('/usr/local/frc/bin/frcKillRobot.sh -t')
46 }
47 postdeploy << { ctx ->
48 ctx.execute("sync")
49 ctx.execute("ldconfig")
50 }
51 }
52
53 artifact('jre', JREArtifact) {
54 jreDependency = 'edu.wpi.first.jdk:roborio-2020:11.0.4u10-2'
55 }
56
57 javaArtifact('myRobotJava') {
58 jar = 'shadowJar'
59 postdeploy << { ctx ->
60 ctx.execute("echo '/usr/local/frc/JRE/bin/java -XX:+UseConcMarkSweepGC -Djava.library.path=/usr/local/frc/third-party/lib -Djava.lang.invoke.stringConcat=BC_SB -jar /home/admin/myRobot-all.jar' > /home/admin/myRobotJavaRun")
61 ctx.execute("chmod +x /home/admin/myRobotJavaRun; chown lvuser /home/admin/myRobotJavaRun")
62 }
63 }
64
65 nativeArtifact('myRobotCpp') {
66 component = 'myRobotCpp'
67 targetPlatform = nativeUtils.wpi.platforms.roborio
68 libraryDirectory = '/usr/local/frc/third-party/lib'
69 buildType = 'debug'
70 postdeploy << { ctx ->
71 ctx.execute('chmod +x myRobotCpp')
72 }
73
74 }
75
76 nativeArtifact('myRobotCppStatic') {
77 component = 'myRobotCppStatic'
78 targetPlatform = nativeUtils.wpi.platforms.roborio
79 buildType = 'debug'
80
81 postdeploy << { ctx ->
82 ctx.execute('chmod +x myRobotCppStatic')
83 }
84 }
85 }
86}
87
88tasks.register('deployJava') {
89 try {
90 dependsOn tasks.named('deployJreRoborio')
91 dependsOn tasks.named('deployMyRobotJavaRoborio')
92 dependsOn tasks.named('deployMyRobotCppLibrariesRoborio')
93 } catch (ignored) {
94 }
95}
96
97tasks.register('deployShared') {
98 try {
99 dependsOn tasks.named('deployMyRobotCppLibrariesRoborio')
100 dependsOn tasks.named('deployMyRobotCppRoborio')
101 } catch (ignored) {
102 }
103}
104
105tasks.register('deployStatic') {
106 try {
107 dependsOn tasks.named('deployMyRobotCppStaticRoborio')
108 } catch (ignored) {
109 }
110}
111
112mainClassName = 'Main'
113
114apply plugin: 'com.github.johnrengelman.shadow'
115
116repositories {
117 mavenCentral()
118}
119
120dependencies {
121 implementation project(':wpilibj')
122 implementation project(':hal')
123 implementation project(':wpiutil')
124 implementation project(':ntcore')
125 implementation project(':cscore')
126 implementation project(':cameraserver')
127 implementation project(':wpilibOldCommands')
128 implementation project(':wpilibNewCommands')
129}
130
131model {
132 components {
133 myRobotCpp(NativeExecutableSpec) {
134 targetBuildTypes 'debug'
135 sources {
136 cpp {
137 source {
138 srcDirs = ['src/main/native/cpp']
139 includes = ['**/*.cpp']
140 }
141 exportedHeaders {
142 srcDirs = ['src/main/native/include']
143 includes = ['**/*.h']
144 }
145 }
146 }
147 binaries.all { binary ->
148 lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared'
149 lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
150 lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
151 lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
152 lib project: ':cscore', library: 'cscore', linkage: 'shared'
153 lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared'
154 lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
155 project(':hal').addHalDependency(binary, 'shared')
156 project(':hal').addHalJniDependency(binary)
157 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
158 lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
159 if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
160 nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
161 }
162 }
163 }
164 myRobotCppStatic(NativeExecutableSpec) {
165 targetBuildTypes 'debug'
166 nativeUtils.excludeBinariesFromStrip(it)
167 sources {
168 cpp {
169 source {
170 srcDirs = ['src/main/native/cpp']
171 includes = ['**/*.cpp']
172 }
173 exportedHeaders {
174 srcDirs = ['src/main/native/include']
175 includes = ['**/*.h']
176 }
177 }
178 }
179 binaries.all { binary ->
180 lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'static'
181 lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'static'
182 lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
183 lib project: ':ntcore', library: 'ntcore', linkage: 'static'
184 lib project: ':cscore', library: 'cscore', linkage: 'static'
185 project(':hal').addHalDependency(binary, 'static')
186 lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
187 lib project: ':cameraserver', library: 'cameraserver', linkage: 'static'
188 if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
189 nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
190 }
191 }
192 }
193 }
194 tasks {
195 def c = $.components
196 project.tasks.create('runCpp', Exec) {
197 group = 'WPILib'
198 description = "Run the myRobotCpp executable"
199 def found = false
200 def systemArch = getCurrentArch()
201 c.each {
202 if (it in NativeExecutableSpec && it.name == "myRobotCpp") {
203 it.binaries.each {
204 if (!found) {
205 def arch = it.targetPlatform.name
206 if (arch == systemArch) {
207 dependsOn it.tasks.install
208 commandLine it.tasks.install.runScriptFile.get().asFile.toString()
209 def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
210 run.dependsOn it.tasks.install
211 run.systemProperty 'java.library.path', filePath
212 run.environment 'LD_LIBRARY_PATH', filePath
213 run.workingDir filePath
214
215 found = true
216 }
217 }
218 }
219 }
220 }
221 }
222 installAthena(Task) {
223 $.binaries.each {
224 if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCpp') {
225 dependsOn it.tasks.install
226 }
227 }
228 }
229 installAthenaStatic(Task) {
230 $.binaries.each {
231 if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCppStatic') {
232 dependsOn it.tasks.install
233 }
234 }
235 }
236 }
237}