2022-02-08 17:06:23 +03:00
|
|
|
// @generated by autocargo
|
|
|
|
use std::env;
|
|
|
|
use std::fs;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
use thrift_compiler::Config;
|
2023-06-17 00:06:54 +03:00
|
|
|
use thrift_compiler::GenContext;
|
2022-02-08 17:06:23 +03:00
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn main() {
|
|
|
|
// Rerun if this gets rewritten.
|
|
|
|
println!("cargo:rerun-if-changed=thrift_build.rs");
|
|
|
|
|
|
|
|
let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided");
|
|
|
|
let out_dir: &Path = out_dir.as_ref();
|
|
|
|
fs::write(
|
|
|
|
out_dir.join("cratemap"),
|
|
|
|
"eden_config crate",
|
|
|
|
).expect("Failed to write cratemap");
|
|
|
|
|
|
|
|
let conf = {
|
2023-06-17 00:06:54 +03:00
|
|
|
let mut conf = Config::from_env(GenContext::Lib).expect("Failed to instantiate thrift_compiler::Config");
|
2022-02-08 17:06:23 +03:00
|
|
|
|
|
|
|
let path_from_manifest_to_base: &Path = "../../..".as_ref();
|
|
|
|
let cargo_manifest_dir =
|
|
|
|
env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not provided");
|
|
|
|
let cargo_manifest_dir: &Path = cargo_manifest_dir.as_ref();
|
|
|
|
let base_path = cargo_manifest_dir
|
|
|
|
.join(path_from_manifest_to_base)
|
|
|
|
.canonicalize()
|
|
|
|
.expect("Failed to canonicalize base_path");
|
|
|
|
// TODO: replace canonicalize() with std::path::absolute() when
|
|
|
|
// https://github.com/rust-lang/rust/pull/91673 is available (~Rust 1.60)
|
|
|
|
// and remove this block.
|
|
|
|
#[cfg(windows)]
|
|
|
|
let base_path = Path::new(
|
|
|
|
base_path
|
|
|
|
.as_path()
|
|
|
|
.to_string_lossy()
|
|
|
|
.trim_start_matches(r"\\?\"),
|
|
|
|
)
|
|
|
|
.to_path_buf();
|
|
|
|
|
|
|
|
conf.base_path(base_path);
|
|
|
|
|
2023-07-12 17:12:07 +03:00
|
|
|
conf.types_crate("config_thrift__types");
|
|
|
|
|
2023-09-06 20:12:37 +03:00
|
|
|
let options = "deprecated_default_enum_min_i32";
|
2022-02-08 17:06:23 +03:00
|
|
|
if !options.is_empty() {
|
|
|
|
conf.options(options);
|
|
|
|
}
|
|
|
|
|
2023-07-12 17:12:07 +03:00
|
|
|
let lib_include_srcs = vec![
|
|
|
|
|
|
|
|
];
|
|
|
|
let types_include_srcs = vec![
|
2022-02-08 17:06:23 +03:00
|
|
|
|
|
|
|
];
|
2023-07-12 17:12:07 +03:00
|
|
|
conf.lib_include_srcs(lib_include_srcs);
|
|
|
|
conf.types_include_srcs(types_include_srcs);
|
2022-02-08 17:06:23 +03:00
|
|
|
|
|
|
|
conf
|
|
|
|
};
|
|
|
|
|
2023-07-12 17:12:07 +03:00
|
|
|
let srcs: &[&str] = &[
|
|
|
|
"eden_config.thrift"
|
|
|
|
];
|
|
|
|
conf.run(srcs).expect("Failed while running thrift compilation");
|
2022-02-08 17:06:23 +03:00
|
|
|
}
|