Skip to content

Commit 71fa8f4

Browse files
authored
[bazel] Add more default compilation and linker options (#5263)
1 parent c7266e8 commit 71fa8f4

46 files changed

Lines changed: 805 additions & 120 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ortools/base/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ cc_test(
175175
name = "dump_vars_test",
176176
size = "small",
177177
srcs = ["dump_vars_test.cc"],
178-
copts = ORTOOLS_DEFAULT_COPTS,
178+
copts = ORTOOLS_TEST_COPTS,
179179
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
180180
deps = [
181181
":dump_vars",

ortools/base/macros/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,28 @@
1212
# limitations under the License.
1313

1414
load("@rules_cc//cc:cc_library.bzl", "cc_library")
15+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_COPTS", "ORTOOLS_DEFAULT_LINKOPTS")
1516

1617
package(default_visibility = ["//visibility:public"])
1718

1819
cc_library(
1920
name = "os",
2021
hdrs = ["os.h"],
22+
copts = ORTOOLS_DEFAULT_COPTS,
23+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2124
)
2225

2326
cc_library(
2427
name = "os_support",
2528
hdrs = ["os_support.h"],
29+
copts = ORTOOLS_DEFAULT_COPTS,
30+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2631
deps = [":os"],
2732
)
2833

2934
cc_library(
3035
name = "buildenv",
3136
hdrs = ["buildenv.h"],
37+
copts = ORTOOLS_DEFAULT_COPTS,
38+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
3239
)

ortools/constraint_solver/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ load("@protobuf//bazel:proto_library.bzl", "proto_library")
1919
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
2020
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2121
load("@rules_python//python:py_library.bzl", "py_library")
22+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_COPTS", "ORTOOLS_DEFAULT_LINKOPTS")
2223

2324
proto_library(
2425
name = "assignment_proto",
@@ -128,6 +129,8 @@ cc_library(
128129
name = "model_cache",
129130
srcs = ["model_cache.cc"],
130131
hdrs = ["model_cache.h"],
132+
copts = ORTOOLS_DEFAULT_COPTS,
133+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
131134
visibility = ["//visibility:public"],
132135
deps = [
133136
"//ortools/base:safe_hash_map",
@@ -141,6 +144,8 @@ cc_library(
141144
name = "reversible_engine",
142145
srcs = ["reversible_engine.cc"],
143146
hdrs = ["reversible_engine.h"],
147+
copts = ORTOOLS_DEFAULT_COPTS,
148+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
144149
visibility = ["//visibility:public"],
145150
deps = [
146151
":solver_parameters_cc_proto",
@@ -156,6 +161,8 @@ cc_library(
156161
name = "reversible_data",
157162
srcs = ["reversible_data.cc"],
158163
hdrs = ["reversible_data.h"],
164+
copts = ORTOOLS_DEFAULT_COPTS,
165+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
159166
visibility = ["//visibility:public"],
160167
deps = [
161168
":reversible_engine",
@@ -169,6 +176,8 @@ cc_library(
169176
name = "utilities",
170177
srcs = ["utilities.cc"],
171178
hdrs = ["utilities.h"],
179+
copts = ORTOOLS_DEFAULT_COPTS,
180+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
172181
visibility = ["//visibility:public"],
173182
deps = [
174183
"//ortools/base:types",
@@ -236,6 +245,8 @@ cc_library(
236245
"variables.h",
237246
"visitor.h",
238247
],
248+
copts = ORTOOLS_DEFAULT_COPTS,
249+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
239250
visibility = ["//visibility:public"],
240251
deps = [
241252
":assignment_cc_proto",

ortools/constraint_solver/python/BUILD.bazel

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ load("@pybind11_bazel//:build_defs.bzl", "pybind_extension", "pybind_library")
1818
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1919
load("@rules_python//python:py_library.bzl", "py_library")
2020
load("@rules_python//python:py_test.bzl", "py_test")
21+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_COPTS", "ORTOOLS_DEFAULT_LINKOPTS")
2122

2223
cc_library(
2324
name = "constraint_solver_doc",
2425
hdrs = ["constraint_solver_doc.h"],
26+
copts = ORTOOLS_DEFAULT_COPTS,
27+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2528
visibility = ["//visibility:public"],
2629
)
2730

@@ -37,7 +40,6 @@ pybind_extension(
3740
"//ortools/constraint_solver:reversible_engine",
3841
"//ortools/constraint_solver:search_limit_cc_proto",
3942
"//ortools/constraint_solver:solver_parameters_cc_proto",
40-
"//ortools/util:piecewise_linear_function",
4143
"//ortools/util:tuple_set",
4244
"//ortools/util/python:piecewise_linear_function_deps",
4345
"@abseil-cpp//absl/cleanup",
@@ -50,10 +52,7 @@ pybind_extension(
5052
pybind_library(
5153
name = "constraint_solver_deps",
5254
srcs = ["constraint_solver.cc"],
53-
visibility = [
54-
"//ortools/constraint_solver/python:__pkg__",
55-
"//ortools/routing/python:__pkg__",
56-
],
55+
visibility = ["//ortools/routing/python:__pkg__"],
5756
deps = [
5857
":constraint_solver_doc",
5958
"//ortools/constraint_solver:assignment_cc_proto",
@@ -62,7 +61,6 @@ pybind_library(
6261
"//ortools/constraint_solver:reversible_engine",
6362
"//ortools/constraint_solver:search_limit_cc_proto",
6463
"//ortools/constraint_solver:solver_parameters_cc_proto",
65-
"//ortools/util:piecewise_linear_function",
6664
"//ortools/util:tuple_set",
6765
"//ortools/util/python:piecewise_linear_function_deps",
6866
"@abseil-cpp//absl/cleanup",

ortools/constraint_solver/samples/BUILD.bazel

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
load("@rules_cc//cc:cc_test.bzl", "cc_test")
1515
load("@rules_python//python:py_test.bzl", "py_test")
16+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_LINKOPTS", "ORTOOLS_TEST_COPTS")
1617

1718
cc_test(
1819
name = "cp_is_fun_cp_test",
1920
srcs = ["cp_is_fun_cp.cc"],
21+
copts = ORTOOLS_TEST_COPTS,
22+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2023
deps = [
2124
"//ortools/base",
2225
"//ortools/base:log_severity",
@@ -31,14 +34,14 @@ py_test(
3134
name = "cp_is_fun_cp_py3",
3235
srcs = ["cp_is_fun_cp.py"],
3336
main = "cp_is_fun_cp.py",
34-
deps = [
35-
"//ortools/constraint_solver/python:constraint_solver_py",
36-
],
37+
deps = ["//ortools/constraint_solver/python:constraint_solver_py"],
3738
)
3839

3940
cc_test(
4041
name = "minimal_jobshop_cp_test",
4142
srcs = ["minimal_jobshop_cp.cc"],
43+
copts = ORTOOLS_TEST_COPTS,
44+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
4245
deps = [
4346
"//ortools/base",
4447
"//ortools/base:log_severity",
@@ -51,6 +54,8 @@ cc_test(
5154
cc_test(
5255
name = "nqueens_cp_test",
5356
srcs = ["nqueens_cp.cc"],
57+
copts = ORTOOLS_TEST_COPTS,
58+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
5459
deps = [
5560
"//ortools/base",
5661
"//ortools/base:log_severity",
@@ -67,14 +72,14 @@ py_test(
6772
name = "nqueens_cp_py3",
6873
srcs = ["nqueens_cp.py"],
6974
main = "nqueens_cp.py",
70-
deps = [
71-
"//ortools/constraint_solver/python:constraint_solver_py",
72-
],
75+
deps = ["//ortools/constraint_solver/python:constraint_solver_py"],
7376
)
7477

7578
cc_test(
7679
name = "nurses_cp_test",
7780
srcs = ["nurses_cp.cc"],
81+
copts = ORTOOLS_TEST_COPTS,
82+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
7883
deps = [
7984
"//ortools/base",
8085
"//ortools/base:log_severity",
@@ -87,6 +92,8 @@ cc_test(
8792
cc_test(
8893
name = "rabbits_and_pheasants_cp_test",
8994
srcs = ["rabbits_and_pheasants_cp.cc"],
95+
copts = ORTOOLS_TEST_COPTS,
96+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
9097
deps = [
9198
"//ortools/base",
9299
"//ortools/base:log_severity",
@@ -99,6 +106,8 @@ cc_test(
99106
cc_test(
100107
name = "simple_cp_program_test",
101108
srcs = ["simple_cp_program.cc"],
109+
copts = ORTOOLS_TEST_COPTS,
110+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
102111
deps = [
103112
"//ortools/base",
104113
"//ortools/base:log_severity",
@@ -112,14 +121,14 @@ py_test(
112121
name = "simple_cp_program_py3",
113122
srcs = ["simple_cp_program.py"],
114123
main = "simple_cp_program.py",
115-
deps = [
116-
"//ortools/constraint_solver/python:constraint_solver_py",
117-
],
124+
deps = ["//ortools/constraint_solver/python:constraint_solver_py"],
118125
)
119126

120127
cc_test(
121128
name = "simple_ls_program_test",
122129
srcs = ["simple_ls_program.cc"],
130+
copts = ORTOOLS_TEST_COPTS,
131+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
123132
deps = [
124133
"//ortools/base",
125134
"//ortools/base:log_severity",

ortools/graph_base/samples/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
# limitations under the License.
1313

1414
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
15+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_COPTS", "ORTOOLS_DEFAULT_LINKOPTS")
1516
load("//tools/testing:bintest.bzl", "bintest")
1617

1718
package(default_visibility = ["//visibility:public"])
1819

1920
cc_binary(
2021
name = "bfs_directed",
2122
srcs = ["bfs_directed.cc"],
23+
copts = ORTOOLS_DEFAULT_COPTS,
24+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2225
deps = [
2326
"//ortools/base",
2427
"//ortools/graph_base:bfs",
@@ -38,6 +41,8 @@ bintest(
3841
cc_binary(
3942
name = "bfs_undirected",
4043
srcs = ["bfs_undirected.cc"],
44+
copts = ORTOOLS_DEFAULT_COPTS,
45+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
4146
deps = [
4247
"//ortools/base",
4348
"//ortools/graph_base:bfs",
@@ -57,6 +62,8 @@ bintest(
5762
cc_binary(
5863
name = "bfs_one_to_all",
5964
srcs = ["bfs_one_to_all.cc"],
65+
copts = ORTOOLS_DEFAULT_COPTS,
66+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
6067
deps = [
6168
"//ortools/base",
6269
"//ortools/graph_base:bfs",

ortools/gurobi/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# limitations under the License.
1313

1414
load("@rules_cc//cc:cc_library.bzl", "cc_library")
15+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_COPTS", "ORTOOLS_DEFAULT_LINKOPTS")
1516

1617
package(default_visibility = ["//visibility:public"])
1718

@@ -20,5 +21,7 @@ cc_library(
2021
testonly = True,
2122
srcs = ["gurobi_stdout_matchers.cc"],
2223
hdrs = ["gurobi_stdout_matchers.h"],
24+
copts = ORTOOLS_DEFAULT_COPTS,
25+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2326
deps = ["//ortools/base:gmock"],
2427
)

ortools/gurobi/isv_public/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
# limitations under the License.
1313

1414
load("@rules_cc//cc:cc_library.bzl", "cc_library")
15+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_COPTS", "ORTOOLS_DEFAULT_LINKOPTS")
1516

1617
package(default_visibility = ["//visibility:public"])
1718

1819
cc_library(
1920
name = "gurobi_isv",
2021
srcs = ["gurobi_isv.cc"],
2122
hdrs = ["gurobi_isv.h"],
23+
copts = ORTOOLS_DEFAULT_COPTS,
24+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2225
tags = [
2326
"not_build:arm",
2427
"not_run:arm",

ortools/java/com/google/ortools/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
1515
load("@rules_java//java:java_library.bzl", "java_library")
16+
load("//ortools/copts:configure_copts.bzl", "ORTOOLS_DEFAULT_COPTS", "ORTOOLS_DEFAULT_LINKOPTS")
1617

1718
# Utilities to load native libraries in java or-tools.
1819
cc_binary(
1920
name = "libjniortools.so",
21+
copts = ORTOOLS_DEFAULT_COPTS,
22+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
2023
linkshared = True,
2124
target_compatible_with = select({
2225
"@platforms//os:linux": [],
@@ -39,6 +42,8 @@ cc_binary(
3942

4043
cc_binary(
4144
name = "libjniortools.dylib",
45+
copts = ORTOOLS_DEFAULT_COPTS,
46+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
4247
linkshared = True,
4348
target_compatible_with = select({
4449
"@platforms//os:osx": [],
@@ -62,6 +67,8 @@ cc_binary(
6267

6368
cc_binary(
6469
name = "jniortools.dll",
70+
copts = ORTOOLS_DEFAULT_COPTS,
71+
linkopts = ORTOOLS_DEFAULT_LINKOPTS,
6572
linkshared = True,
6673
target_compatible_with = select({
6774
"@platforms//os:windows": [],

0 commit comments

Comments
 (0)