Add claude docs
This commit is contained in:
@@ -75,6 +75,37 @@ if(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
||||
endif()
|
||||
```
|
||||
|
||||
## Embedding JS files (`dusk_embed_js`)
|
||||
|
||||
Source: `cmake/modules/duskjs2c.cmake`
|
||||
|
||||
The `dusk_embed_js()` CMake function embeds a `.js` source file as a
|
||||
C string constant in a generated header. It is used to ship script
|
||||
module code alongside the engine binary without a separate file load.
|
||||
|
||||
```cmake
|
||||
dusk_embed_js(
|
||||
TARGET ${DUSK_LIBRARY_TARGET_NAME}
|
||||
JS_FILE path/to/mymodule.js
|
||||
# NAME is optional; defaults to uppercase stem + "_JS"
|
||||
# e.g. "mymodule.js" -> "MYMODULE_JS"
|
||||
NAME MY_CUSTOM_NAME
|
||||
)
|
||||
```
|
||||
|
||||
The generated header is placed in
|
||||
`${DUSK_GENERATED_HEADERS_DIR}/<stem>_js.h` and defines:
|
||||
|
||||
```c
|
||||
static const char MY_CUSTOM_NAME[] = "... js source ...";
|
||||
static const size_t MY_CUSTOM_NAME_SIZE = sizeof(MY_CUSTOM_NAME) - 1;
|
||||
```
|
||||
|
||||
Under the hood it calls `python -m tools.js2c` from the repo root.
|
||||
The header is generated at build time; include it in the `.c` file
|
||||
that registers the JS module, then pass `NAME` and `NAME_SIZE` to
|
||||
`jerry_eval()` (or the equivalent module load helper).
|
||||
|
||||
## Tests
|
||||
|
||||
- Test files live in `test/` mirroring the `src/dusk/` structure.
|
||||
|
||||
Reference in New Issue
Block a user