The generated UE project and its packaging
A Ferret project that is built for Unreal Engine becomes a native UE C++ project (<Name>.uproject) that a person keeps editing in Unreal (levels are .umap maps with ordinary actors, models are Blueprint actor classes), and a packaged Windows game. Both are returned: the zipped game and the zipped project. This page is about the second half of the build: the generator (tools/ue-cpp/project/generate.mjs), the content import (import_project.py) and the packaging driver (package.mjs). The translation of the TypeScript to C++ is the translator's part; the job that runs all of it on the person's computer is described under the importer app.
The layout#
<Name>/
<Name>.uproject module <Name>; plugins FerretRuntime, PythonScriptPlugin, EditorScriptingUtilities, Interchange
Config/DefaultEngine.ini start map, game mode, Win64 RHI and shader formats, Lumen
Config/DefaultGame.ini ProjectVersion = the build stamp, packaging settings
Config/DefaultInput.ini, DefaultEditor.ini
Source/<Name>.Target.cs the game target; <Name>Editor.Target.cs the editor target (the import needs it)
Source/<Name>/ <Name>.Build.cs, <Name>.h/.cpp, <Name>GameMode.h/.cpp (no default pawn)
Source/<Name>/Translated/ the translator's output, one .cpp per module, and _FerretEntry.cpp
Plugins/FerretRuntime/ the runtime plugin (copy of tools/ue-cpp/plugin/FerretRuntime)
FerretAssets/ ferret-assets.json (what the import reads) and the source files of the assets
Content/Ferret/Start.umap the start map, with an AFerretGameHost (made by the import)
Content/Ferret/Levels/<L>/ one .umap per level package, with its meshes, materials and textures
Content/Ferret/Assets/... the imported models (with BP_<name>), textures, sounds, fonts
Content/Ferret/Data/ files the game reads by their original path, staged as non-UFS: files/, asset-map.json
FERRET_BUILD the stamp
The stamp is the local time of the building computer, yyyymmddHHMM (never UTC). It is written to ProjectVersion and shown by AFerretGameHost::BuildStamp().
Translated modules. Every .cpp/.h of the translator's output is copied to Source/<Name>/Translated/. The translator's own main() is not copied: _FerretEntry.cpp is generated from the order of hoist_N() / init_N() calls in its main.cpp and registers one module, FERRET_REGISTER_MODULE(FerretTranslated, ...), that AFerretGameHost runs at BeginPlay. A hand-written scene registers the same way (see tools/ue-cpp/project/proof-src/). Modules run in the order of their names. bEnableExceptions is on by default (a JavaScript throw is a C++ throw); exceptions: false turns it off.
Names are kept. A runtime lookup by the original path works: Content/Ferret/Data/asset-map.json maps each original asset path to its UE objects, and data files are staged under Content/Ferret/Data/files/<original path> so fetch reads them as in the browser.
The asset list and the import#
assets.mjs lists the files the game can load and gives each a kind. Where it looks:
- An editor project (
ferret.jsonat its root, as the editor makes it): the whole project exceptsrc/and code files (.ts,.js, ...: they are the translator's input). Its levels arelevels/<id>/manifest.jsonwith the scene next to it, no tier folder.ferret.jsonnames the code entry (entry.code, translated), the start level (entry.level: its map becomesGameDefaultMap, with theAFerretGameHostin it) and the spawn (entry.spawn: itsPlayerStartis taggedFerretStart, and the generated game mode starts the player there). A start level or a code entry that is not in the project stops the build before any UE step. - Any other project: its
assets/folder (levels aslevels/<Level>/<tier>/manifest.json); the start map is an empty/Game/Ferret/Startwith the host. - Or only what the translator reached (
onlyAssets).
| Kind | Files | In UE |
|---|---|---|
| level | levels/<Level>/<tier>/manifest.json + the scene .glb + data | one tier (desktop, else the first) becomes /Game/Ferret/Levels/<Level>/<Level>.umap: meshes, materials and textures as assets, the nodes as actors with the package's names and transforms, a PlayerStart per spawn (the importer tools/ue-export/ue/import_ferret.py is reused) |
| model | .glb, .gltf | Interchange import into its own folder /Game/Ferret/Assets/<path>/<name>/ (static or skeletal meshes, materials, textures, animations) and a Blueprint actor class BP_<name> whose components are the glTF nodes: the node names, the parents, the local transforms (glTF metres, right-handed, to UE centimetres, left-handed) and the meshes. The game code's spawn of the model and its lookups by node name work on it |
| texture | .png .jpg .jpeg .tga .bmp .hdr .exr | UTexture2D |
| sound | .wav .flac .ogg .mp3 | USoundWave |
| font | .ttf .otf | UFontFace |
| data | .json .bin .txt .md .csv .xml .ktx2 .wasm .html .css .svg .webp .dds .ico | the file itself, non-UFS, read through the plugin's file access |
Nothing is skipped silently (the tiers of a level package that are not imported are named in the list). The generator fails with the whole list when a file has an unknown type, two assets would get one UE name, a glTF uses EXT_meshopt_compression or KHR_draco_mesh_compression (decode it first), or has KTX2 textures without a PNG/JPEG fallback (UE cannot read KTX2). The import script fails with the list of assets that did not import.
import_project.py runs in the editor commandlet (UnrealEditor-Cmd -run=pythonscript, no rendering), imports every entry, puts an AFerretGameHost into the start map (the start level of ferret.json, else a new /Game/Ferret/Start) and tags the start spawn, and writes asset-map.json (original path to UE objects; for a model its Blueprint and component names).
Packaging#
buildProject({ projectDir, workDir, config, engine, onProgress, signal, ... }) in package.mjs returns { gameZip, projectZip } (and zipPath, the game zip, for the daemon's build step). The stages, each reported as onProgress(stage, fraction) and written to one log (<workDir>/build.log):
fetch: the project folder is read.translate: when the project has its code entry (ferret.jsonentry.code, elsesrc/main.ts) and notranslatedDirwas handed in. The translator runs as a process of its own (node tools/ue-cpp/cli.mjs translate <project> --entry <file> --out <dir> --all) with the folder that holdspackages/andtsconfig.jsonas its root: the repository, or the importer app's toolkit, which is laid out the same way. When it refuses, the build fails with every place it cannot translate (file:line: what).generate: the UE project in<workDir>/ue/<Name>/.compile:Build.bat <Name>Editor Win64 Development -MaxParallelActions=8.import: the content import above.cook,stage,package: oneRunUAT BuildCookRun -platform=Win64 -clientconfig=<config> -build -cook -stage -pak -iostore -archive; the stage is read from the log (COOK/STAGE/PACKAGE COMMAND STARTED, cooked packages).zip:<Name>-<stamp>.zip(the game folder with<Name>.exe) and<Name>-<stamp>-project.zip(the project withoutBinaries,Intermediate,Saved,DerivedDataCache).
| Option | Meaning |
|---|---|
config | Development (default) or Shipping |
name | game and module name (letters, digits, _; default from the folder) |
engine | {dir, version} of the engine; default FERRET_UE_DIR, the installs the importer app finds, C:\Epic Games\UE_5.8 |
rhi | dx12 (default: SM6, Lumen, virtual shadow maps) or dx11 |
translatedDir, extraSources, assets, onlyAssets, startMap, stamp, pluginDir | what is generated from, and where |
limits | {stallMs, timeoutMs, graceMs}; env FERRET_BRIDGE_STALL_MS (30 min), FERRET_BRIDGE_STEP_TIMEOUT_MS (6 h), FERRET_BRIDGE_KILL_GRACE_MS (20 s) |
Limits. At most 8 CPU cores: UBT runs with -MaxParallelActions=8 and every process is started with the affinity mask FF, which the shader workers and the cook inherit. A step whose log does not grow for stallMs, or that runs longer than timeoutMs, is killed; a process that outlives its kill by graceMs is given up. Cancel: aborting the signal kills the process tree (UBT, the editor, the shader workers) at once and rejects with Cancelled.
The proof#
node tools/ue-cpp/project/proof.mjs [--config Development|Shipping] generates a project from a hand-written scene (a lit cube on a floor and a camera) and a few real assets (a level package, a glTF model, a texture, a sound, a font, a JSON file), packages it, starts the .exe, takes a screenshot of the running game (once the pipeline states of the scene's own meshes are compiled and 120 frames have been drawn with them: on the first start of a fresh build UE draws a mesh only after its PSO precache, while the engine as a whole keeps precaching for minutes; the 90 s last resort fails the proof) and checks that the renderer is the NVIDIA RTX 3050, opens the generated project in the editor commandlet and checks its start map and that the log holds no errors. The report and the files are in D:\temp\ue-cpp\proof.