Skip to content

Commit

Permalink
support master version 0.14 and release 0.13.0 (#6)
Browse files Browse the repository at this point in the history
* support master version 0.14

* little fix
  • Loading branch information
jinzhongjia authored Jun 9, 2024
1 parent 013ddc5 commit 6972430
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
zig-cache
zig-out
.direnv
.zig-cache
82 changes: 76 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const std = @import("std");
const builtin = @import("builtin");
const build_11 = @import("build_11.zig").build;
const build_12 = @import("build_12.zig").build;
const build_13 = @import("build_13.zig").build;

const min_zig_string = "0.11.0";

Expand All @@ -21,9 +18,82 @@ comptime {

pub fn build(b: *std.Build) void {
switch (current_zig.minor) {
11 => build_11(b),
12 => build_12(b),
13 => build_13(b),
11 => version_11.build(b),
12, 13, 14 => version_12.build(b),
else => @compileError("unknown version!"),
}
}

const version_11 = struct {
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const msgpack = b.addModule("msgpack", .{
.source_file = .{
.path = "src/msgpack.zig",
},
});

const test_step = b.step("test", "Run unit tests");

const msgpack_unit_tests = b.addTest(.{
.root_source_file = .{
.path = "src/test.zig",
},
.target = target,
.optimize = optimize,
});

msgpack_unit_tests.addModule("msgpack", msgpack);
const run_msgpack_tests = b.addRunArtifact(msgpack_unit_tests);
test_step.dependOn(&run_msgpack_tests.step);
}
};

const version_12 = struct {
const Build = std.Build;
const Module = Build.Module;
const OptimizeMode = std.builtin.OptimizeMode;

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const msgpack = b.addModule("msgpack", .{
.root_source_file = b.path(b.pathJoin(&.{ "src", "msgpack.zig" })),
});

generateDocs(b, optimize, target);

const test_step = b.step("test", "Run unit tests");

const msgpack_unit_tests = b.addTest(.{
.root_source_file = b.path(b.pathJoin(&.{ "src", "test.zig" })),
.target = target,
.optimize = optimize,
});
msgpack_unit_tests.root_module.addImport("msgpack", msgpack);
const run_msgpack_tests = b.addRunArtifact(msgpack_unit_tests);
test_step.dependOn(&run_msgpack_tests.step);
}

fn generateDocs(b: *Build, optimize: OptimizeMode, target: Build.ResolvedTarget) void {
const lib = b.addObject(.{
.name = "zig-msgpack",
.root_source_file = b.path(b.pathJoin(&.{ "src", "msgpack.zig" })),
.target = target,
.optimize = optimize,
});

const docs_step = b.step("docs", "Emit docs");

const docs_install = b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});

docs_step.dependOn(&docs_install.step);
}
};
26 changes: 0 additions & 26 deletions build_11.zig

This file was deleted.

24 changes: 0 additions & 24 deletions build_12.zig

This file was deleted.

45 changes: 0 additions & 45 deletions build_13.zig

This file was deleted.

4 changes: 2 additions & 2 deletions src/msgpack.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const native_endian = builtin.cpu.arch.endian();

const big_endian = switch (current_zig.minor) {
11 => std.builtin.Endian.Big,
12, 13 => std.builtin.Endian.big,
12, 13, 14 => std.builtin.Endian.big,
else => @compileError("not support current version zig"),
};
const little_endian = switch (current_zig.minor) {
11 => std.builtin.Endian.Little,
12, 13 => std.builtin.Endian.little,
12, 13, 14 => std.builtin.Endian.little,
else => @compileError("not support current version zig"),
};

Expand Down
File renamed without changes.

0 comments on commit 6972430

Please sign in to comment.