Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
147 lines (133 loc) · 4.75 KB
/
Copy pathbuild.zig
File metadata and controls
147 lines (133 loc) · 4.75 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const openexr_dep = b.dependency("openexr", .{});
const deflate_dep = b.dependency("libdeflate", .{});
const imath_dep = b.dependency("imath", .{});
// Build libdeflate first
const deflate_mod = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
});
deflate_mod.addIncludePath(deflate_dep.path(""));
deflate_mod.addCSourceFiles(.{
.root = deflate_dep.path(""),
.files = deflate_srcs,
.flags = &.{ "-fPIC", "-Wall", "-O3" },
});
const libdeflate = b.addLibrary(.{
.name = "deflate",
.linkage = .static,
.root_module = deflate_mod,
});
// Build OpenEXRCore
const exr_mod = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
});
// Add include paths
exr_mod.addIncludePath(openexr_dep.path("src/lib/OpenEXRCore"));
exr_mod.addIncludePath(deflate_dep.path("")); // for libdeflate.h
exr_mod.addIncludePath(imath_dep.path("src/Imath")); // for half.h with F16C support
exr_mod.addIncludePath(b.path("")); // for our config headers
// Link libdeflate
exr_mod.linkLibrary(libdeflate);
// Enable F16C for hardware half-float conversion on x86_64
const is_x86 = target.result.cpu.arch == .x86_64 or target.result.cpu.arch == .x86;
exr_mod.addCSourceFiles(.{
.root = openexr_dep.path(""),
.files = openexr_core_srcs,
.flags = if (is_x86) &.{
"-fPIC",
"-Wall",
"-std=gnu11",
"-D_GNU_SOURCE",
"-mf16c", // Hardware half-float conversion (F16C SSE extension)
} else &.{
"-fPIC",
"-Wall",
"-std=gnu11",
"-D_GNU_SOURCE",
},
});
// Add HT compression stubs (we don't include OpenJPH dependency)
exr_mod.addCSourceFiles(.{
.root = b.path(""),
.files = &.{"internal_ht_stub.c"},
.flags = &.{
"-fPIC",
"-Wall",
"-std=gnu11",
"-D_GNU_SOURCE",
},
});
const openexr = b.addLibrary(.{
.name = "openexr",
.linkage = .static,
.root_module = exr_mod,
});
// Install headers for downstream consumers
openexr.installHeadersDirectory(openexr_dep.path("src/lib/OpenEXRCore"), "OpenEXR", .{
.include_extensions = &.{".h"},
});
openexr.installHeader(b.path("OpenEXRConfig.h"), "OpenEXR/OpenEXRConfig.h");
openexr.installHeader(b.path("OpenEXRConfigInternal.h"), "OpenEXR/OpenEXRConfigInternal.h");
openexr.installHeader(b.path("ImathConfig.h"), "OpenEXR/ImathConfig.h");
openexr.installHeader(b.path("IlmThreadConfig.h"), "OpenEXR/IlmThreadConfig.h");
b.installArtifact(openexr);
}
const deflate_srcs: []const []const u8 = &.{
"lib/deflate_compress.c",
"lib/deflate_decompress.c",
"lib/utils.c",
"lib/adler32.c",
"lib/crc32.c",
"lib/zlib_compress.c",
"lib/zlib_decompress.c",
"lib/gzip_compress.c",
"lib/gzip_decompress.c",
// x86 optimizations
"lib/x86/cpu_features.c",
};
const openexr_core_srcs: []const []const u8 = &.{
"src/lib/OpenEXRCore/attributes.c",
"src/lib/OpenEXRCore/base.c",
"src/lib/OpenEXRCore/bytes.c",
"src/lib/OpenEXRCore/channel_list.c",
"src/lib/OpenEXRCore/chunk.c",
"src/lib/OpenEXRCore/coding.c",
"src/lib/OpenEXRCore/compression.c",
"src/lib/OpenEXRCore/context.c",
"src/lib/OpenEXRCore/debug.c",
"src/lib/OpenEXRCore/decoding.c",
"src/lib/OpenEXRCore/encoding.c",
"src/lib/OpenEXRCore/float_vector.c",
"src/lib/OpenEXRCore/internal_b44.c",
"src/lib/OpenEXRCore/internal_b44_table.c",
"src/lib/OpenEXRCore/internal_b44_table_init.c",
"src/lib/OpenEXRCore/internal_dwa.c",
"src/lib/OpenEXRCore/internal_dwa_table.c",
"src/lib/OpenEXRCore/internal_dwa_table_init.c",
"src/lib/OpenEXRCore/internal_huf.c",
"src/lib/OpenEXRCore/internal_piz.c",
"src/lib/OpenEXRCore/internal_pxr24.c",
"src/lib/OpenEXRCore/internal_rle.c",
"src/lib/OpenEXRCore/internal_structs.c",
"src/lib/OpenEXRCore/internal_zip.c",
"src/lib/OpenEXRCore/memory.c",
"src/lib/OpenEXRCore/opaque.c",
"src/lib/OpenEXRCore/pack.c",
"src/lib/OpenEXRCore/parse_header.c",
"src/lib/OpenEXRCore/part.c",
"src/lib/OpenEXRCore/part_attr.c",
"src/lib/OpenEXRCore/preview.c",
"src/lib/OpenEXRCore/std_attr.c",
"src/lib/OpenEXRCore/string.c",
"src/lib/OpenEXRCore/string_vector.c",
"src/lib/OpenEXRCore/unpack.c",
"src/lib/OpenEXRCore/validation.c",
"src/lib/OpenEXRCore/write_header.c",
};