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 to latest master #2910

Merged
merged 1 commit into from
Feb 5, 2023
Merged

Conversation

star-tek-mb
Copy link
Contributor

@star-tek-mb star-tek-mb commented Feb 5, 2023

Version: approximately usable at zig 0.11.0-dev.1571+c1f71963a.

Also, adds package manager support (early MVP).

We need to add root build zig file to support Zig Package Manager. Once package manager gets support for overidding build root directory - we can move this logic in src/build.zig and remove root build.zig.

Also, now every build artifacts must accept target and optimize arguments, so it is also adjusted.

For now, there is not much info about how to use package manager in Zig, so I will leave it here:

Create build.zig.zon:

.{
    .name = "raylib_usage",
    .version = "0.0.0",

    .dependencies = .{
        .raylib = .{
            .url = "https://github.com/raysan5/raylib/archive/543333cae47c397f9bce93fe654aeba7cbe7e33d.tar.gz",
            .hash = "1220a2bf5e5a53060256428b107b7a86077581861e9cb7b42c5083f443575646d59f",
        },
    },
}

Hashes and commits may need to be adjusted (once merged).

Then in build.zig of your project:

...
const raylib_dep = b.dependency("raylib", .{
    .target = target,
    .optimize = optimize,
});
...
exe.linkLibrary(raylib_dep.artifact("raylib"));
...

also, adds package manager support
@raysan5 raysan5 merged commit ff70a04 into raysan5:master Feb 5, 2023
@raysan5
Copy link
Owner

raysan5 commented Feb 5, 2023

@star-tek-mb thank you very much for the review! Maybe this information could be added somewhere in the Wiki for future users?

@star-tek-mb
Copy link
Contributor Author

Yeah, it should be added to Wiki, but after proper tooling for zig package manager (cli). Like adding dependencies (like npm install).

@Not-Nik
Copy link
Sponsor Contributor

Not-Nik commented Mar 15, 2023

I feel like this PR was premature given that Zig 0.11 hasn't been released to this day. The average user (me :)) now can't use raylib's build.zig because it uses std.Build which isn't available in 0.10.1 (the latest release). In the future I would recommend waiting for official releases before updating build.zig given the possibility for sudden unannounced API changes breaking the script.

#2913 related

@raysan5
Copy link
Owner

raysan5 commented Mar 15, 2023

@Not-Nik Thanks for noticing it, I expected Zig 0.11 to be released by next raylib release but it's not...

@star-tek-mb
Copy link
Contributor Author

I feel like this PR was premature given that Zig 0.11 hasn't been released to this day. The average user (me :)) now can't use raylib's build.zig because it uses std.Build which isn't available in 0.10.1 (the latest release). In the future I would recommend waiting for official releases before updating build.zig given the possibility for sudden unannounced API changes breaking the script.

#2913 related

You are right to some extent. But zig 0.11 have many C ABI fixes on windows and linux. (ziglang/zig#14333). So, i recommend to upgrade anyways, but if you want to use raylib for 0.10.1 you can use older raylib version I think.

futureapricot pushed a commit to futureapricot/raylib that referenced this pull request Oct 4, 2023
also, adds package manager support
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.

None yet

3 participants