Skip to content

Commit e1cceff

Browse files
committed
update to zig 0.14.0
1 parent 57aa500 commit e1cceff

File tree

3 files changed

+55
-34
lines changed

3 files changed

+55
-34
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ jobs:
1717
zig-version: [master]
1818
os: [ubuntu-latest, macos-latest, windows-latest]
1919
include:
20-
- zig-version: "0.12.1"
21-
os: ubuntu-latest
22-
- zig-version: "0.13.0"
20+
- zig-version: "0.14.0"
2321
os: ubuntu-latest
2422
runs-on: ${{ matrix.os }}
2523
steps:

build.zig

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ pub fn build(b: *std.Build) void {
77
const target = b.standardTargetOptions(.{});
88
const optimize = b.standardOptimizeOption(.{});
99

10+
const linkage = b.option(std.builtin.LinkMode, "linkage", "Link mode") orelse .static;
11+
const strip = b.option(bool, "strip", "Omit debug information");
12+
const pic = b.option(bool, "pie", "Produce Position Independent Code");
13+
1014
// Most of these config options have not been tested.
1115

1216
var context_bytes = b.option(i64, "context-bytes", "Define to specify how much context to retain around the current parse point, 0 to disable") orelse 1024;
@@ -59,7 +63,7 @@ pub fn build(b: *std.Build) void {
5963
.ios,
6064
.tvos,
6165
.watchos,
62-
// .visionos, // not available on Zig 0.12
66+
.visionos,
6367
=> true,
6468
else => false,
6569
},
@@ -100,43 +104,52 @@ pub fn build(b: *std.Build) void {
100104
.off_t = null,
101105
});
102106

