Owner decision 2026-11-23: the vendored tree is junk. Leleka never builds or runs it (no Cargo.toml or build.rs depends on it), the vanilla benchmark
builds from its own checkout on the server, the comparison measurements are finished and the CUDA ports are frozen. Strata is MIT: its licence text
stays and ships (third_party/strata/LICENSE, `leleka engine license`).
- git rm -r engine: engine/strata (upstream 41cf05a0 plus 25 locally patched files), engine/README.md, engine/upstream.md (its pin record moved to
third_party/strata/UPSTREAM.md) and engine/upstream/ (the two local-patch diffs against the removed tree). They belong to the same vendored mechanism.
- The files Rust and the product still read were moved to third_party/strata and control-plane/tests/mcp_hub in the first commit of this branch.
- The full tree is in git history before this commit; 87e2633af is the last commit that changed it. Restore with `git archive <this commit>^ engine/strata`.
- Four doc-comment lines that the path rewrite made too wide are re-wrapped (check-limits stays at 0 errors).
96 lines
3.8 KiB
Rust
96 lines
3.8 KiB
Rust
//! Build identity for `leleka version`.
|
|
//!
|
|
//! Embeds the git commit of the tree the binary was built from, whether that tree had uncommitted changes, and the
|
|
//! Strata upstream pin recorded in `third_party/strata/UPSTREAM.md`. The release packager
|
|
//! (`scripts/release/package-5090.sh`) exports `LELEKA_GIT_COMMIT` and `LELEKA_GIT_DIRTY` so the values do not
|
|
//! depend on `git` being callable from the build script; an ordinary developer build asks git itself and falls
|
|
//! back to `unknown` (an exported tree has no `.git`).
|
|
//! Nothing here reads the network or changes the generated code of the engine.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::Command;
|
|
|
|
fn git(repo: &Path, args: &[&str]) -> Option<String> {
|
|
let output = Command::new("git")
|
|
.args(args)
|
|
.current_dir(repo)
|
|
.output()
|
|
.ok()?;
|
|
if !output.status.success() {
|
|
return None;
|
|
}
|
|
Some(String::from_utf8_lossy(&output.stdout).trim().to_owned())
|
|
}
|
|
|
|
/// The 40-hex commit on the `Upstream commit SHA` row of the pin table in `third_party/strata/UPSTREAM.md`.
|
|
fn upstream_pin(doc: &Path) -> Option<String> {
|
|
let text = std::fs::read_to_string(doc).ok()?;
|
|
let line = text
|
|
.lines()
|
|
.find(|line| line.contains("Upstream commit SHA"))?;
|
|
let start = line.find('`')? + 1;
|
|
let end = start + line[start..].find('`')?;
|
|
let sha = &line[start..end];
|
|
(sha.len() == 40 && sha.bytes().all(|b| b.is_ascii_hexdigit()))
|
|
.then(|| sha.to_ascii_lowercase())
|
|
}
|
|
|
|
fn main() {
|
|
let manifest = PathBuf::from(
|
|
std::env::var_os("CARGO_MANIFEST_DIR").expect("cargo sets CARGO_MANIFEST_DIR"),
|
|
);
|
|
let repo = manifest.join("..").join("..");
|
|
let doc = repo.join("third_party").join("strata").join("UPSTREAM.md");
|
|
emit_reruns(&repo, &doc);
|
|
let commit = std::env::var("LELEKA_GIT_COMMIT")
|
|
.ok()
|
|
.filter(|value| !value.trim().is_empty())
|
|
.or_else(|| git(&repo, &["rev-parse", "HEAD"]))
|
|
.unwrap_or_else(|| "unknown".to_owned());
|
|
let dirty = tree_state(&repo);
|
|
let pin = upstream_pin(&doc).unwrap_or_else(|| "unknown".to_owned());
|
|
|
|
println!("cargo:rustc-env=LELEKA_BUILD_COMMIT={commit}");
|
|
println!("cargo:rustc-env=LELEKA_BUILD_TREE={dirty}");
|
|
println!("cargo:rustc-env=LELEKA_BUILD_STRATA_PIN={pin}");
|
|
println!(
|
|
"cargo:rustc-env=LELEKA_BUILD_TARGET={}",
|
|
std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_owned())
|
|
);
|
|
println!(
|
|
"cargo:rustc-env=LELEKA_BUILD_PROFILE={}",
|
|
std::env::var("PROFILE").unwrap_or_else(|_| "unknown".to_owned())
|
|
);
|
|
}
|
|
|
|
/// When cargo has to run this script again: the packager variables, the pin document, a commit or a branch switch.
|
|
fn emit_reruns(repo: &Path, doc: &Path) {
|
|
println!("cargo:rerun-if-env-changed=LELEKA_GIT_COMMIT");
|
|
println!("cargo:rerun-if-env-changed=LELEKA_GIT_DIRTY");
|
|
println!("cargo:rerun-if-changed={}", doc.display());
|
|
// A commit moves the reflog of HEAD; a branch switch moves HEAD itself.
|
|
for name in ["HEAD", "logs/HEAD"] {
|
|
if let Some(path) = git(repo, &["rev-parse", "--git-path", name]) {
|
|
println!("cargo:rerun-if-changed={}", repo.join(path).display());
|
|
}
|
|
}
|
|
}
|
|
|
|
/// `clean`, `dirty` or `unknown`: from the packager variable, else from git.
|
|
fn tree_state(repo: &Path) -> &'static str {
|
|
match std::env::var("LELEKA_GIT_DIRTY")
|
|
.ok()
|
|
.filter(|value| !value.trim().is_empty())
|
|
{
|
|
Some(value) => match value.trim() {
|
|
"0" | "no" | "false" | "clean" => "clean",
|
|
_ => "dirty",
|
|
},
|
|
None => match git(repo, &["status", "--porcelain", "--untracked-files=no"]) {
|
|
Some(status) if status.is_empty() => "clean",
|
|
Some(_) => "dirty",
|
|
None => "unknown",
|
|
},
|
|
}
|
|
}
|