Skip to content

Commit cb61273

Browse files
committed
install
1 parent 58288b5 commit cb61273

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,65 @@
1010

1111
[![Main](https://github.com/softprops/zig-jwt/actions/workflows/ci.yml/badge.svg)](https://github.com/softprops/zig-jwt/actions/workflows/ci.yml) ![License Info](https://img.shields.io/github/license/softprops/zig-jwt) ![Release](https://img.shields.io/github/v/release/softprops/zig-jwt) [![Zig Support](https://img.shields.io/badge/zig-0.13.0-black?logo=zig)](https://ziglang.org/documentation/0.13.0/)
1212

13+
## 📼 installing
14+
15+
Create a new exec project with `zig init`. Copy an example from the examples directory into your into `src/main.zig`
16+
17+
Create a `build.zig.zon` file to declare a dependency
18+
19+
> .zon short for "zig object notation" files are essentially zig structs. `build.zig.zon` is zigs native package manager convention for where to declare dependencies
20+
21+
Starting in zig 0.12.0, you can use and should prefer
22+
23+
```sh
24+
zig fetch --save https://github.com/softprops/zig-jwt/archive/refs/tags/v0.1.0.tar.gz
25+
```
26+
27+
otherwise, to manually add it, do so as follows
28+
29+
```diff
30+
.{
31+
.name = "my-app",
32+
.version = "0.1.0",
33+
.dependencies = .{
34+
+ // 👇 declare dep properties
35+
+ .jwt = .{
36+
+ // 👇 uri to download
37+
+ .url = "https://github.com/softprops/zig-jwt/archive/refs/tags/v0.1.0.tar.gz",
38+
+ // 👇 hash verification
39+
+ .hash = "...",
40+
+ },
41+
},
42+
}
43+
```
44+
45+
> the hash below may vary. you can also depend any tag with `https://github.com/softprops/zig-jwt/archive/refs/tags/v{version}.tar.gz` or current main with `https://github.com/softprops/zig-jwt/archive/refs/heads/main/main.tar.gz`. to resolve a hash omit it and let zig tell you the expected value.
46+
47+
Add the following in your `build.zig` file
48+
49+
```diff
50+
const std = @import("std");
51+
52+
pub fn build(b: *std.Build) void {
53+
const target = b.standardTargetOptions(.{});
54+
55+
const optimize = b.standardOptimizeOption(.{});
56+
// 👇 de-reference dep from build.zig.zon
57+
+ const jwt = b.dependency("jwt", .{
58+
+ .target = target,
59+
+ .optimize = optimize,
60+
+ }).module("jwt");
61+
var exe = b.addExecutable(.{
62+
.name = "your-exe",
63+
.root_source_file = .{ .path = "src/main.zig" },
64+
.target = target,
65+
.optimize = optimize,
66+
});
67+
// 👇 add the module to executable
68+
+ exe.root_mode.addImport("jwt", jwt);
69+
70+
b.installArtifact(exe);
71+
}
1372

1473
## examples
1574

0 commit comments

Comments
 (0)