build_variables.php
This minimal file defines a single global array that acts as a registry of files modified during the build pipeline.
Read this when Use this page when tracing PHP asset generation, build hooks, template assembly, or maintenance scripts around build_variables.
Overview
This minimal file defines a single global array that acts as a registry of files modified during the build pipeline. It provides shared state that multiple build scripts can append to, allowing the build system to track which generated or versioned files were created or updated during a build run.
The $updated_files array is initialized empty and populated by the build scripts (e.g. build_mode_css.php, build_font_css.php, build_unified_assets.php, version_asset_links.php) when they write output files. The consumer is pre-commit.hook.php: after running each build script, it stages the accumulated files with git add and resets the array to empty.
While simple, this shared state mechanism is important for coordinating between multiple PHP scripts that run in sequence during the build process. Each script can append to this array to communicate what it modified.
Key Variables
$updated_files- Array that accumulates paths of files written/updated during build
Input/Output
Input: None (initialized empty)
Output: Provides global $updated_files array for other scripts to populate
Usage
Imported by build scripts that generate files:
require_once(__DIR__ . '/build_variables.php');
global $updated_files;
// After writing a file:
$updated_files[] = $versioned_file_path;
Used by:
- Nearly all of the generator scripts (
build_mode_css.php,build_font_css.php,build_versioned_font_css.php,build_icon_sprite_file.php,build_asset_versions.php,build_inlined_images.php,build_unified_assets.php,version_asset_links.php,build_head_includes.php,build_body_includes.php,build_standalone_includes.php) - Append the paths of files they write pre-commit.hook.php- Consumes the array: after each build script runs, it executesgit addon the accumulated paths and clears the array
See Also
- build_paths.php - Directory path constants (often imported together)
- build_functions.php - Utility functions (third shared module)
- build_unified_assets.php - Main bundler that tracks file updates
- version_asset_links.php - Appends to
$updated_files - build_asset_versions.php - Another script that tracks updated files
- pre-commit-hook.php - Consumes
$updated_files(stages them viagit add)