Skip to content

Commit

Permalink
build: update to latest Zig
Browse files Browse the repository at this point in the history
  • Loading branch information
ianprime0509 committed Oct 11, 2023
1 parent dfdc044 commit ea0fcb1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bench/build.zig
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const std = @import("std");
const libxml2 = @import("lib/zig-libxml2/libxml2.zig");
const Build = std.Build;
const Step = Build.Step;

pub fn build(b: *Build) !void {
const xml = b.addModule("xml", .{ .source_file = .{ .path = "../src/xml.zig" } });
const xml = b.dependency("xml", .{}).module("xml");

const bench_scanner = addBench(b, "scanner");
bench_scanner.addModule("xml", xml);
Expand All @@ -18,13 +17,13 @@ pub fn build(b: *Build) !void {
bench_reader.addModule("xml", xml);
bench_reader.linkLibC();

const libxml2_lib = try libxml2.create(b, .{}, .ReleaseFast, .{
const libxml2 = b.dependency("libxml2", .{
.iconv = false,
.lzma = false,
.zlib = false,
});
}).artifact("xml2");
const bench_libxml2 = addBench(b, "libxml2");
libxml2_lib.link(bench_libxml2);
bench_libxml2.linkLibrary(libxml2);

const bench_yxml = addBench(b, "yxml");
bench_yxml.linkLibC();
Expand All @@ -33,7 +32,7 @@ pub fn build(b: *Build) !void {

const bench_mxml = addBench(b, "mxml");
bench_mxml.linkLibC();
bench_mxml.addCSourceFiles(&.{
bench_mxml.addCSourceFiles(.{ .files = &.{
"lib/mxml/mxml-attr.c",
"lib/mxml/mxml-entity.c",
"lib/mxml/mxml-file.c",
Expand All @@ -44,7 +43,7 @@ pub fn build(b: *Build) !void {
"lib/mxml/mxml-search.c",
"lib/mxml/mxml-set.c",
"lib/mxml/mxml-string.c",
}, &.{});
} });
bench_mxml.addIncludePath(.{ .path = "lib/mxml" });
bench_mxml.addIncludePath(.{ .path = "lib/mxml-config" });
}
Expand Down
20 changes: 20 additions & 0 deletions bench/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.{
.name = "zig-xml-benchmarks",
.version = "0.0.0",
.paths = .{
"src",
"lib",
"build.zig",
"build.zig.zon",
},
.dependencies = .{
.xml = .{
.path = "..",
},
.libxml2 = .{
// https://github.com/mitchellh/zig-build-libxml2/pull/1
.url = "git+https://github.com/ianprime0509/zig-build-libxml2#update-zig",
.hash = "1220c48add849a9e9fa9c9b84e0c37b5843f7cefb45a98dab57a08daa772d273f810",
},
},
}
11 changes: 11 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.{
.name = "zig-xml",
.version = "0.0.0",
.paths = .{
"src",
"LICENSE",
"README.md",
"build.zig",
"build.zig.zon",
},
}

0 comments on commit ea0fcb1

Please sign in to comment.