utils/ directory. These are the core tools used throughout the Helium build process for source tree preparation, patching, and packaging.
Overview
The build utilities provide essential functionality for:- Applying and managing patches in GNU Quilt format
- Domain substitution to replace Google domains
- Binary pruning to remove unwanted files
- Source tree downloads and extraction
- Portable package creation
Patch Management
patches.py
Apply and merge patches in GNU Quilt format.The directory tree to apply patches onto
One or more directories containing patches in GNU Quilt format
The GNU patch command to use (auto-detected if omitted)
Enable or disable fuzzy matching when applying patches
Patch detection order
Patch detection order
The script finds the patch binary in this order:
- Uses
--patch-binif specified - Checks
PATCH_BINenvironment variable - Searches for
patchin PATH usingwhich
Merging Patches
Combine multiple patch directories into a single directory.Directory to write merged patches (must not exist unless using —prepend)
GNU Quilt patch directories to merge
Prepend patches to existing destination directory
Dry Run Checking
The module also exportsdry_run_check() for programmatic patch validation:
Domain Substitution
domain_substitution.py
Replace Google domains with blockable placeholder strings.Domain substitution makes it easier to identify and block Google services using hosts files or firewall rules.
Apply Mode
The directory to apply domain substitution
Path to domain_regex.list containing substitution patterns
Path to domain_substitution.list (files to process)
Path to store domain substitution cache (compressed tar)
How domain substitution works
How domain substitution works
- Reads regex patterns from domain_regex.list
- Processes each file in domain_substitution.list
- Applies regex substitutions to file contents
- Saves original content to cache with CRC32 hashes
- Updates file timestamps to track modifications
- Creates cache index for reverting changes
Revert Mode
The directory to reverse domain substitution
Path to the domain substitution cache
Revert process
Revert process
- Extracts cache to temporary directory
- Validates substituted files match expected hashes
- Restores original files from cache
- Removes cache file if successful
- Warns about unused files in cache
Domain Regex Format
Thedomain_regex.list file uses this format:
- Pattern: Regular expression to match
- Delimiter:
#character - Replacement: String to replace matches with
Binary Pruning
prune_binaries.py
Remove binary files and unwanted directories from the source tree.The directory to apply binary pruning
Path to pruning.list file
Skip pruning contingent paths (useful when building with Google tooling)
amd64 - Skip pruning amd64 sysroot
i386 - Skip pruning i386 sysroot
i386 - Skip pruning i386 sysroot
Contingent Paths
Contingent paths are automatically pruned unless--keep-contingent-paths is specified:
Build tools and dependencies
Build tools and dependencies
- CIPD packages (buildtools, third_party tools)
- GCS downloads (sysroots, test data)
- Google-specific build tools
- JDK packages
Test data and fixtures
Test data and fixtures
- Web tests and browser tests
- Performance test datasets
- Fuzzer corpora
- Test fonts and media files
Platform-specific
Platform-specific
- Android WebView
- iOS sources
- Chromecast
- Native Client
Some files are always kept even in contingent paths:
.gn, .gni, .grd, .grdp, .isolate, and .pydeps files.Downloads Management
downloads.py
Download, verify, and extract required files into the source tree.Path to downloads.ini configuration
Directory to store downloaded files
Source tree path (for unpack command)
downloads.ini Format
The configuration file uses INI format:Download URL (supports
{_chromium_version} variable)Filename to save as
Relative path in source tree for extraction
Expected SHA256 hash for verification
tar - Use tar for extraction
7z - Use 7-Zip
winrar - Use WinRAR
7z - Use 7-Zip
winrar - Use WinRAR
Number of leading directory components to strip during extraction
Hash verification
Hash verification
Supported hash algorithms:
- MD5 (
md5key) - SHA1 (
sha1key) - SHA256 (
sha256key) - SHA512 (
sha512key) - Hash URLs (
hash_urlkey with format:chromium|path|algorithm)
Source Tree Cloning
clone.py
Clone a Chromium source tree from various sources.Packaging
filescfg.py
Create portable packages using FILES.cfg specifications.Path to FILES.cfg specification
Directory containing build outputs
Output archive path (.tar.gz, .tar.xz, or .zip)
Unix timestamp for reproducible archives
FILES.cfg format
FILES.cfg format
FILES.cfg is a Python file that defines which files to include:Each entry supports:
filename: Glob patternbuildtype: List of build types (must include ‘official’)arch: CPU architecture filter
Version Management
helium_version.py
Manage Helium version information.Name Substitution
name_substitution.py
Replace product names throughout the source tree.Resource Generation
generate_resources.py
Generate resource files from templates.Common Patterns
Complete source tree preparation
Complete source tree preparation
Reverting changes for testing
Reverting changes for testing
Module Imports
These utilities can also be imported as Python modules:See Also
Developer Utilities
Validation and development tools for maintaining Helium
Build Process
Complete guide to building Helium from source