This is pugixml, packaged for Zig. (Intended for C++ projects using Zig as a build tool.)
First, update your build.zig.zon:
zig fetch --save git+https://github.com/jessechounard/pugixmlNext, in your build.zig, you can access the library as a dependency:
const pugixml_dep = b.dependency("pugixml", .{
.target = target,
.optimize = optimize,
// [optional] build options - see below
});
const pugixml_lib = pugixml_dep.artifact("pugixml");
exe.root_module.linkLibrary(pugixml_lib);Finally, in your C++ file, you can use the library by including pugixml.hpp.
pugixml has a few build-time configurable options. See the pugixml documentation for information on these. The options currently exposed here are:
- wchar-mode (PUGIXML_WCHAR_MODE)
- compact (PUGIXML_COMPACT)
- no-xpath (PUGIXML_NO_XPATH)
- no-stl (PUGIXML_NO_STL)
- no-exceptions (PUGIXML_NO_EXCEPTIONS)
These all default to false and my guess is that's what most people will want. Please give me a shout if you need any of the other pugiconfig.hpp options available here.
An example with options:
const pugixml_dep = b.dependency("pugixml", .{
.target = target,
.optimize = optimize,
.@"no-xpath" = true,
.@"no-stl" = false,
});- Currently only tested on my Windows box. More validation required.
- Add a CI step on github.
I'm a zig newbie. If you see anything I could be doing better here, please let me know. I appreciate the input!