glop: backport from main

This commit is contained in:
Corentin Le Molgat
2025-11-05 12:04:21 +01:00
parent 935a93833f
commit cff88063ba
3 changed files with 22 additions and 42 deletions

View File

@@ -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",
)

View File

@@ -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",
],
)

View File

@@ -14,6 +14,7 @@
// Minimal example to call the GLOP solver.
// [START program]
// [START import]
#include <cstdlib>
#include <iostream>
#include <ostream>