Baking Pipeline
This document explains the engine resource baking pipeline: where it is wired, which source files own baker behavior, and how to validate changes. For the broader engine tool map, see Tools.md.
Use this for reusable engine behavior. Game-specific content folder rules and product package policy belong in the embedding project’s docs.
Source paths inspected
BuildTools/cmake/stages/ScriptsAndBaking.cmakeBuildTools/cmake/helpers/WriteBuildHash.cmakeSource/Applications/BakerApp.cppSource/Applications/BakerLib.cppSource/Tools/Baker.hSource/Tools/Baker.cppSource/Tools/MetadataBaker.hSource/Tools/MetadataBaker.cppSource/Tools/ConfigBaker.hSource/Tools/ConfigBaker.cppSource/Tools/RawCopyBaker.hSource/Tools/RawCopyBaker.cppSource/Tools/ImageBaker.hSource/Tools/ImageBaker.cppSource/Tools/EffectBaker.hSource/Tools/EffectBaker.cppSource/Tools/ProtoBaker.hSource/Tools/ProtoBaker.cppSource/Tools/MapBaker.hSource/Tools/MapBaker.cppSource/Tools/TextBaker.hSource/Tools/TextBaker.cppSource/Tools/ProtoTextBaker.hSource/Tools/ProtoTextBaker.cppSource/Tools/ModelMeshBaker.hSource/Tools/ModelMeshBaker.cppSource/Tools/ModelInfoBaker.hSource/Tools/ModelInfoBaker.cppSource/Tools/AngelScriptBaker.hSource/Tools/AngelScriptBaker.cppSource/Tests/Test_BakerSetup.cppSource/Tests/Test_MetadataBaker.cppSource/Tests/Test_ConfigBaker.cppSource/Tests/Test_RawCopyBaker.cppSource/Tests/Test_ImageBaker.cppSource/Tests/Test_EffectBaker.cppSource/Tests/Test_ProtoBaker.cppSource/Tests/Test_ProtoTextBaker.cppSource/Tests/Test_MapBaker.cppSource/Tests/Test_TextBaker.cppSource/Tests/Test_ModelBaker.cppSource/Tests/Test_AngelScriptBaker.cpp
What baking does
Baking turns project resources and configuration into runtime-ready output. The build pipeline creates BakeResources and ForceBakeResources command targets in BuildTools/cmake/stages/ScriptsAndBaking.cmake. Those targets run the project baker application with the embedding project’s main config applied.
At runtime/source level, baking is owned by:
Source/Applications/BakerApp.cpp— executable app wrapper that constructsMasterBakerand callsBakeAll().Source/Applications/BakerLib.cpp— exported library entry pointFO_BakeResources()for library-based baking flows.Source/Tools/Baker.h/Source/Tools/Baker.cpp— shared baking context, baker setup, data source, output writing, andMasterBaker.
CMake entry points
BuildTools/cmake/stages/ScriptsAndBaking.cmake creates baking commands after application targets are available.
Current target responsibilities:
BakeResourcesruns the project baker with-ForceBaking False.ForceBakeResourcesruns the project baker with-ForceBaking True.- Both apply the embedding project’s main config through
-ApplyConfig <FO_MAIN_CONFIG>and-ApplySubConfig NONE. - Both work from
FO_OUTPUT_PATH. - Resource build-hash state is written through
BuildTools/cmake/helpers/WriteBuildHash.cmakeusingBaking/Resources.build-hash.
The actual final target names that depend on these commands are project/preset-dependent. Do not document one embedding project’s target names as universal engine behavior.
Runtime classes
BakingContext
Defined in Source/Tools/Baker.h. It carries shared bake state:
Settings—BakingSettingsfor the current bake.PackName— current resource pack name.BakeChecker— callback used to decide whether existing baked data is still valid.WriteData— async output writer callback.BakedFiles— existing baked file data source.ForceSyncMode— optional override for synchronous execution.
BaseBaker
The abstract base for individual baker implementations. Each baker provides:
GetName()— stable baker name used by setup/config selection.GetOrder()— ordering key for deterministic bake ordering.BakeFiles()— the actual file transformation step.
BaseBaker::SetupBakers() in Source/Tools/Baker.cpp creates requested bakers and then calls SetupBakersHook() so external/project code can extend the baker list.
MasterBaker
MasterBaker coordinates a full bake through BakeAll(). It is the app-facing type used by both BakerApp.cpp and BakerLib.cpp.
BakerDataSource
BakerDataSource adapts resource inputs/outputs to the engine DataSource interface. It tracks input resource packs, output resources, cache checks, and output path construction.
Built-in baker types
Source/Tools/Baker.cpp registers built-in bakers when requested and enabled:
MetadataBaker—Source/Tools/MetadataBaker.*ConfigBaker—Source/Tools/ConfigBaker.*, nameConfig, order2RawCopyBaker—Source/Tools/RawCopyBaker.*, nameRawCopy, order4ImageBaker—Source/Tools/ImageBaker.*EffectBaker—Source/Tools/EffectBaker.*ProtoBaker—Source/Tools/ProtoBaker.*, nameProto, order6MapBaker—Source/Tools/MapBaker.*, nameMap, order7TextBaker—Source/Tools/TextBaker.*, nameText, order4ProtoTextBaker—Source/Tools/ProtoTextBaker.*ModelMeshBaker—Source/Tools/ModelMeshBaker.*, enabled whenFO_ENABLE_3Dis activeModelInfoBaker—Source/Tools/ModelInfoBaker.*, enabled whenFO_ENABLE_3Dis activeAngelScriptBaker—Source/Tools/AngelScriptBaker.*, enabled whenFO_ANGELSCRIPT_SCRIPTINGis active
When documenting a specific asset type, inspect the relevant baker class and its tests rather than inferring behavior from file extensions alone.
Script compilation relationship
ScriptsAndBaking.cmake also creates script compilation commands:
CompileAngelScriptruns the project AS compiler target whenFO_ANGELSCRIPT_SCRIPTINGis enabled.CompileMonoScriptsrunsBuildTools/compile-mono-scripts.pywhenFO_MONO_SCRIPTINGis enabled.
These are separate command targets from resource baking, but they share the same stage because generated/baked runtime inputs are part of the same build preparation workflow.
Tests to inspect
Baker behavior is covered by focused tests in Source/Tests/:
Test_BakerSetup.cppTest_ConfigBaker.cppTest_MetadataBaker.cppTest_RawCopyBaker.cppTest_ImageBaker.cppTest_EffectBaker.cppTest_ProtoBaker.cppTest_ProtoTextBaker.cppTest_MapBaker.cppTest_TextBaker.cppTest_ModelBaker.cppTest_AngelScriptBaker.cpp
Use the smallest test that matches the baker you changed. If CMake target names are generated by the embedding project, discover them from that project’s presets/build files instead of hard-coding them here.
Change routing
- New baker type: add/modify
Source/Tools/*Baker.*, register it inBaseBaker::SetupBakers()or throughSetupBakersHook(), and add focused tests. - Baking command arguments: update
BuildTools/cmake/stages/ScriptsAndBaking.cmake. - Resource build hash behavior: update
BuildTools/cmake/helpers/WriteBuildHash.cmakeand related tests/build validation. - Metadata baking: update
Source/Tools/MetadataBaker.*and GeneratedApiAndMetadata.md. - Script-specific bake behavior: update
Source/Tools/AngelScriptBaker.*and Scripting.md.
Validation checklist
- Configure from an embedding project root.
- Build the project baker application/library target if the changed path affects app/library code.
- Run the relevant baker test(s) under
Source/Tests/. - Run
BakeResourcesfor incremental behavior when cache/build-hash logic matters. - Run
ForceBakeResourceswhen forced rebuild behavior matters. - Inspect generated output only as output, not as hand-authored source.
- Update this document and BuildToolsPipeline.md if stage responsibilities change.