diff --git a/ortools/glop/samples/BUILD.bazel b/ortools/glop/samples/BUILD.bazel index 65a910f1bd..cddf4f30b1 100644 --- a/ortools/glop/samples/BUILD.bazel +++ b/ortools/glop/samples/BUILD.bazel @@ -11,6 +11,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -load(":code_samples.bzl", "code_sample_cc") +load("@rules_cc//cc:cc_binary.bzl", "cc_binary") +load("//bazel:run_binary_test.bzl", "run_binary_test") -code_sample_cc(name = "simple_glop_program") +package(default_visibility = ["//visibility:public"]) + +cc_binary( + name = "simple_glop_program_cc", + srcs = ["simple_glop_program.cc"], + deps = [ + "//ortools/base", + "//ortools/base:numbers", + "//ortools/glop:lp_solver", + "//ortools/lp_data", + "//ortools/lp_data:base", + ], +) + +run_binary_test( + name = "simple_glop_program_cc_test", + size = "small", + binary = ":simple_glop_program_cc", +) diff --git a/ortools/glop/samples/code_samples.bzl b/ortools/glop/samples/code_samples.bzl deleted file mode 100644 index 357cb19455..0000000000 --- a/ortools/glop/samples/code_samples.bzl +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2010-2025 Google LLC -# 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. - -"""Helper macro to compile and test code samples.""" - -load("@rules_cc//cc:cc_binary.bzl", "cc_binary") -load("@rules_cc//cc:cc_test.bzl", "cc_test") - -def code_sample_cc(name): - cc_binary( - name = name + "_cc", - srcs = [name + ".cc"], - deps = [ - "//ortools/base", - "//ortools/glop:lp_solver", - "//ortools/lp_data", - ], - ) - - cc_test( - name = name + "_cc_test", - size = "small", - srcs = [name + ".cc"], - deps = [ - ":" + name + "_cc", - "//ortools/base", - "//ortools/glop:lp_solver", - "//ortools/lp_data", - ], - ) diff --git a/ortools/glop/samples/simple_glop_program.cc b/ortools/glop/samples/simple_glop_program.cc index 911efd5b2a..645dbb8811 100644 --- a/ortools/glop/samples/simple_glop_program.cc +++ b/ortools/glop/samples/simple_glop_program.cc @@ -14,6 +14,7 @@ // Minimal example to call the GLOP solver. // [START program] // [START import] +#include #include #include