Lines Matching +full:generate +full:- +full:env
1 // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
3 use std::env;
4 use std::env::VarError;
10 // Platform-Specific Instructions: Regenerating gRPC Bindings for Windows
12 // If you need to manually update the 'android/grpc-bindings.rs' file on Windows,
16 // - Download and install the pre-built LLVM binaries from:
18 // - Update the `LIBCLANG_PATH` environment variable to point to the 'bin'
22 // - Set the `GRPCIO_SYS_GRPC_INCLUDE_PATH` environment variable to the
26 // - Run the following Cargo command to regenerate the bindings:
27 // `cargo build --features _gen-bindings`
29 include!("../link-deps.rs");
31 fn get_env(name: &str) -> Option<String> { in get_env()
32 println!("cargo:rerun-if-env-changed={name}"); in get_env()
33 match env::var(name) { in get_env()
37 panic!("unrecognize env var of {name}: {:?}", s.to_string_lossy()); in get_env()
42 // Generate the bindings to grpc C-core.
43 // Try to disable the generation of platform-related bindings.
45 feature = "_gen-bindings",
52 // create a config to generate binding file in bindgen_grpc()
55 config = config.clang_arg("-DGRPC_SYS_SECURE"); in bindgen_grpc()
59 config = config.clang_arg("-D _WIN32_WINNT=0x600"); in bindgen_grpc()
84 println!("cargo:rerun-if-env-changed=TEST_BIND"); in bindgen_grpc()
85 let gen_tests = env::var("TEST_BIND").map_or(false, |s| s == "1"); in bindgen_grpc()
89 .clang_arg("-xc++") in bindgen_grpc()
90 .clang_arg("-I./grpc/include") in bindgen_grpc()
91 .clang_arg("-std=c++11") in bindgen_grpc()
119 cfg.generate() in bindgen_grpc()
120 .expect("Unable to generate grpc bindings") in bindgen_grpc()
126 // need to be updated by default unless the _gen-bindings feature is specified.
128 let target = env::var("TARGET").unwrap(); in config_binding_path()
130 "x86_64-unknown-linux-gnu" in config_binding_path()
131 | "x86_64-unknown-linux-musl" in config_binding_path()
132 | "aarch64-unknown-linux-musl" in config_binding_path()
133 | "aarch64-unknown-linux-gnu" in config_binding_path()
134 | "x86_64-apple-darwin" in config_binding_path()
135 | "aarch64-apple-darwin" => { in config_binding_path()
136 // Cargo treats nonexistent files changed, so we only emit the rerun-if-changed in config_binding_path()
137 // directive when we expect the target-specific pre-generated binding file to be in config_binding_path()
139 println!("cargo:rerun-if-changed=bindings/bindings.rs"); in config_binding_path()
141 PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) in config_binding_path()
145 _ => PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) in config_binding_path()
147 .join("grpc-bindings.rs"), in config_binding_path()
149 #[cfg(feature = "_gen-bindings")] in config_binding_path()
164 "cargo:rustc-env=BINDING_PATH={}", in config_binding_path()
170 println!("cargo:rerun-if-changed=grpc_wrap.cc"); in main()
171 println!("cargo:rerun-if-changed=grpc"); in main()