Files
hcie-rust-v3.05/hcie-build-info/build.rs
T
phantom b49106dc1d BIG REFACTOR GPT SOL
feat: Refactor Iced panel adapter and introduce build metadata management

- Updated Cargo.toml files across multiple crates to use workspace versioning.
- Enhanced the `iced-panel-adapter` to include a new `plain_slider` module and updated widget rendering to support theme colors.
- Added new theme color utilities for recessed and elevated surfaces in `iced-panel-adapter`.
- Introduced a new `hcie-build-info` crate to manage build metadata, including a build ID system.
- Created a build script to synchronize build IDs across the workspace.
- Added a Makefile for simplified build commands for the Iced application.
- Implemented regression tests for vector shape creation history in the engine API.
- Added a new script for managing Cargo commands with synchronized build ID increments.
- Updated line count report to reflect recent changes in codebase.
- Created a visual plan document for future improvements in the Iced history and panel systems.
2026-07-21 04:25:23 +03:00

59 lines
2.4 KiB
Rust

//! Read-only build metadata generation for HCIE GUI packages.
//!
//! **Purpose:** Publishes the build number prepared by `scripts/cargo-with-build-id.sh` to every
//! frontend without mutating watched Cargo inputs from inside a build script.
//! **Logic & Workflow:** Uses the wrapper-provided override when present, otherwise reads the
//! canonical repository `build.id`, validates it, and emits synchronized compile-time variables.
//! **Side Effects / Dependencies:** Reads one repository file and writes only Cargo directives.
use std::fs;
use std::io;
use std::path::PathBuf;
/// Reads and validates the canonical or wrapper-provided build identifier.
///
/// **Returns:** The current build ID as `u64`.
/// **Side Effects / Dependencies:** Reads `build.id` when no override is provided.
fn build_id() -> u64 {
if let Ok(value) = std::env::var("HCIE_BUILD_ID_OVERRIDE") {
return value
.parse::<u64>()
.expect("HCIE_BUILD_ID_OVERRIDE must be an unsigned integer");
}
let manifest_dir = PathBuf::from(
std::env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is required"),
);
let canonical = manifest_dir
.parent()
.expect("hcie-build-info must live directly under the repository root")
.join("build.id");
match fs::read_to_string(&canonical) {
Ok(value) => value.trim().parse::<u64>().unwrap_or_else(|error| {
panic!("invalid integer in {}: {error}", canonical.display())
}),
Err(error) if error.kind() == io::ErrorKind::NotFound => 0,
Err(error) => panic!("failed to read {}: {error}", canonical.display()),
}
}
/// Publishes synchronized build metadata to the library crate.
fn main() {
let manifest_dir = PathBuf::from(
std::env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is required"),
);
let canonical = manifest_dir
.parent()
.expect("hcie-build-info must live directly under the repository root")
.join("build.id");
println!("cargo:rerun-if-changed={}", canonical.display());
println!("cargo:rerun-if-env-changed=HCIE_BUILD_ID_OVERRIDE");
let build_id = build_id();
let base_version = std::env::var("CARGO_PKG_VERSION").expect("package version is required");
println!("cargo:rustc-env=HCIE_BUILD_ID={build_id}");
println!(
"cargo:rustc-env=HCIE_BUILD_VERSION={base_version}+build.{build_id}"
);
}