Skip to content

Commit

Permalink
Clearly define oss and non-oss deps
Browse files Browse the repository at this point in the history
Summary:
This diff makes use of autocargo's `extra_buck_dependencies` to keep
cargo-only deps in `Cargo.toml` and out of the buck graph, and uses
`rust_oss.is_oss_build()` to keep those same deps only visible in
`fbcode//mode/dev-rust-oss`.

Reviewed By: dtolnay

Differential Revision: D52103638

fbshipit-source-id: db9e316ebe4d73fd995f6f7180a9234289065568
  • Loading branch information
zertosh authored and facebook-github-bot committed Dec 13, 2023
1 parent a555afd commit e6eecfb
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 42 deletions.
9 changes: 0 additions & 9 deletions shed/cachelib_stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@

#![deny(warnings)]

#[cfg(fbcode_build)]
mod _unused {
// used in oss
use abomonation as _;
use anyhow as _;
use bytes as _;
use futures_ext as _;
}

#[cfg(not(fbcode_build))]
mod oss;

Expand Down
2 changes: 0 additions & 2 deletions shed/fbinit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ pub use fbinit_macros::test;
#[cfg(not(fbcode_build))]
pub use oss::*;
#[cfg(fbcode_build)]
use quickcheck as _; // used in oss
#[cfg(fbcode_build)]
pub use real_fbinit::*;
2 changes: 1 addition & 1 deletion shed/hostname/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ license = "MIT OR Apache-2.0"

[dependencies]
anyhow = "1.0.75"
hostname_orig = { package = "hostname", version = "0.3" }
real_hostname = { package = "hostname", version = "0.3" }
4 changes: 1 addition & 3 deletions shed/hostname/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ use anyhow::Result;
pub fn get_hostname() -> Result<String> {
#[cfg(not(fbcode_build))]
{
Ok(::hostname_orig::get()?.to_string_lossy().into_owned())
Ok(::real_hostname::get()?.to_string_lossy().into_owned())
}

#[cfg(fbcode_build)]
{
use hostname_orig as _; // used in oss

fbwhoami::FbWhoAmI::get()?
.name
.clone()
Expand Down
2 changes: 1 addition & 1 deletion shed/justknobs_stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! init_cached_config_just_knobs/init_cached_config_just_knobs_worker.
//! * thread-local-in-memory, which is useful for testing. It allows to override justknobs within a
//! test without affecting other tests. Used always when cfg(test) is true.
use anyhow as _;
use anyhow::Result;
use cached_config::CachedConfigJustKnobs;
#[cfg(fbcode_build)]
Expand Down
2 changes: 0 additions & 2 deletions shed/memcache_stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@
#[cfg(fbcode_build)]
pub use fb_memcache::*;
#[cfg(fbcode_build)]
use memcache_common as _; // used in oss
#[cfg(not(fbcode_build))]
pub use memcache_common::*;
2 changes: 0 additions & 2 deletions shed/scuba_stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@
#[cfg(fbcode_build)]
pub use fb_scuba::*;
#[cfg(fbcode_build)]
use scuba_sample as _;
#[cfg(not(fbcode_build))]
pub use scuba_sample::*;
2 changes: 1 addition & 1 deletion shed/secure_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
//! Crate with useful security utilities
#![deny(warnings, missing_docs, clippy::all, rustdoc::broken_intra_doc_links)]
#![cfg_attr(not(fbcode_build), allow(unused_crate_dependencies))]

#[cfg(fbcode_build)]
pub mod facebook;

#[cfg(not(fbcode_build))]
mod oss;

Expand Down
1 change: 0 additions & 1 deletion shed/services/common/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

#![deny(warnings, missing_docs, clippy::all, rustdoc::broken_intra_doc_links)]
#![cfg_attr(not(fbcode_build), allow(unused_crate_dependencies))]

//! Crate defining basic trates and structures for handing fb303 thrift services
Expand Down
5 changes: 0 additions & 5 deletions shed/services/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
#![deny(warnings)]
#![cfg_attr(not(fbcode_build), feature(never_type))]

#[cfg(fbcode_build)]
use fbinit as _; // used in oss
#[cfg(fbcode_build)]
use services_common as _; // used in oss

#[cfg(not(fbcode_build))]
mod oss;

Expand Down
14 changes: 0 additions & 14 deletions shed/sql/common/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//! to implement traits to be used with the sql's queries macro.
#![deny(warnings, missing_docs, clippy::all, rustdoc::broken_intra_doc_links)]
#![cfg_attr(not(fbcode_build), allow(unused_crate_dependencies))]

pub mod mysql;
pub mod sqlite;
Expand All @@ -24,12 +23,6 @@ use mysql_async::prelude::FromValue;
use mysql_async::Value;
use vec1::Vec1;

// Used in OSS build only
#[cfg(fbcode_build)]
mod _oss_only {
use thiserror as _;
}

/// Struct to store a set of write, read and read-only connections for a shard.
#[derive(Clone)]
pub struct SqlConnections {
Expand Down Expand Up @@ -158,10 +151,3 @@ impl WriteResult {
self.affected_rows
}
}

// Used in docs
#[cfg(test)]
mod _unused {
use sql as _;
use sql_tests_lib as _;
}
1 change: 0 additions & 1 deletion shed/sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
//! ```
#![deny(warnings, missing_docs, clippy::all, rustdoc::broken_intra_doc_links)]
#![cfg_attr(not(fbcode_build), allow(unused_crate_dependencies))]

#[cfg(test)]
mod tests;
Expand Down

0 comments on commit e6eecfb

Please sign in to comment.