bazel: backport cleanup from main

This commit is contained in:
Corentin Le Molgat
2025-10-16 13:07:46 +02:00
parent 159110560a
commit 0ecd0b6535
5 changed files with 60 additions and 55 deletions

View File

@@ -34,8 +34,8 @@ cc_library(
cc_test(
name = "scheduler_test",
size = "medium",
srcs = ["scheduler_test.cc"],
tags = ["noci"],
deps = [
":scheduler",
":solvers_cc_proto",
@@ -95,8 +95,8 @@ cc_library(
cc_test(
name = "iteration_stats_test",
size = "medium",
srcs = ["iteration_stats_test.cc"],
tags = ["noci"],
deps = [
":iteration_stats",
":quadratic_program",
@@ -152,6 +152,7 @@ cc_test(
name = "primal_dual_hybrid_gradient_test",
size = "medium",
srcs = ["primal_dual_hybrid_gradient_test.cc"],
tags = ["noci"],
deps = [
":iteration_stats",
":primal_dual_hybrid_gradient",
@@ -253,8 +254,9 @@ cc_library(
cc_test(
name = "sharded_optimization_utils_test",
size = "medium",
size = "small",
srcs = ["sharded_optimization_utils_test.cc"],
tags = ["noci"],
deps = [
":quadratic_program",
":sharded_optimization_utils",
@@ -286,8 +288,8 @@ cc_library(
cc_test(
name = "sharded_quadratic_program_test",
size = "medium",
srcs = ["sharded_quadratic_program_test.cc"],
tags = ["noci"],
deps = [
":quadratic_program",
":sharded_quadratic_program",
@@ -317,8 +319,9 @@ cc_library(
cc_test(
name = "sharder_test",
size = "medium",
size = "small",
srcs = ["sharder_test.cc"],
tags = ["noci"],
deps = [
":scheduler",
":sharder",
@@ -427,8 +430,8 @@ cc_library(
cc_test(
name = "trust_region_test",
size = "medium",
srcs = ["trust_region_test.cc"],
tags = ["noci"],
deps = [
":quadratic_program",
":sharded_optimization_utils",

View File

@@ -11,6 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# This directory contains scheduling libraries to solve different types of
# scheduling problem.
load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
@@ -18,6 +21,37 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(default_visibility = ["//visibility:public"])
### RCPSP ###
proto_library(
name = "rcpsp_proto",
srcs = ["rcpsp.proto"],
)
cc_proto_library(
name = "rcpsp_cc_proto",
deps = [":rcpsp_proto"],
)
py_proto_library(
name = "rcpsp_py_pb2",
deps = [":rcpsp_proto"],
)
cc_library(
name = "rcpsp_parser",
srcs = ["rcpsp_parser.cc"],
hdrs = ["rcpsp_parser.h"],
deps = [
":rcpsp_cc_proto",
"//ortools/base:path",
"//ortools/util:filelineiter",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/strings",
],
)
### Jobshop Scheduling ###
proto_library(
name = "jobshop_scheduling_proto",
srcs = ["jobshop_scheduling.proto"],
@@ -37,42 +71,17 @@ cc_library(
":jobshop_scheduling_cc_proto",
"//ortools/base",
"//ortools/base:path",
"//ortools/base:types",
"//ortools/util:filelineiter",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/flags:flag",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/strings",
"@protobuf",
],
)
proto_library(
name = "rcpsp_proto",
srcs = ["rcpsp.proto"],
)
cc_proto_library(
name = "rcpsp_cc_proto",
deps = [":rcpsp_proto"],
)
py_proto_library(
name = "rcpsp_py_proto",
deps = [":rcpsp_proto"],
)
cc_library(
name = "rcpsp_parser",
srcs = ["rcpsp_parser.cc"],
hdrs = ["rcpsp_parser.h"],
visibility = ["//visibility:public"],
deps = [
":rcpsp_cc_proto",
"//ortools/base",
"//ortools/base:file",
"//ortools/base:path",
"//ortools/util:filelineiter",
"@abseil-cpp//absl/strings",
"@protobuf//:wrappers_cc_proto",
],
)
### Course Scheduling ###
proto_library(
name = "course_scheduling_proto",
srcs = ["course_scheduling.proto"],
@@ -80,6 +89,5 @@ proto_library(
cc_proto_library(
name = "course_scheduling_cc_proto",
visibility = ["//visibility:public"],
deps = [":course_scheduling_proto"],
)

View File

@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Python wrapper for ..
load("@pip_deps//:requirements.bzl", "requirement")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("@rules_python//python:py_test.bzl", "py_test")
@@ -24,6 +22,7 @@ pybind_extension(
deps = [
"//ortools/scheduling:rcpsp_cc_proto",
"//ortools/scheduling:rcpsp_parser",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/strings",
"@pybind11_protobuf//pybind11_protobuf:native_proto_caster",
],
@@ -31,11 +30,12 @@ pybind_extension(
py_test(
name = "rcpsp_test",
size = "small",
srcs = ["rcpsp_test.py"],
data = ["//ortools/scheduling/testdata:j301_1.sm"],
deps = [
":rcpsp",
"//ortools/scheduling:rcpsp_py_proto",
"//ortools/scheduling:rcpsp_py_pb2",
requirement("absl-py"),
],
)

View File

@@ -12,32 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from absl import app
from absl import flags
import os
from absl.testing import absltest
from ortools.scheduling.python import rcpsp
FLAGS = flags.FLAGS
class RcpspTest(absltest.TestCase):
def testParseAndAccess(self):
parser = rcpsp.RcpspParser()
test_srcdir = os.environ.get("TEST_SRCDIR")
data = "ortools/scheduling/testdata/j301_1.sm"
try:
filename = f"{FLAGS.test_srcdir}/_main/{data}"
except flags._exceptions.UnparsedFlagAccessError:
if test_srcdir:
filename = f"{test_srcdir}/_main/{data}"
else:
filename = f"../../../{data}"
parser = rcpsp.RcpspParser()
self.assertTrue(parser.parse_file(filename))
problem = parser.problem()
self.assertLen(problem.resources, 4)
self.assertLen(problem.tasks, 32)
def main(unused_argv):
absltest.main()
if __name__ == "__main__":
app.run(main)
absltest.main()

View File

@@ -114,7 +114,7 @@ cc_library(
":base_types",
":set_cover_cc_proto",
":set_cover_model",
"//ortools/base",
"//ortools/base:logging",
"//ortools/base:mathutil",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",