11const std = @import ("std" );
22const 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
74const min_zig_string = "0.11.0" ;
85
@@ -21,9 +18,82 @@ comptime {
2118
2219pub 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+ };
0 commit comments