diff --git a/build.zig b/build.zig index 6dc05e8..df7951b 100644 --- a/build.zig +++ b/build.zig @@ -3,14 +3,24 @@ const std = @import("std"); pub fn build(b: *std.build.Builder) void { // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. - const mode = b.standardReleaseOptions(); + const optimize = b.standardOptimizeOption(.{}); - const lib = b.addStaticLibrary("zig-jwt", "jwt.zig"); - lib.setBuildMode(mode); - lib.install(); + const target = b.standardTargetOptions(.{}); + _ = b.addModule("jwt", .{ + .source_file = .{ .path = "jwt.zig" }, + }); - var main_tests = b.addTest("jwt.zig"); - main_tests.setBuildMode(mode); + const lib = b.addStaticLibrary(.{ + .name = "zig-jwt", + .root_source_file = .{ .path = "jwt.zig" }, + .optimize = optimize, + .target = target, + }); + b.installArtifact(lib); + + var main_tests = b.addTest(.{ + .root_source_file = .{ .path = "jwt.zig" }, + }); const test_step = b.step("test", "Run library tests"); test_step.dependOn(&main_tests.step); diff --git a/jwt.zig b/jwt.zig index 0d0ca50..a3eb3cf 100644 --- a/jwt.zig +++ b/jwt.zig @@ -46,7 +46,7 @@ pub fn encode(allocator: std.mem.Allocator, comptime alg: Algorithm, payload: an pub fn encodeMessage(allocator: std.mem.Allocator, comptime alg: Algorithm, message: []const u8, signatureOptions: SignatureOptions) ![]const u8 { var protected_header = std.json.ObjectMap.init(allocator); defer protected_header.deinit(); - try protected_header.put("alg", .{ .string = std.meta.tagName(alg) }); + try protected_header.put("alg", .{ .string = @tagName(alg) }); try protected_header.put("typ", .{ .string = "JWT" }); if (signatureOptions.kid) |kid| { try protected_header.put("kid", .{ .string = kid });