Skip to content

Commit 0ce6caa

Browse files
: add generated build info module with commit hash and metadata (#1738)
Summary: this diff adds an experimental [build identity module](https://www.internalfb.com/phabricator/paste/view/P2018151567) to hyperactor_mesh. at buck build time we generate a rust module ("build_info.rs") with four values: sapling changeset hash, build timestamp, user, and host. the file is not checked in; it is produced in buck-out and added to the crate via `mapped_srcs`. cargo / oss builds do not see it. fbcode builds get a new `hyperactor_mesh::build_info` module (behind `#[cfg(fbcode_build)]`) that exposes `commit()`, `timestamp()`, `user()`, and `host()`. each of those returns a `&'static str` baked in at build time. no syscalls or runtime i/o. the module can also register these values into the global config/attrs registry. calling `init()` installs `BUILD_COMMIT`, `BUILD_TIMESTAMP`, `BUILD_USER`, and `BUILD_HOST` into process-wide `Attrs` via `hyperactor::config::global`. callsites that only need to compare versions (e.g. host/proc handshake) can read `commit()` directly. code that wants to surface this via logs or admin endpoints can call `init()` once and query the global config. this is buck-only. we do not add a `build.rs`, we do not write into the source tree, and cargo builds are unchanged. rfc: host/child handshake will start comparing `commit()` at startup and warn or fail on mismatch. Differential Revision: D86009410
1 parent fe19d21 commit 0ce6caa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hyperactor_mesh/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,25 @@ pub mod test_utils;
3535
mod testresource;
3636
pub mod v1;
3737

38+
// Generated build information module
39+
#[cfg(fbcode_build)]
40+
#[path = "../build_info.rs"]
41+
pub mod build_info;
42+
3843
pub use actor_mesh::RootActorMesh;
3944
pub use actor_mesh::SlicedActorMesh;
4045
pub use bootstrap::Bootstrap;
4146
pub use bootstrap::bootstrap;
4247
pub use bootstrap::bootstrap_or_die;
48+
// Re-export build info attributes for easy access
49+
#[cfg(fbcode_build)]
50+
pub use build_info::BUILD_COMMIT;
51+
#[cfg(fbcode_build)]
52+
pub use build_info::BUILD_HOST;
53+
#[cfg(fbcode_build)]
54+
pub use build_info::BUILD_TIMESTAMP;
55+
#[cfg(fbcode_build)]
56+
pub use build_info::BUILD_USER;
4357
pub use comm::CommActor;
4458
pub use dashmap;
4559
pub use hyperactor_mesh_macros::sel;

0 commit comments

Comments
 (0)