|
| 1 | +# WARP.md |
| 2 | + |
| 3 | +This file provides guidance to WARP (warp.dev) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +GDevelop is a full-featured, no-code, open-source game development software for creating 2D, 3D and multiplayer games. The codebase consists of: |
| 8 | +- **Core** (C++): Game structure and IDE manipulation tools |
| 9 | +- **GDJS** (TypeScript): The game engine using PixiJS and Three.js |
| 10 | +- **GDevelop.js**: WebAssembly bindings of Core/GDJS/Extensions to JavaScript |
| 11 | +- **newIDE** (React/Electron): The game editor application |
| 12 | +- **Extensions**: Objects, behaviors, and features for the game engine |
| 13 | + |
| 14 | +## Architecture Fundamentals |
| 15 | + |
| 16 | +### IDE vs Runtime Distinction |
| 17 | +- **IDE/Editor**: Code that runs in the GDevelop editor (not in games) |
| 18 | +- **Runtime**: Code that runs during a game (the game engine) |
| 19 | +- Extensions have both IDE declarations (in `JsExtension.js`) and Runtime implementations (in TypeScript files) |
| 20 | +- For example: `gd::Variable` (IDE, in Core) vs `gdjs.Variable` (Runtime, in GDJS) |
| 21 | + |
| 22 | +### Key Directories |
| 23 | +- `Core/GDCore/Project/`: Classes describing game structure (Project, Scene, Object, Behavior, Events) |
| 24 | +- `Core/GDCore/IDE/`: Tools for manipulating projects (refactoring, search, etc.) |
| 25 | +- `GDJS/Runtime/`: Game engine (TypeScript) |
| 26 | +- `GDJS/GDJS/`: C++ IDE part (exporters, code generation from events) |
| 27 | +- `GDevelop.js/Bindings/Bindings.idl`: Interface definition for C++ to JavaScript bridge |
| 28 | +- `newIDE/app/`: React-based editor application |
| 29 | +- `Extensions/`: Built-in extensions (not part of Core) |
| 30 | + |
| 31 | +### Events and Code Generation |
| 32 | +- Events are NOT executed at runtime - they are transpiled to JavaScript/TypeScript code |
| 33 | +- Code generation happens in `GDJS/GDJS/Events/CodeGeneration/` |
| 34 | +- A `gd::Instruction` is essentially a function call with parameters |
| 35 | +- StandardEvent contains conditions (filters) and actions |
| 36 | + |
| 37 | +## Common Development Commands |
| 38 | + |
| 39 | +### Setting Up Development Environment |
| 40 | + |
| 41 | +```bash |
| 42 | +# Clone and install IDE dependencies |
| 43 | +git clone https://github.com/4ian/GDevelop.git |
| 44 | +cd GDevelop/newIDE/app |
| 45 | +npm install # or yarn |
| 46 | +``` |
| 47 | + |
| 48 | +### Running the Web IDE |
| 49 | + |
| 50 | +```bash |
| 51 | +cd newIDE/app |
| 52 | +npm start |
| 53 | +# Opens at http://localhost:3000 (or http://gdevelop-app-local.com:3000 for cloud storage testing) |
| 54 | +``` |
| 55 | + |
| 56 | +### Running the Electron App |
| 57 | + |
| 58 | +```bash |
| 59 | +# Terminal 1: Keep the web app running |
| 60 | +cd newIDE/app |
| 61 | +npm start |
| 62 | + |
| 63 | +# Terminal 2: Run Electron |
| 64 | +cd newIDE/electron-app |
| 65 | +npm install |
| 66 | +npm start |
| 67 | +``` |
| 68 | + |
| 69 | +### GDJS Game Engine Development |
| 70 | + |
| 71 | +```bash |
| 72 | +# Build the game engine |
| 73 | +cd GDJS |
| 74 | +npm install |
| 75 | +npm run build |
| 76 | + |
| 77 | +# Build options: |
| 78 | +npm run build # Production build (minified) |
| 79 | +npm run build -- --debug # Debug build (no minification) |
| 80 | +npm run build -- --out=/path/to/output # Custom output path |
| 81 | + |
| 82 | +# Type checking |
| 83 | +npm run check-types |
| 84 | + |
| 85 | +# Format code |
| 86 | +npm run format |
| 87 | + |
| 88 | +# Check formatting |
| 89 | +npm run check-format |
| 90 | +``` |
| 91 | + |
| 92 | +### Running Game Engine Tests |
| 93 | + |
| 94 | +```bash |
| 95 | +cd GDJS/tests |
| 96 | +npm install |
| 97 | + |
| 98 | +# Run tests |
| 99 | +npm run test # Single run with Chrome Headless |
| 100 | +npm run test:watch # Watch mode |
| 101 | +npm run test-benchmark:watch # With benchmarks |
| 102 | +npm run test:firefox:watch # Using Firefox |
| 103 | +``` |
| 104 | + |
| 105 | +### IDE Development |
| 106 | + |
| 107 | +```bash |
| 108 | +cd newIDE/app |
| 109 | + |
| 110 | +# Run tests |
| 111 | +npm test |
| 112 | + |
| 113 | +# Type checking with Flow |
| 114 | +npm run flow |
| 115 | + |
| 116 | +# Format code |
| 117 | +npm run format |
| 118 | + |
| 119 | +# Check formatting |
| 120 | +npm run check-format |
| 121 | + |
| 122 | +# Run Storybook for UI component development |
| 123 | +npm run storybook # Opens on http://localhost:9009 |
| 124 | + |
| 125 | +# Extract translations |
| 126 | +npm run extract-all-translations |
| 127 | + |
| 128 | +# Compile translations |
| 129 | +npm run compile-translations |
| 130 | +``` |
| 131 | + |
| 132 | +### Building GDevelop.js (C++ to WebAssembly) |
| 133 | + |
| 134 | +**Note**: Only needed if modifying C++ code in Core, GDJS Platform, or Extensions. |
| 135 | + |
| 136 | +```bash |
| 137 | +# Install Emscripten 3.1.21 first |
| 138 | +git clone https://github.com/emscripten-core/emsdk/ |
| 139 | +cd emsdk |
| 140 | +./emsdk install 3.1.21 |
| 141 | +./emsdk activate 3.1.21 |
| 142 | + |
| 143 | +# Load Emscripten environment (required for each new terminal session) |
| 144 | +source ./emsdk_env.sh # Linux/macOS |
| 145 | +# or ./emsdk_env.ps1 (Windows PowerShell) |
| 146 | +# or ./emsdk_env.bat (Windows cmd) |
| 147 | + |
| 148 | +# Build GDevelop.js |
| 149 | +cd GDevelop.js |
| 150 | +npm install |
| 151 | +npm run build |
| 152 | + |
| 153 | +# Build variants: |
| 154 | +npm run build -- --variant=dev # Faster linking for development |
| 155 | +npm run build -- --variant=debug # With debugging information |
| 156 | +npm run build -- --variant=debug-assertions # With memory checks |
| 157 | +npm run build -- --variant=debug-sanitizers # With sanitizers (very slow) |
| 158 | + |
| 159 | +# Run tests |
| 160 | +npm test |
| 161 | +``` |
| 162 | + |
| 163 | +### Extension Development |
| 164 | + |
| 165 | +```bash |
| 166 | +# After modifying extension files, changes are auto-imported when IDE is running |
| 167 | +# Watch for console message: "GDJS Runtime update" |
| 168 | + |
| 169 | +# Manual import (if needed): |
| 170 | +cd newIDE/app/scripts |
| 171 | +node import-GDJS-Runtime.js |
| 172 | + |
| 173 | +# Or reload extensions only: |
| 174 | +cd newIDE/app |
| 175 | +npm run reload-extensions |
| 176 | +``` |
| 177 | + |
| 178 | +### Working with Extensions |
| 179 | + |
| 180 | +Extension files are in `Extensions/[ExtensionName]/`: |
| 181 | +- `JsExtension.js`: IDE declaration (actions, conditions, expressions, properties) |
| 182 | +- `*runtimeobject.ts`: Runtime object implementation |
| 183 | +- `*runtimebehavior.ts`: Runtime behavior implementation |
| 184 | +- `*tools.ts`: Runtime functions for actions/conditions |
| 185 | +- `*-pixi-renderer.ts`: PixiJS renderer for objects |
| 186 | +- `*.spec.js`: Tests for the extension |
| 187 | + |
| 188 | +After editing extension files: |
| 189 | +1. If you modified `JsExtension.js`: Reload IDE with Ctrl+R (Cmd+R on macOS) |
| 190 | +2. If you modified Runtime files: Relaunch a game preview |
| 191 | +3. Always check the developer console for errors |
| 192 | + |
| 193 | +## Code Style and Tools |
| 194 | + |
| 195 | +### JavaScript/TypeScript |
| 196 | +- Use Prettier for formatting (already configured) |
| 197 | +- IDE uses Flow for type checking |
| 198 | +- Game engine uses TypeScript |
| 199 | +- Modern JavaScript features are supported (see newIDE/docs/) |
| 200 | + |
| 201 | +### C++ |
| 202 | +- C++11 standard (consider upgrading to C++17) |
| 203 | +- Use clang-format with Google style: `{BasedOnStyle: Google, BinPackParameters: false, BinPackArguments: false}` |
| 204 | +- Configuration in `.clang_format` and `.clang-tidy` |
| 205 | + |
| 206 | +### Recommended VS Code Extensions |
| 207 | +- Prettier - Code formatter |
| 208 | +- ESLint |
| 209 | +- Flow Language Support |
| 210 | +- clang-format |
| 211 | + |
| 212 | +## Testing Strategy |
| 213 | + |
| 214 | +### Game Engine Tests |
| 215 | +- Located in `GDJS/tests/` for core engine |
| 216 | +- Located alongside extensions in `Extensions/[ExtensionName]/tests/` |
| 217 | +- Run with Karma using Chrome Headless (or Firefox) |
| 218 | +- Include benchmarks with `--enableBenchmarks` flag |
| 219 | + |
| 220 | +### IDE Tests |
| 221 | +- Use Jest (via react-scripts) |
| 222 | +- Run with `npm test` in `newIDE/app` |
| 223 | +- Coverage: `npm run analyze-test-coverage` |
| 224 | + |
| 225 | +### Extension Tests |
| 226 | +Individual extension tests run as part of the GDJS test suite. |
| 227 | + |
| 228 | +## Important Development Notes |
| 229 | + |
| 230 | +### GDevelop.js Bridge |
| 231 | +- `Bindings.idl` defines what C++ is exposed to JavaScript |
| 232 | +- 90% of the time, editing `Bindings.idl` is sufficient |
| 233 | +- May need to add header files to `Wrapper.cpp` for new C++ classes |
| 234 | +- Compiled with CMake using Emscripten |
| 235 | + |
| 236 | +### Resource Import |
| 237 | +When IDE starts, it automatically: |
| 238 | +- Downloads or copies libGD.js (if not building locally) |
| 239 | +- Imports GDJS Runtime |
| 240 | +- Imports extensions |
| 241 | +- Imports external editors (Piskel, JFXR, Yarn) |
| 242 | +- Builds theme resources |
| 243 | + |
| 244 | +Manual resource import: |
| 245 | +```bash |
| 246 | +cd newIDE/app |
| 247 | +npm run import-resources |
| 248 | +``` |
| 249 | + |
| 250 | +### Cloud Storage Development |
| 251 | +To test Google Drive, Dropbox, OneDrive in development: |
| 252 | +1. Add to `/etc/hosts`: `127.0.0.1 gdevelop-app-local.com` |
| 253 | +2. Access IDE at `http://gdevelop-app-local.com:3000` |
| 254 | + |
| 255 | +### Hot Reloading |
| 256 | +- IDE: Changes auto-reload when running `npm start` |
| 257 | +- Game Engine: Auto-rebuilds when files change (watch console) |
| 258 | +- Extensions: Auto-imported when IDE is running in development |
| 259 | + |
| 260 | +### Build System |
| 261 | +- IDE: Uses react-scripts with react-app-rewired for customization |
| 262 | +- Game Engine: Uses esbuild (fast builds) + TypeScript for type checking |
| 263 | +- C++ parts: CMake build system |
| 264 | +- Desktop app: Electron Builder |
| 265 | + |
| 266 | +## CI/CD |
| 267 | + |
| 268 | +Builds run on: |
| 269 | +- **CircleCI**: macOS and Linux builds |
| 270 | +- **AppVeyor**: Windows builds |
| 271 | +- **Semaphore**: Fast tests |
| 272 | + |
| 273 | +Artifacts uploaded to S3 at `s3://gdevelop-releases/[branch]/[commit|latest]/` |
| 274 | + |
| 275 | +## Documentation |
| 276 | + |
| 277 | +- Core C++ Documentation: https://docs.gdevelop.io/GDCore%20Documentation/ |
| 278 | +- GDJS Runtime Documentation: https://docs.gdevelop.io/GDJS%20Runtime%20Documentation/ |
| 279 | +- Architecture Overview: `Core/GDevelop-Architecture-Overview.md` |
| 280 | +- IDE README: `newIDE/README.md` |
| 281 | +- GDJS README: `GDJS/README.md` |
| 282 | +- Extensions Guide: `newIDE/README-extensions.md` |
| 283 | +- Themes Guide: `newIDE/README-themes.md` |
| 284 | + |
| 285 | +## Quick Reference for Common Tasks |
| 286 | + |
| 287 | +### I want to add a new action/condition to an extension |
| 288 | +1. Edit `Extensions/[ExtensionName]/JsExtension.js` to declare it |
| 289 | +2. Implement the function in `Extensions/[ExtensionName]/*tools.ts` |
| 290 | +3. Reload IDE (Ctrl+R) and test in a preview |
| 291 | + |
| 292 | +### I want to create a new behavior |
| 293 | +1. Create `*runtimebehavior.ts` extending `gdjs.RuntimeBehavior` |
| 294 | +2. Declare in `JsExtension.js` using `addBehavior` |
| 295 | +3. Implement `doStepPreEvents`/`doStepPostEvents` for logic |
| 296 | + |
| 297 | +### I want to create a new object type |
| 298 | +1. Create `*runtimeobject.ts` extending `gdjs.RuntimeObject` |
| 299 | +2. Create `*-pixi-renderer.ts` for the renderer |
| 300 | +3. Declare in `JsExtension.js` using `addObject` |
| 301 | + |
| 302 | +### I want to modify the Core C++ library |
| 303 | +1. Make changes to C++ files in `Core/` |
| 304 | +2. Add to `Bindings.idl` if exposing to JavaScript |
| 305 | +3. Rebuild GDevelop.js with Emscripten |
| 306 | +4. Test in IDE |
| 307 | + |
| 308 | +### I need to run a single test file |
| 309 | +```bash |
| 310 | +# For GDJS tests |
| 311 | +cd GDJS/tests |
| 312 | +npm run test:watch # Then use Karma's filtering |
| 313 | + |
| 314 | +# For IDE tests |
| 315 | +cd newIDE/app |
| 316 | +npm test -- --testPathPattern=YourTest.spec.js |
| 317 | +``` |
| 318 | + |
| 319 | +## File Organization Patterns |
| 320 | + |
| 321 | +### Extension Structure |
| 322 | +``` |
| 323 | +Extensions/MyExtension/ |
| 324 | + JsExtension.js # IDE declaration |
| 325 | + mytools.ts # Runtime functions |
| 326 | + myruntimeobject.ts # Runtime object |
| 327 | + myruntimebehavior.ts # Runtime behavior |
| 328 | + my-pixi-renderer.ts # PixiJS renderer |
| 329 | + myeffect.ts # Shader/filter |
| 330 | + tests/ |
| 331 | + *.spec.js # Tests |
| 332 | +``` |
| 333 | + |
| 334 | +### IDE App Structure |
| 335 | +``` |
| 336 | +newIDE/app/src/ |
| 337 | + MainFrame/ # Main application frame |
| 338 | + EventsSheet/ # Events editor |
| 339 | + ObjectsRendering/ # Scene editor renderers |
| 340 | + ObjectEditor/ # Object properties editors |
| 341 | + BehaviorsEditor/ # Behavior editors |
| 342 | + UI/ # Reusable UI components |
| 343 | + Utils/ # Utility functions |
| 344 | + Export/ # Export functionality |
| 345 | +``` |
| 346 | + |
| 347 | +## Performance Considerations |
| 348 | + |
| 349 | +- GDJS uses esbuild for near-instant builds during development |
| 350 | +- Type checking is separate and slower - run periodically |
| 351 | +- Use `--max-old-space-size=7168` for Node.js when building IDE |
| 352 | +- Build times: GDJS ~seconds, GDevelop.js ~minutes, Full IDE build ~minutes |
| 353 | + |
| 354 | +## Asynchronous Actions |
| 355 | + |
| 356 | +To create async actions: |
| 357 | +1. Make your function return a `gdjs.AsyncTask` |
| 358 | +2. Use `gdjs.PromiseTask` for promises: `return new gdjs.PromiseTask(yourPromise)` |
| 359 | +3. Declare with `setAsyncFunctionName()` instead of `setFunctionName()` |
| 360 | +4. Only actions can be asynchronous (not conditions or expressions) |
0 commit comments