Merge "Make the new wpilib build"
diff --git a/WORKSPACE b/WORKSPACE
index c74eae5..1829355 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -159,6 +159,16 @@
url = "http://www.frc971.org/Build-Dependencies/allwpilib_ni-libraries_57e9fb3.tar.gz",
)
+# Generated with:
+# git fetch https://github.com/wpilibsuite/ni-libraries master
+# git archive --output=allwpilib_ni-libraries_4785480.tar.gz --format=tar.gz 4785480
+new_http_archive(
+ name = "allwpilib_ni_libraries_2019",
+ build_file = "debian/ni-libraries-2019.BUILD",
+ sha256 = "2cdcde3391f36877b7533e15d0f36baf696b27c1107b77192a8200e26f13278c",
+ url = "http://www.frc971.org/Build-Dependencies/allwpilib_ni-libraries_4785480.tar.gz",
+)
+
# Downloaded from:
# https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz
new_http_archive(
diff --git a/debian/ni-libraries-2019.BUILD b/debian/ni-libraries-2019.BUILD
new file mode 100644
index 0000000..09522cd
--- /dev/null
+++ b/debian/ni-libraries-2019.BUILD
@@ -0,0 +1,19 @@
+cc_library(
+ name = "ni-libraries",
+ srcs = [
+ "src/lib/chipobject/libNiFpga.so.18.0.0",
+ "src/lib/chipobject/libNiFpgaLv.so.18.0.0",
+ "src/lib/chipobject/libNiRioSrv.so.18.0.0",
+ "src/lib/chipobject/libRoboRIO_FRC_ChipObject.so.19.0.0",
+ "src/lib/chipobject/libniriodevenum.so.18.0.0",
+ "src/lib/chipobject/libniriosession.so.18.0.0",
+ "src/lib/netcomm/libFRC_NetworkCommunication.so.19.0.0",
+ ],
+ hdrs = glob(["src/include/**"]),
+ includes = [
+ "src/include",
+ ],
+ linkstatic = True,
+ restricted_to = ["@//tools:roborio"],
+ visibility = ["//visibility:public"],
+)
diff --git a/third_party/allwpilib_2019/BUILD b/third_party/allwpilib_2019/BUILD
new file mode 100644
index 0000000..ea548fc
--- /dev/null
+++ b/third_party/allwpilib_2019/BUILD
@@ -0,0 +1,89 @@
+licenses(["notice"])
+
+# Names of WPILib "devices" I don't want to deal with making trivial updates to
+# chop out various ugliness or have to vet for sanity.
+_excluded_devices = [
+ "AnalogGyro",
+ "SerialPort",
+ "SerialHelper",
+ "visa",
+]
+
+# Header files we don't want to have.
+_bad_hdrs = ([
+ "hal/include/HAL/LabVIEW/HAL.h",
+] + ["**/%s.*" % d for d in _excluded_devices])
+
+_hal_header_dirs = [
+ "hal/src/main/native/athena",
+ "hal/src/main/native/include",
+]
+
+_hal_h_hdrs = glob(
+ [d + "/**/*.h" for d in _hal_header_dirs],
+ exclude = _bad_hdrs,
+)
+
+_hal_hpp_hdrs = glob(
+ [d + "/**/*.hpp" for d in _hal_header_dirs],
+ exclude = _bad_hdrs,
+)
+
+py_binary(
+ name = "generate_FRCUsageReporting",
+ srcs = [
+ "generate_FRCUsageReporting.py",
+ ],
+)
+
+genrule(
+ name = "do_generate_FRCUsageReporting",
+ srcs = [
+ "hal/src/generate/FRCUsageReporting.h.in",
+ "hal/src/generate/Instances.txt",
+ "hal/src/generate/ResourceType.txt",
+ ],
+ outs = [
+ "hal/src/main/native/include/hal/FRCUsageReporting.h",
+ ],
+ cmd = " ".join([
+ "$(location :generate_FRCUsageReporting)",
+ "$(location hal/src/generate/FRCUsageReporting.h.in)",
+ "$(location hal/src/generate/Instances.txt)",
+ "$(location hal/src/generate/ResourceType.txt)",
+ "$(location hal/src/main/native/include/hal/FRCUsageReporting.h)",
+ ]),
+ tools = [
+ ":generate_FRCUsageReporting",
+ ],
+)
+
+cc_library(
+ name = "hal",
+ srcs = glob(
+ include = [
+ "hal/src/main/native/athena/*.cpp",
+ "hal/src/main/native/athena/cpp/*.cpp",
+ "hal/src/main/native/athena/ctre/*.cpp",
+ "hal/src/main/native/shared/handles/*.cpp",
+ ],
+ exclude = ["**/%s.*" % d for d in _excluded_devices],
+ ),
+ hdrs = _hal_h_hdrs + _hal_hpp_hdrs + [
+ "hal/src/main/native/include/hal/FRCUsageReporting.h",
+ ],
+ copts = [
+ "-Wno-unused-parameter",
+ "-Wno-cast-align",
+ ],
+ defines = ["WPILIB2019=1"],
+ includes = _hal_header_dirs,
+ linkopts = ["-lpthread"],
+ restricted_to = ["//tools:roborio"],
+ visibility = ["//third_party:__pkg__"],
+ deps = [
+ "//aos/logging",
+ "//third_party/allwpilib_2019/wpiutil",
+ "@allwpilib_ni_libraries_2019//:ni-libraries",
+ ],
+)
diff --git a/third_party/allwpilib_2019/generate_FRCUsageReporting.py b/third_party/allwpilib_2019/generate_FRCUsageReporting.py
new file mode 100644
index 0000000..23b9807
--- /dev/null
+++ b/third_party/allwpilib_2019/generate_FRCUsageReporting.py
@@ -0,0 +1,25 @@
+from __future__ import print_function
+
+import sys
+
+header_in_name = sys.argv[1]
+instances_txt_name = sys.argv[2]
+resource_type_txt_name = sys.argv[3]
+header_out_name = sys.argv[4]
+
+with open(header_in_name, 'r') as f:
+ header_in = f.read().replace('\r', '')
+
+with open(instances_txt_name, 'r') as f:
+ instances_txt = [l.strip() for l in f.readlines()]
+
+with open(resource_type_txt_name, 'r') as f:
+ resource_type_txt = [l.strip() for l in f.readlines()]
+
+with open(header_out_name, 'w') as out:
+ header = header_in
+ header = header.replace('${usage_reporting_types_cpp}',
+ ',\n'.join(resource_type_txt))
+ header = header.replace('${usage_reporting_instances_cpp}',
+ ',\n'.join(instances_txt))
+ out.write(header)
diff --git a/third_party/allwpilib_2019/hal/src/main/native/athena/HAL.cpp b/third_party/allwpilib_2019/hal/src/main/native/athena/HAL.cpp
index dbdb826..8c62fdc 100644
--- a/third_party/allwpilib_2019/hal/src/main/native/athena/HAL.cpp
+++ b/third_party/allwpilib_2019/hal/src/main/native/athena/HAL.cpp
@@ -30,7 +30,6 @@
#include "hal/Errors.h"
#include "hal/Notifier.h"
#include "hal/handles/HandlesInternal.h"
-#include "visa/visa.h"
using namespace hal;
@@ -44,7 +43,6 @@
void InitializeHAL() {
InitializeAccelerometer();
InitializeAnalogAccumulator();
- InitializeAnalogGyro();
InitializeAnalogInput();
InitializeAnalogInternal();
InitializeAnalogOutput();
@@ -68,7 +66,6 @@
InitializePower();
InitializePWM();
InitializeRelay();
- InitializeSerialPort();
InitializeSolenoid();
InitializeSPI();
InitializeThreads();
@@ -169,30 +166,6 @@
return ERR_CANSessionMux_NotAllowed_MESSAGE;
case HAL_ERR_CANSessionMux_NotInitialized:
return ERR_CANSessionMux_NotInitialized_MESSAGE;
- case VI_ERROR_SYSTEM_ERROR:
- return VI_ERROR_SYSTEM_ERROR_MESSAGE;
- case VI_ERROR_INV_OBJECT:
- return VI_ERROR_INV_OBJECT_MESSAGE;
- case VI_ERROR_RSRC_LOCKED:
- return VI_ERROR_RSRC_LOCKED_MESSAGE;
- case VI_ERROR_RSRC_NFOUND:
- return VI_ERROR_RSRC_NFOUND_MESSAGE;
- case VI_ERROR_INV_RSRC_NAME:
- return VI_ERROR_INV_RSRC_NAME_MESSAGE;
- case VI_ERROR_QUEUE_OVERFLOW:
- return VI_ERROR_QUEUE_OVERFLOW_MESSAGE;
- case VI_ERROR_IO:
- return VI_ERROR_IO_MESSAGE;
- case VI_ERROR_ASRL_PARITY:
- return VI_ERROR_ASRL_PARITY_MESSAGE;
- case VI_ERROR_ASRL_FRAMING:
- return VI_ERROR_ASRL_FRAMING_MESSAGE;
- case VI_ERROR_ASRL_OVERRUN:
- return VI_ERROR_ASRL_OVERRUN_MESSAGE;
- case VI_ERROR_RSRC_BUSY:
- return VI_ERROR_RSRC_BUSY_MESSAGE;
- case VI_ERROR_INV_PARAMETER:
- return VI_ERROR_INV_PARAMETER_MESSAGE;
case HAL_PWM_SCALE_ERROR:
return HAL_PWM_SCALE_ERROR_MESSAGE;
case HAL_SERIAL_PORT_NOT_FOUND:
diff --git a/third_party/allwpilib_2019/hal/src/main/native/athena/HALInitializer.h b/third_party/allwpilib_2019/hal/src/main/native/athena/HALInitializer.h
index 384fe58..7956083 100644
--- a/third_party/allwpilib_2019/hal/src/main/native/athena/HALInitializer.h
+++ b/third_party/allwpilib_2019/hal/src/main/native/athena/HALInitializer.h
@@ -20,7 +20,6 @@
extern void InitializeAccelerometer();
extern void InitializeAnalogAccumulator();
-extern void InitializeAnalogGyro();
extern void InitializeAnalogInput();
extern void InitializeAnalogInternal();
extern void InitializeAnalogOutput();
@@ -45,7 +44,6 @@
extern void InitializePower();
extern void InitializePWM();
extern void InitializeRelay();
-extern void InitializeSerialPort();
extern void InitializeSolenoid();
extern void InitializeSPI();
extern void InitializeThreads();
diff --git a/third_party/allwpilib_2019/hal/src/main/native/include/hal/HAL.h b/third_party/allwpilib_2019/hal/src/main/native/include/hal/HAL.h
index f0da13f..0236adf 100644
--- a/third_party/allwpilib_2019/hal/src/main/native/include/hal/HAL.h
+++ b/third_party/allwpilib_2019/hal/src/main/native/include/hal/HAL.h
@@ -13,7 +13,6 @@
#include "hal/Accelerometer.h"
#include "hal/AnalogAccumulator.h"
-#include "hal/AnalogGyro.h"
#include "hal/AnalogInput.h"
#include "hal/AnalogOutput.h"
#include "hal/AnalogTrigger.h"
@@ -33,7 +32,6 @@
#include "hal/Power.h"
#include "hal/Relay.h"
#include "hal/SPI.h"
-#include "hal/SerialPort.h"
#include "hal/Solenoid.h"
#endif // HAL_USE_LABVIEW
diff --git a/third_party/allwpilib_2019/wpiutil/BUILD b/third_party/allwpilib_2019/wpiutil/BUILD
new file mode 100644
index 0000000..aceed4a
--- /dev/null
+++ b/third_party/allwpilib_2019/wpiutil/BUILD
@@ -0,0 +1,21 @@
+licenses(["notice"])
+
+cc_library(
+ name = "wpiutil",
+ srcs = glob([
+ "src/main/native/cpp/llvm/*.cpp",
+ "src/main/native/cpp/llvm/Unix/Path.inc",
+ "src/main/native/cpp/support/timestamp.cpp",
+ ]),
+ hdrs = glob([
+ "src/main/native/include/**",
+ ]),
+ copts = [
+ "-Wno-unused-parameter",
+ ],
+ includes = [
+ "src/main/native/include",
+ ],
+ restricted_to = ["//tools:roborio"],
+ visibility = ["//visibility:public"],
+)