-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.gradle
More file actions
114 lines (99 loc) · 3.9 KB
/
Copy pathbuild.gradle
File metadata and controls
114 lines (99 loc) · 3.9 KB
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
apply plugin: 'cpp'
apply plugin: 'google-test-test-suite'
apply plugin: 'edu.wpi.first.GradleRIO'
apply plugin: TinkerboardPlugin
toolchainsPlugin.withRaspbian()
deploy {
targets {
target('coprocessor') {
directory = '/home/vision'
locations {
// Change this if you've changed the target hostname, username or password.
ssh {
address = 'curtinvision.local'
// address = '192.168.0.100'
user = 'vision'
password = 'curtinfrc'
}
}
// For VSCode Debugging - we won't be able to deploy to every target!
if (project.hasProperty("debugMode"))
failOnMissing = false
}
}
artifacts {
nativeArtifact('vision') {
targetPlatform = project.hasProperty('raspberry') ? wpi.platforms.raspbian : TinkerboardPlugin.tinkerboardPlatform
targets << 'coprocessor'
component = 'curtinFrcVision'
buildType = 'debug'
predeploy << { execute('sudo systemctl stop vision || true') }
// Make sure we can run our program!
postdeploy << { execute('chmod +x curtinFrcVision'); execute('sudo systemctl restart vision || true') }
}
// Some extra stuff for our vision program. Includes system configs, also!
fileTreeArtifact('visionResources') {
targets << 'coprocessor'
files = fileTree(dir: 'src/main/resources')
// Install the systemd service. This makes our vision run on startup!
postdeploy << {
// Install a symlink for the service so the system can run it! A symlink is like a pointer for files
execute('sudo ln -sf $(pwd)/system/vision.service /etc/systemd/system')
if (project.hasProperty('stop')) {
execute('sudo systemctl daemon-reload; sudo service vision stop; sudo service vision status')
} else {
// Reload the system services and start our vision service. Also print out the status :)
execute('sudo systemctl daemon-reload; sudo service vision restart; sudo service vision status')
}
}
// Configure the SSH server. Also backs up the ssh config
postdeploy << {
// Back up the stock sshd config, just in case!
execute('sudo cp -n /etc/ssh/sshd_config /etc/ssh/sshd_config.old')
// Replace the stock sshd config with ours (to allow X forwarding)
execute('sudo cp $(pwd)/system/sshd_config /etc/ssh/sshd_config')
}
}
// 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') }
}
}
}
model {
components {
curtinFrcVision(NativeExecutableSpec) {
targetPlatform wpi.platforms.desktop
targetPlatform wpi.platforms.raspbian
targetPlatform TinkerboardPlugin.tinkerboardPlatform
sources.cpp {
source {
srcDir 'src/main/cpp'
}
exportedHeaders {
srcDir 'src/main/include'
}
}
binaries.all {
if (targetPlatform.name == wpi.platforms.desktop) {
cppCompiler.define '__DESKTOP__'
if (targetPlatform.operatingSystem.isLinux()) {
linker.args << '-lusb-1.0'
}
} else if (targetPlatform.name == TinkerboardPlugin.tinkerboardPlatform) {
linker.args << '-pthread'
}
}
useLibrary(it, 'opencv', 'cameraserver', 'cscore', 'ntcore', 'wpiutil')
wpi.deps.vendor.cpp(it)
}
}
}
task runVision(dependsOn: "simulateCurtinFrcVision${wpi.platforms.desktop.capitalize()}DebugExecutable")