floooh / sokol-zig

Zig bindings for the sokol headers (https://github.com/floooh/sokol)
zlib License
355 stars 49 forks source link

Add prefix_path argument to buildSokol #4

Closed ktravis closed 3 years ago

ktravis commented 3 years ago

This allows another project to include sokol-zig (either directly, or as a git submodule) in its tree, but still make use of the functions defined in build.zig. For example, placing this repo at ./deps/sokol/, I add to my project's ./build.zig:

const sokol_lib = @import("deps/sokol/build.zig").buildSokol(b, "deps/sokol/");
exe.linkLibrary(sokol_lib);
exe.addPackagePath("sokol", "deps/sokol/src/sokol/sokol.zig");

This could be accomplished with other patterns as well, though I've seen this used naturally in a few other Zig projects.

Let me know if I should change anything, or if this is not the right approach - happy to accommodate!

floooh commented 3 years ago

Good idea thanks! I don't know yet what the conventions are for such library style projects (I guess once some sort of dependency management solution exists this will be better defined).

Thanks for the PR!