Update to the 2019 wpilib
Lots of gratuitious incompatibilities to deal with. Started sanifying a
few classes rather than figuring out how to update them too. Has not yet
been tested on a robot, but everything still builds so it should be
fine.
Also ported over our FPGA timestamp fixes, which were previously only in
allwpilib_2018.
Also upgraded to the new roborio compiler, which has to happen at the
same time due to incompatible pre-compiled libraries.
Change-Id: Ib9b6ad8fc0112d90a9855afe1b706588ef4ebde9
diff --git a/frc971/wpilib/ahal/Utility.cc b/frc971/wpilib/ahal/Utility.cc
index 7a00e42..f4b9f38 100644
--- a/frc971/wpilib/ahal/Utility.cc
+++ b/frc971/wpilib/ahal/Utility.cc
@@ -15,10 +15,12 @@
#include <cstring>
#include <sstream>
-#include "HAL/DriverStation.h"
-#include "HAL/HAL.h"
#include "frc971/wpilib/ahal/ErrorBase.h"
-#include "llvm/SmallString.h"
+#include "hal/DriverStation.h"
+#include "hal/HAL.h"
+#include "wpi/Path.h"
+#include "wpi/SmallString.h"
+#include "wpi/raw_ostream.h"
using namespace frc;
@@ -28,31 +30,31 @@
* The users don't call this, but instead use the wpi_assert macros in
* Utility.h.
*/
-bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText,
- llvm::StringRef message, llvm::StringRef fileName,
- int lineNumber, llvm::StringRef funcName) {
+bool wpi_assert_impl(bool conditionValue, const wpi::Twine &conditionText,
+ const wpi::Twine &message, wpi::StringRef fileName,
+ int lineNumber, wpi::StringRef funcName) {
if (!conditionValue) {
- std::stringstream locStream;
- locStream << funcName << " [";
- llvm::SmallString<128> fileTemp;
- locStream << basename(fileName.c_str(fileTemp)) << ":" << lineNumber << "]";
+ wpi::SmallString<128> locBuf;
+ wpi::raw_svector_ostream locStream(locBuf);
+ locStream << funcName << " [" << wpi::sys::path::filename(fileName) << ":"
+ << lineNumber << "]";
- std::stringstream errorStream;
+ wpi::SmallString<128> errorBuf;
+ wpi::raw_svector_ostream errorStream(errorBuf);
errorStream << "Assertion \"" << conditionText << "\" ";
- if (message[0] != '\0') {
- errorStream << "failed: " << message << std::endl;
+ if (message.isTriviallyEmpty() ||
+ (message.isSingleStringRef() && message.getSingleStringRef().empty())) {
+ errorStream << "failed.\n";
} else {
- errorStream << "failed." << std::endl;
+ errorStream << "failed: " << message << "\n";
}
std::string stack = GetStackTrace(2);
- std::string location = locStream.str();
- std::string error = errorStream.str();
// Print the error and send it to the DriverStation
- HAL_SendError(1, 1, 0, error.c_str(), location.c_str(), stack.c_str(), 1);
+ HAL_SendError(1, 1, 0, errorBuf.c_str(), locBuf.c_str(), stack.c_str(), 1);
}
return conditionValue;
@@ -63,33 +65,34 @@
* This should not be called directly; it should only be used by
* wpi_assertEqual_impl and wpi_assertNotEqual_impl.
*/
-void wpi_assertEqual_common_impl(llvm::StringRef valueA, llvm::StringRef valueB,
- llvm::StringRef equalityType,
- llvm::StringRef message,
- llvm::StringRef fileName, int lineNumber,
- llvm::StringRef funcName) {
- std::stringstream locStream;
- locStream << funcName << " [";
- llvm::SmallString<128> fileTemp;
- locStream << basename(fileName.c_str(fileTemp)) << ":" << lineNumber << "]";
+void wpi_assertEqual_common_impl(const wpi::Twine &valueA,
+ const wpi::Twine &valueB,
+ const wpi::Twine &equalityType,
+ const wpi::Twine &message,
+ wpi::StringRef fileName, int lineNumber,
+ wpi::StringRef funcName) {
+ wpi::SmallString<128> locBuf;
+ wpi::raw_svector_ostream locStream(locBuf);
+ locStream << funcName << " [" << wpi::sys::path::filename(fileName) << ":"
+ << lineNumber << "]";
- std::stringstream errorStream;
+ wpi::SmallString<128> errorBuf;
+ wpi::raw_svector_ostream errorStream(errorBuf);
errorStream << "Assertion \"" << valueA << " " << equalityType << " "
<< valueB << "\" ";
- if (message[0] != '\0') {
- errorStream << "failed: " << message << std::endl;
+ if (message.isTriviallyEmpty() ||
+ (message.isSingleStringRef() && message.getSingleStringRef().empty())) {
+ errorStream << "failed.\n";
} else {
- errorStream << "failed." << std::endl;
+ errorStream << "failed: " << message << "\n";
}
std::string trace = GetStackTrace(3);
- std::string location = locStream.str();
- std::string error = errorStream.str();
// Print the error and send it to the DriverStation
- HAL_SendError(1, 1, 0, error.c_str(), location.c_str(), trace.c_str(), 1);
+ HAL_SendError(1, 1, 0, errorBuf.c_str(), locBuf.c_str(), trace.c_str(), 1);
}
/**
@@ -99,10 +102,11 @@
* The users don't call this, but instead use the wpi_assertEqual macros in
* Utility.h.
*/
-bool wpi_assertEqual_impl(int valueA, int valueB, llvm::StringRef valueAString,
- llvm::StringRef valueBString, llvm::StringRef message,
- llvm::StringRef fileName, int lineNumber,
- llvm::StringRef funcName) {
+bool wpi_assertEqual_impl(int valueA, int valueB,
+ const wpi::Twine &valueAString,
+ const wpi::Twine &valueBString,
+ const wpi::Twine &message, wpi::StringRef fileName,
+ int lineNumber, wpi::StringRef funcName) {
if (!(valueA == valueB)) {
wpi_assertEqual_common_impl(valueAString, valueBString, "==", message,
fileName, lineNumber, funcName);
@@ -118,10 +122,10 @@
* Utility.h.
*/
bool wpi_assertNotEqual_impl(int valueA, int valueB,
- llvm::StringRef valueAString,
- llvm::StringRef valueBString,
- llvm::StringRef message, llvm::StringRef fileName,
- int lineNumber, llvm::StringRef funcName) {
+ const wpi::Twine &valueAString,
+ const wpi::Twine &valueBString,
+ const wpi::Twine &message, wpi::StringRef fileName,
+ int lineNumber, wpi::StringRef funcName) {
if (!(valueA != valueB)) {
wpi_assertEqual_common_impl(valueAString, valueBString, "!=", message,
fileName, lineNumber, funcName);