Skip to content

Commit 98e6b3b

Browse files
committed
Changes to be compatible with crate2nix (#316)
see stackabletech/operator-templating#212 for more details
1 parent cc831e6 commit 98e6b3b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

rust/operator-binary/build.rs

Lines changed: 11 additions & 1 deletion
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");
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();
313
}

rust/operator-binary/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod rbac;
55

66
use crate::hbase_controller::HBASE_CONTROLLER_NAME;
77

8-
use clap::Parser;
8+
use clap::{crate_description, crate_version, Parser};
99
use futures::StreamExt;
1010
use stackable_hbase_crd::{HbaseCluster, APP_NAME};
1111
use stackable_operator::{
@@ -19,12 +19,13 @@ use std::sync::Arc;
1919

2020
mod built_info {
2121
include!(concat!(env!("OUT_DIR"), "/built.rs"));
22+
pub const TARGET_PLATFORM: Option<&str> = option_env!("TARGET");
2223
}
2324

2425
const OPERATOR_NAME: &str = "hbase.stackable.com";
2526

2627
#[derive(Parser)]
27-
#[clap(about = built_info::PKG_DESCRIPTION, author = stackable_operator::cli::AUTHOR)]
28+
#[clap(about, author)]
2829
struct Opts {
2930
#[clap(subcommand)]
3031
cmd: Command,
@@ -48,10 +49,10 @@ async fn main() -> anyhow::Result<()> {
4849
tracing_target,
4950
);
5051
stackable_operator::utils::print_startup_string(
51-
built_info::PKG_DESCRIPTION,
52-
built_info::PKG_VERSION,
52+
crate_description!(),
53+
crate_version!(),
5354
built_info::GIT_VERSION,
54-
built_info::TARGET,
55+
built_info::TARGET_PLATFORM.unwrap_or("unknown target"),
5556
built_info::BUILT_TIME_UTC,
5657
built_info::RUSTC_VERSION,
5758
);

0 commit comments

Comments
 (0)