mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
f2f02bf804
Summary: picking up from D37112756. given thrift library `foo`, where before we'd generate target `foo-rust` (containing a `types.rs` module) we now generate two targets, `foo-rust` & `foo-rust-types` where the `types.rs` module is in the latter crate which is depended upon by the former. the motivation is to enable greater build parallelism (see D37112756 for more). ## buck ### files and symlinks in buck-out/. single-file-thrift-library-foo multi-crate {F1041073024} multi-file-thrift-library-foo multi-crate {F1041073062} ## autocargo ### files in target/. single-file-thrift-library-foo multi-crate {F1041073095} multi-file-thrift-library-foo multi-crate {F1041073125} ## deployment plan - diff (1) land autocargo changes (D47342888) - will break autocargo workflows not using `arc` - diff (2) initiate an autocargo bump - https://www.internalfb.com/intern/msdk/bump/autocargo - diff (3) (D46573767 - this diff) rebase all remaining changes on (2) and land it - thrift compiler, compiler wrapper, rust thrift build defs - regenerated 'Cargo.toml', 'thrift_build.rs' and 'thrift_lib.rs' files - will break autocargo thrift builds (bad "thrift1"; invoking incompatible thrift compiler) - diff (4) initiate a thrift1 bump (now (3) has landed) and land it - https://www.internalfb.com/intern/msdk/bump/thrift1 Reviewed By: zertosh Differential Revision: D46573767 fbshipit-source-id: b2db8e3bf307a6498f92cdb8a64c26b8871a0a1d
70 lines
2.0 KiB
Rust
70 lines
2.0 KiB
Rust
// @generated by autocargo
|
|
use std::env;
|
|
use std::fs;
|
|
use std::path::Path;
|
|
|
|
use thrift_compiler::Config;
|
|
use thrift_compiler::GenContext;
|
|
|
|
#[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 = {
|
|
let mut conf = Config::from_env(GenContext::Lib).expect("Failed to instantiate thrift_compiler::Config");
|
|
|
|
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);
|
|
|
|
conf.types_crate("config_thrift__types");
|
|
|
|
let options = "";
|
|
if !options.is_empty() {
|
|
conf.options(options);
|
|
}
|
|
|
|
let lib_include_srcs = vec![
|
|
|
|
];
|
|
let types_include_srcs = vec![
|
|
|
|
];
|
|
conf.lib_include_srcs(lib_include_srcs);
|
|
conf.types_include_srcs(types_include_srcs);
|
|
|
|
conf
|
|
};
|
|
|
|
let srcs: &[&str] = &[
|
|
"eden_config.thrift"
|
|
];
|
|
conf.run(srcs).expect("Failed while running thrift compilation");
|
|
}
|