build: update for zig-0.13
This commit is contained in:
parent
06e2392816
commit
e8d1a7491e
10
build.zig
10
build.zig
@ -9,9 +9,8 @@ pub fn build(b: *std.Build) void {
|
|||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const cmark = b.addModule("cmark", .{
|
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, .{
|
const cmark_c = cmark_build.cmark_lib(b, .{
|
||||||
.name = "cmark-c",
|
.name = "cmark-c",
|
||||||
@ -19,17 +18,17 @@ pub fn build(b: *std.Build) void {
|
|||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cmark.linkLibrary(cmark_c);
|
||||||
|
|
||||||
add_examples(b, .{
|
add_examples(b, .{
|
||||||
.target = target,
|
.target = target,
|
||||||
.cmark_module = cmark,
|
.cmark_module = cmark,
|
||||||
.cmark_c = cmark_c,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExampleOptions = struct {
|
const ExampleOptions = struct {
|
||||||
target: std.Build.ResolvedTarget,
|
target: std.Build.ResolvedTarget,
|
||||||
cmark_module: *std.Build.Module,
|
cmark_module: *std.Build.Module,
|
||||||
cmark_c: *std.Build.Step.Compile,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Example = struct {
|
const Example = struct {
|
||||||
@ -47,13 +46,12 @@ pub fn add_examples(b: *std.Build, options: ExampleOptions) void {
|
|||||||
inline for (examples) |example| {
|
inline for (examples) |example| {
|
||||||
const ex_exe = b.addExecutable(.{
|
const ex_exe = b.addExecutable(.{
|
||||||
.name = example.name,
|
.name = example.name,
|
||||||
.root_source_file = .{ .path = example.file },
|
.root_source_file = b.path(example.file),
|
||||||
.target = options.target,
|
.target = options.target,
|
||||||
.optimize = .Debug,
|
.optimize = .Debug,
|
||||||
});
|
});
|
||||||
|
|
||||||
ex_exe.root_module.addImport("cmark", options.cmark_module);
|
ex_exe.root_module.addImport("cmark", options.cmark_module);
|
||||||
ex_exe.linkLibrary(options.cmark_c);
|
|
||||||
|
|
||||||
const install = b.addInstallArtifact(ex_exe, .{});
|
const install = b.addInstallArtifact(ex_exe, .{});
|
||||||
example_step.dependOn(&install.step);
|
example_step.dependOn(&install.step);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.{
|
.{
|
||||||
.name = "cmark-zig",
|
.name = "cmark",
|
||||||
.version = "0.1.0-pre",
|
.version = "0.1.0-pre",
|
||||||
.dependencies = .{},
|
.dependencies = .{},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
@ -23,10 +23,10 @@ pub fn cmark_lib(
|
|||||||
|
|
||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
lib.addCSourceFiles(.{ .files = &common_sources, .flags = &cflags });
|
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(.{
|
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",
|
.include_path = "config.h",
|
||||||
}, .{
|
}, .{
|
||||||
.HAVE_STDBOOL_H = void{},
|
.HAVE_STDBOOL_H = void{},
|
||||||
@ -35,7 +35,7 @@ pub fn cmark_lib(
|
|||||||
});
|
});
|
||||||
|
|
||||||
const cmark_version_h = b.addConfigHeader(.{
|
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",
|
.include_path = "cmark_version.h",
|
||||||
}, .{
|
}, .{
|
||||||
.PROJECT_VERSION_MAJOR = 0,
|
.PROJECT_VERSION_MAJOR = 0,
|
||||||
@ -45,7 +45,7 @@ pub fn cmark_lib(
|
|||||||
|
|
||||||
lib.addConfigHeader(config_h);
|
lib.addConfigHeader(config_h);
|
||||||
lib.addConfigHeader(cmark_version_h);
|
lib.addConfigHeader(cmark_version_h);
|
||||||
lib.addIncludePath(.{ .path = cmark_zig_prefix });
|
lib.addIncludePath(b.path(cmark_zig_prefix));
|
||||||
lib.installConfigHeader(cmark_version_h);
|
lib.installConfigHeader(cmark_version_h);
|
||||||
|
|
||||||
inline for (install_headers) |header| {
|
inline for (install_headers) |header| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user