Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-serve-http/build.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-serve-http / build.rs` 118 lines ยท 4996 bytes Raw Blame History 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 //! Build identity of the omega door for the persistent KV engine identity (sc#505, ADR 0003 17 //! section 1.2.2). Embedded at build time, read by `kv_persist::OmegaBuild::linked()`: 18 //! 19 //! - `AIEN_SERVE_HTTP_GIT_COMMIT`: the commit this crate was built from (`AIEN_BUILD_COMMIT` 20 //! when set, else `git rev-parse HEAD`, else `unknown`). 21 //! - `AIEN_SERVE_HTTP_GIT_DIRTY`: `1` when `git status` showed modified tracked files at build 22 //! time, `0` when clean (or `AIEN_BUILD_COMMIT` given), `unknown` without git. Re-checked 23 //! when HEAD or the index moves, not on every unstaged edit. 24 //! - `AIEN_SERVE_HTTP_OMEGA_LOCK`: the omega commit `omega.lock` pins. 25 //! - `AIEN_SERVE_HTTP_GPU_RECORDED_SHA256`: the `libomega_gpu.a` sha256 `native-artifacts.lock` 26 //! records for that commit and this target, or `unrecorded`. 27 use std::path::{Path, PathBuf}; 28 use std::process::Command; 29 30 fn git(root: &Path, args: &[&str]) -> Option { 31 let out = Command::new("git") 32 .arg("-C") 33 .arg(root) 34 .args(args) 35 .output() 36 .ok()?; 37 if !out.status.success() { 38 return None; 39 } 40 Some(String::from_utf8(out.stdout).ok()?.trim().to_string()) 41 } 42 43 fn main() { 44 let manifest = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); 45 let root = manifest.join("../.."); 46 let target = std::env::var("TARGET").unwrap_or_default(); 47 48 println!("cargo:rerun-if-env-changed=AIEN_BUILD_COMMIT"); 49 let forced = std::env::var("AIEN_BUILD_COMMIT") 50 .ok() 51 .filter(|s| !s.trim().is_empty()); 52 let (commit, dirty) = match forced { 53 Some(c) => (c.trim().to_string(), "0".to_string()), 54 None => { 55 for p in ["HEAD", "index"] { 56 if let Some(path) = git(&root, &["rev-parse", "--git-path", p]) { 57 let path = if Path::new(&path).is_absolute() { 58 PathBuf::from(path) 59 } else { 60 root.join(path) 61 }; 62 println!("cargo:rerun-if-changed={}", path.display()); 63 } 64 } 65 if let Some(name) = git(&root, &["symbolic-ref", "-q", "HEAD"]) { 66 if let Some(path) = git(&root, &["rev-parse", "--git-path", &name]) { 67 let path = if Path::new(&path).is_absolute() { 68 PathBuf::from(path) 69 } else { 70 root.join(path) 71 }; 72 if path.exists() { 73 println!("cargo:rerun-if-changed={}", path.display()); 74 } 75 } 76 } 77 let commit = git(&root, &["rev-parse", "HEAD"]) 78 .filter(|s| !s.is_empty()) 79 .unwrap_or_else(|| "unknown".into()); 80 let dirty = match git(&root, &["status", "--porcelain", "--untracked-files=no"]) { 81 Some(s) if s.is_empty() => "0", 82 Some(_) => "1", 83 None => "unknown", 84 }; 85 (commit, dirty.to_string()) 86 } 87 }; 88 println!("cargo:rustc-env=AIEN_SERVE_HTTP_GIT_COMMIT={commit}"); 89 println!("cargo:rustc-env=AIEN_SERVE_HTTP_GIT_DIRTY={dirty}"); 90 91 let lock_path = root.join("omega.lock"); 92 println!("cargo:rerun-if-changed={}", lock_path.display()); 93 let omega = std::fs::read_to_string(&lock_path) 94 .map(|s| s.trim().to_string()) 95 .unwrap_or_default(); 96 let omega = if omega.is_empty() { 97 "unknown".to_string() 98 } else { 99 omega 100 }; 101 println!("cargo:rustc-env=AIEN_SERVE_HTTP_OMEGA_LOCK={omega}"); 102 103 let artifacts = root.join("native-artifacts.lock"); 104 println!("cargo:rerun-if-changed={}", artifacts.display()); 105 let recorded = std::fs::read_to_string(&artifacts) 106 .ok() 107 .and_then(|text| { 108 text.lines() 109 .filter(|l| !l.trim_start().starts_with('#')) 110 .find_map(|l| { 111 let f: Vec<&str> = l.split_whitespace().collect(); 112 (f.len() >= 4 && f[0] == "libomega_gpu.a" && f[1] == omega && f[2] == target) 113 .then(|| f[3].to_string()) 114 }) 115 }) 116 .unwrap_or_else(|| "unrecorded".to_string()); 117 println!("cargo:rustc-env=AIEN_SERVE_HTTP_GPU_RECORDED_SHA256={recorded}"); 118 }