janet-lang / jaylib

Janet bindings to Raylib
MIT License
137 stars 36 forks source link

Build fails on macos 13+ (janet 1.29.1-meson) #49

Closed gamecubate closed 1 year ago

gamecubate commented 1 year ago

What version of janet was jaylib last successfully built for?

Build attempts for janet 1.29.1-meson and raylib 4.5.0 (installed with brew) fail (macos 13.0.1).

$ janet -v
1.29.1-meson

$ jpm install https://github.com/janet-lang/jaylib.git
[RAYLIB (master #)]$ jpm install https://github.com/janet-lang/jaylib.git
Initialized empty Git repository in /usr/local/Cellar/janet/1.29.1/lib/janet/.cache/git__https___github.com_janet-lang_jaylib.git/.git/
remote: Enumerating objects: 640, done.
remote: Counting objects: 100% (437/437), done.
remote: Compressing objects: 100% (156/156), done.
remote: Total 640 (delta 317), reused 350 (delta 281), pack-reused 203
Receiving objects: 100% (640/640), 1.74 MiB | 2.39 MiB/s, done.
Resolving deltas: 100% (422/422), done.
From https://github.com/janet-lang/jaylib
 * [new branch]      master     -> origin/master
From https://github.com/janet-lang/jaylib
 * branch            HEAD       -> FETCH_HEAD
HEAD is now at 2355a67 Merge pull request #44 from turnerdev/shaders
Submodule 'raylib' (https://github.com/raysan5/raylib.git) registered for path 'raylib'
Cloning into '/usr/local/Cellar/janet/1.29.1/lib/janet/.cache/git__https___github.com_janet-lang_jaylib.git/raylib'...
Submodule path 'raylib': checked out 'fec96137e8d10ee6c88914fbe5e5429c13ee1dac'
compiling raylib/src/rtextures.c to build/raylib___src___rtextures.o...
compiling raylib/src/rtext.c to build/raylib___src___rtext.o...
compiling raylib/src/rglfw.c to build/raylib___src___rglfw.o...
compiling raylib/src/rshapes.c to build/raylib___src___rshapes.o...
compiling raylib/src/rcore.c to build/raylib___src___rcore.o...
compiling raylib/src/raudio.c to build/raylib___src___raudio.o...
compiling raylib/src/utils.c to build/raylib___src___utils.o...
generating meta file build/jaylib.meta.janet...
compiling raylib/src/rmodels.c to build/raylib___src___rmodels.o...
compiling src/main.c to build/src___main.o...
compiling raylib/src/utils.c to build/raylib___src___utils.static.o...
In file included from src/main.c:13:
src/3d.h:453:59: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign]
    ModelAnimation *anims = LoadModelAnimations(fileName, &animCount);
                                                          ^~~~~~~~~~
raylib/src/raylib.h:1488:79: note: passing argument to parameter 'animCount' here
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount);   // Load model animations from file
                                                                              ^
In file included from src/main.c:15:
src/shader.h:56:13: error: expected expression
            float valueFloat = (float) janet_getnumber(argv, 2);
            ^
src/shader.h:57:62: error: use of undeclared identifier 'valueFloat'
            SetShaderValue(*shader, locIndex, (const void*) &valueFloat, uniformType);
                                                             ^
src/shader.h:60:13: error: expected expression
            int valueInt = janet_getinteger(argv, 2);
            ^
src/shader.h:61:62: error: use of undeclared identifier 'valueInt'
            SetShaderValue(*shader, locIndex, (const void*) &valueInt, uniformType);
                                                             ^
src/shader.h:64:13: error: expected expression
            Vector2 valueVec2 = jaylib_getvec2(argv, 2);
            ^
src/shader.h:65:62: error: use of undeclared identifier 'valueVec2'
            SetShaderValue(*shader, locIndex, (const void*) &valueVec2, uniformType);
                                                             ^
src/shader.h:68:13: error: expected expression
            Vector3 valueVec3 = jaylib_getvec3(argv, 2);
            ^
src/shader.h:69:62: error: use of undeclared identifier 'valueVec3'
            SetShaderValue(*shader, locIndex, (const void*) &valueVec3, uniformType);
                                                             ^
src/shader.h:72:13: error: expected expression
            Vector4 valueVec4 = jaylib_getvec4(argv, 2);
            ^
src/shader.h:73:62: error: use of undeclared identifier 'valueVec4'
            SetShaderValue(*shader, locIndex, (const void*) &valueVec4, uniformType);
                                                             ^
1 warning and 10 errors generated.
error: command failed with non-zero exit code 1
In file included from raylib/src/raudio.c:256:
raylib/src/external/jar_xm.h:521:9: warning: 'ALIGN' macro redefined [-Wmacro-redefined]
#define ALIGN(x, b) (((x) + ((b) - 1)) & ~((b) - 1))
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/i386/param.h:85:9: note: previous definition is here
#define ALIGN(p)        __DARWIN_ALIGN(p)
        ^
raylib/src/raudio.c:1290:45: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        qoaplay_desc *ctxQoa = qoaplay_open(fileName);
                                            ^~~~~~~~
raylib/src/external/qoaplay.c:86:34: note: passing argument to parameter 'path' here
qoaplay_desc *qoaplay_open(char *path)
                                 ^
2 warnings generated.
error: build fail
  in pdag [/usr/local/Cellar/janet/1.29.1/lib/janet/jpm/dagbuild.janet] (tailcall) on line 79, column 23
  in <anonymous> [/usr/local/Cellar/janet/1.29.1/lib/janet/jpm/pm.janet] on line 236, column 9
  in <anonymous> [/usr/local/Cellar/janet/1.29.1/lib/janet/jpm/pm.janet] on line 221, column 5
  in bundle-install [/usr/local/Cellar/janet/1.29.1/lib/janet/jpm/pm.janet] on line 219, column 3
  in install [/usr/local/Cellar/janet/1.29.1/lib/janet/jpm/commands.janet] on line 190, column 20
  in run [/usr/local/Cellar/janet/1.29.1/lib/janet/jpm/cli.janet] (tailcall) on line 88, column 9
  in run-main [boot.janet] on line 3889, column 16
  in cli-main [boot.janet] on line 4042, column 17
bakpakin commented 1 year ago

Builds fine on my linux box with latest master version of Janet and jpm.

sogaiu commented 1 year ago

Building / installation worked for me for a x86_64 Linux environment as well as for Windows 10.

I used janet 4b7b285a and jpm bdf5999a.

I don't have a macos environment to test with unfortunately.


On a side note, because jaylib is currently listed in pkgs.janet, I think one can use the following more convenient invocation:

jpm install jaylib
pyrmont commented 1 year ago

The problem here is the use of a label (case SHADER_UNIFORM_FLOAT) immediately before a declaration (float valueFloat = (float) janet_getnumber(argv, 2);). This is not valid C99 or Objective-C apparently (see this comment on Stack Overflow). I'm not sure why this is an error on macOS but not the other platforms (although maybe related to -ObjC C flag in project.janet?).

In any case, you can solve the problem like so:

switch (uniformType) {
        case SHADER_UNIFORM_FLOAT:
        {
            float valueFloat = (float) janet_getnumber(argv, 2);
            SetShaderValue(*shader, locIndex, (const void*) &valueFloat, uniformType);
            break;
        }
        case SHADER_UNIFORM_INT:
        {
            int valueInt = janet_getinteger(argv, 2);
            SetShaderValue(*shader, locIndex, (const void*) &valueInt, uniformType);
            break;
        }
        case SHADER_UNIFORM_VEC2:
        {
            Vector2 valueVec2 = jaylib_getvec2(argv, 2);
            SetShaderValue(*shader, locIndex, (const void*) &valueVec2, uniformType);
            break;
        }
        case SHADER_UNIFORM_VEC3:
        {
            Vector3 valueVec3 = jaylib_getvec3(argv, 2);
            SetShaderValue(*shader, locIndex, (const void*) &valueVec3, uniformType);
            break;
        }
        case SHADER_UNIFORM_VEC4:
        {
            Vector4 valueVec4 = jaylib_getvec4(argv, 2);
            SetShaderValue(*shader, locIndex, (const void*) &valueVec4, uniformType);
            break;
        }
        default:
            janet_panicf("unknown uniform type %d", uniformType);
            break;
    }
gamecubate commented 1 year ago

@pyrmont Thanks ! Build succeeds albeit with a few warnings and 4 failed tests. I will look into the jaylib-specific warnings and submit a PR shortly.

[jaylib (master *)]$ jpm clean ; jpm build
Deleted build directory build/
compiling src/main.c to build/src___main.o...
compiling raylib/src/rcore.c to build/raylib___src___rcore.o...
compiling raylib/src/rmodels.c to build/raylib___src___rmodels.o...
compiling raylib/src/raudio.c to build/raylib___src___raudio.o...
compiling raylib/src/rglfw.c to build/raylib___src___rglfw.o...
compiling raylib/src/rshapes.c to build/raylib___src___rshapes.o...
compiling raylib/src/rtext.c to build/raylib___src___rtext.o...
compiling raylib/src/rtextures.c to build/raylib___src___rtextures.o...
compiling raylib/src/utils.c to build/raylib___src___utils.o...
generating meta file build/jaylib.meta.janet...
In file included from src/main.c:13:
src/3d.h:453:59: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign]
    ModelAnimation *anims = LoadModelAnimations(fileName, &animCount);
                                                          ^~~~~~~~~~
