/
conanfile.py
184 lines (164 loc) · 9.24 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import os
from conans import ConanFile, CMake, tools
from shutil import copyfile
class GORTConan(ConanFile):
name = "ortools"
version = "8.0"
license = "Apache License 2.0"
url = "https://github.com/google/or-tools/"
description = "Google Optimization Tools"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake_find_package"
options = {
"shared": [True, False],
"fPIC": [True, False],
"BUILD_DEPS": [True, False],
"BUILD_ZLIB": [True, False],
"BUILD_absl": [True, False],
"BUILD_gflags": [True, False],
"BUILD_glog": [True, False],
"BUILD_Protobuf": [True, False],
"USE_SCIP": [True, False],
"BUILD_SCIP": [True, False],
"USE_COINOR": [True, False],
"BUILD_CoinUtils": [True, False],
"BUILD_Osi": [True, False],
"BUILD_Clp": [True, False],
"BUILD_Cgl": [True, False],
"BUILD_Cbc": [True, False],
"BUILD_SAMPLES": [True, False],
"BUILD_EXAMPLES": [True, False]
}
default_options = {
'shared': False,
'fPIC': True,
'BUILD_DEPS': False,
'BUILD_ZLIB': False,
'BUILD_absl': True,
'BUILD_gflags': False,
'BUILD_glog': False,
'BUILD_Protobuf': True,
'USE_SCIP': False,
'BUILD_SCIP': False,
'USE_COINOR': True,
'BUILD_CoinUtils': True,
'BUILD_Osi': True,
'BUILD_Clp': True,
'BUILD_Cgl': True,
'BUILD_Cbc': True,
'BUILD_SAMPLES': False,
'BUILD_EXAMPLES': False
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration(
"Shared build is not supported on Windows by upstream")
def requirements(self):
if not self.options.BUILD_ZLIB:
self.requires("zlib/1.2.11@")
if not self.options.BUILD_gflags:
self.requires("gflags/2.2.2@")
if not self.options.BUILD_glog:
self.requires("glog/0.4.0@")
@property
def _archive_url(self):
return "https://github.com/google/or-tools/archive/v%s.tar.gz" % self.version
@property
def source_subfolder(self):
return "or-tools"
def source(self):
if self.settings.os == "Windows":
tools.get(self._archive_url)
archive = "or-tools-{}".format(self.version)
os.rename(archive, self.source_subfolder)
# self.run("git clone https://github.com/google/or-tools")
# self.run("cd or-tools && git checkout tags/v%s -b v%s" %
# (self.version, self.version))
else:
# from https://developers.google.com/optimization/install/cpp/linux
url = "https://github.com/google/or-tools/releases/download/v%s/" % self.version
zip_file_name = "or-tools_Ubuntu-20.04_v8.0.8283.tar.gz"
tools.get(url + zip_file_name)
os.rename("or-tools_Ubuntu-20.04-64bit_v8.0.8283", "or-tools")
def build(self):
if self.settings.os == "Windows":
cmake = CMake(self)
cmake.definitions['BUILD_DEPS'] = "ON" if self.options.BUILD_DEPS else "OFF"
cmake.definitions['BUILD_ZLIB'] = "ON" if self.options.BUILD_ZLIB else "OFF"
cmake.definitions['BUILD_absl'] = "ON" if self.options.BUILD_absl else "OFF"
cmake.definitions['BUILD_gflags'] = "ON" if self.options.BUILD_gflags else "OFF"
cmake.definitions['BUILD_glog'] = "ON" if self.options.BUILD_glog else "OFF"
cmake.definitions['BUILD_Protobuf'] = "ON" if self.options.BUILD_Protobuf else "OFF"
cmake.definitions['USE_SCIP'] = "ON" if self.options.USE_SCIP else "OFF"
cmake.definitions['BUILD_SCIP'] = "ON" if self.options.BUILD_SCIP else "OFF"
cmake.definitions['USE_COINOR'] = "ON" if self.options.USE_COINOR else "OFF"
cmake.definitions['BUILD_CoinUtils'] = "ON" if self.options.BUILD_CoinUtils else "OFF"
cmake.definitions['BUILD_Osi'] = "ON" if self.options.BUILD_Osi else "OFF"
cmake.definitions['BUILD_Clp'] = "ON" if self.options.BUILD_Clp else "OFF"
cmake.definitions['BUILD_Cgl'] = "ON" if self.options.BUILD_Cgl else "OFF"
cmake.definitions['BUILD_Cbc'] = "ON" if self.options.BUILD_Cbc else "OFF"
cmake.definitions['BUILD_SAMPLES'] = "ON" if self.options.BUILD_SAMPLES else "OFF"
cmake.definitions['BUILD_EXAMPLES'] = "ON" if self.options.BUILD_EXAMPLES else "OFF"
cmake.configure()
cmake.build()
cmake.install()
else: # assume Linux or compatible
pass
def package(self):
if self.settings.os == "Windows":
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
else: # assume Linux or compatible
self.copy("LICENSE*", src="or-tools/", dst=".")
self.copy("*", src="or-tools/include", dst="include")
self.copy("*", src="or-tools/lib", dst="lib")
def package_info(self):
if self.settings.os == "Windows":
self.cpp_info.cxxflags = ["-DUSE_CBC",
"-DUSE_CLP", "-DUSE_BOP", "-DUSE_GLOP"]
self.cpp_info.cxxflags.append("/DNOMINMAX")
common_libs = ["CbcSolver", "Cbc", "OsiCbc", "Cgl", "ClpSolver", "Clp", "OsiClp", "Osi", "CoinUtils",
"absl_bad_any_cast_impl", "absl_bad_optional_access", "absl_bad_variant_access", "absl_base", "absl_city",
"absl_civil_time", "absl_cord", "absl_debugging_internal", "absl_demangle_internal",
"absl_examine_stack", "absl_exponential_biased", "absl_failure_signal_handler", "absl_flags", "absl_flags_config",
"absl_flags_internal", "absl_flags_marshalling", "absl_flags_parse", "absl_flags_program_name",
"absl_flags_usage", "absl_flags_usage_internal", "absl_graphcycles_internal", "absl_hash", "absl_hashtablez_sampler",
"absl_int128", "absl_leak_check", "absl_leak_check_disable", "absl_log_severity", "absl_malloc_internal",
"absl_random_distributions", "absl_random_internal_distribution_test_util", "absl_random_internal_pool_urbg",
"absl_random_internal_randen", "absl_random_internal_randen_hwaes", "absl_random_internal_randen_hwaes_impl",
"absl_random_internal_randen_slow", "absl_random_internal_seed_material", "absl_random_seed_gen_exception",
"absl_random_seed_sequences", "absl_raw_hash_set", "absl_raw_logging_internal", "absl_scoped_set_env",
"absl_spinlock_wait", "absl_stacktrace", "absl_status", "absl_str_format_internal", "absl_strings",
"absl_strings_internal", "absl_symbolize", "absl_synchronization", "absl_throw_delegate", "absl_time", "absl_time_zone",
"ortools"]
if self.options.BUILD_SCIP:
common_libs.append("libscip")
common_libs.append("shlwapi")
common_libs.append("psapi")
common_libs.append("ws2_32")
self.cpp_info.release.libs = common_libs.copy()
self.cpp_info.release.libs.extend([
"libprotobuf", "libprotobuf-lite", "libprotoc"
])
self.cpp_info.debug.libs = common_libs.copy()
self.cpp_info.debug.libs.extend([
"libprotobufd", "libprotobuf-lited", "libprotocd"
])
if self.options.BUILD_gflags:
self.cpp_info.release.libs.append("gflags_nothreads_static")
self.cpp_info.debug.libs.append(
"gflags_nothreads_static_debug")
if self.options.BUILD_glog:
self.cpp_info.release.libs.append("glog")
self.cpp_info.debug.libs.append("glogd")
if self.options.BUILD_ZLIB:
self.cpp_info.release.libs.append("zlib")
self.cpp_info.debug.libs.append("zlibd")
self.cpp_info.libs = self.cpp_info.debug.libs if self.settings.build_type == "Debug" else self.cpp_info.release.libs
else: # assume Linux or compatible
self.cpp_info.cxxflags = ["-DUSE_CBC",
"-DUSE_CLP", "-DUSE_BOP", "-DUSE_GLOP"]
self.cpp_info.libs = ["CbcSolver", "Cbc", "OsiCbc", "Cgl", "ClpSolver", "Clp", "OsiClp", "Osi", "CoinUtils", "absl_bad_any_cast_impl", "absl_bad_optional_access", "absl_bad_variant_access", "absl_base", "absl_city", "absl_civil_time", "absl_debugging_internal", "absl_demangle_internal", "absl_examine_stack", "absl_failure_signal_handler",
"absl_graphcycles_internal", "absl_hash", "absl_hashtablez_sampler", "absl_int128", "absl_leak_check", "absl_malloc_internal", "absl_raw_hash_set", "absl_spinlock_wait", "absl_stacktrace", "absl_str_format_internal", "absl_strings", "absl_strings_internal", "absl_symbolize", "absl_synchronization", "absl_throw_delegate", "absl_time", "absl_time_zone", "protobuf", "glog", "gflags", "ortools"]