From 741b04e40fc1c2bc470e1af973d7dccd948101e5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 26 Apr 2024 15:39:05 -0700 Subject: [PATCH] Update autocargo component on FBS:master Reviewed By: zertosh Differential Revision: D56655848 fbshipit-source-id: 3ff1c47bd562e6fa88e17432f1535dd7002044f5 --- .../annotation/all/clients/thrift_build.rs | 87 ++++++------------- .../rust/annotation/all/clients/thrift_lib.rs | 1 + .../rust/annotation/all/mocks/thrift_build.rs | 87 ++++++------------- .../rust/annotation/all/mocks/thrift_lib.rs | 1 + .../annotation/all/services/thrift_build.rs | 87 ++++++------------- .../annotation/all/services/thrift_lib.rs | 1 + .../lib/rust/annotation/all/thrift_build.rs | 87 ++++++------------- thrift/lib/rust/annotation/all/thrift_lib.rs | 1 + .../annotation/compat/clients/thrift_build.rs | 80 +++++------------ .../annotation/compat/clients/thrift_lib.rs | 1 + .../annotation/compat/mocks/thrift_build.rs | 80 +++++------------ .../annotation/compat/mocks/thrift_lib.rs | 1 + .../compat/services/thrift_build.rs | 80 +++++------------ .../annotation/compat/services/thrift_lib.rs | 1 + .../rust/annotation/compat/thrift_build.rs | 80 +++++------------ .../lib/rust/annotation/compat/thrift_lib.rs | 1 + .../annotation/cpp/clients/thrift_build.rs | 82 ++++++----------- .../rust/annotation/cpp/clients/thrift_lib.rs | 1 + .../rust/annotation/cpp/mocks/thrift_build.rs | 82 ++++++----------- .../rust/annotation/cpp/mocks/thrift_lib.rs | 1 + .../annotation/cpp/services/thrift_build.rs | 82 ++++++----------- .../annotation/cpp/services/thrift_lib.rs | 1 + .../lib/rust/annotation/cpp/thrift_build.rs | 82 ++++++----------- thrift/lib/rust/annotation/cpp/thrift_lib.rs | 1 + .../annotation/go/clients/thrift_build.rs | 79 +++++------------ .../rust/annotation/go/clients/thrift_lib.rs | 1 + .../rust/annotation/go/mocks/thrift_build.rs | 79 +++++------------ .../rust/annotation/go/mocks/thrift_lib.rs | 1 + .../annotation/go/services/thrift_build.rs | 79 +++++------------ .../rust/annotation/go/services/thrift_lib.rs | 1 + thrift/lib/rust/annotation/go/thrift_build.rs | 79 +++++------------ thrift/lib/rust/annotation/go/thrift_lib.rs | 1 + .../annotation/hack/clients/thrift_build.rs | 79 +++++------------ .../annotation/hack/clients/thrift_lib.rs | 1 + .../annotation/hack/mocks/thrift_build.rs | 79 +++++------------ .../rust/annotation/hack/mocks/thrift_lib.rs | 1 + .../annotation/hack/services/thrift_build.rs | 79 +++++------------ .../annotation/hack/services/thrift_lib.rs | 1 + .../lib/rust/annotation/hack/thrift_build.rs | 79 +++++------------ thrift/lib/rust/annotation/hack/thrift_lib.rs | 1 + .../annotation/java/clients/thrift_build.rs | 79 +++++------------ .../annotation/java/clients/thrift_lib.rs | 1 + .../annotation/java/mocks/thrift_build.rs | 79 +++++------------ .../rust/annotation/java/mocks/thrift_lib.rs | 1 + .../annotation/java/services/thrift_build.rs | 79 +++++------------ .../annotation/java/services/thrift_lib.rs | 1 + .../lib/rust/annotation/java/thrift_build.rs | 79 +++++------------ thrift/lib/rust/annotation/java/thrift_lib.rs | 1 + .../annotation/python/clients/thrift_build.rs | 79 +++++------------ .../annotation/python/clients/thrift_lib.rs | 1 + .../annotation/python/mocks/thrift_build.rs | 79 +++++------------ .../annotation/python/mocks/thrift_lib.rs | 1 + .../python/services/thrift_build.rs | 79 +++++------------ .../annotation/python/services/thrift_lib.rs | 1 + .../rust/annotation/python/thrift_build.rs | 79 +++++------------ .../lib/rust/annotation/python/thrift_lib.rs | 1 + .../annotation/rust/clients/thrift_build.rs | 79 +++++------------ .../annotation/rust/clients/thrift_lib.rs | 1 + .../annotation/rust/mocks/thrift_build.rs | 79 +++++------------ .../rust/annotation/rust/mocks/thrift_lib.rs | 1 + .../annotation/rust/services/thrift_build.rs | 79 +++++------------ .../annotation/rust/services/thrift_lib.rs | 1 + .../lib/rust/annotation/rust/thrift_build.rs | 79 +++++------------ thrift/lib/rust/annotation/rust/thrift_lib.rs | 1 + .../annotation/scope/clients/thrift_build.rs | 77 +++++----------- .../annotation/scope/clients/thrift_lib.rs | 1 + .../annotation/scope/mocks/thrift_build.rs | 77 +++++----------- .../rust/annotation/scope/mocks/thrift_lib.rs | 1 + .../annotation/scope/services/thrift_build.rs | 77 +++++----------- .../annotation/scope/services/thrift_lib.rs | 1 + .../lib/rust/annotation/scope/thrift_build.rs | 77 +++++----------- .../lib/rust/annotation/scope/thrift_lib.rs | 1 + .../annotation/thrift/clients/thrift_build.rs | 79 +++++------------ .../annotation/thrift/clients/thrift_lib.rs | 1 + .../annotation/thrift/mocks/thrift_build.rs | 79 +++++------------ .../annotation/thrift/mocks/thrift_lib.rs | 1 + .../thrift/services/thrift_build.rs | 79 +++++------------ .../annotation/thrift/services/thrift_lib.rs | 1 + .../rust/annotation/thrift/thrift_build.rs | 79 +++++------------ .../lib/rust/annotation/thrift/thrift_lib.rs | 1 + .../src/tests/clients/thrift_build.rs | 77 +++++----------- .../src/tests/clients/thrift_lib.rs | 1 + .../src/tests/mocks/thrift_build.rs | 77 +++++----------- .../src/tests/mocks/thrift_lib.rs | 1 + .../src/tests/services/thrift_build.rs | 77 +++++----------- .../src/tests/services/thrift_lib.rs | 1 + .../src/tests/thrift_build.rs | 77 +++++----------- .../src/tests/thrift_lib.rs | 1 + .../cargo_thrift/clients/thrift_build.rs | 78 +++++------------ .../cargo_thrift/clients/thrift_lib.rs | 1 + .../cargo_thrift/mocks/thrift_build.rs | 78 +++++------------ .../cargo_thrift/mocks/thrift_lib.rs | 1 + .../cargo_thrift/services/thrift_build.rs | 78 +++++------------ .../cargo_thrift/services/thrift_lib.rs | 1 + .../dep_tests/cargo_thrift/thrift_build.rs | 78 +++++------------ .../src/dep_tests/cargo_thrift/thrift_lib.rs | 1 + .../src/dep_tests/clients/thrift_build.rs | 78 +++++------------ .../rust/src/dep_tests/clients/thrift_lib.rs | 1 + .../rust/src/dep_tests/mocks/thrift_build.rs | 78 +++++------------ .../rust/src/dep_tests/mocks/thrift_lib.rs | 1 + .../src/dep_tests/services/thrift_build.rs | 78 +++++------------ .../rust/src/dep_tests/services/thrift_lib.rs | 1 + thrift/lib/rust/src/dep_tests/thrift_build.rs | 78 +++++------------ thrift/lib/rust/src/dep_tests/thrift_lib.rs | 1 + 104 files changed, 1268 insertions(+), 2916 deletions(-) diff --git a/thrift/lib/rust/annotation/all/clients/thrift_build.rs b/thrift/lib/rust/annotation/all/clients/thrift_build.rs index 9c403b7475d..765a68f9485 100644 --- a/thrift/lib/rust/annotation/all/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/all/clients/thrift_build.rs @@ -1,21 +1,12 @@ // @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"), - "annotation annotations //thrift/facebook/erlang:annotations-rust +const CRATEMAP: &str = "\ +annotation annotations //thrift/facebook/erlang:annotations-rust compat compat //thrift/annotation:compat-rust cpp cpp //thrift/annotation:cpp-rust go go //thrift/annotation:go-rust @@ -25,53 +16,29 @@ java java //thrift/annotation:java-rust python python //thrift/annotation:python-rust rust rust //thrift/annotation:rust-rust scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("all__types"); - conf.clients_crate("all__clients"); - conf.services_crate("all__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - - ]; +thrift thrift //thrift/annotation:thrift-rust +"; +#[rustfmt::skip] +fn main() { + println!("cargo:rerun-if-changed=thrift_build.rs"); + let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("all__types"); + conf.clients_crate("all__clients"); + conf.services_crate("all__services"); + let srcs = &[]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/all/clients/thrift_lib.rs b/thrift/lib/rust/annotation/all/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/all/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/all/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/all/mocks/thrift_build.rs b/thrift/lib/rust/annotation/all/mocks/thrift_build.rs index d7a5415d268..117a0b00917 100644 --- a/thrift/lib/rust/annotation/all/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/all/mocks/thrift_build.rs @@ -1,21 +1,12 @@ // @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"), - "annotation annotations //thrift/facebook/erlang:annotations-rust +const CRATEMAP: &str = "\ +annotation annotations //thrift/facebook/erlang:annotations-rust compat compat //thrift/annotation:compat-rust cpp cpp //thrift/annotation:cpp-rust go go //thrift/annotation:go-rust @@ -25,53 +16,29 @@ java java //thrift/annotation:java-rust python python //thrift/annotation:python-rust rust rust //thrift/annotation:rust-rust scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("all__types"); - conf.clients_crate("all__clients"); - conf.services_crate("all__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - - ]; +thrift thrift //thrift/annotation:thrift-rust +"; +#[rustfmt::skip] +fn main() { + println!("cargo:rerun-if-changed=thrift_build.rs"); + let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("all__types"); + conf.clients_crate("all__clients"); + conf.services_crate("all__services"); + let srcs = &[]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/all/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/all/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/all/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/all/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/all/services/thrift_build.rs b/thrift/lib/rust/annotation/all/services/thrift_build.rs index e02d9435e12..cbd24f02156 100644 --- a/thrift/lib/rust/annotation/all/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/all/services/thrift_build.rs @@ -1,21 +1,12 @@ // @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"), - "annotation annotations //thrift/facebook/erlang:annotations-rust +const CRATEMAP: &str = "\ +annotation annotations //thrift/facebook/erlang:annotations-rust compat compat //thrift/annotation:compat-rust cpp cpp //thrift/annotation:cpp-rust go go //thrift/annotation:go-rust @@ -25,53 +16,29 @@ java java //thrift/annotation:java-rust python python //thrift/annotation:python-rust rust rust //thrift/annotation:rust-rust scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("all__types"); - conf.clients_crate("all__clients"); - conf.services_crate("all__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - - ]; +thrift thrift //thrift/annotation:thrift-rust +"; +#[rustfmt::skip] +fn main() { + println!("cargo:rerun-if-changed=thrift_build.rs"); + let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("all__types"); + conf.clients_crate("all__clients"); + conf.services_crate("all__services"); + let srcs = &[]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/all/services/thrift_lib.rs b/thrift/lib/rust/annotation/all/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/all/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/all/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/all/thrift_build.rs b/thrift/lib/rust/annotation/all/thrift_build.rs index d4ac69b179f..8402cee1cdf 100644 --- a/thrift/lib/rust/annotation/all/thrift_build.rs +++ b/thrift/lib/rust/annotation/all/thrift_build.rs @@ -1,21 +1,12 @@ // @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"), - "annotation annotations //thrift/facebook/erlang:annotations-rust +const CRATEMAP: &str = "\ +annotation annotations //thrift/facebook/erlang:annotations-rust compat compat //thrift/annotation:compat-rust cpp cpp //thrift/annotation:cpp-rust go go //thrift/annotation:go-rust @@ -25,53 +16,29 @@ java java //thrift/annotation:java-rust python python //thrift/annotation:python-rust rust rust //thrift/annotation:rust-rust scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("all__types"); - conf.clients_crate("all__clients"); - conf.services_crate("all__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - - ]; +thrift thrift //thrift/annotation:thrift-rust +"; +#[rustfmt::skip] +fn main() { + println!("cargo:rerun-if-changed=thrift_build.rs"); + let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("all__types"); + conf.clients_crate("all__clients"); + conf.services_crate("all__services"); + let srcs = &[]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/all/thrift_lib.rs b/thrift/lib/rust/annotation/all/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/all/thrift_lib.rs +++ b/thrift/lib/rust/annotation/all/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/compat/clients/thrift_build.rs b/thrift/lib/rust/annotation/compat/clients/thrift_build.rs index 2d65826851b..c2a9cd580b0 100644 --- a/thrift/lib/rust/annotation/compat/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/compat/clients/thrift_build.rs @@ -1,68 +1,36 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +compat crate //thrift/annotation:compat-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "compat crate //thrift/annotation:compat-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("compat__types"); - conf.clients_crate("compat__clients"); - conf.services_crate("compat__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/compat.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("compat__types"); + conf.clients_crate("compat__clients"); + conf.services_crate("compat__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../../annotation/compat.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/compat/clients/thrift_lib.rs b/thrift/lib/rust/annotation/compat/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/compat/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/compat/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/compat/mocks/thrift_build.rs b/thrift/lib/rust/annotation/compat/mocks/thrift_build.rs index aa4ab0ffb02..f87ea9fc744 100644 --- a/thrift/lib/rust/annotation/compat/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/compat/mocks/thrift_build.rs @@ -1,68 +1,36 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +compat crate //thrift/annotation:compat-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "compat crate //thrift/annotation:compat-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("compat__types"); - conf.clients_crate("compat__clients"); - conf.services_crate("compat__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/compat.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("compat__types"); + conf.clients_crate("compat__clients"); + conf.services_crate("compat__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../../annotation/compat.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/compat/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/compat/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/compat/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/compat/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/compat/services/thrift_build.rs b/thrift/lib/rust/annotation/compat/services/thrift_build.rs index 27f8c968d5b..b19a0146e29 100644 --- a/thrift/lib/rust/annotation/compat/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/compat/services/thrift_build.rs @@ -1,68 +1,36 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +compat crate //thrift/annotation:compat-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "compat crate //thrift/annotation:compat-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("compat__types"); - conf.clients_crate("compat__clients"); - conf.services_crate("compat__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/compat.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("compat__types"); + conf.clients_crate("compat__clients"); + conf.services_crate("compat__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../../annotation/compat.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/compat/services/thrift_lib.rs b/thrift/lib/rust/annotation/compat/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/compat/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/compat/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/compat/thrift_build.rs b/thrift/lib/rust/annotation/compat/thrift_build.rs index fcc6e887bf6..095300f3d0a 100644 --- a/thrift/lib/rust/annotation/compat/thrift_build.rs +++ b/thrift/lib/rust/annotation/compat/thrift_build.rs @@ -1,68 +1,36 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +compat crate //thrift/annotation:compat-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "compat crate //thrift/annotation:compat-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("compat__types"); - conf.clients_crate("compat__clients"); - conf.services_crate("compat__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/compat.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("compat__types"); + conf.clients_crate("compat__clients"); + conf.services_crate("compat__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../annotation/compat.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/compat/thrift_lib.rs b/thrift/lib/rust/annotation/compat/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/compat/thrift_lib.rs +++ b/thrift/lib/rust/annotation/compat/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/cpp/clients/thrift_build.rs b/thrift/lib/rust/annotation/cpp/clients/thrift_build.rs index de328ab9286..46893452b1f 100644 --- a/thrift/lib/rust/annotation/cpp/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/cpp/clients/thrift_build.rs @@ -1,69 +1,37 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +cpp crate //thrift/annotation:cpp-rust +scope scope //thrift/annotation:scope-rust +thrift thrift //thrift/annotation:thrift-rust +"; #[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"), - "cpp crate //thrift/annotation:cpp-rust -scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("cpp__types"); - conf.clients_crate("cpp__clients"); - conf.services_crate("cpp__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/cpp.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("cpp__types"); + conf.clients_crate("cpp__clients"); + conf.services_crate("cpp__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../../annotation/cpp.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/cpp/clients/thrift_lib.rs b/thrift/lib/rust/annotation/cpp/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/cpp/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/cpp/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/cpp/mocks/thrift_build.rs b/thrift/lib/rust/annotation/cpp/mocks/thrift_build.rs index 697f1f15ec2..7c7ef7700bf 100644 --- a/thrift/lib/rust/annotation/cpp/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/cpp/mocks/thrift_build.rs @@ -1,69 +1,37 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +cpp crate //thrift/annotation:cpp-rust +scope scope //thrift/annotation:scope-rust +thrift thrift //thrift/annotation:thrift-rust +"; #[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"), - "cpp crate //thrift/annotation:cpp-rust -scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("cpp__types"); - conf.clients_crate("cpp__clients"); - conf.services_crate("cpp__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/cpp.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("cpp__types"); + conf.clients_crate("cpp__clients"); + conf.services_crate("cpp__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../../annotation/cpp.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/cpp/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/cpp/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/cpp/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/cpp/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/cpp/services/thrift_build.rs b/thrift/lib/rust/annotation/cpp/services/thrift_build.rs index ff797715062..44651e71aff 100644 --- a/thrift/lib/rust/annotation/cpp/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/cpp/services/thrift_build.rs @@ -1,69 +1,37 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +cpp crate //thrift/annotation:cpp-rust +scope scope //thrift/annotation:scope-rust +thrift thrift //thrift/annotation:thrift-rust +"; #[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"), - "cpp crate //thrift/annotation:cpp-rust -scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("cpp__types"); - conf.clients_crate("cpp__clients"); - conf.services_crate("cpp__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/cpp.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("cpp__types"); + conf.clients_crate("cpp__clients"); + conf.services_crate("cpp__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../../annotation/cpp.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/cpp/services/thrift_lib.rs b/thrift/lib/rust/annotation/cpp/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/cpp/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/cpp/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/cpp/thrift_build.rs b/thrift/lib/rust/annotation/cpp/thrift_build.rs index 30883a208dd..8c952b94089 100644 --- a/thrift/lib/rust/annotation/cpp/thrift_build.rs +++ b/thrift/lib/rust/annotation/cpp/thrift_build.rs @@ -1,69 +1,37 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +cpp crate //thrift/annotation:cpp-rust +scope scope //thrift/annotation:scope-rust +thrift thrift //thrift/annotation:thrift-rust +"; #[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"), - "cpp crate //thrift/annotation:cpp-rust -scope scope //thrift/annotation:scope-rust -thrift thrift //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("cpp__types"); - conf.clients_crate("cpp__clients"); - conf.services_crate("cpp__services"); - - let options = "deprecated_default_enum_min_i32"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/cpp.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("cpp__types"); + conf.clients_crate("cpp__clients"); + conf.services_crate("cpp__services"); + conf.options("deprecated_default_enum_min_i32"); + let srcs = &["../../../../annotation/cpp.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/cpp/thrift_lib.rs b/thrift/lib/rust/annotation/cpp/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/cpp/thrift_lib.rs +++ b/thrift/lib/rust/annotation/cpp/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/go/clients/thrift_build.rs b/thrift/lib/rust/annotation/go/clients/thrift_build.rs index c6f1619c0d0..fc841ace84e 100644 --- a/thrift/lib/rust/annotation/go/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/go/clients/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +go crate //thrift/annotation:go-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "go crate //thrift/annotation:go-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("go__types"); - conf.clients_crate("go__clients"); - conf.services_crate("go__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/go.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("go__types"); + conf.clients_crate("go__clients"); + conf.services_crate("go__services"); + let srcs = &["../../../../../annotation/go.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/go/clients/thrift_lib.rs b/thrift/lib/rust/annotation/go/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/go/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/go/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/go/mocks/thrift_build.rs b/thrift/lib/rust/annotation/go/mocks/thrift_build.rs index 1df7619577a..b9b5e9efcb7 100644 --- a/thrift/lib/rust/annotation/go/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/go/mocks/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +go crate //thrift/annotation:go-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "go crate //thrift/annotation:go-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("go__types"); - conf.clients_crate("go__clients"); - conf.services_crate("go__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/go.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("go__types"); + conf.clients_crate("go__clients"); + conf.services_crate("go__services"); + let srcs = &["../../../../../annotation/go.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/go/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/go/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/go/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/go/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/go/services/thrift_build.rs b/thrift/lib/rust/annotation/go/services/thrift_build.rs index eaeab2956e5..c155d36957e 100644 --- a/thrift/lib/rust/annotation/go/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/go/services/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +go crate //thrift/annotation:go-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "go crate //thrift/annotation:go-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("go__types"); - conf.clients_crate("go__clients"); - conf.services_crate("go__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/go.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("go__types"); + conf.clients_crate("go__clients"); + conf.services_crate("go__services"); + let srcs = &["../../../../../annotation/go.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/go/services/thrift_lib.rs b/thrift/lib/rust/annotation/go/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/go/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/go/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/go/thrift_build.rs b/thrift/lib/rust/annotation/go/thrift_build.rs index bbb6c7b1e19..e0cce57027e 100644 --- a/thrift/lib/rust/annotation/go/thrift_build.rs +++ b/thrift/lib/rust/annotation/go/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +go crate //thrift/annotation:go-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "go crate //thrift/annotation:go-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("go__types"); - conf.clients_crate("go__clients"); - conf.services_crate("go__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/go.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("go__types"); + conf.clients_crate("go__clients"); + conf.services_crate("go__services"); + let srcs = &["../../../../annotation/go.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/go/thrift_lib.rs b/thrift/lib/rust/annotation/go/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/go/thrift_lib.rs +++ b/thrift/lib/rust/annotation/go/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/hack/clients/thrift_build.rs b/thrift/lib/rust/annotation/hack/clients/thrift_build.rs index b17efc373c6..1a4b4ab2333 100644 --- a/thrift/lib/rust/annotation/hack/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/hack/clients/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +hack crate //thrift/annotation:hack-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "hack crate //thrift/annotation:hack-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("hack__types"); - conf.clients_crate("hack__clients"); - conf.services_crate("hack__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/hack.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("hack__types"); + conf.clients_crate("hack__clients"); + conf.services_crate("hack__services"); + let srcs = &["../../../../../annotation/hack.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/hack/clients/thrift_lib.rs b/thrift/lib/rust/annotation/hack/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/hack/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/hack/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/hack/mocks/thrift_build.rs b/thrift/lib/rust/annotation/hack/mocks/thrift_build.rs index 2ec7390b1d5..0ce1df27503 100644 --- a/thrift/lib/rust/annotation/hack/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/hack/mocks/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +hack crate //thrift/annotation:hack-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "hack crate //thrift/annotation:hack-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("hack__types"); - conf.clients_crate("hack__clients"); - conf.services_crate("hack__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/hack.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("hack__types"); + conf.clients_crate("hack__clients"); + conf.services_crate("hack__services"); + let srcs = &["../../../../../annotation/hack.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/hack/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/hack/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/hack/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/hack/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/hack/services/thrift_build.rs b/thrift/lib/rust/annotation/hack/services/thrift_build.rs index 07612031bad..825e5afa3ff 100644 --- a/thrift/lib/rust/annotation/hack/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/hack/services/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +hack crate //thrift/annotation:hack-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "hack crate //thrift/annotation:hack-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("hack__types"); - conf.clients_crate("hack__clients"); - conf.services_crate("hack__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/hack.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("hack__types"); + conf.clients_crate("hack__clients"); + conf.services_crate("hack__services"); + let srcs = &["../../../../../annotation/hack.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/hack/services/thrift_lib.rs b/thrift/lib/rust/annotation/hack/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/hack/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/hack/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/hack/thrift_build.rs b/thrift/lib/rust/annotation/hack/thrift_build.rs index b45ddb2ea28..cb4a98570ea 100644 --- a/thrift/lib/rust/annotation/hack/thrift_build.rs +++ b/thrift/lib/rust/annotation/hack/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +hack crate //thrift/annotation:hack-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "hack crate //thrift/annotation:hack-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("hack__types"); - conf.clients_crate("hack__clients"); - conf.services_crate("hack__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/hack.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("hack__types"); + conf.clients_crate("hack__clients"); + conf.services_crate("hack__services"); + let srcs = &["../../../../annotation/hack.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/hack/thrift_lib.rs b/thrift/lib/rust/annotation/hack/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/hack/thrift_lib.rs +++ b/thrift/lib/rust/annotation/hack/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/java/clients/thrift_build.rs b/thrift/lib/rust/annotation/java/clients/thrift_build.rs index e2d47e74c7f..0ec87e28e1e 100644 --- a/thrift/lib/rust/annotation/java/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/java/clients/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +java crate //thrift/annotation:java-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "java crate //thrift/annotation:java-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("java__types"); - conf.clients_crate("java__clients"); - conf.services_crate("java__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/java.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("java__types"); + conf.clients_crate("java__clients"); + conf.services_crate("java__services"); + let srcs = &["../../../../../annotation/java.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/java/clients/thrift_lib.rs b/thrift/lib/rust/annotation/java/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/java/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/java/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/java/mocks/thrift_build.rs b/thrift/lib/rust/annotation/java/mocks/thrift_build.rs index 4988c882183..8e52e4f5832 100644 --- a/thrift/lib/rust/annotation/java/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/java/mocks/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +java crate //thrift/annotation:java-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "java crate //thrift/annotation:java-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("java__types"); - conf.clients_crate("java__clients"); - conf.services_crate("java__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/java.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("java__types"); + conf.clients_crate("java__clients"); + conf.services_crate("java__services"); + let srcs = &["../../../../../annotation/java.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/java/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/java/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/java/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/java/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/java/services/thrift_build.rs b/thrift/lib/rust/annotation/java/services/thrift_build.rs index 849958be20a..8be79ca8231 100644 --- a/thrift/lib/rust/annotation/java/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/java/services/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +java crate //thrift/annotation:java-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "java crate //thrift/annotation:java-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("java__types"); - conf.clients_crate("java__clients"); - conf.services_crate("java__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/java.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("java__types"); + conf.clients_crate("java__clients"); + conf.services_crate("java__services"); + let srcs = &["../../../../../annotation/java.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/java/services/thrift_lib.rs b/thrift/lib/rust/annotation/java/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/java/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/java/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/java/thrift_build.rs b/thrift/lib/rust/annotation/java/thrift_build.rs index 941c69228ee..7a2ed28c3a7 100644 --- a/thrift/lib/rust/annotation/java/thrift_build.rs +++ b/thrift/lib/rust/annotation/java/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +java crate //thrift/annotation:java-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "java crate //thrift/annotation:java-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("java__types"); - conf.clients_crate("java__clients"); - conf.services_crate("java__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/java.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("java__types"); + conf.clients_crate("java__clients"); + conf.services_crate("java__services"); + let srcs = &["../../../../annotation/java.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/java/thrift_lib.rs b/thrift/lib/rust/annotation/java/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/java/thrift_lib.rs +++ b/thrift/lib/rust/annotation/java/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/python/clients/thrift_build.rs b/thrift/lib/rust/annotation/python/clients/thrift_build.rs index 5957c508e58..38392bfd54d 100644 --- a/thrift/lib/rust/annotation/python/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/python/clients/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +python crate //thrift/annotation:python-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "python crate //thrift/annotation:python-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("python__types"); - conf.clients_crate("python__clients"); - conf.services_crate("python__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/python.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("python__types"); + conf.clients_crate("python__clients"); + conf.services_crate("python__services"); + let srcs = &["../../../../../annotation/python.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/python/clients/thrift_lib.rs b/thrift/lib/rust/annotation/python/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/python/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/python/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/python/mocks/thrift_build.rs b/thrift/lib/rust/annotation/python/mocks/thrift_build.rs index 51f2db6041c..e44ca0ac9cf 100644 --- a/thrift/lib/rust/annotation/python/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/python/mocks/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +python crate //thrift/annotation:python-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "python crate //thrift/annotation:python-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("python__types"); - conf.clients_crate("python__clients"); - conf.services_crate("python__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/python.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("python__types"); + conf.clients_crate("python__clients"); + conf.services_crate("python__services"); + let srcs = &["../../../../../annotation/python.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/python/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/python/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/python/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/python/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/python/services/thrift_build.rs b/thrift/lib/rust/annotation/python/services/thrift_build.rs index 6fe58267ca5..e5fbc4f54ea 100644 --- a/thrift/lib/rust/annotation/python/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/python/services/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +python crate //thrift/annotation:python-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "python crate //thrift/annotation:python-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("python__types"); - conf.clients_crate("python__clients"); - conf.services_crate("python__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/python.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("python__types"); + conf.clients_crate("python__clients"); + conf.services_crate("python__services"); + let srcs = &["../../../../../annotation/python.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/python/services/thrift_lib.rs b/thrift/lib/rust/annotation/python/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/python/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/python/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/python/thrift_build.rs b/thrift/lib/rust/annotation/python/thrift_build.rs index 2b657278fe9..0e46a93fedd 100644 --- a/thrift/lib/rust/annotation/python/thrift_build.rs +++ b/thrift/lib/rust/annotation/python/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +python crate //thrift/annotation:python-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "python crate //thrift/annotation:python-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("python__types"); - conf.clients_crate("python__clients"); - conf.services_crate("python__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/python.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("python__types"); + conf.clients_crate("python__clients"); + conf.services_crate("python__services"); + let srcs = &["../../../../annotation/python.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/python/thrift_lib.rs b/thrift/lib/rust/annotation/python/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/python/thrift_lib.rs +++ b/thrift/lib/rust/annotation/python/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/rust/clients/thrift_build.rs b/thrift/lib/rust/annotation/rust/clients/thrift_build.rs index 58460531733..81b2275c92d 100644 --- a/thrift/lib/rust/annotation/rust/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/rust/clients/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +rust crate //thrift/annotation:rust-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "rust crate //thrift/annotation:rust-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("rust__types"); - conf.clients_crate("rust__clients"); - conf.services_crate("rust__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/rust.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("rust__types"); + conf.clients_crate("rust__clients"); + conf.services_crate("rust__services"); + let srcs = &["../../../../../annotation/rust.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/rust/clients/thrift_lib.rs b/thrift/lib/rust/annotation/rust/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/rust/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/rust/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/rust/mocks/thrift_build.rs b/thrift/lib/rust/annotation/rust/mocks/thrift_build.rs index cdf1b2a8d7e..f4d39e39fb3 100644 --- a/thrift/lib/rust/annotation/rust/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/rust/mocks/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +rust crate //thrift/annotation:rust-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "rust crate //thrift/annotation:rust-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("rust__types"); - conf.clients_crate("rust__clients"); - conf.services_crate("rust__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/rust.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("rust__types"); + conf.clients_crate("rust__clients"); + conf.services_crate("rust__services"); + let srcs = &["../../../../../annotation/rust.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/rust/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/rust/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/rust/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/rust/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/rust/services/thrift_build.rs b/thrift/lib/rust/annotation/rust/services/thrift_build.rs index 3ee17775f04..f086883675a 100644 --- a/thrift/lib/rust/annotation/rust/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/rust/services/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +rust crate //thrift/annotation:rust-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "rust crate //thrift/annotation:rust-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("rust__types"); - conf.clients_crate("rust__clients"); - conf.services_crate("rust__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/rust.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("rust__types"); + conf.clients_crate("rust__clients"); + conf.services_crate("rust__services"); + let srcs = &["../../../../../annotation/rust.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/rust/services/thrift_lib.rs b/thrift/lib/rust/annotation/rust/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/rust/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/rust/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/rust/thrift_build.rs b/thrift/lib/rust/annotation/rust/thrift_build.rs index a379b66a343..4007efeb077 100644 --- a/thrift/lib/rust/annotation/rust/thrift_build.rs +++ b/thrift/lib/rust/annotation/rust/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +rust crate //thrift/annotation:rust-rust +scope scope //thrift/annotation:scope-rust +"; #[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"), - "rust crate //thrift/annotation:rust-rust -scope scope //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("rust__types"); - conf.clients_crate("rust__clients"); - conf.services_crate("rust__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/rust.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("rust__types"); + conf.clients_crate("rust__clients"); + conf.services_crate("rust__services"); + let srcs = &["../../../../annotation/rust.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/rust/thrift_lib.rs b/thrift/lib/rust/annotation/rust/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/rust/thrift_lib.rs +++ b/thrift/lib/rust/annotation/rust/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/scope/clients/thrift_build.rs b/thrift/lib/rust/annotation/scope/clients/thrift_build.rs index b4275a7ff87..c7c2a6f4389 100644 --- a/thrift/lib/rust/annotation/scope/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/scope/clients/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope crate //thrift/annotation:scope-rust +"; #[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"), - "scope crate //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("scope__types"); - conf.clients_crate("scope__clients"); - conf.services_crate("scope__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/scope.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("scope__types"); + conf.clients_crate("scope__clients"); + conf.services_crate("scope__services"); + let srcs = &["../../../../../annotation/scope.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/scope/clients/thrift_lib.rs b/thrift/lib/rust/annotation/scope/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/scope/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/scope/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/scope/mocks/thrift_build.rs b/thrift/lib/rust/annotation/scope/mocks/thrift_build.rs index 11923257887..72c0cce1206 100644 --- a/thrift/lib/rust/annotation/scope/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/scope/mocks/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope crate //thrift/annotation:scope-rust +"; #[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"), - "scope crate //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("scope__types"); - conf.clients_crate("scope__clients"); - conf.services_crate("scope__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/scope.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("scope__types"); + conf.clients_crate("scope__clients"); + conf.services_crate("scope__services"); + let srcs = &["../../../../../annotation/scope.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/scope/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/scope/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/scope/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/scope/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/scope/services/thrift_build.rs b/thrift/lib/rust/annotation/scope/services/thrift_build.rs index c6cf99bda8e..5c581b8ee5a 100644 --- a/thrift/lib/rust/annotation/scope/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/scope/services/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope crate //thrift/annotation:scope-rust +"; #[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"), - "scope crate //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("scope__types"); - conf.clients_crate("scope__clients"); - conf.services_crate("scope__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/scope.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("scope__types"); + conf.clients_crate("scope__clients"); + conf.services_crate("scope__services"); + let srcs = &["../../../../../annotation/scope.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/scope/services/thrift_lib.rs b/thrift/lib/rust/annotation/scope/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/scope/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/scope/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/scope/thrift_build.rs b/thrift/lib/rust/annotation/scope/thrift_build.rs index df0f960bf36..975b51dce14 100644 --- a/thrift/lib/rust/annotation/scope/thrift_build.rs +++ b/thrift/lib/rust/annotation/scope/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope crate //thrift/annotation:scope-rust +"; #[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"), - "scope crate //thrift/annotation:scope-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("scope__types"); - conf.clients_crate("scope__clients"); - conf.services_crate("scope__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/scope.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("scope__types"); + conf.clients_crate("scope__clients"); + conf.services_crate("scope__services"); + let srcs = &["../../../../annotation/scope.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/scope/thrift_lib.rs b/thrift/lib/rust/annotation/scope/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/scope/thrift_lib.rs +++ b/thrift/lib/rust/annotation/scope/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/thrift/clients/thrift_build.rs b/thrift/lib/rust/annotation/thrift/clients/thrift_build.rs index c7a33e3f8c6..51a9639fc4d 100644 --- a/thrift/lib/rust/annotation/thrift/clients/thrift_build.rs +++ b/thrift/lib/rust/annotation/thrift/clients/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope scope //thrift/annotation:scope-rust +thrift crate //thrift/annotation:thrift-rust +"; #[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"), - "scope scope //thrift/annotation:scope-rust -thrift crate //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("thrift__types"); - conf.clients_crate("thrift__clients"); - conf.services_crate("thrift__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("thrift__types"); + conf.clients_crate("thrift__clients"); + conf.services_crate("thrift__services"); + let srcs = &["../../../../../annotation/thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/thrift/clients/thrift_lib.rs b/thrift/lib/rust/annotation/thrift/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/thrift/clients/thrift_lib.rs +++ b/thrift/lib/rust/annotation/thrift/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/thrift/mocks/thrift_build.rs b/thrift/lib/rust/annotation/thrift/mocks/thrift_build.rs index 5f62165b3ad..8bf3e9595ee 100644 --- a/thrift/lib/rust/annotation/thrift/mocks/thrift_build.rs +++ b/thrift/lib/rust/annotation/thrift/mocks/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope scope //thrift/annotation:scope-rust +thrift crate //thrift/annotation:thrift-rust +"; #[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"), - "scope scope //thrift/annotation:scope-rust -thrift crate //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("thrift__types"); - conf.clients_crate("thrift__clients"); - conf.services_crate("thrift__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("thrift__types"); + conf.clients_crate("thrift__clients"); + conf.services_crate("thrift__services"); + let srcs = &["../../../../../annotation/thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/thrift/mocks/thrift_lib.rs b/thrift/lib/rust/annotation/thrift/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/thrift/mocks/thrift_lib.rs +++ b/thrift/lib/rust/annotation/thrift/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/thrift/services/thrift_build.rs b/thrift/lib/rust/annotation/thrift/services/thrift_build.rs index e3497d8ecf1..8abec0e3b57 100644 --- a/thrift/lib/rust/annotation/thrift/services/thrift_build.rs +++ b/thrift/lib/rust/annotation/thrift/services/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope scope //thrift/annotation:scope-rust +thrift crate //thrift/annotation:thrift-rust +"; #[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"), - "scope scope //thrift/annotation:scope-rust -thrift crate //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("thrift__types"); - conf.clients_crate("thrift__clients"); - conf.services_crate("thrift__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../../annotation/thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("thrift__types"); + conf.clients_crate("thrift__clients"); + conf.services_crate("thrift__services"); + let srcs = &["../../../../../annotation/thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/thrift/services/thrift_lib.rs b/thrift/lib/rust/annotation/thrift/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/thrift/services/thrift_lib.rs +++ b/thrift/lib/rust/annotation/thrift/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/annotation/thrift/thrift_build.rs b/thrift/lib/rust/annotation/thrift/thrift_build.rs index baca8e1514a..1f7cd8cd6b6 100644 --- a/thrift/lib/rust/annotation/thrift/thrift_build.rs +++ b/thrift/lib/rust/annotation/thrift/thrift_build.rs @@ -1,68 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +scope scope //thrift/annotation:scope-rust +thrift crate //thrift/annotation:thrift-rust +"; #[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"), - "scope scope //thrift/annotation:scope-rust -thrift crate //thrift/annotation:thrift-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("thrift__types"); - conf.clients_crate("thrift__clients"); - conf.services_crate("thrift__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../../../annotation/thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("thrift__types"); + conf.clients_crate("thrift__clients"); + conf.services_crate("thrift__services"); + let srcs = &["../../../../annotation/thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/annotation/thrift/thrift_lib.rs b/thrift/lib/rust/annotation/thrift/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/annotation/thrift/thrift_lib.rs +++ b/thrift/lib/rust/annotation/thrift/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_build.rs b/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_build.rs index 6a4d07d114e..aa856ef097d 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_build.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust +"; #[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"), - "test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("teststructs__types"); - conf.clients_crate("teststructs__clients"); - conf.services_crate("teststructs__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../test_structs.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("teststructs__types"); + conf.clients_crate("teststructs__clients"); + conf.services_crate("teststructs__services"); + let srcs = &["../test_structs.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_lib.rs b/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_lib.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_build.rs b/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_build.rs index 0692cbc9f6b..3bd4acbfe9d 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_build.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust +"; #[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"), - "test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("teststructs__types"); - conf.clients_crate("teststructs__clients"); - conf.services_crate("teststructs__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../test_structs.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("teststructs__types"); + conf.clients_crate("teststructs__clients"); + conf.services_crate("teststructs__services"); + let srcs = &["../test_structs.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_lib.rs b/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_lib.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_build.rs b/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_build.rs index 465e847c967..ba0bbefd895 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_build.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust +"; #[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"), - "test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("teststructs__types"); - conf.clients_crate("teststructs__clients"); - conf.services_crate("teststructs__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../test_structs.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("teststructs__types"); + conf.clients_crate("teststructs__clients"); + conf.services_crate("teststructs__services"); + let srcs = &["../test_structs.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_lib.rs b/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_lib.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/deterministic_hash/src/tests/thrift_build.rs b/thrift/lib/rust/deterministic_hash/src/tests/thrift_build.rs index 2c909f93f8a..79896014c4c 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/thrift_build.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/thrift_build.rs @@ -1,67 +1,34 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust +"; #[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"), - "test_structs crate //thrift/lib/rust/deterministic_hash/src/tests:teststructs-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("teststructs__types"); - conf.clients_crate("teststructs__clients"); - conf.services_crate("teststructs__services"); - - let options = ""; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "test_structs.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("teststructs__types"); + conf.clients_crate("teststructs__clients"); + conf.services_crate("teststructs__services"); + let srcs = &["test_structs.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/deterministic_hash/src/tests/thrift_lib.rs b/thrift/lib/rust/deterministic_hash/src/tests/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/deterministic_hash/src/tests/thrift_lib.rs +++ b/thrift/lib/rust/deterministic_hash/src/tests/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_build.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_build.rs index feeb13aae1c..41709ffdc63 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust +"; #[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"), - "test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("test_if__types"); - conf.clients_crate("test_if__clients"); - conf.services_crate("test_if__services"); - - let options = "deprecated_default_enum_min_i32,serde"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../test_thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_if__types"); + conf.clients_crate("test_if__clients"); + conf.services_crate("test_if__services"); + conf.options("deprecated_default_enum_min_i32,serde"); + let srcs = &["../../test_thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_build.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_build.rs index c95f935dde8..fcce62a2970 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust +"; #[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"), - "test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("test_if__types"); - conf.clients_crate("test_if__clients"); - conf.services_crate("test_if__services"); - - let options = "deprecated_default_enum_min_i32,serde"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../test_thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_if__types"); + conf.clients_crate("test_if__clients"); + conf.services_crate("test_if__services"); + conf.options("deprecated_default_enum_min_i32,serde"); + let srcs = &["../../test_thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_build.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_build.rs index e5e76b2a1ab..66bfd6c1fb5 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust +"; #[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"), - "test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("test_if__types"); - conf.clients_crate("test_if__clients"); - conf.services_crate("test_if__services"); - - let options = "deprecated_default_enum_min_i32,serde"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../../test_thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_if__types"); + conf.clients_crate("test_if__clients"); + conf.services_crate("test_if__services"); + conf.options("deprecated_default_enum_min_i32,serde"); + let srcs = &["../../test_thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_build.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_build.rs index 69b5859afcd..2c922f5b220 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust +"; #[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"), - "test_thrift crate //thrift/lib/rust/src/dep_tests:test_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("test_if__types"); - conf.clients_crate("test_if__clients"); - conf.services_crate("test_if__services"); - - let options = "deprecated_default_enum_min_i32,serde"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../test_thrift.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_if__types"); + conf.clients_crate("test_if__clients"); + conf.services_crate("test_if__services"); + conf.options("deprecated_default_enum_min_i32,serde"); + let srcs = &["../test_thrift.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/cargo_thrift/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/clients/thrift_build.rs b/thrift/lib/rust/src/dep_tests/clients/thrift_build.rs index 2ac9e741ab5..04ad095370c 100644 --- a/thrift/lib/rust/src/dep_tests/clients/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/clients/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust +"; #[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"), - "test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Clients).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("test_deprecated_optional_with_default_is_some_if__types"); - conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); - conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); - - let options = "deprecated_optional_with_default_is_some"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../test_deprecated_optional_with_default_is_some.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Clients) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_deprecated_optional_with_default_is_some_if__types"); + conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); + conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); + conf.options("deprecated_optional_with_default_is_some"); + let srcs = &["../test_deprecated_optional_with_default_is_some.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/clients/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/clients/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/clients/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/clients/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/mocks/thrift_build.rs b/thrift/lib/rust/src/dep_tests/mocks/thrift_build.rs index fdeb84153f3..e09b13da2b7 100644 --- a/thrift/lib/rust/src/dep_tests/mocks/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/mocks/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust +"; #[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"), - "test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Mocks).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("test_deprecated_optional_with_default_is_some_if__types"); - conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); - conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); - - let options = "deprecated_optional_with_default_is_some"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../test_deprecated_optional_with_default_is_some.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Mocks) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_deprecated_optional_with_default_is_some_if__types"); + conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); + conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); + conf.options("deprecated_optional_with_default_is_some"); + let srcs = &["../test_deprecated_optional_with_default_is_some.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/mocks/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/mocks/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/mocks/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/mocks/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/services/thrift_build.rs b/thrift/lib/rust/src/dep_tests/services/thrift_build.rs index d991bf0ac64..d5e26e227c9 100644 --- a/thrift/lib/rust/src/dep_tests/services/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/services/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust +"; #[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"), - "test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Services).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("test_deprecated_optional_with_default_is_some_if__types"); - conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); - conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); - - let options = "deprecated_optional_with_default_is_some"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "../test_deprecated_optional_with_default_is_some.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Services) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_deprecated_optional_with_default_is_some_if__types"); + conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); + conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); + conf.options("deprecated_optional_with_default_is_some"); + let srcs = &["../test_deprecated_optional_with_default_is_some.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/services/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/services/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/services/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/services/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!(); diff --git a/thrift/lib/rust/src/dep_tests/thrift_build.rs b/thrift/lib/rust/src/dep_tests/thrift_build.rs index 7f18beaa197..90b62694c04 100644 --- a/thrift/lib/rust/src/dep_tests/thrift_build.rs +++ b/thrift/lib/rust/src/dep_tests/thrift_build.rs @@ -1,67 +1,35 @@ // @generated by autocargo + use std::env; use std::fs; use std::path::Path; - use thrift_compiler::Config; use thrift_compiler::GenContext; - +const CRATEMAP: &str = "\ +test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust +"; #[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"), - "test_deprecated_optional_with_default_is_some crate //thrift/lib/rust/src/dep_tests:test_deprecated_optional_with_default_is_some_if-rust", - ).expect("Failed to write cratemap"); - - let conf = { - let mut conf = Config::from_env(GenContext::Types).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("test_deprecated_optional_with_default_is_some_if__types"); - conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); - conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); - - let options = "deprecated_optional_with_default_is_some"; - if !options.is_empty() { - conf.options(options); - } - - let types_include_srcs = vec![ - - ]; - conf.types_include_srcs(types_include_srcs); - - conf - }; - - let srcs: &[&str] = &[ - "test_deprecated_optional_with_default_is_some.thrift" - ]; + let cratemap_path = Path::new(&out_dir).join("cratemap"); + fs::write(cratemap_path, CRATEMAP).expect("Failed to write cratemap"); + let mut conf = Config::from_env(GenContext::Types) + .expect("Failed to instantiate thrift_compiler::Config"); + let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not provided"); + let mut base_path = Path::new(&cargo_manifest_dir) + .join("../../../../..") + .canonicalize() + .expect("Failed to canonicalize base_path"); + if cfg!(windows) { + base_path = base_path.to_string_lossy().trim_start_matches(r"\\?\").into(); + } + conf.base_path(base_path); + conf.types_crate("test_deprecated_optional_with_default_is_some_if__types"); + conf.clients_crate("test_deprecated_optional_with_default_is_some_if__clients"); + conf.services_crate("test_deprecated_optional_with_default_is_some_if__services"); + conf.options("deprecated_optional_with_default_is_some"); + let srcs = &["test_deprecated_optional_with_default_is_some.thrift"]; conf.run(srcs).expect("Failed while running thrift compilation"); } diff --git a/thrift/lib/rust/src/dep_tests/thrift_lib.rs b/thrift/lib/rust/src/dep_tests/thrift_lib.rs index 88a7cd8a77e..a010a62d170 100644 --- a/thrift/lib/rust/src/dep_tests/thrift_lib.rs +++ b/thrift/lib/rust/src/dep_tests/thrift_lib.rs @@ -1,2 +1,3 @@ // @generated by autocargo + ::codegen_includer_proc_macro::include!();