-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
142 lines (128 loc) · 4.77 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
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2020.2.2"
}
toolchainsPlugin.withRaspbian()
// Init and update git submodules
task submodulesUpdate(type:Exec) {
// When no internet connexion is present, git fails
ignoreExitValue true
if (org.gradle.internal.os.OperatingSystem.current().windows) {
commandLine 'cmd', '/c', 'git', 'submodule', 'foreach', 'git', 'pull', '&&', 'git', 'submodule', 'foreach', 'git', 'checkout', 'master'
}
else {
commandLine 'git', 'submodule', 'update', '--init', '--recursive', '--remote'
}
}
allprojects {
afterEvaluate {
for(def task in it.tasks)
if(task != rootProject.tasks.submodulesUpdate)
task.dependsOn rootProject.tasks.submodulesUpdate
}
}
// Define my targets (raspberry) and artifacts (deployable files)
// This is added by GradleRIO's backing project EmbeddedTools.
deploy {
targets {
target("coprocessor") {
directory = '/home/vision'
locations {
// Change this if you've changed the target hostname, username or password.
ssh {
address = 'lyonvision.local'
user = 'vision'
password = 'lyon'
}
}
}
}
artifacts {
nativeArtifact('vision') {
targetPlatform = wpi.platforms.raspbian
targets << 'coprocessor'
component = 'visionProgram'
buildType = 'release'
predeploy << { execute('sudo systemctl stop vision || true') }
// Make sure we can run our program!
postdeploy << { execute('chmod +x visionProgram'); execute('sudo systemctl restart vision || true') }
}
// Built in artifact to deploy arbitrary files to the raspberry.
fileTreeArtifact('visionData') {
// The directory below is the local directory to deploy
files = fileTree(dir: 'src/data')
// Deploy to raspberry target, into /home/vision/data
targets << 'coprocessor'
directory = '/home/vision/data'
}
// Store all the libraries in /home/vision/libraries, that way we don't poison /usr/local.
withType(jaci.gradle.deploy.artifact.BinaryLibraryArtifact) {
directory = '/home/vision/libraries'
predeploy << {
execute("sudo mkdir -p ${directory} && sudo chmod -R 777 ${directory}/..")
// Make sure the system can find our libraries!
execute("echo ${directory} | sudo tee /etc/ld.so.conf.d/vision.conf")
}
// Refresh the system's cache of known libraries, so ours can be found
postdeploy << { execute('sudo ldconfig') }
}
}
}
// Set this to true to enable desktop support.
def includeDesktopSupport = true
model {
components {
visionProgram(NativeExecutableSpec) {
targetPlatform wpi.platforms.raspbian
if (includeDesktopSupport) {
targetPlatform wpi.platforms.desktop
}
sources.cpp {
source {
srcDir 'src'
include '**/*.cpp'
exclude 'test'
}
exportedHeaders {
srcDir 'src'
include '**/*.h'
exclude 'test'
}
}
binaries.all {
if (targetPlatform.name == wpi.platforms.desktop) {
cppCompiler.define '__DESKTOP__'
if (targetPlatform.operatingSystem.isLinux()) {
linker.args << '-lusb-1.0'
}
}
}
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
wpi.deps.wpilib(it)
wpi.deps.vendor.cpp(it)
}
}
testSuites {
visionProgramTest(GoogleTestTestSuiteSpec) {
testing $.components.visionProgram
sources.cpp {
source {
srcDir 'src/test'
include '**/*.cpp'
}
}
wpi.deps.wpilib(it)
wpi.deps.googleTest(it)
wpi.deps.vendor.cpp(it)
}
}
}
// Copie du dossier Data/ dans le dossier ou se trouve le programme Windows
task copyData(type: Copy) {
from 'src/data'
into "build/install/visionProgram/${wpi.platforms.desktop}/debug/lib/data"
}
// La copie doit être executée après l'installation du programme (sinon le dossier est effacé)
copyData.mustRunAfter "installVisionProgram${wpi.platforms.desktop.capitalize()}DebugExecutable"
task runVision(dependsOn: ["simulateVisionProgram${wpi.platforms.desktop.capitalize()}DebugExecutable", "copyData"])