Skip to content

Commit

Permalink
Move build_count to buck2_common to allow sharing
Browse files Browse the repository at this point in the history
Summary: BuildCountManager is presently used only in recorder. However, in the upcoming diffs, this will be used to determine if a build is cold/incremental. Moving it to buck2_common to allow sharing of the code.

Reviewed By: stepancheg

Differential Revision: D63633575

fbshipit-source-id: 91c2b6e54c9bcb51acc5a4d3ccac64cbe6cd884f
  • Loading branch information
Rajneesh Lakkundi authored and facebook-github-bot committed Oct 7, 2024
1 parent 67165df commit fb0a273
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion app/buck2_client_ctx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#![feature(extract_if)]

pub mod argfiles;
pub mod build_count;
pub mod client_cpu_tracker;
pub mod client_ctx;
pub mod client_metadata;
Expand Down
4 changes: 2 additions & 2 deletions app/buck2_client_ctx/src/subscribers/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use std::time::SystemTime;
use anyhow::Context;
use async_trait::async_trait;
use buck2_cli_proto::command_result;
use buck2_common::build_count::BuildCount;
use buck2_common::build_count::BuildCountManager;
use buck2_common::convert::ProstDurationExt;
use buck2_core::fs::fs_util;
use buck2_core::fs::paths::abs_path::AbsPathBuf;
Expand Down Expand Up @@ -59,8 +61,6 @@ use termwiz::istty::IsTty;
use super::system_warning::check_download_speed;
use super::system_warning::check_memory_pressure;
use super::system_warning::check_remaining_disk_space;
use crate::build_count::BuildCount;
use crate::build_count::BuildCountManager;
use crate::client_ctx::ClientCommandContext;
use crate::client_metadata::ClientMetadata;
use crate::common::CommonEventLogOptions;
Expand Down
1 change: 1 addition & 0 deletions app/buck2_common/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ rust_library(
"fbsource//third-party/rust:derive_more",
"fbsource//third-party/rust:digest",
"fbsource//third-party/rust:dirs",
"fbsource//third-party/rust:fs4",
"fbsource//third-party/rust:futures",
"fbsource//third-party/rust:globset",
"fbsource//third-party/rust:hex",
Expand Down
1 change: 1 addition & 0 deletions app/buck2_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ derive_more = { workspace = true }
digest = { workspace = true }
dirs = { workspace = true }
fbinit = { workspace = true }
fs4 = { workspace = true }
futures = { workspace = true }
globset = { workspace = true }
hex = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::collections::HashMap;
use std::time::Duration;

use anyhow::Context;
use buck2_common::client_utils;
use buck2_core::fs::async_fs_util;
use buck2_core::fs::paths::abs_norm_path::AbsNormPathBuf;
use buck2_core::fs::paths::file_name::FileName;
Expand All @@ -20,6 +19,8 @@ use fs4::FileExt;
use serde::Deserialize;
use serde::Serialize;

use crate::client_utils;

// Version for serialized BuildCount on disk.
// Update if changing BuildCount to allow building with deployed and compiled buck on the same rev.
pub const BUILD_COUNT_VERSION: u64 = 1;
Expand Down Expand Up @@ -76,7 +77,7 @@ impl BuildCountMap {
return Default::default();
}

// If the target has never been succesfully built it won't be in the map, in that case its count is 0.
// If the target has never been successfully built it won't be in the map, in that case its count is 0.
return patterns
.target_patterns
.iter()
Expand Down
1 change: 1 addition & 0 deletions app/buck2_common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

pub mod argv;
pub mod buckd_connection;
pub mod build_count;
pub mod buildfiles;
pub mod cas_digest;
pub mod chunk_reader;
Expand Down

0 comments on commit fb0a273

Please sign in to comment.