raylib/src/raylib.h:1488:79: note: passing argument to parameter 'animCount' here
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount);   // Load model animations from file
                                                                              ^
compiling raylib/src/utils.c to build/raylib___src___utils.static.o...
compiling raylib/src/rshapes.c to build/raylib___src___rshapes.static.o...
1 warning generated.
compiling src/main.c to build/src___main.static.o...
In file included from raylib/src/raudio.c:256:
raylib/src/external/jar_xm.h:521:9: warning: 'ALIGN' macro redefined [-Wmacro-redefined]
#define ALIGN(x, b) (((x) + ((b) - 1)) & ~((b) - 1))
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/i386/param.h:85:9: note: previous definition is here
#define ALIGN(p)        __DARWIN_ALIGN(p)
        ^
raylib/src/raudio.c:1290:45: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        qoaplay_desc *ctxQoa = qoaplay_open(fileName);
                                            ^~~~~~~~
raylib/src/external/qoaplay.c:86:34: note: passing argument to parameter 'path' here
qoaplay_desc *qoaplay_open(char *path)
                                 ^
In file included from src/main.c:13:
src/3d.h:453:59: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign]
    ModelAnimation *anims = LoadModelAnimations(fileName, &animCount);
                                                          ^~~~~~~~~~
raylib/src/raylib.h:1488:79: note: passing argument to parameter 'animCount' here
RLAPI ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount);   // Load model animations from file
                                                                              ^
