diff --git a/README.md b/README.md index 9a3276dd..242f7591 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,65 @@ A complete autogenerated set of Zig bindings for the Win32 API. These bindings are generated by https://github.com/marlersoft/zigwin32gen + +## Install / Update (v0.12.0) + +Re-run this command to overwrite and update hash to get latest updates + +```bash +zig fetch --save https://github.com/marlersoft/zigwin32/archive/main.tar.gz +``` + +This will add an entry into `dependencies` in your `build.zig.zon` file like this: + +```zig +.{ + // ... + .dependencies = .{ + .zigwin32 = .{ + .url = "https://github.com/marlersoft/zigwin32/archive/main.tar.gz", + .hash = "" + } + } +} +``` + +After the package is installed. The package/dependency can be referenced and added to the `build.zig` file to expose it to libraries and executables. + +```zig +// build.zig +// ... +pub fn build(b: *std.Build) void { + // ... + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const zigwin32 = b.dependency("zigwin32", .{}); + + const your_module = b.addModule("your-module", .{ + .root_source_file = b.path("src/root.zig"), + }); + + your_module.addImport("zigwin32", zigwin32.module("zigwin32")) + + // or + + const exe = b.addExecutable(.{ + .name = "", + .root_source_file = b.path("main.zig"), + .target = target, + .optimize = optimize, + }); + + exe.root_module.addImport("zigwin32", zigwin32.module("zigwin32")) + + // ... +} +``` + +Now the dependency is fully imported and can be used + +```zig +// any-file.zig +const zigwin32 = @import("zigwin32"); +```