flatc/lib.rs
1//! Builds [flatbuffers] and provides the path to the built `flatc` in the
2//! public API. Typically meant to be used by build scripts, but can be useful
3//! otherwise if the project itself is using `flatc` during runtime.
4//!
5//! [flatbuffers]: https://github.com/google/flatbuffers
6
7#[forbid(unsafe_code)]
8
9/// Path of the built `flatc` executable.
10pub fn flatc() -> &'static std::path::Path {
11 if cfg!(windows) {
12 std::path::Path::new(concat!(env!("OUT_DIR"), "\\bin\\flatc.exe"))
13 } else {
14 std::path::Path::new(concat!(env!("OUT_DIR"), "/bin/flatc"))
15 }
16}
17
18#[test]
19fn flatc_exists() {
20 assert!(flatc().exists())
21}