Skip to content

Commit 1ceceb1

Browse files
boxofroxPhyXTGears-1720
authored andcommitted
Build, deploy, and print a version file.
Provide a simple means by which to verify our robot is running the correct code by deploying a version file and printing the contents to the dashboard console when the robot is disabled. Also ignore the version file in git. We don't want builds reporting the same version across commits. STATUS: Builds. - Justin C
1 parent 03d21f8 commit 1ceceb1

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,4 @@ bin/
158158

159159

160160
# End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode
161+
src/main/deploy/version.txt

Makefile

-16
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,4 @@ build:
1010
@./gradlew build
1111

1212
deploy: build
13-
@$(make-version-file)
1413
@./gradlew deploy
15-
@$(clean-version-file)
16-
17-
define make-version-file
18-
cat > src/main/deploy/version.txt <<'EOF'
19-
========================================
20-
FRC Team 1720 - PhyXTGears
21-
22-
Software version: $(shell git describe --tags)
23-
========================================
24-
EOF
25-
endef
26-
27-
define clean-version-file
28-
@rm src/main/deploy/version.txt
29-
endef

build.gradle

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id "cpp"
33
id "google-test-test-suite"
44
id "edu.wpi.first.GradleRIO" version "2019.4.1"
5+
id "org.ajoberstar.grgit" version "2.3.0"
56
}
67

78
// Define my targets (RoboRIO) and artifacts (deployable files)
@@ -85,3 +86,18 @@ model {
8586
}
8687
}
8788
}
89+
90+
task versionFile {
91+
doFirst {
92+
new File('src/main/deploy/version.txt').text = """
93+
========================================
94+
FRC Team 1720 - PhyXTGears
95+
Robot: Space Walrus
96+
Season: 2019
97+
Software version: ${grgit.describe()}
98+
========================================
99+
"""
100+
}
101+
}
102+
103+
tasks.getByName('deploy').dependsOn(versionFile)

src/main/cpp/Robot.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ void Robot::RobotPeriodic() {
132132
}
133133

134134
void Robot::DisabledInit() {
135+
PrintVersionFile();
136+
135137
m_ClimbStep->Cancel();
136138

137139
GetCreeperClimb().Disable();
@@ -450,6 +452,14 @@ void Robot::JoystickDemoIntakeHatch() {
450452
std::cout << "hook: b(" << bottom << ") t(" << top << ")" << std::endl;
451453
}
452454

455+
void Robot::PrintVersionFile() {
456+
std::ifstream versionFile("/home/lvuser/deploy/version.txt");
457+
458+
if (versionFile.is_open()) {
459+
std::cout << versionFile.rdbuf();
460+
}
461+
}
462+
453463
#ifndef RUNNING_FRC_TESTS
454464
int main() {
455465
return frc::StartRobot<Robot>();

src/main/include/Robot.h

+3
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,7 @@ class Robot : public frc::TimedRobot {
126126
void JoystickDemoCreeperClimb();
127127
void JoystickDemoHatchCheesecake();
128128
void JoystickDemoIntakeHatch();
129+
130+
//
131+
void PrintVersionFile();
129132
};

0 commit comments

Comments
 (0)