Skip to content

Building #1

@konsumer

Description

@konsumer

Hi, great work on the codegen.

I am trying to use it to generate native quickjs extension, and I'm having a lot of issues, and I think the problems are not related to emscripten at all.

I feel like I am in a kind of circular dependency-hell, and hoped you might be able to help.

# get code
git clone https://github.com/bellard/quickjs.git --depth 1
git clone https://github.com/raysan5/raylib.git --depth 1
git clone https://github.com/raysan5/raygui.git --depth 1
git clone https://github.com/exaequos/raylib-qjs.git --depth 1

# build deps
cd quickjs
make
cd ../raylib
cmake -B build
cmake --build build

# build raygui demos to test
cd ../raygui/projects/CMake
cmake -B build
cmake --build build
cd ../../..


# so far so good

# generate code, without emscripten
python3 raylib-qjs/src/raylib_qjs.py raylib-qjs/api/raylib_api.json raylib-qjs/api/rcamera_api.json raylib-qjs/api/raygui_api.json raylib-qjs/api/raymath_api.json | grep -vE emscripten.h > raylib_qjs.c

# build
clang -Lquickjs -Lraylib/build/raylib -lraylib -lquickjs -Iraylib/src -Iquickjs/ -Iraygui/src -shared -o raylib_qjs.so raylib_qjs.c

Then I get tons of errors like:

raylib_qjs.c:21539:16: error: call to undeclared function 'IsMaterialReady'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 21539 |     bool ret = IsMaterialReady(arg0);
       |                ^
raylib_qjs.c:21539:16: note: did you mean 'js_IsMaterialReady'?
raylib_qjs.c:21532:16: note: 'js_IsMaterialReady' declared here
 21532 | static JSValue js_IsMaterialReady(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
       |                ^
 21533 | {
 21534 |     Material * argptr0 = (Material *)JS_GetOpaque2(ctx, argv[0], js_Material_class_id);
 21535 |         if (argptr0 == NULL) return JS_EXCEPTION;
 21536 |
 21537 |         Material arg0 = *argptr0;
 21538 |
 21539 |     bool ret = IsMaterialReady(arg0);

which makes me think I have a version-mismatch, so I try with a version closer to what I think you are using:

rm -rf raylib
git clone https://github.com/raysan5/raylib.git --depth 1 --branch 5.0

# rebuild raylib
cd raylib
cmake -B build
cmake --build build
cd ..

all good, now I have raylib@5.0

# build
clang -Lquickjs -Lraylib/build/raylib -lraylib -lquickjs -Iraylib/src -Iquickjs/ -Iraygui/src -shared -o raylib_qjs.so raylib_qjs.c

It compiles, but I get tons of linker warnings/errors like:

ld: warning: object file (raylib/build/raylib/libraylib.a[2](rcore.c.o)) was built for newer 'macOS' version (14.6) than being linked (14.0)

and

Undefined symbols for architecture arm64:
  "_CFArrayAppendValue", referenced from:
      __glfwInitJoysticksCocoa in libraylib.a[26](cocoa_joystick.m.o)
      _matchCallback in libraylib.a[26](cocoa_joystick.m.o)
  "_CFArrayCreateMutable", referenced from:

I have raylib (5.5) installed with brew, too, so I do this:

clang -Lquickjs -lquickjs -Iquickjs/ -Iraygui/src $(pkg-config --cflags --libs raylib) -shared -o raylib_qjs.so raylib_qjs.c

and I get

raylib_qjs.c:4:10: fatal error: 'rcamera.h' file not found
    4 | #include "rcamera.h"

So I think maybe I need to go back to raylib 5.5 (since that is version installed on my system) and codegen from that.

rm -rf raylib
git clone https://github.com/raysan5/raylib.git --depth 1

# rebuild raylib
cd raylib
cmake -B build
cmake --build build
cd ..

python3 raylib-qjs/src/raylib_qjs.py raylib-qjs/api/*.json | grep -vE emscripten.h > raylib_qjs.c

and I get param type not supported: Font

Since the script exits, and I want to see all the errors, I remove the exit(0)

param type not supported: Font
return type not supported: Font
param type not supported: Vector2 *
param type not supported: Rectangle *
param type not supported: Vector2 *
param type not supported: Color *
param type not supported: Color *
param type not supported: Vector3 *
param type not supported: Vector3 *

I tried to edit the codegen for these types, but I found it incredibly hard to follow. Do you have interest in supporting raylib 5.5? Is there something else I should do to get this to build? I tried to make my own quickjs-wrapper-generator a while ago, and got very overwhelmed, so I'd like to use yours, if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions