2025-01-10 11:35:44 +01:00
|
|
|
# Copyright 2010-2025 Google LLC
|
2022-06-20 18:27:09 +02:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2020-12-17 23:42:34 +01:00
|
|
|
"""Helper macro to compile and test code samples."""
|
|
|
|
|
|
2025-07-23 09:05:10 +00:00
|
|
|
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
|
|
|
|
load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
2024-09-30 15:30:44 +02:00
|
|
|
|
2020-12-17 23:42:34 +01:00
|
|
|
def code_sample_cc(name):
|
2024-09-30 15:30:44 +02:00
|
|
|
cc_binary(
|
2022-07-27 16:45:14 +02:00
|
|
|
name = name + "_cc",
|
2022-06-21 11:35:03 +02:00
|
|
|
srcs = [name + ".cc"],
|
|
|
|
|
deps = [
|
|
|
|
|
"//ortools/base",
|
|
|
|
|
"//ortools/constraint_solver:cp",
|
|
|
|
|
"//ortools/constraint_solver:routing",
|
|
|
|
|
"//ortools/constraint_solver:routing_enums_cc_proto",
|
|
|
|
|
],
|
|
|
|
|
)
|
2020-11-13 16:08:47 +01:00
|
|
|
|
2024-09-30 15:30:44 +02:00
|
|
|
cc_test(
|
2022-07-27 16:45:14 +02:00
|
|
|
name = name + "_cc_test",
|
2022-06-21 11:35:03 +02:00
|
|
|
size = "small",
|
|
|
|
|
srcs = [name + ".cc"],
|
|
|
|
|
deps = [
|
2022-07-27 16:45:14 +02:00
|
|
|
":" + name + "_cc",
|
2022-06-21 11:35:03 +02:00
|
|
|
"//ortools/base",
|
|
|
|
|
"//ortools/constraint_solver:cp",
|
|
|
|
|
"//ortools/constraint_solver:routing",
|
|
|
|
|
"//ortools/constraint_solver:routing_enums_cc_proto",
|
|
|
|
|
],
|
|
|
|
|
)
|