Skip to content

Commit f9bb123

Browse files
committed
zig 0.16
1 parent cccda51 commit f9bb123

35 files changed

Lines changed: 602 additions & 813 deletions

‎.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: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pub fn build(b: *std.Build) void {
3838
.use_png = true,
3939
.use_glib = false,
4040
.use_dwrite = false,
41-
.use_freetype = true,
4241
.use_quartz = false,
4342
.target = target,
4443
.optimize = optimize,
@@ -47,6 +46,7 @@ pub fn build(b: *std.Build) void {
4746
const libjpeg_turbo = b.dependency("libjpeg_turbo", .{
4847
.target = target,
4948
.optimize = optimize,
49+
.pie = true,
5050
}).artifact("libjpeg_turbo");
5151

5252
const giflib = b.dependency("giflib", .{
@@ -86,19 +86,23 @@ pub fn build(b: *std.Build) void {
8686
.target = target,
8787
.optimize = optimize,
8888
.root_source_file = b.path("src/unicode.zig"),
89+
.link_libc = true,
90+
.pic = true,
8991
})
9092
});
9193

9294
unicode.root_module.addImport("Scripts", zg.module("Scripts"));
9395
unicode.root_module.addImport("Graphemes", zg.module("Graphemes"));
94-
unicode.linkLibC();
9596

9697
const canvas = b.addLibrary(.{
9798
.name = "canvas",
9899
.linkage = .dynamic,
99100
.root_module = b.createModule(.{
100101
.target = target,
101102
.optimize = optimize,
103+
.pic = true,
104+
.link_libc = true,
105+
.link_libcpp = true,
102106
})
103107
});
104108

@@ -107,7 +111,7 @@ pub fn build(b: *std.Build) void {
107111
.optimize = optimize,
108112
}).artifact("node_api");
109113

