Make osqp build

Prep for using it in the catapult.

Change-Id: Ic642b1c04469563de13a8a6227407aacb75eff6a
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/third_party/osqp-cpp/BUILD b/third_party/osqp-cpp/BUILD
new file mode 100644
index 0000000..e419d2b
--- /dev/null
+++ b/third_party/osqp-cpp/BUILD
@@ -0,0 +1,32 @@
+cc_library(
+    name = "osqp-cpp",
+    srcs = [
+        "src/osqp++.cc",
+    ],
+    hdrs = [
+        "include/osqp++.h",
+    ],
+    includes = [
+        "include",
+    ],
+    target_compatible_with = ["@platforms//os:linux"],
+    visibility = ["//visibility:public"],
+    deps = [
+        "//third_party/osqp",
+        "@com_google_absl//absl/status",
+        "@com_google_absl//absl/status:statusor",
+        "@org_tuxfamily_eigen//:eigen",
+    ],
+)
+
+cc_test(
+    name = "osqp-cpp_test",
+    srcs = [
+        "test/osqp++_test.cc",
+    ],
+    deps = [
+        ":osqp-cpp",
+        "//aos/testing:googletest",
+        "@com_google_googletest//:gtest",
+    ],
+)
diff --git a/third_party/osqp-cpp/include/osqp++.h b/third_party/osqp-cpp/include/osqp++.h
index 3f79fa9..86c9ea7 100644
--- a/third_party/osqp-cpp/include/osqp++.h
+++ b/third_party/osqp-cpp/include/osqp++.h
@@ -30,7 +30,7 @@
 
 // Must match the typedef in osqp/include/glob_opts.h (if not, it will trigger
 // a static_assert failure in osqp++.cc).
-using c_int = long long;  // NOLINT
+using c_int = int;  // NOLINT
 
 // A memory-safe mirror of the OSQPData struct defined in osqp/include/types.h.
 // The number of variables and constraints is implied by the shape of
diff --git a/third_party/osqp-cpp/src/osqp++.cc b/third_party/osqp-cpp/src/osqp++.cc
index 5fa119e..596339c 100644
--- a/third_party/osqp-cpp/src/osqp++.cc
+++ b/third_party/osqp-cpp/src/osqp++.cc
@@ -36,7 +36,7 @@
 static_assert(std::is_same_v<c_float, double>,
               "OSQP's c_float typedef is unexpectedly not the same as double");
 
-static_assert(sizeof(OSQPSettings) == 176,
+static_assert(sizeof(OSQPSettings) == 144,
               "The size of OSQPSettings has changed unexpectedly. Make sure "
               "that the map between ::OSQPSettings and osqp::OsqpSettings "
               "remains up to date.");
@@ -303,7 +303,7 @@
     }
   }
 
-  for (size_t i = 0; i < new_matrix.nonZeros(); ++i) {
+  for (Eigen::Index i = 0; i < new_matrix.nonZeros(); ++i) {
     if (ref_matrix->i[i] != new_matrix.innerIndexPtr()[i]) {
       return absl::InvalidArgumentError(
           "Sparsity of the new matrix differs from the previously "
@@ -541,6 +541,7 @@
 Map<const VectorXd> OsqpSolver::primal_infeasibility_certificate() const {
   OSQP_CHECK(IsInitialized());
   const OsqpExitCode exit_code = StatusToExitCode(workspace_->info->status_val);
+  (void)exit_code;
   OSQP_CHECK(exit_code == OsqpExitCode::kPrimalInfeasible ||
              exit_code == OsqpExitCode::kPrimalInfeasibleInaccurate);
   return Map<const VectorXd>(workspace_->delta_y, workspace_->data->m);