build: update for zig-0.13

This commit is contained in:
torque 2024-06-18 18:20:49 -07:00
parent 06e2392816
commit e8d1a7491e
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk
3 changed files with 9 additions and 11 deletions

View File

@ -9,9 +9,8 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const cmark = b.addModule("cmark", .{
.root_source_file = .{ .path = "src/cmark.zig" },
.root_source_file = b.path("src/cmark.zig"),
});
cmark.addIncludePath(.{ .path = b.getInstallPath(.header, "") });
const cmark_c = cmark_build.cmark_lib(b, .{
.name = "cmark-c",
@ -19,17 +18,17 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
cmark.linkLibrary(cmark_c);
add_examples(b, .{
.target = target,
.cmark_module = cmark,
.cmark_c = cmark_c,
});
}
const ExampleOptions = struct {
target: std.Build.ResolvedTarget,
cmark_module: *std.Build.Module,
cmark_c: *std.Build.Step.Compile,
};
const Example = struct {
@ -47,13 +46,12 @@ pub fn add_examples(b: *std.Build, options: ExampleOptions) void {
inline for (examples) |example| {
const ex_exe = b.addExecutable(.{
.name = example.name,
.root_source_file = .{ .path = example.file },
.root_source_file = b.path(example.file),
.target = options.target,
.optimize = .Debug,
});
ex_exe.root_module.addImport("cmark", options.cmark_module);
ex_exe.linkLibrary(options.cmark_c);
const install = b.addInstallArtifact(ex_exe, .{});
example_step.dependOn(&install.step);

View File

@ -1,5 +1,5 @@
.{
.name = "cmark-zig",
.name = "cmark",
.version = "0.1.0-pre",
.dependencies = .{},
.paths = .{

View File

@ -23,10 +23,10 @@ pub fn cmark_lib(
lib.linkLibC();
lib.addCSourceFiles(.{ .files = &common_sources, .flags = &cflags });
lib.addIncludePath(.{ .path = cmark_src_prefix ++ "include" });
lib.addIncludePath(b.path(cmark_src_prefix ++ "include"));
const config_h = b.addConfigHeader(.{
.style = .{ .cmake = .{ .path = cmark_src_prefix ++ "config.h.in" } },
.style = .{ .cmake = b.path(cmark_src_prefix ++ "config.h.in") },
.include_path = "config.h",
}, .{
.HAVE_STDBOOL_H = void{},
@ -35,7 +35,7 @@ pub fn cmark_lib(
});
const cmark_version_h = b.addConfigHeader(.{
.style = .{ .cmake = .{ .path = cmark_src_prefix ++ "cmark_version.h.in" } },
.style = .{ .cmake = b.path(cmark_src_prefix ++ "cmark_version.h.in") },
.include_path = "cmark_version.h",
}, .{
.PROJECT_VERSION_MAJOR = 0,
@ -45,7 +45,7 @@ pub fn cmark_lib(
lib.addConfigHeader(config_h);
lib.addConfigHeader(cmark_version_h);
lib.addIncludePath(.{ .path = cmark_zig_prefix });
lib.addIncludePath(b.path(cmark_zig_prefix));
lib.installConfigHeader(cmark_version_h);
inline for (install_headers) |header| {