Merge pull request #368 from legrosbuffle/master
Bazel: Add optional support for GLPK.
This commit is contained in:
@@ -28,3 +28,11 @@ http_archive(
|
||||
strip_prefix = "protobuf-b4b0e304be5a68de3d0ee1af9b286f958750f5e4",
|
||||
sha256 = "ff771a662fb6bd4d3cc209bcccedef3e93980a49f71df1e987f6afa3bcdcba3a",
|
||||
)
|
||||
|
||||
new_http_archive(
|
||||
name = "glpk",
|
||||
url = "http://ftp.gnu.org/gnu/glpk/glpk-4.52.tar.gz",
|
||||
sha256 = "9a5dab356268b4f177c33e00ddf8164496dc2434e83bd1114147024df983a3bb",
|
||||
build_file = "../src/glpk.BUILD",
|
||||
)
|
||||
|
||||
|
||||
@@ -31,3 +31,10 @@ new_http_archive(
|
||||
build_file = "//bazel:gtest.BUILD",
|
||||
strip_prefix = "googletest-release-1.8.0/googletest",
|
||||
)
|
||||
|
||||
new_http_archive(
|
||||
name = "glpk",
|
||||
url = "http://ftp.gnu.org/gnu/glpk/glpk-4.52.tar.gz",
|
||||
sha256 = "9a5dab356268b4f177c33e00ddf8164496dc2434e83bd1114147024df983a3bb",
|
||||
build_file = "glpk.BUILD",
|
||||
)
|
||||
|
||||
29
src/glpk.BUILD
Normal file
29
src/glpk.BUILD
Normal file
@@ -0,0 +1,29 @@
|
||||
cc_library(
|
||||
name = "glpk",
|
||||
srcs = glob([
|
||||
"glpk-4.52/src/*.c",
|
||||
"glpk-4.52/src/*/*.c",
|
||||
"glpk-4.52/src/*.h",
|
||||
"glpk-4.52/src/*/*.h",
|
||||
]),
|
||||
hdrs = [
|
||||
"glpk-4.52/src/glpk.h",
|
||||
],
|
||||
copts = [
|
||||
"-Wno-error",
|
||||
"-w",
|
||||
"-Iexternal/glpk/glpk-4.52/src",
|
||||
"-Iexternal/glpk/glpk-4.52/src/amd",
|
||||
"-Iexternal/glpk/glpk-4.52/src/bflib",
|
||||
"-Iexternal/glpk/glpk-4.52/src/cglib",
|
||||
"-Iexternal/glpk/glpk-4.52/src/colamd",
|
||||
"-Iexternal/glpk/glpk-4.52/src/env",
|
||||
"-Iexternal/glpk/glpk-4.52/src/minisat",
|
||||
"-Iexternal/glpk/glpk-4.52/src/misc",
|
||||
"-Iexternal/glpk/glpk-4.52/src/proxy",
|
||||
"-Iexternal/glpk/glpk-4.52/src/zlib",
|
||||
"-DHAVE_ZLIB",
|
||||
],
|
||||
includes=["glpk-4.52/src"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -1,5 +1,12 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
# If you want to use the GLPK solver, build with '--define USE_GLPK=' (or add
|
||||
# it to your bazel.rc file). This will download, build and link to GLPK.
|
||||
config_setting(
|
||||
name = "with_glpk",
|
||||
values = { "define": "USE_GLPK=" }
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "linear_solver_proto",
|
||||
srcs = ["linear_solver.proto"],
|
||||
@@ -20,7 +27,10 @@ cc_library(
|
||||
"linear_solver.cc",
|
||||
"model_exporter.cc",
|
||||
"model_validator.cc",
|
||||
],
|
||||
] + select({
|
||||
":with_glpk": ["glpk_interface.cc"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
hdrs = [
|
||||
"glop_utils.h",
|
||||
"linear_expr.h",
|
||||
@@ -32,13 +42,21 @@ cc_library(
|
||||
"-DUSE_GLOP",
|
||||
"-DUSE_BOP",
|
||||
],
|
||||
defines = [
|
||||
"HAVE_CONFIG_H"
|
||||
] + select({
|
||||
":with_glpk": ["USE_GLPK"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":linear_solver_cc_proto",
|
||||
"//base:timer",
|
||||
"//base",
|
||||
"//base:file",
|
||||
"//base:hash",
|
||||
"//base:map_util",
|
||||
"//base:stl_util",
|
||||
"//base:random",
|
||||
"//bop:bop_parameters_cc_proto",
|
||||
"//bop:integral_solver",
|
||||
@@ -47,5 +65,9 @@ cc_library(
|
||||
"//lp_data",
|
||||
"//util:fp_utils",
|
||||
"//util:proto_tools",
|
||||
],
|
||||
] + select({
|
||||
":with_glpk": ["@glpk//:glpk"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
@@ -149,7 +149,6 @@
|
||||
#include "base/integral_types.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/timer.h"
|
||||
#include "glop/parameters.pb.h"
|
||||
#include "linear_solver/linear_expr.h"
|
||||
#include "linear_solver/linear_solver.pb.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user