Skip to main content

.ctproject (project file)

A .ctproject is a game.json with build targets added. Each build target says which platform to export for, how your BT code ships, and where the finished game goes. Studio opens a .ctproject as a project, and ctgame build --target NAME builds one of its targets. Anything that runs a game.json can also run a .ctproject.

Put it at the project root (Studio names it project.ctproject). Relative paths are relative to its folder.

Example​

{
"version": "1.0.0",
"game": { "name": "My Game" },
"module": { "name": "my-game" },
"bt": { "sources": ["bt/main.bt"], "entry": "launchGame" },
"build_targets": [
{
"name": "Windows",
"platform": "windows",
"code_mode": "aot_shared",
"output": "build/windows/MyGame.exe",
"deployment": "D:/Games/MyGame"
},
{
"name": "Linux",
"platform": "linux",
"code_mode": "aot_linked",
"output": "build/linux/MyGame"
},
{
"name": "WebAssembly",
"platform": "webassembly",
"code_mode": "bytecode",
"output": "build/web/index.html"
}
]
}

build_targets[]​

All game.json fields apply, including your game's version and the optional format section. The project file adds build_targets, an array of targets:

FieldTypeDefaultDescription
namestring—Required. Target name, used with ctgame build --target NAME. Must be unique.
platformstringdesktopdesktop (the computer you build on), windows, linux, macos or webassembly. Desktop platforms must match the computer running the build.
code_modestring—How your BT code ships; see Code modes. If omitted, the manifest's bt section is packaged as it is.
outputstring—Required. Path of the executable to produce, including its name (with .exe on Windows), or the .html page for webassembly. Its folder must be a separate folder just for the build, not the project folder.
deploymentstring—Folder that Build & Deploy (--deploy) replaces with the finished build, for example a test install folder. Everything already in it is replaced.
bt_debug_runtimebooleanfalseDesktop only. Build with the debugger-capable BT runtime so a debugger can attach to the exported game (keeps bt.debug). Needs no C toolchain unless the game has its own C code (Toolchains).
native_buildobject—Deprecated. Ignored by exports; Studio keeps it when saving.

Code modes​

ValueWhat ships (Linux/Windows x64)WebAssembly
sourceYour .bt scripts, compiled when the game starts.Supported
bytecodePrecompiled bytecode (bin/program.ctbt). Starts faster than source and doesn't ship your scripts.Supported (JIT off)
aot_embeddedMachine code inside the executable. One file; no C compiler needed.Not supported
aot_sharedThe executable plus bin/program.dll or bin/program.so beside it. Ship both.Not supported
aot_linkedMachine code linked into the executable. One file, fastest startup; needs a C toolchain. aot_static means the same.Not supported

AOT means ahead-of-time: your scripts are compiled to machine code at build time. See Deployment modes for how to choose. macOS is Not supported (Platforms).

What a build does​

  • A desktop build replaces the output folder with a fresh copy that contains only the game (the executable, plus bin/program.* for aot_shared). If the build fails, the previous build is left in place.
  • A web build writes its files into the output folder and leaves other files there alone.
  • Build caches go in a .ctbuild/ folder in the project. Don't commit it; deleting it is safe but makes the next build slower. See Files a build produces.
  • Compiled code modes compile bt.sources and the ui.entry script together. Every script folder is packaged whole, so any package your scripts include must be inside a script folder or listed in package.copy.
  • If the project has native.sources, the C code is compiled into the executable. See Native SDK.
  • ctgame never modifies your project files.

-o, --icon, --wasm and --wasm-build-dir can't be combined with --target. See ctgame.

In Studio​

  • If the project has no target for Windows, Linux or WebAssembly, Studio shows a default one (outputs build/windows/game.exe, build/linux/game, build/web/index.html). These are saved to the file only when you save or build.
  • Studio only rewrites build_targets and studio_debug_host; the rest of the file is left exactly as you wrote it. If the file changed on disk since Studio loaded it, use Reload Targets before saving.
  • Create Project File copies your game.json to project.ctproject in the same folder. The two files are independent afterwards.
  • Your local toolchain paths (CMake, compiler) are stored per machine, not in the project; see Studio user state.

Errors​

MessageCause
Each build target needs a name and output pathA target is missing name or output.
Build target names must be unique / duplicate build target nameTwo targets share a name.
unknown build targetNo target has the name given to --target.
build target platform does not match this hostDesktop targets must be built on that OS.
target output must be an executable in a separate package directoryoutput is missing or its folder is the project folder (or contains it).
deployment must be a separate folder outside the output folder--deploy without deployment, or the two folders overlap.
unknown code deployment modeMisspelled code_mode.
WebAssembly supports loose scripts and bytecode; BT AOT emits x64 codeUse source or bytecode for web targets.
loose-script mode requires source inputs in the projectcode_mode: "source" needs bt.sources, not bt.program.
compiled targets require BT source inputsThe project has no bt section to compile.

Older project files​

Studio still opens an old-style .ctproject that just points at a game.json:

version: 1
manifest: "game.json"

ctgame doesn't accept this form. Use Create Project File from the game.json to get a current project file.

See also​