Skip to content

Commit b1b4652

Browse files
committed
Changes to be compatible with crate2nix (#330)
see stackabletech/operator-templating#212 for more details
1 parent 259c351 commit b1b4652

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
@@ -10,7 +10,7 @@ use crate::druid_connection_controller::DRUID_CONNECTION_CONTROLLER_NAME;
1010
use crate::superset_controller::SUPERSET_CONTROLLER_NAME;
1111
use crate::superset_db_controller::SUPERSET_DB_CONTROLLER_NAME;
1212

13-
use clap::Parser;
13+
use clap::{crate_description, crate_version, Parser};
1414
use futures::StreamExt;
1515
use stackable_operator::{
1616
cli::{Command, ProductOperatorRun},
@@ -36,13 +36,14 @@ use std::sync::Arc;
3636

3737
mod built_info {
3838
include!(concat!(env!("OUT_DIR"), "/built.rs"));
39+
pub const TARGET_PLATFORM: Option<&str> = option_env!("TARGET");
3940
}
4041

4142
pub const APP_PORT: u16 = 8088;
4243
pub const OPERATOR_NAME: &str = "superset.stackable.tech";
4344

4445
#[derive(Parser)]
45-
#[clap(about = built_info::PKG_DESCRIPTION, author = stackable_operator::cli::AUTHOR)]
46+
#[clap(about, author)]
4647
struct Opts {
4748
#[clap(subcommand)]
4849
cmd: Command,
@@ -68,10 +69,10 @@ async fn main() -> anyhow::Result<()> {
6869
tracing_target,
6970
);
7071
stackable_operator::utils::print_startup_string(
71-
built_info::PKG_DESCRIPTION,
72-
built_info::PKG_VERSION,
72+
crate_description!(),
73+
crate_version!(),
7374
built_info::GIT_VERSION,
74-
built_info::TARGET,
75+
built_info::TARGET_PLATFORM.unwrap_or("unknown target"),
7576
built_info::BUILT_TIME_UTC,
7677
built_info::RUSTC_VERSION,
7778
);

0 commit comments

Comments
 (0)