From 92ded3e3711c014187360da4820c00f8edf476b9 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Sat, 14 Mar 2026 08:05:14 +0700 Subject: [PATCH] Export source identifiers into build script --- src/bin/repo.rs | 4 +--- src/cook/cook_build.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/bin/repo.rs b/src/bin/repo.rs index ef8e50e7a..1c5817a72 100644 --- a/src/bin/repo.rs +++ b/src/bin/repo.rs @@ -697,10 +697,8 @@ fn handle_cook( recipe_dir, &source_dir, &target_dir, - &recipe.name, - &recipe.recipe, + &recipe, &config.cook, - !recipe.is_deps, logger, ) .map_err(|err| anyhow!("failed to build: {:?}", err))?; diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index 302d7a385..392a2464b 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -2,10 +2,10 @@ use pkg::PackageError; use pkg::{Package, PackageName}; use crate::config::CookConfig; -use crate::cook::fs::*; use crate::cook::package::{package_source_paths, package_target}; use crate::cook::pty::PtyOut; use crate::cook::script::*; +use crate::cook::{fetch, fs::*}; use crate::recipe::Recipe; use crate::recipe::{AutoDeps, CookRecipe}; use crate::recipe::{BuildKind, OptionalPackageRecipe}; @@ -171,12 +171,13 @@ pub fn build( recipe_dir: &Path, source_dir: &Path, target_dir: &Path, - name: &PackageName, - recipe: &Recipe, + cook_recipe: &CookRecipe, cook_config: &CookConfig, - check_source: bool, logger: &PtyOut, ) -> Result<(Vec, BTreeSet), String> { + let recipe = &cook_recipe.recipe; + let name = &cook_recipe.name; + let check_source = !cook_recipe.is_deps; let sysroot_dir = target_dir.join("sysroot"); let toolchain_dir = target_dir.join("toolchain"); let stage_dirs = get_stage_dirs(&recipe.optional_packages, target_dir); @@ -442,6 +443,11 @@ pub fn build( if cook_config.offline { command.env("COOKBOOK_OFFLINE", "1"); } + if let Ok(ident_source) = fetch::fetch_get_source_info(&cook_recipe) { + command.env("COOKBOOK_SOURCE_IDENT", ident_source.source_identifier); + command.env("COOKBOOK_COMMIT_IDENT", ident_source.commit_identifier); + command.env("COOKBOOK_TIME_IDENT", ident_source.time_identifier); + } command };