-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
59 lines (51 loc) · 2.05 KB
/
build.zig
File metadata and controls
59 lines (51 loc) · 2.05 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
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 headers = b.addTranslateC(.{
.target = target,
.optimize = optimize,
.root_source_file = wuffs_dep.path("release/c/wuffs-v0.4.c"),
.link_libc = true,
});
// Headers-only module, useful when depending on a system-provided shared library.
_ = headers.addModule("headers");
// This is the main module that contains both translated headers and implementation.
const wuffs = b.addModule("wuffs", .{
.root_source_file = headers.getOutput(),
.target = target,
.optimize = optimize,
.link_libc = true,
});
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);
}