Skip to content

Commit 2b65261

Browse files
committed
zig 0.16
1 parent 277bba3 commit 2b65261

15 files changed

Lines changed: 69 additions & 85 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ npm-debug.log
2121
.idea
2222

2323
.zig-cache/
24+
zig-pkg/

‎build.zig‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,23 @@ pub fn build(b: *std.Build) void {
101101
.target = target,
102102
.optimize = optimize,
103103
.root_source_file = b.path("src/unicode.zig"),
104+
.link_libc = true,
105+
.pic = true,
104106
})
105107
});
106108

107109
unicode.root_module.addImport("Scripts", zg.module("Scripts"));
108110
unicode.root_module.addImport("Graphemes", zg.module("Graphemes"));
109-
unicode.linkLibC();
110111

111112
const canvas = b.addLibrary(.{
112113
.name = "canvas",
113114
.linkage = .dynamic,
114115
.root_module = b.createModule(.{
115116
.target = target,
116117
.optimize = optimize,
118+
.pic = true,
119+
.link_libc = true,
120+
.link_libcpp = true,
117121
})
118122
});
119123

@@ -122,7 +126,7 @@ pub fn build(b: *std.Build) void {
122126
.optimize = optimize,
123127
}).artifact("node_api");
124128

125-
canvas.addCSourceFiles(.{
129+
canvas.root_module.addCSourceFiles(.{
126130
.files = &.{
127131
"src/bmp/BMPParser.cc",
128132
"src/Canvas.cc",
@@ -165,24 +169,22 @@ pub fn build(b: *std.Build) void {
165169
canvas.root_module.strip = true;
166170
}
167171

168-
canvas.linkLibC();
169-
canvas.linkLibCpp();
170-
canvas.addObject(node_api);
171-
canvas.linkLibrary(cairo);
172-
canvas.linkLibrary(libjpeg_turbo);
173-
canvas.linkLibrary(libpng);
174-
canvas.linkLibrary(giflib);
175-
canvas.linkLibrary(sheenbidi);
176-
canvas.linkLibrary(unicode);
177-
canvas.linkLibrary(harfbuzz);
178-
canvas.linkLibrary(lunasvg);
172+
canvas.root_module.addObject(node_api);
173+
canvas.root_module.linkLibrary(cairo);
174+
canvas.root_module.linkLibrary(libjpeg_turbo);
175+
canvas.root_module.linkLibrary(libpng);
176+
canvas.root_module.linkLibrary(giflib);
177+
canvas.root_module.linkLibrary(sheenbidi);
178+
canvas.root_module.linkLibrary(unicode);
179+
canvas.root_module.linkLibrary(harfbuzz);
180+
canvas.root_module.linkLibrary(lunasvg);
179181

180182
// some deps, especially lunasvg, compile with -ffunction-sections and
181183
// -fdata-sections so we don't have to distribute unused parts of libraries
182184
canvas.link_gc_sections = true;
183185

184186
if (target.result.os.tag == .windows) {
185-
canvas.linkSystemLibrary("dwrite");
187+
canvas.root_module.linkSystemLibrary("dwrite", .{});
186188
}
187189

188190
if (target.result.os.tag == .macos) {
@@ -200,19 +202,19 @@ pub fn build(b: *std.Build) void {
200202
" \r\n",
201203
);
202204

203-
canvas.addSystemFrameworkPath(.{
205+
canvas.root_module.addSystemFrameworkPath(.{
204206
.cwd_relative = b.pathJoin(&.{
205207
path,
206208
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/System/Library/Frameworks",
207209
}),
208210
});
209-
canvas.addSystemIncludePath(.{
211+
canvas.root_module.addSystemIncludePath(.{
210212
.cwd_relative = b.pathJoin(&.{
211213
path,
212214
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/include",
213215
}),
214216
});
215-
canvas.addLibraryPath(.{
217+
canvas.root_module.addLibraryPath(.{
216218
.cwd_relative = b.pathJoin(&.{
217219
path,
218220
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/lib",

‎build.zig.zon‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.fingerprint = 0xa59f6c18a5521654,
44
.version = "0.0.0",
55
.paths = .{""},
6-
.minimum_zig_version = "0.15.1",
6+
.minimum_zig_version = "0.16.0",
77
// Sub-packages only specify dependencies for upstream C/C++ code.
88
// Everything else goes here so it's easier to share dependencies and ensure
99
// we don't build duplicate versions. Generally build.zig[.zon] files should
@@ -22,8 +22,8 @@
2222
},
2323
// Zig dependencies don't need as much tweaking
2424
.zg = .{
25-
.url = "https://codeberg.org/atman/zg/archive/d9f596626e8ec05a9f3e47f7bc83aedd5bd2f989.tar.gz",
26-
.hash = "zg-0.15.3-oGqU3P5ItAJHmwDLfzX6sg6Xc5MhSJU2TctHfWu_sKLv",
25+
.url = "https://codeberg.org/atman/zg/archive/ce364b17d60b28fda1af24c6575b93c47afe043e.tar.gz",
26+
.hash = "zg-0.16.2-oGqU3HqftgI6rwFS90ypwfjgToH8Pz829OKuFURlm773",
2727
},
2828
.giflib = .{ .path = "./pkg/giflib" },
2929
.libpng = .{ .path = "./pkg/libpng" },

‎pkg/cairo/build.zig‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn build(b: *std.Build) !void {
1818

1919
lib.link_data_sections = true;
2020
lib.link_function_sections = true;
21-
lib.addIncludePath(cairo.path("src"));
21+
lib.root_module.addIncludePath(cairo.path("src"));
2222

2323
var cairo_sources = std.ArrayList([]const u8).empty;
2424
defer cairo_sources.deinit(b.allocator);
@@ -143,14 +143,14 @@ pub fn build(b: *std.Build) !void {
143143

144144
const feature_config = b.addConfigHeader(.{ .include_path = "cairo-features.h" }, .{});
145145

146-
lib.linkSystemLibrary("m");
146+
lib.root_module.linkSystemLibrary("m", .{});
147147

148148
const zlib = b.dependency("zlib", .{
149149
.target = target,
150150
.optimize = optimize,
151151
});
152152

153-
lib.linkLibrary(zlib.artifact("z"));
153+
lib.root_module.linkLibrary(zlib.artifact("z"));
154154

155155
config.addValues(.{
156156
.HAVE_ZLIB = 1,
@@ -169,7 +169,7 @@ pub fn build(b: *std.Build) !void {
169169
.optimize = optimize,
170170
});
171171

172-
lib.linkLibrary(png.artifact("png"));
172+
lib.root_module.linkLibrary(png.artifact("png"));
173173

174174
config.addValues(.{
175175
.CAIRO_CAN_TEST_SVG_SURFACE = 1,
@@ -185,7 +185,7 @@ pub fn build(b: *std.Build) !void {
185185
.target = target,
186186
.optimize = optimize,
187187
}).artifact("freetype");
188-
lib.linkLibrary(freetype);
188+
lib.root_module.linkLibrary(freetype);
189189
lib.installLibraryHeaders(freetype);
190190

191191
feature_config.addValues(.{ .CAIRO_HAS_FT_FONT = 1 });
@@ -204,8 +204,8 @@ pub fn build(b: *std.Build) !void {
204204
"-DCAIRO_WIN32_STATIC_BUILD",
205205
});
206206

207-
lib.linkSystemLibrary("gdi32");
208-
lib.linkSystemLibrary("msimg32");
207+
lib.root_module.linkSystemLibrary("gdi32", .{});
208+
lib.root_module.linkSystemLibrary("msimg32", .{});
209209

210210
feature_config.addValues(.{
211211
.CAIRO_HAS_WIN32_SURFACE = 1,
@@ -214,14 +214,14 @@ pub fn build(b: *std.Build) !void {
214214
}
215215

216216
if (b.systemIntegrationOption("pixman", .{})) {
217-
lib.linkSystemLibrary("pixman-1");
217+
lib.root_module.linkSystemLibrary("pixman-1", .{});
218218
} else if (b.lazyDependency("pixman", .{
219219
.target = target,
220220
.optimize = optimize,
221221
})) |dep| {
222222
const pixman = dep.artifact("pixman");
223223
pixman.root_module.sanitize_c = .off;
224-
lib.linkLibrary(pixman);
224+
lib.root_module.linkLibrary(pixman);
225225
lib.installLibraryHeaders(pixman);
226226
}
227227

@@ -235,7 +235,7 @@ pub fn build(b: *std.Build) !void {
235235
.CAIRO_HAS_OBSERVER_SURFACE = 1,
236236
});
237237

238-
lib.linkSystemLibrary("pthread");
238+
lib.root_module.linkSystemLibrary("pthread", .{});
239239

240240
config.addValues(.{
241241
.CAIRO_HAS_PTHREAD = 1,
@@ -250,10 +250,10 @@ pub fn build(b: *std.Build) !void {
250250
if (!target.result.cpu.arch.isX86())
251251
config.addValues(.{ .ATOMIC_OP_NEEDS_MEMORY_BARRIER = 1 });
252252

253-
lib.addConfigHeader(config);
254-
lib.addConfigHeader(feature_config);
253+
lib.root_module.addConfigHeader(config);
254+
lib.root_module.addConfigHeader(feature_config);
255255

256-
lib.addCSourceFiles(.{
256+
lib.root_module.addCSourceFiles(.{
257257
.root = cairo.path("src"),
258258
.files = try cairo_sources.toOwnedSlice(b.allocator),
259259
.flags = c_flags.items,

‎pkg/freetype/build.zig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn build(b: *std.Build) !void {
1616
}),
1717
});
1818

19-
lib.addIncludePath(upstream.path("include"));
19+
lib.root_module.addIncludePath(upstream.path("include"));
2020
lib.installHeadersDirectory(upstream.path("include"), "", .{});
2121

2222
// Dependencies

‎pkg/freetype/build.zig.zon‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
.{
22
.name = .freetype,
3+
.fingerprint = 0xac2059b6c1cddc9f,
34
.version = "0.0.0",
45
.dependencies = .{
56
.freetype = .{
67
.url = "https://github.com/freetype/freetype/archive/refs/tags/VER-2-14-1.tar.gz",
78
.hash = "N-V-__8AAJx1qgDwI7KTM6yDZ4ArrZU6qmKKuvDHRVrxUkTw",
89
},
9-
// TODO: this needs to be kept in sync with the root build.zig.zon
10-
.zlib = .{
11-
.url = "git+https://github.com/allyourcodebase/zlib#3599c16d41dbe749ae51b0ff7ab864c61adc779a",
12-
.hash = "zlib-1.3.1-ZZQ7lc8NAABUbHzDe_cSWboCqMbrLkVwvFkKnojgeiT2",
13-
},
14-
// TODO: this needs to be kept in sync with the root build.zig.zon
15-
.libpng = .{
16-
.url = "https://github.com/allyourcodebase/libpng/archive/d512607515687aa60b975d6a191aef9a692dac87.zip",
17-
.hash = "libpng-1.6.50-oiaFGt4qAAB_vzrtvz9hA7_UiBW4arSaMVGc7ekKMCZ2",
18-
},
10+
.zlib = .{ .path = "../zlib" },
11+
.libpng = .{ .path = "../libpng" },
1912
},
2013
}

‎pkg/harfbuzz/build.zig‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ pub fn build(b: *std.Build) !void {
1111
.root_module = b.createModule(.{
1212
.target = target,
1313
.optimize = optimize,
14+
.link_libc = true,
15+
.link_libcpp = true,
1416
.pic = true,
1517
})
1618
});
1719

18-
harfbuzz.addCSourceFile(.{
20+
harfbuzz.root_module.addCSourceFile(.{
1921
.file = upstream.path("src/harfbuzz.cc"),
2022
});
2123
harfbuzz.installHeadersDirectory(upstream.path("src"), "", .{});
2224

23-
harfbuzz.linkLibC();
24-
harfbuzz.linkLibCpp();
25-
2625
b.installArtifact(harfbuzz);
2726
}

‎pkg/harfbuzz/build.zig.zon‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.{
22
.name = .harfbuzz,
3+
.fingerprint = 0xbd60917c14346ca6,
34
.version = "0.0.0",
45
.dependencies = .{
56
.harfbuzz = .{

‎pkg/lunasvg/build.zig‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub fn build(b: *std.Build) !void {
1010
.root_module = b.createModule(.{
1111
.target = target,
1212
.optimize = optimize,
13+
.pic = true,
14+
.link_libc = true,
1315
})
1416
});
1517

@@ -19,7 +21,7 @@ pub fn build(b: *std.Build) !void {
1921
.optimize = optimize,
2022
}).artifact("cairo");
2123

22-
plutovg.addCSourceFiles(.{
24+
plutovg.root_module.addCSourceFiles(.{
2325
.root = upstream.path(""),
2426
.files = &.{
2527
"plutovg/source/plutovg-blend.c",
@@ -46,10 +48,9 @@ pub fn build(b: *std.Build) !void {
4648
}
4749
});
4850

49-
plutovg.addIncludePath(upstream.path("plutovg/include"));
51+
plutovg.root_module.addIncludePath(upstream.path("plutovg/include"));
5052
plutovg.installHeadersDirectory(upstream.path("plutovg/include"), "", .{});
51-
plutovg.linkLibrary(cairo);
52-
plutovg.linkLibC();
53+
plutovg.root_module.linkLibrary(cairo);
5354

5455
// strip out anything we didn't use, which for plutovg is a lot (on this fork)
5556
plutovg.link_data_sections = true;
@@ -61,10 +62,13 @@ pub fn build(b: *std.Build) !void {
6162
.root_module = b.createModule(.{
6263
.target = target,
6364
.optimize = optimize,
65+
.pic = true,
66+
.link_libc = true,
67+
.link_libcpp = true,
6468
})
6569
});
6670

67-
lunasvg.addCSourceFiles(.{
71+
lunasvg.root_module.addCSourceFiles(.{
6872
.root = upstream.path(""),
6973
.files = &.{
7074
"source/lunasvg.cpp",
@@ -98,12 +102,10 @@ pub fn build(b: *std.Build) !void {
98102
lunasvg.link_data_sections = true;
99103
lunasvg.link_function_sections = true;
100104

101-
lunasvg.addIncludePath(upstream.path("include"));
105+
lunasvg.root_module.addIncludePath(upstream.path("include"));
102106
lunasvg.installHeadersDirectory(upstream.path("include"), "", .{});
103-
lunasvg.linkLibrary(plutovg);
104-
lunasvg.linkLibC();
105-
lunasvg.linkLibCpp();
106-
lunasvg.linkLibrary(cairo);
107+
lunasvg.root_module.linkLibrary(plutovg);
108+
lunasvg.root_module.linkLibrary(cairo);
107109

108110
b.installArtifact(lunasvg);
109111
}

‎pkg/lunasvg/build.zig.zon‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.{
22
.name = .lunasvg,
3+
.fingerprint = 0xd309c055ae5fca1b,
34
.version = "0.0.0",
45
.dependencies = .{
56
.cairo = .{ .path = "../cairo" },

0 commit comments

Comments
 (0)