|
1 |
| -use cfg_aliases::cfg_aliases; |
2 |
| - |
3 | 1 | fn main() {
|
4 |
| - cfg_aliases! { |
5 |
| - http1: { feature = "http1" }, |
6 |
| - http2: { feature = "http2" }, |
7 |
| - |
8 |
| - client : { feature = "client" }, |
9 |
| - server : { feature = "server" }, |
10 |
| - |
11 |
| - ffi: { feature = "ffi" }, |
12 |
| - full: { feature = "full" }, |
13 |
| - nightly: { feature = "nightly" }, |
14 |
| - runtime: { feature = "runtime" }, |
15 |
| - tracing: { feature = "tracing" }, |
16 |
| - |
17 |
| - http_client: { all(any(http1, http2), client) }, |
18 |
| - http1_client: { all(http1, client) }, |
19 |
| - http2_client: { all(http2, client) }, |
20 |
| - |
21 |
| - http_server: { all(any(http1, http2), server) }, |
22 |
| - http1_server: { all(http1, server) }, |
23 |
| - http2_server: { all(http2, server) }, |
24 |
| - } |
| 2 | + // Add to the list of expected config names and values that is used when checking the reachable |
| 3 | + // cfg expressions with the unexpected_cfgs lint. |
| 4 | + // |
| 5 | + // See https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-check-cfg |
| 6 | + println!("cargo:rustc-check-cfg=cfg(http1)"); |
| 7 | + println!("cargo:rustc-check-cfg=cfg(http2)"); |
| 8 | + println!("cargo:rustc-check-cfg=cfg(client)"); |
| 9 | + println!("cargo:rustc-check-cfg=cfg(server)"); |
| 10 | + println!("cargo:rustc-check-cfg=cfg(ffi)"); |
| 11 | + println!("cargo:rustc-check-cfg=cfg(full)"); |
| 12 | + println!("cargo:rustc-check-cfg=cfg(nightly)"); |
| 13 | + println!("cargo:rustc-check-cfg=cfg(runtime)"); // TODO evaluate if this is needed (see below) |
| 14 | + println!("cargo:rustc-check-cfg=cfg(tracing)"); |
| 15 | + println!("cargo:rustc-check-cfg=cfg(http_client)"); |
| 16 | + println!("cargo:rustc-check-cfg=cfg(http1_client)"); |
| 17 | + println!("cargo:rustc-check-cfg=cfg(http2_client)"); |
| 18 | + println!("cargo:rustc-check-cfg=cfg(http_server)"); |
| 19 | + println!("cargo:rustc-check-cfg=cfg(http1_server)"); |
| 20 | + println!("cargo:rustc-check-cfg=cfg(http2_server)"); |
| 21 | + |
| 22 | + // Add cfg flags that simplify using cfg expressions in the code. e.g. instead of |
| 23 | + // `#[cfg(all(any(feature = "http1", feature = "http2"), feature = "server")]` you can use |
| 24 | + // `#[cfg(http_server)]` |
| 25 | + // |
| 26 | + // See https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-cfg |
| 27 | + #[cfg(feature = "http1")] |
| 28 | + println!("cargo:rustc-cfg=http1"); |
| 29 | + |
| 30 | + #[cfg(feature = "http2")] |
| 31 | + println!("cargo:rustc-cfg=http2"); |
| 32 | + |
| 33 | + #[cfg(any(feature = "http1", feature = "http2"))] |
| 34 | + println!("cargo:rustc-cfg=http"); |
| 35 | + |
| 36 | + #[cfg(feature = "client")] |
| 37 | + println!("cargo:rustc-cfg=client"); |
| 38 | + |
| 39 | + #[cfg(feature = "server")] |
| 40 | + println!("cargo:rustc-cfg=server"); |
| 41 | + |
| 42 | + #[cfg(feature = "ffi")] |
| 43 | + println!("cargo:rustc-cfg=ffi"); |
| 44 | + |
| 45 | + #[cfg(feature = "full")] |
| 46 | + println!("cargo:rustc-cfg=full"); |
| 47 | + |
| 48 | + #[cfg(feature = "nightly")] |
| 49 | + println!("cargo:rustc-cfg=nightly"); |
| 50 | + |
| 51 | + // TODO: this feature doesn't actually exist in the cargo.toml |
| 52 | + // this condition was added to simplify the conditions in src/mock.rs, but I'm not sure if those |
| 53 | + // conditions were actually working as intended |
| 54 | + // #[cfg(feature = "runtime")] |
| 55 | + // println!("cargo:rustc-cfg=runtime"); |
| 56 | + |
| 57 | + #[cfg(feature = "tracing")] |
| 58 | + println!("cargo:rustc-cfg=tracing"); |
| 59 | + |
| 60 | + #[cfg(all(any(feature = "http1", feature = "http2"), feature = "client"))] |
| 61 | + println!("cargo:rustc-cfg=http_client"); |
| 62 | + |
| 63 | + #[cfg(all(feature = "http1", feature = "client"))] |
| 64 | + println!("cargo:rustc-cfg=http1_client"); |
| 65 | + |
| 66 | + #[cfg(all(feature = "http2", feature = "client"))] |
| 67 | + println!("cargo:rustc-cfg=http2_client"); |
| 68 | + |
| 69 | + #[cfg(all(any(feature = "http1", feature = "http2"), feature = "server"))] |
| 70 | + println!("cargo:rustc-cfg=http_server"); |
| 71 | + |
| 72 | + #[cfg(all(feature = "http1", feature = "server"))] |
| 73 | + println!("cargo:rustc-cfg=http1_server"); |
| 74 | + |
| 75 | + #[cfg(all(feature = "http2", feature = "server"))] |
| 76 | + println!("cargo:rustc-cfg=http2_server"); |
25 | 77 | }
|
0 commit comments