Source File Compilation
Purpose
The source file compilation stage is the core of the build process. It compiles source files (.erl, .yrl, .xrl, .mib, etc.) into their target artifacts (.beam, .bin, .hrl), managing dependencies between files, determining what needs recompilation, executing compilers in the correct order, supporting parallel compilation where possible, and tracking compiled artifacts for incremental builds.
When It Executes
This stage executes within rebar_prv_compile after application discovery and ordering:
- Dependency Compilation:
copy_and_build_deps/4compiles all dependencies - Project App Compilation:
copy_and_build_project_apps/3compiles project applications - Root Extras Compilation:
build_root_extras/2compiles extra source directories
Within each context, the compile/4 function orchestrates multiple sub-stages.
Prerequisites
- Applications discovered and ordered
- Dependencies fetched and ready
- Output directories created
- Code paths configured
- DAGs (Dependency Graphs) initialized for each compiler
Outputs
- Compiled
.beamfiles inebin/directories - Generated header files (
.hrlfrom.yrl,.mib) - Generated source files (
.erlfrom.yrl,.xrl) - Updated DAGs with artifact metadata and timestamps
- Code available for subsequent compilation stages