Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update for Zig 0.14.0 #46

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
zig-version: [0.13.0, master]
zig-version: [0.13.0, master] # TODO: change to 0.14.0 as baseline
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zig-xml

zig-xml is an XML library for Zig, currently supporting Zig 0.13.0 and the
zig-xml is an XML library for Zig, currently supporting Zig 0.14.0 and the
latest master at the time of writing.

See the documentation in the code for more information about the available APIs
Expand Down Expand Up @@ -36,10 +36,7 @@ pass, and 924 are skipped due to unsupported features.
## Fuzzing

There is a fuzzing sub-project in the `fuzz` directory using
https://github.com/kristoff-it/zig-afl-kit. If running on Zig 0.13.0, an extra
step needs to be taken to make the fuzzing more effective:
https://github.com/kristoff-it/zig-afl-kit/blob/main/README.md#-------important-------
On Zig master, this is not needed.
https://github.com/kristoff-it/zig-afl-kit.

## License

Expand Down
7 changes: 5 additions & 2 deletions bench/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ pub fn build(b: *Build) !void {
}

fn addBench(b: *Build, name: []const u8) *Step.Compile {
const exe = b.addExecutable(.{
.name = name,
const mod = b.createModule(.{
.root_source_file = b.path(b.fmt("src/{s}.zig", .{name})),
.target = b.graph.host,
.optimize = .ReleaseFast,
});
const exe = b.addExecutable(.{
.name = name,
.root_module = mod,
});
b.installArtifact(exe);
return exe;
}
25 changes: 14 additions & 11 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ pub fn build(b: *Build) void {

const test_step = b.step("test", "Run the tests");
const xml_test = b.addTest(.{
.root_source_file = b.path("src/xml.zig"),
.target = target,
.root_module = xml,
});
const xml_test_run = b.addRunArtifact(xml_test);
test_step.dependOn(&xml_test_run.step);

const docs_step = b.step("docs", "Build the documentation");
const xml_docs = b.addObject(.{
.name = "xml",
.root_source_file = b.path("src/xml.zig"),
.target = target,
.optimize = .Debug,
.root_module = xml,
});
const xml_docs_copy = b.addInstallDirectory(.{
.source_dir = xml_docs.getEmittedDocs(),
Expand All @@ -36,23 +33,29 @@ pub fn build(b: *Build) void {

const install_examples_step = b.step("install-examples", "Build and install the example programs");

const example_reader_exe = b.addExecutable(.{
.name = "reader",
const example_reader_mod = b.createModule(.{
.root_source_file = b.path("examples/reader.zig"),
.target = target,
.optimize = optimize,
});
example_reader_exe.root_module.addImport("xml", xml);
example_reader_mod.addImport("xml", xml);
const example_reader_exe = b.addExecutable(.{
.name = "reader",
.root_module = example_reader_mod,
});
const example_reader_install = b.addInstallArtifact(example_reader_exe, .{});
install_examples_step.dependOn(&example_reader_install.step);

const example_canonicalize_exe = b.addExecutable(.{
.name = "canonicalize",
const example_canonicalize_mod = b.createModule(.{
.root_source_file = b.path("examples/canonicalize.zig"),
.target = target,
.optimize = optimize,
});
example_canonicalize_exe.root_module.addImport("xml", xml);
example_canonicalize_mod.addImport("xml", xml);
const example_canonicalize_exe = b.addExecutable(.{
.name = "canonicalize",
.root_module = example_canonicalize_mod,
});
const example_canonicalize_install = b.addInstallArtifact(example_canonicalize_exe, .{});
install_examples_step.dependOn(&example_canonicalize_install.step);
}
15 changes: 9 additions & 6 deletions fuzz/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ pub fn build(b: *std.Build) void {
.optimize = .Debug,
});

const afl_obj = b.addObject(.{
.name = "fuzz-xml",
const afl_mod = b.createModule(.{
.root_source_file = b.path("src/fuzz.zig"),
.target = target,
.optimize = .Debug,
.stack_check = false,
.link_libc = true,
.fuzz = true,
});
afl_mod.addImport("xml", xml.module("xml"));
const afl_obj = b.addObject(.{
.name = "fuzz-xml",
.root_module = afl_mod,
});
afl_obj.root_module.stack_check = false;
afl_obj.root_module.link_libc = true;
if (@hasField(std.Build.Module, "fuzz")) afl_obj.root_module.fuzz = true;
afl_obj.root_module.addImport("xml", xml.module("xml"));

const afl_exe = afl.addInstrumentedExe(b, target, .Debug, afl_obj);
const afl_exe_install = b.addInstallBinFile(afl_exe, "fuzz-xml");
Expand Down
Loading
Loading