Compare commits
2 Commits
2a4b73c0f5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
e8d1a7491e
|
|||
|
06e2392816
|
10
build.zig
10
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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.{
|
||||
.name = "cmark-zig",
|
||||
.name = "cmark",
|
||||
.version = "0.1.0-pre",
|
||||
.dependencies = .{},
|
||||
.paths = .{
|
||||
|
||||
@@ -23,10 +23,11 @@ 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{},
|
||||
.HAVE___ATTRIBUTE__ = void{},
|
||||
@@ -34,7 +35,8 @@ 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,
|
||||
.PROJECT_VERSION_MINOR = 30,
|
||||
@@ -43,11 +45,11 @@ pub fn cmark_lib(
|
||||
|
||||
lib.addConfigHeader(config_h);
|
||||
lib.addConfigHeader(cmark_version_h);
|
||||
lib.addIncludePath(.{ .path = cmark_zig_prefix });
|
||||
lib.installConfigHeader(cmark_version_h, .{ .dest_rel_path = "cmark_version.h" });
|
||||
lib.addIncludePath(b.path(cmark_zig_prefix));
|
||||
lib.installConfigHeader(cmark_version_h);
|
||||
|
||||
inline for (install_headers) |header| {
|
||||
lib.installHeader(header.base_dir ++ header.name, header.name);
|
||||
lib.installHeader(b.path(header.base_dir ++ header.name), header.name);
|
||||
}
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
@@ -102,7 +102,7 @@ const AllocHeader = extern struct {
|
||||
}
|
||||
|
||||
inline fn fromTipPointer(tip: *u8) *AllocHeader {
|
||||
return @fieldParentPtr(AllocHeader, "tip", tip);
|
||||
return @alignCast(@fieldParentPtr("tip", tip));
|
||||
}
|
||||
|
||||
inline fn fullAllocFromTip(tip: *anyopaque) align(@alignOf(AllocHeader)) []u8 {
|
||||
|
||||
Reference in New Issue
Block a user