Skip to content

Commit 81c1f73

Browse files
committed
Changes to become compatible with crate2nix
1 parent df06c74 commit 81c1f73

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

rust/operator-binary/build.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
use std::path::PathBuf;
2+
13
fn main() {
2-
built::write_built_file().expect("Failed to acquire build-time information");
3-
}
4+
let out_dir = PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR is required"));
5+
built::write_built_file_with_opts(
6+
// built's env module depends on a whole bunch of variables that crate2nix doesn't provide
7+
// so we grab the specific env variables that we care about out ourselves instead.
8+
built::Options::default().set_env(false),
9+
"Cargo.toml".as_ref(),
10+
&out_dir.join("built.rs"),
11+
)
12+
.unwrap();
13+
}

rust/operator-binary/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod znode_controller;
88
use crate::zk_controller::ZK_CONTROLLER_NAME;
99
use crate::znode_controller::ZNODE_CONTROLLER_NAME;
1010

11-
use clap::Parser;
11+
use clap::{crate_description, crate_version, Parser};
1212
use futures::StreamExt;
1313
use stackable_operator::{
1414
cli::{Command, ProductOperatorRun},
@@ -28,13 +28,14 @@ use std::sync::Arc;
2828

2929
mod built_info {
3030
include!(concat!(env!("OUT_DIR"), "/built.rs"));
31+
pub const TARGET_PLATFORM: Option<&str> = option_env!("TARGET");
3132
}
3233

3334
const APP_NAME: &str = "zookeeper";
3435
const OPERATOR_NAME: &str = "zookeeper.stackable.tech";
3536

3637
#[derive(clap::Parser)]
37-
#[clap(about = built_info::PKG_DESCRIPTION, author = stackable_operator::cli::AUTHOR)]
38+
#[clap(about, author)]
3839
struct Opts {
3940
#[clap(subcommand)]
4041
cmd: Command,
@@ -59,10 +60,10 @@ async fn main() -> anyhow::Result<()> {
5960
tracing_target,
6061
);
6162
stackable_operator::utils::print_startup_string(
62-
built_info::PKG_DESCRIPTION,
63-
built_info::PKG_VERSION,
63+
crate_description!(),
64+
crate_version!(),
6465
built_info::GIT_VERSION,
65-
built_info::TARGET,
66+
built_info::TARGET_PLATFORM.unwrap_or("unknown target"),
6667
built_info::BUILT_TIME_UTC,
6768
built_info::RUSTC_VERSION,
6869
);

0 commit comments

Comments
 (0)