From 044ac92d360ccf94040aa386111da35bf257e775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Liebau?= Date: Tue, 14 Feb 2023 21:08:56 +0100 Subject: [PATCH 1/2] Changes to become compatible with crate2nix. --- rust/operator-binary/build.rs | 14 ++++++++++++-- rust/operator-binary/src/main.rs | 11 ++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/rust/operator-binary/build.rs b/rust/operator-binary/build.rs index d8f91cb9..d6e8ee61 100644 --- a/rust/operator-binary/build.rs +++ b/rust/operator-binary/build.rs @@ -1,3 +1,13 @@ +use std::path::PathBuf; + fn main() { - built::write_built_file().expect("Failed to acquire build-time information"); -} + let out_dir = PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR is required")); + built::write_built_file_with_opts( + // built's env module depends on a whole bunch of variables that crate2nix doesn't provide + // so we grab the specific env variables that we care about out ourselves instead. + built::Options::default().set_env(false), + "Cargo.toml".as_ref(), + &out_dir.join("built.rs"), + ) + .unwrap(); +} \ No newline at end of file diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index ba279aff..dbded266 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -10,7 +10,7 @@ use crate::druid_connection_controller::DRUID_CONNECTION_CONTROLLER_NAME; use crate::superset_controller::SUPERSET_CONTROLLER_NAME; use crate::superset_db_controller::SUPERSET_DB_CONTROLLER_NAME; -use clap::Parser; +use clap::{crate_description, crate_version, Parser}; use futures::StreamExt; use stackable_operator::{ cli::{Command, ProductOperatorRun}, @@ -36,13 +36,14 @@ use std::sync::Arc; mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); + pub const TARGET_PLATFORM: Option<&str> = option_env!("TARGET"); } pub const APP_PORT: u16 = 8088; pub const OPERATOR_NAME: &str = "superset.stackable.tech"; #[derive(Parser)] -#[clap(about = built_info::PKG_DESCRIPTION, author = stackable_operator::cli::AUTHOR)] +#[clap(about, author)] struct Opts { #[clap(subcommand)] cmd: Command, @@ -68,10 +69,10 @@ async fn main() -> anyhow::Result<()> { tracing_target, ); stackable_operator::utils::print_startup_string( - built_info::PKG_DESCRIPTION, - built_info::PKG_VERSION, + crate_description!(), + crate_version!(), built_info::GIT_VERSION, - built_info::TARGET, + built_info::TARGET_PLATFORM.unwrap_or("unknown target"), built_info::BUILT_TIME_UTC, built_info::RUSTC_VERSION, ); From 718aad0494e562f62b9bde4cc2b0f7fdfbd0fe82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Liebau?= Date: Tue, 14 Feb 2023 22:13:05 +0100 Subject: [PATCH 2/2] rustfmt --- rust/operator-binary/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/operator-binary/build.rs b/rust/operator-binary/build.rs index d6e8ee61..ed36fcf0 100644 --- a/rust/operator-binary/build.rs +++ b/rust/operator-binary/build.rs @@ -9,5 +9,5 @@ fn main() { "Cargo.toml".as_ref(), &out_dir.join("built.rs"), ) - .unwrap(); -} \ No newline at end of file + .unwrap(); +}