compiling raylib/src/rtext.c to build/raylib___src___rtext.static.o...
1 warning generated.
compiling raylib/src/rcore.c to build/raylib___src___rcore.static.o...
compiling raylib/src/rglfw.c to build/raylib___src___rglfw.static.o...
compiling raylib/src/rtextures.c to build/raylib___src___rtextures.static.o...
compiling raylib/src/rmodels.c to build/raylib___src___rmodels.static.o...
2 warnings generated.
creating native module build/jaylib.so...
compiling raylib/src/raudio.c to build/raylib___src___raudio.static.o...
ld: warning: -undefined dynamic_lookup may not work with chained fixups
In file included from raylib/src/raudio.c:256:
raylib/src/external/jar_xm.h:521:9: warning: 'ALIGN' macro redefined [-Wmacro-redefined]
#define ALIGN(x, b) (((x) + ((b) - 1)) & ~((b) - 1))
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/i386/param.h:85:9: note: previous definition is here
#define ALIGN(p)        __DARWIN_ALIGN(p)
        ^
raylib/src/raudio.c:1290:45: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        qoaplay_desc *ctxQoa = qoaplay_open(fileName);
                                            ^~~~~~~~
raylib/src/external/qoaplay.c:86:34: note: passing argument to parameter 'path' here
qoaplay_desc *qoaplay_open(char *path)
                                 ^
2 warnings generated.
creating static library build/jaylib.a...
gamecubate commented 1 year ago

PR submitted.

50

pyrmont commented 1 year ago

This can be closed.