110-
canvas.addCSourceFiles(.{
114+
canvas.root_module.addCSourceFiles(.{
111115
.files = &.{
112116
"src/bmp/BMPParser.cc",
113117
"src/Canvas.cc",
@@ -150,24 +154,22 @@ pub fn build(b: *std.Build) void {
150154
canvas.root_module.strip = true;
151155
}
152156

153-
canvas.linkLibC();
154-
canvas.linkLibCpp();
155-
canvas.addObject(node_api);
156-
canvas.linkLibrary(cairo);
157-
canvas.linkLibrary(libjpeg_turbo);
158-
canvas.linkLibrary(libpng);
159-
canvas.linkLibrary(giflib);
160-
canvas.linkLibrary(sheenbidi);
161-
canvas.linkLibrary(unicode);
162-
canvas.linkLibrary(harfbuzz);
163-
canvas.linkLibrary(lunasvg);
157+
canvas.root_module.addObject(node_api);
158+
canvas.root_module.linkLibrary(cairo);
159+
canvas.root_module.linkLibrary(libjpeg_turbo);
160+
canvas.root_module.linkLibrary(libpng);
161+
canvas.root_module.linkLibrary(giflib);
162+
canvas.root_module.linkLibrary(sheenbidi);
163+
canvas.root_module.linkLibrary(unicode);
164+
canvas.root_module.linkLibrary(harfbuzz);
165+
canvas.root_module.linkLibrary(lunasvg);
164166

165167
// some deps, especially lunasvg, compile with -ffunction-sections and
166168
// -fdata-sections so we don't have to distribute unused parts of libraries
167169
canvas.link_gc_sections = true;
168170

169171
if (target.result.os.tag == .windows) {
170-
canvas.linkSystemLibrary("dwrite");
172+
canvas.root_module.linkSystemLibrary("dwrite", .{});
171173
}
172174

173175
if (target.result.os.tag == .macos) {
@@ -185,19 +187,19 @@ pub fn build(b: *std.Build) void {
185187
" \r\n",
186188
);
187189

188-
canvas.addSystemFrameworkPath(.{
190+
canvas.root_module.addSystemFrameworkPath(.{
189191
.cwd_relative = b.pathJoin(&.{
190192
path,
191193
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/System/Library/Frameworks",
192194
}),
193195
});
194-
canvas.addSystemIncludePath(.{
196+
canvas.root_module.addSystemIncludePath(.{
195197
.cwd_relative = b.pathJoin(&.{
196198
path,
197199
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/include",
198200
}),
199201
});
200-
canvas.addLibraryPath(.{
202+
canvas.root_module.addLibraryPath(.{
201203
.cwd_relative = b.pathJoin(&.{
202204
path,
203205
"Platforms/MacOSX.platform/Developer/SDKs/" ++ sdk ++ "/usr/lib",

‎build.zig.zon‎

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,32 @@
33
.fingerprint = 0xa59f6c18a5521654,
44
.version = "0.0.0",
55
.paths = .{""},
6-
.minimum_zig_version = "0.15.1",
6+
.minimum_zig_version = "0.16.0",
7+
// Sub-packages only specify dependencies for upstream C/C++ code.
8+
// Everything else goes here so it's easier to share dependencies and ensure
9+
// we don't build duplicate versions. Generally build.zig[.zon] files should
10+
// be vendored so we can simplify them and have control over upgrades and
11+
// things like -fPIC. Exceptions should (and are) justified below
712
.dependencies = .{
13+
// Simple and general enough to use the canonical URL
814
.node_api = .{
9-
.url = "https://github.com/chearon/node-api-zig/archive/44210ae903fbfa3491cddc0260d468796213e4c8.tar.gz",
10-
.hash = "node_api-0.0.0-AAAAAAQgAAB-W9HyzJg5Vhja3uNMMcDiFaCJvBLt41GD",
11-
},
12-
// TODO: this needs to be kept in sync with freetype's build.zig.zon
13-
.libpng = .{
14-
.url = "https://github.com/allyourcodebase/libpng/archive/d512607515687aa60b975d6a191aef9a692dac87.zip",
15-
.hash = "libpng-1.6.50-oiaFGt4qAAB_vzrtvz9hA7_UiBW4arSaMVGc7ekKMCZ2",
15+
.url = "https://github.com/chearon/node-api-zig/archive/37d992b2ff53608e301ce2d5bd76ec31a1a247d9.tar.gz",
16+
.hash = "node_api-0.0.0-D68afJgfAABNKwoA-8I7d4v9fJUwM89W-yOHKMSNU7Em",
1617
},
18+
// Too complicated to maintain here (large build.zig)
1719
.libjpeg_turbo = .{
18-
.url = "https://github.com/chearon/libjpeg-turbo/archive/8b323deee8527cf5053417b66ce8d13c81772b99.tar.gz",
19-
.hash = "libjpeg_turbo-3.1.1-1-iiYWshOCSQAUOo5zsLPqfjJMOLgpkJvcFTf6Cyn_AvkA",
20-
},
21-
.giflib = .{
22-
.url = "https://github.com/chearon/giflib/archive/986b2816254c3cebf7f9f735eb32564e4600cc66.tar.gz",
23-
.hash = "giflib-5.2.2-TakyOnIKIwCYvNoi8kEaGj5KYEc9hZ900YBld700u-PM",
20+
.url = "https://github.com/chearon/libjpeg-turbo/archive/3dea62701a3c831a20d97605531bf54aeb1c349d.tar.gz",
21+
.hash = "libjpeg_turbo-3.1.1-1-iiYWsuiBSQDuCBaSIbuRCB4V9FhkNnBifh6EPCi2xEcZ",
2422
},
23+
// Zig dependencies are less prone to needing build tweaks
2524
.zg = .{
26-
.url = "https://codeberg.org/atman/zg/archive/d9f596626e8ec05a9f3e47f7bc83aedd5bd2f989.tar.gz",
27-
.hash = "zg-0.15.3-oGqU3P5ItAJHmwDLfzX6sg6Xc5MhSJU2TctHfWu_sKLv",
28-
},
29-
// TODO: this needs to be kept in sync with freetype's build.zig.zon
30-
.zlib = .{
31-
.url = "git+https://github.com/allyourcodebase/zlib#3599c16d41dbe749ae51b0ff7ab864c61adc779a",
32-
.hash = "zlib-1.3.1-ZZQ7lc8NAABUbHzDe_cSWboCqMbrLkVwvFkKnojgeiT2",
25+
.url = "https://codeberg.org/atman/zg/archive/ce364b17d60b28fda1af24c6575b93c47afe043e.tar.gz",
26+
.hash = "zg-0.16.2-oGqU3HqftgI6rwFS90ypwfjgToH8Pz829OKuFURlm773",
3327
},
34-
.cairo = .{ .path = "./pkg/cairo"},
28+
.giflib = .{ .path = "./pkg/giflib" },
29+
.zlib = .{ .path = "./pkg/zlib" },
30+
.libpng = .{ .path = "./pkg/libpng" },
31+
.cairo = .{ .path = "./pkg/cairo" },
3532
.sheenbidi = .{ .path = "./pkg/sheenbidi" },
3633
.harfbuzz = .{ .path = "./pkg/harfbuzz" },
3734
.freetype = .{ .path = "./pkg/freetype" },

0 commit comments

Comments
 (0)