This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
218 lines (187 loc) · 7.7 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2021.3.1"
}
import jaci.gradle.nativedeps.*
def roboRIODeployDir = '"' + '/home/lvuser/deploy/' + '"'
def ntRemoteServer = '"' + '187.162.43.150' + '"'
def ntRemotePort = '1735'
// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project EmbeddedTools.
deploy {
targets {
roboRIO("roborio") {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = frc.getTeamOrDefault(4635)
}
}
artifacts {
frcNativeArtifact('frcCpp') {
targets << "roborio"
component = 'frcUserProgram'
// Debug can be overridden by command line, for use with VSCode
debug = frc.getDebugOrDefault(false)
}
// Built in artifact to deploy arbitrary files to the roboRIO.
fileTreeArtifact('frcStaticFileDeploy') {
// The directory below is the local directory to deploy
files = fileTree(dir: 'src/main/deploy')
// Deploy to RoboRIO target, into /home/lvuser/deploy
targets << "roborio"
directory = roboRIODeployDir
}
}
}
// set this to true to include the src folder in the include directories passed
// to the compiler. Some eclipse project imports depend on this behavior.
// We recommend leaving this disabled if possible. Note for eclipse project
// imports this is enabled by default. For new projects, its disabled
def includeSrcInIncludeRoot = false
// set this to true to enable desktop support.
// ""./gradlew clion" only generates a valid CMakeLists.txt file if this is set to false, set to false to generate and return to true afterwards
def includeDesktopSupport = false
// Enable simulation gui support. Must check the box in vscode to enable support
// upon debugging
dependencies {
simulation wpi.deps.sim.gui(wpi.platforms.desktop, true)
simulation wpi.deps.sim.driverstation(wpi.platforms.desktop, true)
// Websocket extensions require additional configuration.
// simulation wpi.deps.sim.ws_server(wpi.platforms.desktop, true)
// simulation wpi.deps.sim.ws_client(wpi.platforms.desktop, true)
}
// Simulation configuration (e.g. environment variables).
sim {
// Sets the websocket client remote host.
// envVar "HALSIMWS_HOST", "10.0.0.2"
}
model {
components {
sysidlib(NativeLibrarySpec) {
targetPlatform wpi.platforms.roborio
if (includeDesktopSupport) {
targetPlatform wpi.platforms.desktop
}
sources.cpp {
source {
srcDir "libs/sysid/sysid-library/src/main/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDir "libs/sysid/sysid-library/src/main/include"
include '**/*.h'
}
}
wpi.deps.vendor.cpp(it)
wpi.deps.wpilib(it)
}
fmt(NativeLibrarySpec) {
targetPlatform wpi.platforms.roborio
if (includeDesktopSupport) {
targetPlatform wpi.platforms.desktop
}
sources.cpp {
source {
srcDir "libs/fmt/src"
include '**/*.cc'
}
exportedHeaders {
srcDir "libs/fmt/include"
include '**/*.h'
}
}
}
spdlog(NativeLibrarySpec) {
targetPlatform wpi.platforms.roborio
if (includeDesktopSupport) {
targetPlatform wpi.platforms.desktop
}
binaries.all {
cppCompiler.define "SPDLOG_FMT_EXTERNAL"
cppCompiler.define "SPDLOG_COMPILED_LIB"
lib library: 'fmt', linkage: 'shared'
}
sources.cpp {
source {
srcDir "libs/spdlog/src"
include '**/*.cpp'
}
exportedHeaders {
srcDir "libs/spdlog/include"
}
}
}
frcUserProgram(NativeExecutableSpec) {
targetPlatform wpi.platforms.roborio
if (includeDesktopSupport) {
targetPlatform wpi.platforms.desktop
}
binaries.all {
if (buildType.name == 'release') it.buildable = false
cppCompiler.define "SPDLOG_FMT_EXTERNAL"
def target = targetPlatform.name == wpi.platforms.roborio ? 'Robot' : 'Simulation'
if (target == 'Simulation') {
cppCompiler.define('SIMULATION')
def projectDir = '"' + project.projectDir.toString() + "/deploy/" + '"'
cppCompiler.define('DEPLOY_DIR', projectDir)
cppCompiler.define('NT_REMOTE_SERVER', ntRemoteServer)
cppCompiler.define('NT_REMOTE_PORT', ntRemotePort)
}else{
cppCompiler.define('DEPLOY_DIR', roboRIODeployDir)
}
def libraryLink = 'shared'
lib library: 'fmt', linkage: libraryLink
lib library: 'spdlog', linkage: libraryLink
lib library: 'sysidlib', linkage: libraryLink
}
sources.cpp {
source {
srcDir 'src/'
include '*.cpp', '**/*.cpp'
}
exportedHeaders {
srcDir 'src/'
srcDir 'libs/mINI/src'
}
}
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
wpi.deps.vendor.cpp(it)
wpi.deps.wpilib(it)
}
}
testSuites {
frcUserProgramTest(GoogleTestTestSuiteSpec) {
testing $.components.frcUserProgram
binaries.all {
def target = targetPlatform.name == wpi.platforms.roborio ? 'Robot' : 'Simulation'
if (target == 'Simulation') {
cppCompiler.define('SIMULATION')
def projectDir = '"' + project.projectDir.toString() + "/deploy/" + '"'
cppCompiler.define('DEPLOY_DIR', projectDir)
cppCompiler.define('NT_REMOTE_SERVER', ntRemoteServer)
cppCompiler.define('NT_REMOTE_PORT', ntRemotePort)
}else{
cppCompiler.define('DEPLOY_DIR', roboRIODeployDir)
}
if (buildType.name == 'release') it.buildable = false
cppCompiler.define "SPDLOG_FMT_EXTERNAL"
def libraryLink = 'shared'
lib library: 'fmt', linkage: libraryLink
lib library: 'spdlog', linkage: libraryLink
lib library: 'sysidlib', linkage: libraryLink
}
sources.cpp {
source {
srcDir 'tests/'
include '*.cpp','**/*.cpp'
}
}
wpi.deps.vendor.cpp(it)
wpi.deps.wpilib(it)
wpi.deps.googleTest(it)
}
}
}