diff options
author | Joel Galenson <jgalenson@google.com> | 2021-06-21 17:11:55 -0700 |
---|---|---|
committer | Joel Galenson <jgalenson@google.com> | 2021-06-21 17:26:52 -0700 |
commit | 2c22405ca1892f0aea3d123d3391034f9a383073 (patch) | |
tree | c139d6aabd0ebb3c9f2113026caa79251ce8463f /build.rs | |
parent | 6f65f18de43a918103ccec861094e1803552dd80 (diff) | |
download | grpcio-sys-2c22405ca1892f0aea3d123d3391034f9a383073.tar.gz |
Upgrade rust/crates/grpcio-sys to 0.9.0+1.38.0android-s-beta-4android-s-beta-3android-s-beta-4
Test: make
Change-Id: I216e32d09b497864276eaa4743f6c88722cebe14
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 49 |
1 files changed, 24 insertions, 25 deletions
@@ -1,6 +1,5 @@ // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. -use std::collections::HashSet; use std::env::VarError; use std::io::prelude::*; use std::io::BufReader; @@ -11,7 +10,24 @@ use cmake::Config as CmakeConfig; use pkg_config::{Config as PkgConfig, Library}; use walkdir::WalkDir; -const GRPC_VERSION: &str = "1.35.0"; +const GRPC_VERSION: &str = "1.38.0"; + +/// Following two arrays are generated by running pkg-config manually. We can +/// also choose to run pkg-config at build time, but it will requires pkg-config +/// in path, which is unfriendly for platforms like Windows. +// grpc_unsecure.pc is not accurate, see also grpc/grpc#24512. Should also include "address_sorting", "upb", "cares", "z". +#[rustfmt::skip] +const COMMON_DEPS: &[&str] = &[ + "absl_bad_optional_access", "absl_bad_variant_access", "absl_base", "absl_city", "absl_civil_time", + "absl_cord", "absl_debugging_internal", "absl_demangle_internal", "absl_exponential_biased", + "absl_graphcycles_internal", "absl_hash", "absl_hashtablez_sampler", "absl_int128", "absl_log_severity", + "absl_malloc_internal", "absl_raw_hash_set", "absl_raw_logging_internal", "absl_spinlock_wait", + "absl_stacktrace", "absl_status", "absl_statusor", "absl_str_format_internal", "absl_strings", + "absl_strings_internal", "absl_symbolize", "absl_synchronization", "absl_throw_delegate", "absl_time", + "absl_time_zone", "absl_wyhash", "address_sorting", "cares", "gpr", "upb", "z", +]; +const GRPC_DEPS: &[&str] = &["grpc", "re2"]; +const GRPC_UNSECURE_DEPS: &[&str] = &["grpc_unsecure"]; fn probe_library(library: &str, cargo_metadata: bool) -> Library { match PkgConfig::new() @@ -190,23 +206,12 @@ fn build_grpc(cc: &mut cc::Build, library: &str) { } } - let collect = |path, to: &mut HashSet<_>| { - let f = fs::File::open(format!("{}/libs/opt/pkgconfig/{}.pc", build_dir, path)).unwrap(); - for l in io::BufReader::new(f).lines() { - let l = l.unwrap(); - if l.starts_with("Libs: ") { - for lib in l.split_whitespace() { - if let Some(s) = lib.strip_prefix("-l") { - to.insert(s.to_string()); - } - } - } - } + let libs = if library.contains("unsecure") { + GRPC_UNSECURE_DEPS + } else { + GRPC_DEPS }; - let mut libs = HashSet::new(); - collect("gpr", &mut libs); - collect(library, &mut libs); - for l in libs { + for l in COMMON_DEPS.iter().chain(libs) { println!("cargo:rustc-link-lib=static={}", l); } @@ -217,12 +222,6 @@ fn build_grpc(cc: &mut cc::Build, library: &str) { println!("cargo:rustc-link-lib=static=ssl"); println!("cargo:rustc-link-lib=static=crypto"); } - } else { - // grpc_unsecure.pc is not accurate, see also grpc/grpc#24512. - println!("cargo:rustc-link-lib=static=upb"); - println!("cargo:rustc-link-lib=static=cares"); - println!("cargo:rustc-link-lib=static=z"); - println!("cargo:rustc-link-lib=static=address_sorting"); } cc.include("grpc/include"); @@ -299,7 +298,7 @@ fn get_env(name: &str) -> Option<String> { // Generate the bindings to grpc C-core. // Try to disable the generation of platform-related bindings. #[cfg(feature = "use-bindgen")] -fn bindgen_grpc(file_path: &PathBuf) { +fn bindgen_grpc(file_path: &Path) { // create a config to generate binding file let mut config = bindgen::Builder::default(); if cfg!(feature = "secure") { |