aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / crates / aien-runtime / build.rs
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | //! `cfg(compose_linked)` when aien-omega-compose linked the real |
| 17 | //! librx_compose.a (its build script's `links` metadata), so tests that need |
| 18 | //! the Cortex journal are reported IGNORED in a stub build instead of passing |
| 19 | //! vacuously. |
| 20 | //! |
| 21 | //! `AIEN_RUNTIME_GIT_COMMIT` (sc#504, ADR 0003 section 1.2.2): the commit this |
| 22 | //! crate was built from, part of the host engine build id that the persistent |
| 23 | //! KV namespace binds. Taken from the `AIEN_BUILD_COMMIT` environment variable |
| 24 | //! when set (builds without a git checkout), else from `git rev-parse HEAD`, |
| 25 | //! else `unknown`. |
| 26 | use std::process::Command; |
| 27 | |
| 28 | fn git(args: &[&str]) -> Option<String> { |
| 29 | let out = Command::new("git").args(args).output().ok()?; |
| 30 | if !out.status.success() { |
| 31 | return None; |
| 32 | } |
| 33 | let s = String::from_utf8(out.stdout).ok()?.trim().to_string(); |
| 34 | (!s.is_empty()).then_some(s) |
| 35 | } |
| 36 | |
| 37 | fn main() { |
| 38 | println!("cargo:rustc-check-cfg=cfg(compose_linked)"); |
| 39 | println!("cargo:rerun-if-env-changed=DEP_RX_COMPOSE_LINKED"); |
| 40 | if std::env::var("DEP_RX_COMPOSE_LINKED").as_deref() == Ok("1") { |
| 41 | println!("cargo:rustc-cfg=compose_linked"); |
| 42 | } |
| 43 | |
| 44 | println!("cargo:rerun-if-env-changed=AIEN_BUILD_COMMIT"); |
| 45 | let commit = std::env::var("AIEN_BUILD_COMMIT") |
| 46 | .ok() |
| 47 | .filter(|s| !s.trim().is_empty()) |
| 48 | .or_else(|| { |
| 49 | // Rebuild when HEAD moves: the HEAD file and the branch ref it names. |
| 50 | if let Some(head) = git(&["rev-parse", "--git-path", "HEAD"]) { |
| 51 | println!("cargo:rerun-if-changed={head}"); |
| 52 | } |
| 53 | if let Some(name) = git(&["symbolic-ref", "-q", "HEAD"]) { |
| 54 | if let Some(path) = git(&["rev-parse", "--git-path", &name]) { |
| 55 | if std::path::Path::new(&path).exists() { |
| 56 | println!("cargo:rerun-if-changed={path}"); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | git(&["rev-parse", "HEAD"]) |
| 61 | }) |
| 62 | .unwrap_or_else(|| "unknown".to_string()); |
| 63 | println!("cargo:rustc-env=AIEN_RUNTIME_GIT_COMMIT={commit}"); |
| 64 | } |