|
16 | 16 |
|
17 | 17 | load("@pip_deps//:requirements.bzl", "requirement") |
18 | 18 | load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") |
| 19 | +load("@rules_cc//cc:cc_binary.bzl", "cc_binary") |
19 | 20 | load("@rules_cc//cc:cc_library.bzl", "cc_library") |
20 | 21 | load("@rules_python//python:py_library.bzl", "py_library") |
21 | 22 | load("@rules_python//python:py_test.bzl", "py_test") |
@@ -133,3 +134,71 @@ py_test( |
133 | 134 | requirement("absl-py"), |
134 | 135 | ], |
135 | 136 | ) |
| 137 | + |
| 138 | +cc_library( |
| 139 | + name = "wrappers", |
| 140 | + srcs = ["wrappers.cc"], |
| 141 | + hdrs = ["wrappers.h"], |
| 142 | + visibility = ["//visibility:public"], |
| 143 | + deps = [ |
| 144 | + "@abseil-cpp//absl/algorithm:container", |
| 145 | + "@abseil-cpp//absl/base:nullability", |
| 146 | + "@abseil-cpp//absl/container:flat_hash_map", |
| 147 | + "@abseil-cpp//absl/container:flat_hash_set", |
| 148 | + "@abseil-cpp//absl/log", |
| 149 | + "@abseil-cpp//absl/log:check", |
| 150 | + "@abseil-cpp//absl/log:die_if_null", |
| 151 | + "@abseil-cpp//absl/strings", |
| 152 | + "@abseil-cpp//absl/types:span", |
| 153 | + "@protobuf", |
| 154 | + ], |
| 155 | +) |
| 156 | + |
| 157 | +cc_binary( |
| 158 | + name = "gen_wrappers_test_pybind11", |
| 159 | + srcs = ["gen_wrappers_test_pybind11.cc"], |
| 160 | + deps = [ |
| 161 | + ":wrappers", |
| 162 | + "//ortools/base", |
| 163 | + "//ortools/util/testdata:wrappers_test_cc_proto", |
| 164 | + "@abseil-cpp//absl/flags:parse", |
| 165 | + "@abseil-cpp//absl/flags:usage", |
| 166 | + "@abseil-cpp//absl/log:die_if_null", |
| 167 | + "@abseil-cpp//absl/log:initialize", |
| 168 | + "@abseil-cpp//absl/strings", # IWYU pragma: keep |
| 169 | + "@abseil-cpp//absl/strings:str_format", |
| 170 | + ], |
| 171 | +) |
| 172 | + |
| 173 | +genrule( |
| 174 | + name = "run_gen_wrappers_test_pybind11", |
| 175 | + outs = ["wrappers_test_pybind11.h"], |
| 176 | + cmd = "$(location :gen_wrappers_test_pybind11) > $@", |
| 177 | + tools = [":gen_wrappers_test_pybind11"], |
| 178 | +) |
| 179 | + |
| 180 | +cc_library( |
| 181 | + name = "wrappers_test_pybind11", |
| 182 | + hdrs = ["wrappers_test_pybind11.h"], |
| 183 | +) |
| 184 | + |
| 185 | +pybind_extension( |
| 186 | + name = "wrappers_test_extension", |
| 187 | + srcs = ["wrappers_test_extension.cc"], |
| 188 | + visibility = ["//visibility:public"], |
| 189 | + deps = [ |
| 190 | + ":wrappers_test_pybind11", |
| 191 | + "//ortools/port:proto_utils", |
| 192 | + "//ortools/util/testdata:wrappers_test_cc_proto", |
| 193 | + "@abseil-cpp//absl/strings", |
| 194 | + ], |
| 195 | +) |
| 196 | + |
| 197 | +py_test( |
| 198 | + name = "wrappers_test", |
| 199 | + srcs = ["wrappers_test.py"], |
| 200 | + deps = [ |
| 201 | + ":wrappers_test_extension", |
| 202 | + requirement("absl-py"), |
| 203 | + ], |
| 204 | +) |
0 commit comments