103-
const expat = b.addStaticLibrary(.{
107+
const expat = b.addLibrary(.{
108+
.linkage = linkage,
104109
.name = "expat",
105-
.target = target,
106-
.optimize = optimize,
107-
.link_libc = true,
110+
.root_module = b.createModule(.{
111+
.target = target,
112+
.optimize = optimize,
113+
.link_libc = true,
114+
.strip = strip,
115+
.pic = pic,
116+
}),
108117
});
109118
b.installArtifact(expat);
110-
expat.linkLibC();
111-
expat.addConfigHeader(config_header);
119+
expat.root_module.addConfigHeader(config_header);
112120
if (large_size) expat.root_module.addCMacro("XML_LARGE_SIZE", "1");
113121
if (min_size) expat.root_module.addCMacro("XML_MIN_SIZE", "1");
114122
if (char_type != .char) expat.root_module.addCMacro("XML_UNICODE", "1");
115123
if (char_type == .wchar_t) expat.root_module.addCMacro("XML_UNICODE_WCHAR_T", "1");
116-
expat.addIncludePath(upstream.path("expat/lib"));
124+
expat.root_module.addIncludePath(upstream.path("expat/lib"));
117125
expat.installHeader(upstream.path("expat/lib/expat.h"), "expat.h");
118126
expat.installHeader(upstream.path("expat/lib/expat_external.h"), "expat_external.h");
119-
expat.addCSourceFiles(.{
127+
expat.root_module.addCSourceFiles(.{
120128
.files = sources,
121129
.root = upstream.path("expat"),
122130
.flags = if (need_short_char_arg) &.{ "-std=c99", "-fshort-wchar" } else &.{"-std=c99"},
123131
});
124132

125133
const xmlwf = b.addExecutable(.{
126134
.name = "xmlwf",
127-
.target = target,
128-
.optimize = optimize,
135+
.root_module = b.createModule(.{
136+
.target = target,
137+
.optimize = optimize,
138+
.link_libc = true,
139+
.strip = strip,
140+
.pic = pic,
141+
}),
129142
});
130-
xmlwf.addConfigHeader(config_header);
131-
xmlwf.addIncludePath(upstream.path("expat/lib"));
143+
xmlwf.root_module.addConfigHeader(config_header);
144+
xmlwf.root_module.addIncludePath(upstream.path("expat/lib"));
132145
if (char_type != .char) xmlwf.root_module.addCMacro("XML_UNICODE", "1");
133146
if (char_type == .wchar_t) xmlwf.root_module.addCMacro("XML_UNICODE_WCHAR_T", "1");
134-
xmlwf.addCSourceFiles(.{
147+
xmlwf.root_module.addCSourceFiles(.{
135148
.files = xmlwf_sources,
136149
.root = upstream.path("expat"),
137150
.flags = if (need_short_char_arg) &.{"-fshort-wchar"} else &.{},
138151
});
139-
xmlwf.linkLibrary(expat);
152+
xmlwf.root_module.linkLibrary(expat);
140153

141154
switch (char_type) {
142155
.char => {},
@@ -160,16 +173,21 @@ pub fn build(b: *std.Build) void {
160173
for (examples) |source| {
161174
const exe = b.addExecutable(.{
162175
.name = std.fs.path.stem(source),
163-
.target = target,
164-
.optimize = optimize,
176+
.root_module = b.createModule(.{
177+
.target = target,
178+
.optimize = optimize,
179+
.link_libc = true,
180+
.strip = strip,
181+
.pic = pic,
182+
}),
165183
});
166184
if (char_type != .char) exe.root_module.addCMacro("XML_UNICODE", "1");
167185
if (char_type == .wchar_t) exe.root_module.addCMacro("XML_UNICODE_WCHAR_T", "1");
168-
exe.addCSourceFile(.{
186+
exe.root_module.addCSourceFile(.{
169187
.file = upstream.path(b.fmt("expat/{s}", .{source})),
170188
.flags = if (need_short_char_arg) &.{"-fshort-wchar"} else &.{},
171189
});
172-
exe.linkLibrary(expat);
190+
exe.root_module.linkLibrary(expat);
173191

174192
examples_step.dependOn(&b.addInstallArtifact(exe, .{ .dest_dir = examples_dir }).step);
175193

@@ -191,24 +209,28 @@ pub fn build(b: *std.Build) void {
191209

192210
const test_exe = b.addExecutable(.{
193211
.name = name,
194-
.target = target,
195-
.optimize = optimize,
212+
.root_module = b.createModule(.{
213+
.target = target,
214+
.optimize = optimize,
215+
.link_libc = true,
216+
.link_libcpp = link_cpp,
217+
.strip = strip,
218+
.pic = pic,
219+
}),
196220
});
197-
test_exe.linkLibC();
198-
if (link_cpp) test_exe.linkLibCpp();
199221
test_exe.root_module.addCMacro("XML_TESTING", "1");
200222
if (char_type != .char) test_exe.root_module.addCMacro("XML_UNICODE", "1");
201223
if (char_type == .wchar_t) test_exe.root_module.addCMacro("XML_UNICODE_WCHAR_T", "1");
202-
test_exe.addCSourceFiles(.{
224+
test_exe.root_module.addCSourceFiles(.{
203225
.flags = flags.items,
204226
.root = upstream.path("expat"),
205227
.files = test_sources,
206228
});
207-
test_exe.addConfigHeader(config_header);
208-
test_exe.addIncludePath(upstream.path("expat/lib"));
229+
test_exe.root_module.addConfigHeader(config_header);
230+
test_exe.root_module.addIncludePath(upstream.path("expat/lib"));
209231
if (large_size) test_exe.root_module.addCMacro("XML_LARGE_SIZE", "1");
210232
if (min_size) test_exe.root_module.addCMacro("XML_MIN_SIZE", "1");
211-
test_exe.addCSourceFiles(.{
233+
test_exe.root_module.addCSourceFiles(.{
212234
.files = sources,
213235
.root = upstream.path("expat"),
214236
.flags = if (need_short_char_arg) &.{ "-std=c99", "-fshort-wchar" } else &.{"-std=c99"},

build.zig.zon

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.{
2-
.name = "libexpat",
2+
.name = .libexpat,
33
.version = "2.6.4",
4-
.minimum_zig_version = "0.12.0",
4+
.minimum_zig_version = "0.14.0",
55
.dependencies = .{
66
.libexpat = .{
7-
.url = "git+https://github.com/libexpat/libexpat.git?ref=R_2_6_4#2691aff4304a6d7e053199c205620136481b9dd1",
8-
.hash = "122023634c5939c209cbc4e27867707244abfd08d1234aeeda686fbe1a65435dd531",
7+
.url = "git+https://github.com/libexpat/libexpat?ref=R_2_6_4#2691aff4304a6d7e053199c205620136481b9dd1",
8+
.hash = "N-V-__8AADPHGggjY0xZOcIJy8TieGdwckSr_QjRI0ru2mhv",
99
},
1010
},
1111
.paths = .{
@@ -14,4 +14,5 @@
1414
"LICENSE",
1515
"README.md",
1616
},
17+
.fingerprint = 0x39523a2723a4f6cb, // Changing this has security and trust implications.
1718
}

0 commit comments

Comments
 (0)