Skip to content

Commit 6972430

Browse files
authored
support master version 0.14 and release 0.13.0 (#6)
* support master version 0.14 * little fix
1 parent 013ddc5 commit 6972430

File tree

7 files changed

+79
-103
lines changed

7 files changed

+79
-103
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
zig-cache
22
zig-out
33
.direnv
4+
.zig-cache

build.zig

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
const std = @import("std");
22
const builtin = @import("builtin");
3-
const build_11 = @import("build_11.zig").build;
4-
const build_12 = @import("build_12.zig").build;
5-
const build_13 = @import("build_13.zig").build;
63

74
const min_zig_string = "0.11.0";
85

@@ -21,9 +18,82 @@ comptime {
2118

2219
pub fn build(b: *std.Build) void {
2320
switch (current_zig.minor) {
24-
11 => build_11(b),
25-
12 => build_12(b),
26-
13 => build_13(b),
21+
11 => version_11.build(b),
22+
12, 13, 14 => version_12.build(b),
2723
else => @compileError("unknown version!"),
2824
}
2925
}
26+
27+
const version_11 = struct {
28+
pub fn build(b: *std.Build) void {
29+
const target = b.standardTargetOptions(.{});
30+
const optimize = b.standardOptimizeOption(.{});
31+
32+
const msgpack = b.addModule("msgpack", .{
33+
.source_file = .{
34+
.path = "src/msgpack.zig",
35+
},
36+
});
37+
38+
const test_step = b.step("test", "Run unit tests");
39+
40+
const msgpack_unit_tests = b.addTest(.{
41+
.root_source_file = .{
42+
.path = "src/test.zig",
43+
},
44+
.target = target,
45+
.optimize = optimize,
46+
});
47+
48+
msgpack_unit_tests.addModule("msgpack", msgpack);
49+
const run_msgpack_tests = b.addRunArtifact(msgpack_unit_tests);
50+
test_step.dependOn(&run_msgpack_tests.step);
51+
}
52+
};
53+
54+
const version_12 = struct {
55+
const Build = std.Build;
56+
const Module = Build.Module;
57+
const OptimizeMode = std.builtin.OptimizeMode;
58+
59+
pub fn build(b: *std.Build) void {
60+
const target = b.standardTargetOptions(.{});
61+
const optimize = b.standardOptimizeOption(.{});
62+
63+
const msgpack = b.addModule("msgpack", .{
64+
.root_source_file = b.path(b.pathJoin(&.{ "src", "msgpack.zig" })),
65+
});
66+
67+
generateDocs(b, optimize, target);
68+
69+
const test_step = b.step("test", "Run unit tests");
70+
71+
const msgpack_unit_tests = b.addTest(.{
72+
.root_source_file = b.path(b.pathJoin(&.{ "src", "test.zig" })),
73+
.target = target,
74+
.optimize = optimize,
75+
});
76+
msgpack_unit_tests.root_module.addImport("msgpack", msgpack);
77+
const run_msgpack_tests = b.addRunArtifact(msgpack_unit_tests);
78+
test_step.dependOn(&run_msgpack_tests.step);
79+
}
80+
81+
fn generateDocs(b: *Build, optimize: OptimizeMode, target: Build.ResolvedTarget) void {
82+
const lib = b.addObject(.{
83+
.name = "zig-msgpack",
84+
.root_source_file = b.path(b.pathJoin(&.{ "src", "msgpack.zig" })),
85+
.target = target,
86+
.optimize = optimize,
87+
});
88+
89+
const docs_step = b.step("docs", "Emit docs");
90+
91+
const docs_install = b.addInstallDirectory(.{
92+
.source_dir = lib.getEmittedDocs(),
93+
.install_dir = .prefix,
94+
.install_subdir = "docs",
95+
});
96+
97+
docs_step.dependOn(&docs_install.step);
98+
}
99+
};

build_11.zig

Lines changed: 0 additions & 26 deletions
This file was deleted.

build_12.zig

Lines changed: 0 additions & 24 deletions
This file was deleted.

build_13.zig

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/msgpack.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ const native_endian = builtin.cpu.arch.endian();
1111

1212
const big_endian = switch (current_zig.minor) {
1313
11 => std.builtin.Endian.Big,
14-
12, 13 => std.builtin.Endian.big,
14+
12, 13, 14 => std.builtin.Endian.big,
1515
else => @compileError("not support current version zig"),
1616
};
1717
const little_endian = switch (current_zig.minor) {
1818
11 => std.builtin.Endian.Little,
19-
12, 13 => std.builtin.Endian.little,
19+
12, 13, 14 => std.builtin.Endian.little,
2020
else => @compileError("not support current version zig"),
2121
};
2222

File renamed without changes.

0 commit comments

Comments
 (0)