Skip to content

Commit d58ab29

Browse files
committed
add xmllint and xmlcatalog
1 parent a3a1719 commit d58ab29

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

build.zig

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,55 @@ pub fn build(b: *std.Build) void {
231231
xml_lib.root_module.linkLibrary(zlib_dependency.artifact("z"));
232232
}
233233
}
234+
235+
const xmllint = b.addExecutable(.{
236+
.name = "xmllint",
237+
.root_module = b.createModule(.{
238+
.target = target,
239+
.optimize = optimize,
240+
.link_libc = true,
241+
.strip = strip,
242+
.pic = pic,
243+
}),
244+
});
245+
b.installArtifact(xmllint);
246+
xmllint.root_module.addCSourceFiles(.{
247+
.files = xmllint_src,
248+
.root = upstream.path("."),
249+
.flags = xml_flags,
250+
});
251+
xmllint.root_module.linkLibrary(xml_lib);
252+
xmllint.root_module.addConfigHeader(config_header);
253+
xmllint.root_module.addIncludePath(upstream.path("include"));
254+
if (target.result.os.tag == .windows and linkage == .static) xmllint.root_module.addCMacro("LIBXML_STATIC", "1");
255+
if (readline) xmllint.root_module.linkSystemLibrary("readline", .{});
256+
if (history) xmllint.root_module.linkSystemLibrary("history", .{});
257+
258+
if (catalog and output) {
259+
const xmlcatalog = b.addExecutable(.{
260+
.name = "xmlcatalog",
261+
.root_module = b.createModule(.{
262+
.target = target,
263+
.optimize = optimize,
264+
.link_libc = true,
265+
.strip = strip,
266+
.pic = pic,
267+
}),
268+
});
269+
b.installArtifact(xmlcatalog);
270+
xmlcatalog.root_module.addCSourceFile(.{
271+
.file = upstream.path("xmlcatalog.c"),
272+
.flags = xml_flags,
273+
});
274+
xmlcatalog.root_module.linkLibrary(xml_lib);
275+
xmlcatalog.root_module.addConfigHeader(config_header);
276+
if (target.result.os.tag == .windows and linkage == .static) xmlcatalog.root_module.addCMacro("LIBXML_STATIC", "1");
277+
if (readline) xmlcatalog.root_module.linkSystemLibrary("readline", .{});
278+
if (history) xmlcatalog.root_module.linkSystemLibrary("history", .{});
279+
}
234280
}
235281

236-
pub const xml_src: []const []const u8 = &.{
282+
const xml_src: []const []const u8 = &.{
237283
"buf.c",
238284
"chvalid.c",
239285
"dict.c",
@@ -255,7 +301,13 @@ pub const xml_src: []const []const u8 = &.{
255301
"xmlstring.c",
256302
};
257303

258-
pub const xml_flags: []const []const u8 = &.{
304+
const xmllint_src: []const []const u8 = &.{
305+
"xmllint.c",
306+
"shell.c",
307+
"lintmain.c",
308+
};
309+
310+
const xml_flags: []const []const u8 = &.{
259311
"-pedantic",
260312
"-Wall",
261313
"-Wextra",

0 commit comments

Comments
 (0)