diff --git a/build.zig b/build.zig index 7028cd1..caae9e9 100644 --- a/build.zig +++ b/build.zig @@ -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); diff --git a/build.zig.zon b/build.zig.zon index 8d689b4..9839db1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,5 @@ .{ - .name = "cmark-zig", + .name = "cmark", .version = "0.1.0-pre", .dependencies = .{}, .paths = .{ diff --git a/cmark.build.zig b/cmark.build.zig index 4173ff7..27ab726 100644 --- a/cmark.build.zig +++ b/cmark.build.zig @@ -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| {