Compare commits
4 Commits
3a73fbe312
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
e8d1a7491e
|
|||
|
06e2392816
|
|||
|
2a4b73c0f5
|
|||
|
4b9dbeea65
|
15
build.zig
15
build.zig
@@ -9,7 +9,7 @@ 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", .{
|
||||||
.source_file = .{ .path = "src/cmark.zig" },
|
.root_source_file = b.path("src/cmark.zig"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const cmark_c = cmark_build.cmark_lib(b, .{
|
const cmark_c = cmark_build.cmark_lib(b, .{
|
||||||
@@ -18,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.zig.CrossTarget,
|
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 {
|
||||||
@@ -40,19 +40,18 @@ const examples = [_]Example{
|
|||||||
.{ .name = "render_html", .file = "examples/render_html.zig" },
|
.{ .name = "render_html", .file = "examples/render_html.zig" },
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn add_examples(b: *std.build, options: ExampleOptions) void {
|
pub fn add_examples(b: *std.Build, options: ExampleOptions) void {
|
||||||
const example_step = b.step("examples", "build examples");
|
const example_step = b.step("examples", "build examples");
|
||||||
|
|
||||||
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.addModule("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);
|
||||||
|
|||||||
13
build.zig.zon
Normal file
13
build.zig.zon
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
.{
|
||||||
|
.name = "cmark",
|
||||||
|
.version = "0.1.0-pre",
|
||||||
|
.dependencies = .{},
|
||||||
|
.paths = .{
|
||||||
|
"src",
|
||||||
|
"deps/cmark/src",
|
||||||
|
"deps/cmark/COPYING",
|
||||||
|
"build.zig",
|
||||||
|
"build.zig.zon",
|
||||||
|
"license",
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ const std = @import("std");
|
|||||||
|
|
||||||
const CmarkBuildOptions = struct {
|
const CmarkBuildOptions = struct {
|
||||||
name: []const u8 = "cmark-c",
|
name: []const u8 = "cmark-c",
|
||||||
target: std.zig.CrossTarget,
|
target: std.Build.ResolvedTarget,
|
||||||
optimize: std.builtin.OptimizeMode,
|
optimize: std.builtin.OptimizeMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -22,11 +22,12 @@ pub fn cmark_lib(
|
|||||||
const cflags = [_][]const u8{};
|
const cflags = [_][]const u8{};
|
||||||
|
|
||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
lib.addCSourceFiles(&common_sources, &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",
|
||||||
}, .{
|
}, .{
|
||||||
.HAVE_STDBOOL_H = void{},
|
.HAVE_STDBOOL_H = void{},
|
||||||
.HAVE___ATTRIBUTE__ = void{},
|
.HAVE___ATTRIBUTE__ = void{},
|
||||||
@@ -34,7 +35,8 @@ 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",
|
||||||
}, .{
|
}, .{
|
||||||
.PROJECT_VERSION_MAJOR = 0,
|
.PROJECT_VERSION_MAJOR = 0,
|
||||||
.PROJECT_VERSION_MINOR = 30,
|
.PROJECT_VERSION_MINOR = 30,
|
||||||
@@ -43,11 +45,11 @@ 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, .{ .dest_rel_path = "cmark_version.h" });
|
lib.installConfigHeader(cmark_version_h);
|
||||||
|
|
||||||
inline for (install_headers) |header| {
|
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);
|
b.installArtifact(lib);
|
||||||
|
|||||||
26
license
Normal file
26
license
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
Copyright (c) 2024, torque@epicyclic.dev
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer in the documentation and/or other materials provided
|
||||||
|
with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
@@ -102,7 +102,7 @@ const AllocHeader = extern struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline fn fromTipPointer(tip: *u8) *AllocHeader {
|
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 {
|
inline fn fullAllocFromTip(tip: *anyopaque) align(@alignOf(AllocHeader)) []u8 {
|
||||||
|
|||||||
Reference in New Issue
Block a user