Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zig build system to zig version 0.11.0 #3393

Merged
merged 4 commits into from
Oct 9, 2023

Conversation

purple4pur
Copy link
Contributor

Discard build.zig and use src/build.zig only, bc by default these two output in different directories.

build command: cd to src then zig build.

Close #3386

@raysan5 raysan5 merged commit 540ad99 into raysan5:master Oct 9, 2023
@raysan5
Copy link
Owner

raysan5 commented Oct 9, 2023

@purple4pur thanks for the review!

@Not-Nik
Copy link
Sponsor Contributor

Not-Nik commented Oct 9, 2023

Unfortunately, removing the top-level build.zig wrecks compatibility with Zig's builtin package manager

@star-tek-mb
Copy link
Contributor

star-tek-mb commented Oct 9, 2023

Yeah. Revert PR please. Latest raylib is up to date with latest zig. Feel free to find commit version which suites your zig version. You are sending patch to master branch while you were using raylib 4.5.0.

@raysan5
Copy link
Owner

raysan5 commented Oct 9, 2023

@Not-Nik @star-tek-mb should this PR be reverted?

@purple4pur
Copy link
Contributor Author

@Not-Nik Ohh thanks for this infomation!

@star-tek-mb Tested with master branch raylib and zig 0.11.0, build.zig and src/build.zig are ready to go, but examples/build.zig fails (same as #3386), which is this PR mainly about.

Let me do more checks on both latest master branches and zig's package manager

@star-tek-mb
Copy link
Contributor

Ok. Thanks. I was mainly arguing with top level build.zig. I need it in my projects.

Sorry for maybe my rude messages. Let me know if you need any help with examples. I will check on zig master later.

@purple4pur
Copy link
Contributor Author

purple4pur commented Oct 10, 2023

@star-tek-mb nvm, your suggestion helps a lot! Also I tested with latest zig 0.12.0-dev.817+54e7f58fc, updating examples/build.zig is still needed

@Not-Nik @star-tek-mb I checked zig's package manager and tried the demo ziglang/zig#14265, top-level build.zig seems necessary. At the point before this PR, confusing problems are:

  1. Running zig build at top-level gets zig-out at top-level (which is expected). Running zig build in src gets errors complaining at

    raylib/src/build.zig

    Lines 195 to 197 in cfffa74

    lib.installHeader("src/raylib.h", "raylib.h");
    lib.installHeader("src/raymath.h", "raymath.h");
    lib.installHeader("src/rlgl.h", "rlgl.h");
    error: unable to update file from 'raylib\src\src\raylib.h' to 'raylib\src\zig-out\include\raylib.h': FileNotFound
  2. If fix above lines then top-level complains.
  3. examples/build.zig uses src/zig-out not zig-out
    .windows => "../src/zig-out/lib/raylib.lib",
    .linux => "../src/zig-out/lib/libraylib.a",
    .macos => "../src/zig-out/lib/libraylib.a",
    .emscripten => "../src/zig-out/lib/libraylib.a",

So my ideas:

  • Option 1: fix src/build.zig to 1. have no conflict with top-level build.zig and 2. always output zig-out to top-level
  • Option 2: keep only one build.zig at top-level, discard src/build.zig
  • Option 3: keep them there, but add a note to src/build.zig, which reminds users not to build in src

I've tried Option 1 before this PR, but still don't solve :(
Any suggestions?

@Not-Nik
Copy link
Sponsor Contributor

Not-Nik commented Oct 10, 2023

Also I tested with latest zig 0.12.0-dev.817+54e7f58fc, updating examples/build.zig is still needed

I strongly oppose updating Zig to a pre-release version.

As for the build.zig positions, I don't think any changes are necessary from the version before this PR.

raysan5 added a commit that referenced this pull request Oct 10, 2023
@purple4pur
Copy link
Contributor Author

purple4pur commented Oct 10, 2023

OK. I then open a PR that just focuses on examples/build.zig with zig 0.11.0.

Much appreciated @Not-Nik !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[build] Cannot build examples with zig 0.11.0, build.zig needs to be updated
4 participants