Added BUILD rules for blasfeo and hpipm

These are needed for the controls toolbox ct.

Change-Id: I50608f01abfdf24ad52f1dda5a4c81fd079afb16
diff --git a/third_party/blasfeo/BUILD b/third_party/blasfeo/BUILD
new file mode 100644
index 0000000..92be2d4
--- /dev/null
+++ b/third_party/blasfeo/BUILD
@@ -0,0 +1,84 @@
+licenses(["notice"])  # lgpl
+
+cc_library(
+    name = "blasfeo",
+    hdrs = [
+        "include/blasfeo_block_size.h",
+        "include/blasfeo_common.h",
+        "include/blasfeo_d_aux.h",
+        "include/blasfeo_d_kernel.h",
+        "include/blasfeo_s_aux.h",
+        "include/blasfeo_s_kernel.h",
+        "include/blasfeo_target.h",
+        "include/blasfeo_d_blas.h",
+        "include/blasfeo_m_aux.h",
+        "include/blasfeo_s_blas.h",
+    ],
+    includes = [
+        "include",
+    ],
+    srcs = [
+        # ext
+        "auxiliary/d_aux_lib4.c",
+        "auxiliary/avx/kernel_dgecp_lib4.c",
+        "auxiliary/avx/kernel_dgetr_lib4.c",
+        "auxiliary/s_aux_lib8.c",
+        "auxiliary/m_aux_lib48.c",
+        # kernels
+        "kernel/avx/kernel_dgemm_8x4_lib4.S",
+        "kernel/avx/kernel_dgemm_4x4_lib4.S",
+        "kernel/avx/kernel_dgemm_diag_lib4.c",
+        "kernel/avx/kernel_dgemv_12_lib4.S",
+        "kernel/avx/kernel_dgemv_8_lib4.S",
+        "kernel/avx/kernel_dgemv_4_lib4.S",
+        "kernel/avx/kernel_dsymv_6_lib4.S",
+        "kernel/avx/kernel_dgetrf_pivot_4_lib4.c",
+        "kernel/avx/kernel_dgeqrf_4_lib4.c",
+        "kernel/avx/kernel_dgebp_lib4.S",
+        "kernel/avx/kernel_sgemm_16x4_lib8.S",
+        "kernel/avx/kernel_sgemm_8x8_lib8.S",
+        "kernel/avx/kernel_sgemm_8x4_lib8.S",
+        "kernel/avx/kernel_sgecp_lib8.S",
+        "kernel/avx/kernel_sgemm_diag_lib8.c",
+        "kernel/avx/kernel_sgetr_lib8.S",
+        "kernel/avx/kernel_sgead_lib8.S",
+        "kernel/avx/kernel_sgesc_lib8.S",
+        "kernel/avx/kernel_sgemv_8_lib8.S",
+        "kernel/avx/kernel_sgemv_4_lib8.S",
+        # blas
+        "blas/d_blas1_lib4.c",
+        "blas/d_blas2_lib4.c",
+        "blas/d_blas2_diag_lib.c",
+        "blas/d_blas3_lib4.c",
+        "blas/d_blas3_diag_lib4.c",
+        "blas/d_lapack_lib4.c",
+        "blas/s_blas1_lib8.c",
+        "blas/s_blas2_lib8.c",
+        "blas/s_blas2_diag_lib.c",
+        "blas/s_blas3_lib8.c",
+        "blas/s_blas3_diag_lib8.c",
+        "blas/s_lapack_lib8.c",
+        # ext_dep
+        "auxiliary/d_aux_ext_dep_lib.c",
+        "auxiliary/s_aux_ext_dep_lib.c",
+        "auxiliary/v_aux_ext_dep_lib.c",
+        "auxiliary/i_aux_ext_dep_lib.c",
+    ],
+    copts = [
+        "-mavx",
+        "-DTARGET_X64_INTEL_SANDY_BRIDGE",
+        "-DLA_HIGH_PERFORMANCE",
+        "-DOS_LINUX",
+        "-DEXT_DEP",
+        "-Wno-unused-variable",
+        "-Wno-uninitialized",
+        "-Wno-unused-parameter",
+        "-Wno-unused-label",
+        "-Wno-cast-align",
+    ],
+    textual_hdrs = [
+        "blas/x_blas2_diag_lib.c",
+    ],
+    visibility = ["//visibility:public"],
+    restricted_to = ["//tools:k8"],
+)
diff --git a/third_party/blasfeo/include/blasfeo_target.h b/third_party/blasfeo/include/blasfeo_target.h
new file mode 100644
index 0000000..f0022ea
--- /dev/null
+++ b/third_party/blasfeo/include/blasfeo_target.h
@@ -0,0 +1,9 @@
+#ifndef TARGET_X64_INTEL_HASWELL
+#define TARGET_X64_INTEL_HASWELL
+#endif
+#ifndef LA_HIGH_PERFORMANCE
+#define LA_HIGH_PERFORMANCE
+#endif
+#ifndef EXT_DEP
+#define EXT_DEP
+#endif
diff --git a/third_party/hpipm/BUILD b/third_party/hpipm/BUILD
new file mode 100644
index 0000000..32729e1
--- /dev/null
+++ b/third_party/hpipm/BUILD
@@ -0,0 +1,86 @@
+licenses(["notice"])  # lgpl
+
+cc_library(
+    name = "hpipm",
+    includes = [ "include" ],
+    hdrs = [
+        "include/hpipm_s_core_qp_ipm_hard.h",
+        "include/hpipm_d_dense_qp.h",
+        "include/hpipm_s_ocp_qp.h",
+        "include/hpipm_s_ocp_qp_sol.h",
+        "include/hpipm_d_ocp_qp.h",
+        "include/hpipm_d_ocp_qp_sol.h",
+        "include/hpipm_s_dense_qp.h",
+        "include/hpipm_d_ocp_qp_ipm_hard.h",
+        "include/hpipm_s_dense_qp_sol.h",
+        "include/hpipm_s_dense_qp_ipm_hard.h",
+        "include/hpipm_s_core_qp_ipm_hard_aux.h",
+        "include/hpipm_s_dense_qp_kkt.h",
+        "include/hpipm_m_ocp_qp_ipm_hard.h",
+        "include/hpipm_d_core_qp_ipm_hard.h",
+        "include/hpipm_d_core_qp_ipm_hard_aux.h",
+        "include/hpipm_d_dense_qp_sol.h",
+        "include/hpipm_d_ocp_qp_kkt.h",
+        "include/hpipm_d_cond.h",
+        "include/hpipm_m_ocp_qp_kkt.h",
+        "include/hpipm_d_cond_aux.h",
+        "include/hpipm_s_ocp_qp_ipm_hard.h",
+        "include/hpipm_s_ocp_qp_kkt.h",
+        "include/hpipm_d_dense_qp_ipm_hard.h",
+        "include/hpipm_d_dense_qp_kkt.h",
+    ],
+    srcs = [
+        # dense qp
+        "dense_qp/d_dense_qp.c",
+        "dense_qp/d_dense_qp_sol.c",
+        "dense_qp/d_dense_qp_kkt.c",
+        "dense_qp/d_dense_qp_ipm_hard.c",
+        "dense_qp/s_dense_qp.c",
+        "dense_qp/s_dense_qp_sol.c",
+        "dense_qp/s_dense_qp_kkt.c",
+        "dense_qp/s_dense_qp_ipm_hard.c",
+        # ocp qp
+        "ocp_qp/d_ocp_qp.c",
+        "ocp_qp/d_ocp_qp_sol.c",
+        "ocp_qp/d_ocp_qp_kkt.c",
+        "ocp_qp/d_ocp_qp_ipm_hard.c",
+        "ocp_qp/s_ocp_qp.c",
+        "ocp_qp/s_ocp_qp_sol.c",
+        "ocp_qp/s_ocp_qp_kkt.c",
+        "ocp_qp/s_ocp_qp_ipm_hard.c",
+        "ocp_qp/m_ocp_qp.c",
+        "ocp_qp/m_ocp_qp_kkt.c",
+        "ocp_qp/m_ocp_qp_ipm_hard.c",
+        # core qp
+        "core_qp/d_core_qp_ipm_hard_aux.c",
+        "core_qp/d_core_qp_ipm_hard.c",
+        "core_qp/s_core_qp_ipm_hard_aux.c",
+        "core_qp/s_core_qp_ipm_hard.c",
+        # cond
+        "cond/d_cond_aux.c",
+        "cond/d_cond.c",
+        "cond/d_part_cond.c",
+    ],
+    textual_hdrs = [
+        "ocp_qp/x_ocp_qp_sol.c",
+        "dense_qp/x_dense_qp.c",
+        "dense_qp/x_dense_qp_ipm_hard.c",
+        "core_qp/x_core_qp_ipm_hard_aux.c",
+        "core_qp/x_core_qp_ipm_hard.c",
+        "dense_qp/x_dense_qp_sol.c",
+        "ocp_qp/x_ocp_qp_ipm_hard.c",
+        "ocp_qp/x_ocp_qp.c",
+        "ocp_qp/x_ocp_qp_kkt.c",
+        "dense_qp/x_dense_qp_kkt.c",
+    ],
+    deps = [
+        "//third_party/blasfeo",
+    ],
+    copts = [
+        "-Wno-pointer-arith",
+        "-Wno-unused-variable",
+        "-Wno-unused-parameter",
+    ],
+    visibility = ["//visibility:public"],
+    restricted_to = ["//tools:k8"],
+)