The Rust language supports [conditional compilation](https://doc.rust-lang.org/reference/conditional-compilation.html) using attributes like `#[cfg(test)]`.
Rust also supports [build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) using a `build.rs` file to run code as part of the build process to prepare for compilation.

I would like to use conditional compilation in Rust code to conditionally compile depending on whether we're compiling for a build script, similar to how that is possible for `test` builds.

Imagine the following:

```rust
#[cfg(build)]
fn main() {
    // Part of build script
}

#[cfg(not(build))]
fn main() {
    // Not part of build script, probably regular build
}

```

This does not work, because `build` is not a valid identifier here.
Is it possible to do this using a different attribute, or could some other trick be used to achieve something similar?

---

For some context on this issue:  

My goal is to generate shell completion scripts through `clap` at compile time. I've quite a comprehensive `App` definition across multiple files in the application. I'd like to use this in `build.rs` by including these parts using the `include!(...)` macro (as [suggested](https://docs.rs/clap/2.32.0/clap/struct.App.html#examples-47) by `clap`), so I don't have to define `App` a second time. This pulls some dependencies with it, which I'd like to exclude when used by the `build.rs` file as they aren't needed in that case. [This](https://github.com/timvisee/ffsend/blob/f51bd673ff60f9403260702a90a4f192e6f93538/src/cmd/handler.rs#L51) is what I'm trying to make available in my `build.rs` script.