-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
64 lines (54 loc) · 2.19 KB
/
build.zig
File metadata and controls
64 lines (54 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const wuffs_dep = b.dependency("wuffs", .{});
const Translator = @import("translate_c").Translator;
const translate_c = b.dependency("translate_c", .{
.optimize = .ReleaseFast,
});
const t: Translator = .init(translate_c, .{
.c_source_file = wuffs_dep.path("release/c/wuffs-v0.4.c"),
.target = target,
.optimize = optimize,
});
// This is the main module that contains both translated headers and implementation.
const wuffs = b.addModule("wuffs", .{
.root_source_file = t.output_file,
.target = target,
.optimize = optimize,
.link_libc = true,
});
wuffs.addImport("c_builtins", translate_c.module("c_builtins"));
wuffs.addImport("helpers", translate_c.module("helpers"));
wuffs.addCSourceFile(.{
.file = wuffs_dep.path("release/c/wuffs-v0.4.c"),
.flags = &.{"-DWUFFS_IMPLEMENTATION"},
});
wuffs.sanitize_c = .off; // fixes a crash in ReleaseSafe mode at "return (*func_ptrs->decode_image_config)(self, a_dst, a_src)"
// Same as 'wuffs' but without the translate-c stuff, added as a temporary workaround for regressions in Zig 0.16 translateC.
const impl = b.addModule("impl", .{
.target = target,
.optimize = optimize,
.link_libc = true,
});
impl.addCSourceFile(.{
.file = wuffs_dep.path("release/c/wuffs-v0.4.c"),
.flags = &.{"-DWUFFS_IMPLEMENTATION"},
});
impl.sanitize_c = .off; // fixes a crash in ReleaseSafe mode at "return (*func_ptrs->decode_image_config)(self, a_dst, a_src)"
const lib = b.addLibrary(.{
.name = "wuffs",
.linkage = .static,
.root_module = impl,
});
lib.installHeader(wuffs_dep.path("release/c/wuffs-v0.4.c"), "wuffs.h");
b.installArtifact(lib);
const dynamic_lib = b.addLibrary(.{
.name = "wuffs",
.linkage = .dynamic,
.root_module = impl,
});
dynamic_lib.installHeader(wuffs_dep.path("release/c/wuffs-v0.4.c"), "wuffs.h");
b.installArtifact(dynamic_lib);
}