-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare ORTools for static compilation in Rust #428
base: development
Are you sure you want to change the base?
Changes from 6 commits
22afe17
1126bf6
97b5a45
b7342ad
7d600f6
4fe56a9
ecf5b0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
common --enable_platform_specific_config | ||
|
||
build --incompatible_strict_action_env | ||
run --incompatible_strict_action_env | ||
test --incompatible_strict_action_env | ||
build:linux --cxxopt=-std=c++20 | ||
build:macos --cxxopt=-std=c++20 | ||
build:windows --cxxopt=-std:c++20 | ||
|
||
run --incompatible_strict_action_env --cxxopt=-std=c++20 | ||
test --incompatible_strict_action_env --cxxopt=-std=c++20 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,10 @@ google_or_tools_mac() | |
google_or_tools_linux() | ||
google_or_tools_windows() | ||
|
||
load("//library/ortools/cc:deps.bzl", "google_or_tools_mac", "google_or_tools_linux", "google_or_tools_windows") | ||
google_or_tools_mac() | ||
google_or_tools_linux() | ||
google_or_tools_windows() | ||
load("//library/ortools/cc:deps.bzl", "google_or_tools") | ||
google_or_tools() | ||
load("@com_google_protobuf//:protobuf_deps.bzl", google_or_tools_protobuf_deps = "protobuf_deps") | ||
google_or_tools_protobuf_deps() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or tools has its own protobuf dependencies |
||
|
||
# Load //tool/common | ||
load("//tool/common:deps.bzl", "vaticle_dependencies_ci_pip", vaticle_dependencies_tool_maven_artifacts = "maven_artifacts") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,51 +16,87 @@ | |
# | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") | ||
|
||
def build_file_content(lib): | ||
return """ | ||
cc_import( | ||
name = "lib", | ||
shared_library = "lib/{0}", | ||
visibility = ["//visibility:public"] | ||
) | ||
cc_library( | ||
name = "incl", | ||
hdrs = glob([ | ||
"include/ortools/**/*.h", | ||
"include/absl/**/*.h", | ||
"include/absl/**/*.inc", | ||
"include/google/protobuf/**/*.inc", | ||
"include/google/protobuf/**/*.h", | ||
]), | ||
strip_include_prefix = "include/", | ||
visibility = ["//visibility:public"] | ||
) | ||
""".format(lib) | ||
def google_or_tools(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# Abseil-cpp | ||
git_repository( | ||
name = "com_google_absl", | ||
tag = "20211102.0", | ||
remote = "https://github.com/abseil/abseil-cpp.git", | ||
) | ||
|
||
def google_or_tools_linux(): | ||
http_archive( | ||
name = "or_tools_linux", | ||
urls = ["https://github.com/google/or-tools/releases/download/v9.0/or-tools_debian-10_v9.0.9048.tar.gz"], | ||
strip_prefix = "or-tools_Debian-10-64bit_v9.0.9048/", | ||
sha256 = "063fb1d8765ae23b0bb25b9c561e904532713416fe0458f7db45a0f72190eb50", | ||
build_file_content = build_file_content("libortools.so") | ||
# Protobuf | ||
git_repository( | ||
name = "com_google_protobuf", | ||
tag = "v3.19.4", | ||
remote = "https://github.com/protocolbuffers/protobuf.git", | ||
) | ||
|
||
# ZLIB | ||
new_git_repository( | ||
name = "zlib", | ||
build_file = "@com_google_protobuf//:third_party/zlib.BUILD", | ||
tag = "v1.2.11", | ||
remote = "https://github.com/madler/zlib.git", | ||
) | ||
|
||
git_repository( | ||
name = "com_google_re2", | ||
patches = ["@com_google_ortools//bazel:re2.patch"], | ||
tag = "2022-02-01", | ||
remote = "https://github.com/google/re2.git", | ||
) | ||
|
||
git_repository( | ||
name = "com_google_googletest", | ||
tag = "release-1.11.0", | ||
remote = "https://github.com/google/googletest.git", | ||
) | ||
|
||
def google_or_tools_mac(): | ||
http_archive( | ||
name = "or_tools_mac", | ||
urls = ["https://github.com/google/or-tools/releases/download/v9.0/or-tools_MacOsX-11.2.3_v9.0.9048.tar.gz"], | ||
strip_prefix = "or-tools_MacOsX-11.2.3_v9.0.9048/", | ||
sha256 = "adf73a00d4ec49558b67be5ce3cfc8f30268da2253b35feb11d0d40700550bf6", | ||
build_file_content = build_file_content("libortools.dylib") | ||
name = "glpk", | ||
build_file = "//bazel:glpk.BUILD", | ||
sha256 = "4a1013eebb50f728fc601bdd833b0b2870333c3b3e5a816eeba921d95bec6f15", | ||
url = "http://ftp.gnu.org/gnu/glpk/glpk-5.0.tar.gz", | ||
) | ||
|
||
def google_or_tools_windows(): | ||
http_archive( | ||
name = "or_tools_windows", | ||
urls = ["https://github.com/google/or-tools/releases/download/v9.0/or-tools_VisualStudio2019-64bit_v9.0.9048.zip"], | ||
strip_prefix = "or-tools_VisualStudio2019-64bit_v9.0.9048/", | ||
sha256 = "1be7286e082ba346f8729a873c5fd85418ac2dc95b847d9baa5381c5ac5f5fd9", | ||
build_file_content = build_file_content("ortools.lib") | ||
name = "bliss", | ||
build_file = "@com_google_ortools//bazel:bliss.BUILD", | ||
patches = ["@com_google_ortools//bazel:bliss-0.73.patch"], | ||
sha256 = "f57bf32804140cad58b1240b804e0dbd68f7e6bf67eba8e0c0fa3a62fd7f0f84", | ||
url = "http://www.tcs.hut.fi/Software/bliss/bliss-0.73.zip", | ||
) | ||
|
||
new_git_repository( | ||
name = "scip", | ||
build_file = "@com_google_ortools//bazel:scip.BUILD", | ||
patches = ["@com_google_ortools//bazel:scip.patch"], | ||
patch_args = ["-p1"], | ||
tag = "v800", | ||
remote = "https://github.com/scipopt/scip.git", | ||
) | ||
|
||
# Eigen has no Bazel build. | ||
new_git_repository( | ||
name = "eigen", | ||
tag = "3.4.0", | ||
remote = "https://gitlab.com/libeigen/eigen.git", | ||
build_file_content = | ||
""" | ||
cc_library( | ||
name = 'eigen3', | ||
srcs = [], | ||
includes = ['.'], | ||
hdrs = glob(['Eigen/**']), | ||
visibility = ['//visibility:public'], | ||
) | ||
""" | ||
) | ||
|
||
git_repository( | ||
name = "com_google_ortools", | ||
remote = "https://github.com/google/or-tools.git", | ||
tag = "v9.3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we use a tag instead of |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,11 @@ using namespace std; | |
namespace operations_research { | ||
using MPSolverResultStatus = MPSolver::ResultStatus; | ||
|
||
std::unique_ptr<MPSolver> new_mpsolver() { | ||
std::unique_ptr<MPSolver> new_mpsolver_sat() { | ||
return std::unique_ptr<MPSolver>(MPSolver::CreateSolver("SAT")); | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expose the SAT interface explicitly |
||
} | ||
|
||
std::unique_ptr<MPSolver> new_mpsolver_scip() { | ||
return std::unique_ptr<MPSolver>(MPSolver::CreateSolver("SCIP")); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set different build flags per-host.
This is because OR-tools compilation requires C++20, and the flag to set this is different for windows MSVC compilers and non-MSVC compilers.
Note that this flag is another barrier to cross-compilation, if that ever comes back onto the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command basically is a note to bazel that it should should select platform-specific configurations according to the host platform