|
52 | 52 |
|
53 | 53 | from .utils import ARCH, write_info_bin, write_info_src
|
54 | 54 |
|
| 55 | +# Abseil libraries to link in the later stage |
| 56 | +ABSL_LIBS_EXT = "lib" if os.name == "nt" else "a" |
| 57 | +ABSL_LIBS = ( |
| 58 | + "absl_str_format_internal", |
| 59 | + "absl_strings", |
| 60 | + "absl_strings_internal", |
| 61 | + "absl_string_view", |
| 62 | + "absl_log_initialize", |
| 63 | + "absl_log_entry", |
| 64 | + "absl_log_flags", |
| 65 | + "absl_log_severity", |
| 66 | + "absl_log_internal_check_op", |
| 67 | + "absl_log_internal_conditions", |
| 68 | + "absl_log_internal_message", |
| 69 | + "absl_log_internal_nullguard", |
| 70 | + "absl_log_internal_proto", |
| 71 | + "absl_log_internal_format", |
| 72 | + "absl_log_internal_globals", |
| 73 | + "absl_log_internal_log_sink_set", |
| 74 | + "absl_log_sink", |
| 75 | + "absl_raw_logging_internal", |
| 76 | + "absl_log_globals", |
| 77 | + "utf8_validity", |
| 78 | + "absl_cord", |
| 79 | + "absl_cordz_info", |
| 80 | + "absl_cordz_handle", |
| 81 | + "absl_cordz_functions", |
| 82 | + "absl_cord_internal", |
| 83 | + "absl_crc_cord_state", |
| 84 | + "absl_crc32c", |
| 85 | + "absl_crc_internal", |
| 86 | + "absl_exponential_biased", |
| 87 | + "absl_synchronization", |
| 88 | + "absl_graphcycles_internal", |
| 89 | + "absl_kernel_timeout_internal", |
| 90 | + "absl_time", |
| 91 | + "absl_time_zone", |
| 92 | + "absl_int128", |
| 93 | + "absl_examine_stack", |
| 94 | + "absl_stacktrace", |
| 95 | + "absl_symbolize", |
| 96 | + "absl_demangle_internal", |
| 97 | + "absl_debugging_internal", |
| 98 | + "absl_malloc_internal", |
| 99 | + "absl_throw_delegate", |
| 100 | + "absl_strerror", |
| 101 | + "absl_raw_hash_set", |
| 102 | + "absl_hash", |
| 103 | + "absl_city", |
| 104 | + "absl_low_level_hash", |
| 105 | + "absl_base", |
| 106 | + "absl_spinlock_wait", |
| 107 | + "absl_status", |
| 108 | + "absl_statusor", |
| 109 | + "absl_bad_optional_access", |
| 110 | +) |
55 | 111 | # Load version information
|
56 | 112 | VERSION = [999, 0, 0, "a", 0]
|
57 | 113 | VERSION_TEXT = "999.0.0"
|
@@ -243,7 +299,17 @@ def _finalize_protobuf(self):
|
243 | 299 |
|
244 | 300 | self.log.info("Copying Protobuf libraries")
|
245 | 301 |
|
| 302 | + # load protobuf-related static libraries |
246 | 303 | libs = glob(os.path.join(self.with_protobuf_lib_dir, "libprotobuf*"))
|
| 304 | + |
| 305 | + # load absl-related static libraries |
| 306 | + libs += glob( |
| 307 | + os.path.join(self.with_protobuf_lib_dir, f"*absl_*.{ABSL_LIBS_EXT}") |
| 308 | + ) |
| 309 | + libs += glob( |
| 310 | + os.path.join(self.with_protobuf_lib_dir, f"*utf8_*.{ABSL_LIBS_EXT}") |
| 311 | + ) |
| 312 | + |
247 | 313 | for lib in libs:
|
248 | 314 | if os.path.isfile(lib):
|
249 | 315 | self.log.info("copying %s -> %s", lib, self._build_protobuf_lib_dir)
|
@@ -302,29 +368,25 @@ def run(self):
|
302 | 368 | disabled = [] # Extensions to be disabled
|
303 | 369 | for ext in self.extensions:
|
304 | 370 | # Add Protobuf include and library dirs
|
305 |
| - if ext.name == "_mysqlxpb": |
306 |
| - if not self.with_mysqlxpb_cext: |
307 |
| - self.log.warning("The '_mysqlxpb' C extension will not be built") |
308 |
| - disabled.append(ext) |
309 |
| - continue |
310 |
| - if platform.system() == "Darwin": |
311 |
| - symbol_file = tempfile.NamedTemporaryFile() |
312 |
| - ext.extra_link_args.extend( |
313 |
| - ["-exported_symbols_list", symbol_file.name] |
314 |
| - ) |
315 |
| - with open(symbol_file.name, "w") as fp: |
316 |
| - fp.write("_PyInit__mysqlxpb") |
317 |
| - fp.write("\n") |
318 |
| - ext.include_dirs.append(self.with_protobuf_include_dir) |
319 |
| - ext.library_dirs.append(self._build_protobuf_lib_dir) |
320 |
| - ext.libraries.append("libprotobuf" if os.name == "nt" else "protobuf") |
321 |
| - # Add -std=c++11 needed for Protobuf 3.6.1 |
322 |
| - ext.extra_compile_args.append("-std=c++11") |
323 |
| - self._run_protoc() |
324 |
| - |
325 |
| - if ext.name != "_mysqlxpb": |
| 371 | + if not self.with_mysqlxpb_cext: |
| 372 | + self.log.warning("The '_mysqlxpb' C extension will not be built") |
326 | 373 | disabled.append(ext)
|
327 | 374 | continue
|
| 375 | + if platform.system() == "Darwin": |
| 376 | + symbol_file = tempfile.NamedTemporaryFile() |
| 377 | + ext.extra_link_args.extend(["-exported_symbols_list", symbol_file.name]) |
| 378 | + with open(symbol_file.name, "w") as fp: |
| 379 | + fp.write("_PyInit__mysqlxpb") |
| 380 | + fp.write("\n") |
| 381 | + ext.include_dirs.append(self.with_protobuf_include_dir) |
| 382 | + ext.library_dirs.append(self._build_protobuf_lib_dir) |
| 383 | + ext.libraries.append("libprotobuf" if os.name == "nt" else "protobuf") |
| 384 | + ext.libraries.extend(ABSL_LIBS) |
| 385 | + |
| 386 | + if os.name != "nt": |
| 387 | + # Add -std=c++14 needed for Protobuf 4.25.3 |
| 388 | + ext.extra_compile_args.append("-std=c++14") |
| 389 | + self._run_protoc() |
328 | 390 |
|
329 | 391 | # Suppress unknown pragmas
|
330 | 392 | if os.name == "posix":
|
|
0 commit comments