Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,21 @@ jobs:

- name: Build
run: zig build --summary all

build_tools:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Zig
uses: mlugg/setup-zig@v2

- name: Set up readline for tools
run: |
sudo apt-get update
sudo apt-get install -y libreadline-dev

- name: Build (with tools)
run: zig build -Dtools --summary all
59 changes: 55 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ pub fn build(b: *std.Build) void {
const want_xpath = b.option(bool, "xpath", "XPath 1.0 support (default=true)");
const want_xptr = b.option(bool, "xptr", "XPointer support (default=true)");

const tools = b.option(bool, "tools", "Build tools, enables (requires) readline and optionally history (default=false)") orelse false;

const output = want_output orelse (!minimum or want_c14n == true or want_writer == true);
const pattern = want_pattern orelse (!minimum or want_schemas == true or want_schematron == true);
const regexps = want_regexps orelse (!minimum or want_relaxng == true or want_schemas == true);
const push = want_push orelse (!minimum or want_reader == true or want_writer == true);
const readline = want_readline orelse (want_history == true);
const readline = want_readline orelse (tools or want_history == true);
const xpath = want_xpath orelse (!minimum or want_c14n == true or want_schematron == true or want_xptr == true);

const c14n = want_c14n orelse (!minimum and output and xpath);
const history = want_history orelse false;
const history = want_history orelse (tools or false);
const reader = want_reader orelse (!minimum and push);
const schemas = want_schemas orelse (!minimum and pattern and regexps);
const relaxng = want_relaxng orelse (!minimum and schemas);
Expand Down Expand Up @@ -189,8 +191,6 @@ pub fn build(b: *std.Build) void {
if (xinclude) xml_lib.root_module.addCSourceFile(.{ .file = upstream.path("xinclude.c"), .flags = xml_flags });
if (xpath) xml_lib.root_module.addCSourceFile(.{ .file = upstream.path("xpath.c"), .flags = xml_flags });
if (xptr) xml_lib.root_module.addCSourceFiles(.{ .files = &.{ "xlink.c", "xpointer.c" }, .root = upstream.path(""), .flags = xml_flags });
if (readline) xml_lib.root_module.linkSystemLibrary("readline", .{});
if (history) xml_lib.root_module.linkSystemLibrary("history", .{});
if (lzma) xml_lib.root_module.linkSystemLibrary("lzma", .{});
if (icu) xml_lib.root_module.linkSystemLibrary("icu-i18n", .{});
if (target.result.os.tag == .windows) xml_lib.root_module.linkSystemLibrary("bcrypt", .{});
Expand Down Expand Up @@ -241,6 +241,51 @@ pub fn build(b: *std.Build) void {
xml_lib.root_module.linkLibrary(zlib_dependency.artifact("z"));
}
}

if (tools and !readline) std.debug.panic("tools require readline", .{});

// Build tools
if (tools and readline) {
const xmllint = b.addExecutable(.{
.name = "xmllint",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
xmllint.linkLibrary(xml_lib);
xmllint.addCSourceFiles(.{
.files = &xmllint_src,
.flags = xml_flags,
.root = upstream.path("."),
});
xmllint.linkSystemLibrary2("readline", .{});
if (history) xmllint.linkSystemLibrary2("history", .{});
xmllint.root_module.addConfigHeader(config_header);
xmllint.root_module.addIncludePath(upstream.path("include"));

b.installArtifact(xmllint);

const xmlcatalog = b.addExecutable(.{
.name = "xmlcatalog",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
xmlcatalog.linkLibrary(xml_lib);
xmlcatalog.addCSourceFile(.{
.file = upstream.path("xmlcatalog.c"),
.flags = xml_flags,
});
xmlcatalog.linkSystemLibrary2("readline", .{});
if (history) xmlcatalog.linkSystemLibrary2("history", .{});
xmlcatalog.root_module.addConfigHeader(config_header);

b.installArtifact(xmlcatalog);
}
}

pub const xml_src: []const []const u8 = &.{
Expand All @@ -265,6 +310,12 @@ pub const xml_src: []const []const u8 = &.{
"xmlstring.c",
};

const xmllint_src = [_][]const u8{
"xmllint.c",
"lintmain.c",
"shell.c",
};

pub const xml_flags: []const []const u8 = &.{
"-pedantic",
"-Wall",
Expand Down