Skip to content

Commit f4517a2

Browse files
committed
update
Signed-off-by: Pablo Alessandro Santos Hugen <phugen@redhat.com>
1 parent 4921c0d commit f4517a2

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

build.zig

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
11
const std = @import("std");
2+
const LinkMode = std.builtin.LinkMode;
23

3-
pub fn build(b: *std.Build) void {
4+
const manifest = @import("build.zig.zon");
5+
6+
pub fn build(b: *std.Build) !void {
47
const target = b.standardTargetOptions(.{});
58
const optimize = b.standardOptimizeOption(.{});
6-
const linkage = b.option(std.builtin.LinkMode, "linkage", "Library linkage type") orelse .static;
9+
const os = target.result.os.tag;
10+
const arch = target.result.cpu.arch;
11+
12+
const options = .{
13+
.linkage = b.option(LinkMode, "linkage", "Library linkage type") orelse
14+
.static,
15+
};
716

817
const upstream = b.dependency("upstream", .{});
9-
const src = upstream.path("");
18+
const mod = b.createModule(.{
19+
.target = target,
20+
.optimize = optimize,
21+
.link_libc = true,
22+
});
1023

11-
const os = target.result.os.tag;
12-
const arch = target.result.cpu.arch;
24+
mod.addIncludePath(upstream.path("include"));
25+
26+
mod.addCMacro("HasTHREADS", "1");
27+
mod.addCMacro("HAVE_TIMESPEC_GET", "1");
28+
if (os != .windows) {
29+
mod.addCMacro("HAVE_FUNC_ATTRIBUTE_VISIBILITY", "1");
30+
mod.addCMacro("HAVE_GMTIME_R", "1");
31+
}
32+
if (arch.endian() == .big) mod.addCMacro("WORDS_BIGENDIAN", "1");
33+
if (arch != .x86_64 and arch != .x86) mod.addCMacro("CMS_DONT_USE_SSE2", "1");
34+
35+
mod.addCSourceFiles(.{
36+
.root = upstream.path(""),
37+
.files = src,
38+
.flags = if (os != .windows) &.{"-fvisibility=hidden"} else &.{},
39+
});
1340

14-
const mod = b.createModule(.{ .target = target, .optimize = optimize, .link_libc = true });
15-
mod.addIncludePath(src.path(b, "include"));
16-
mod.addCSourceFiles(.{ .root = src, .files = sources, .flags = &((if (os != .windows) .{
17-
"-fvisibility=hidden",
18-
"-DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1",
19-
"-DHAVE_GMTIME_R=1",
20-
} else .{ "", "", "" }) ++
21-
.{ "-DHasTHREADS=1", "-DHAVE_TIMESPEC_GET=1" } ++
22-
.{if (arch.endian() == .big) "-DWORDS_BIGENDIAN=1" else ""} ++
23-
.{if (arch != .x86_64 and arch != .x86) "-DCMS_DONT_USE_SSE2=1" else ""}) });
24-
25-
const lib = b.addLibrary(.{ .name = "lcms2", .root_module = mod, .linkage = linkage });
26-
inline for (.{ "lcms2.h", "lcms2_plugin.h" }) |h| lib.installHeader(src.path(b, "include/" ++ h), h);
41+
const lib = b.addLibrary(.{
42+
.name = "lcms2",
43+
.root_module = mod,
44+
.linkage = options.linkage,
45+
.version = try .parse(manifest.version),
46+
});
47+
inline for (.{ "lcms2.h", "lcms2_plugin.h" }) |h| lib.installHeader(upstream.path("include/" ++ h), h);
2748
b.installArtifact(lib);
2849
}
2950

30-
const sources: []const []const u8 = &.{
51+
const src: []const []const u8 = &.{
3152
"src/cmsalpha.c", "src/cmscam02.c", "src/cmscgats.c", "src/cmscnvrt.c",
3253
"src/cmserr.c", "src/cmsgamma.c", "src/cmsgmt.c", "src/cmshalf.c",
3354
"src/cmsintrp.c", "src/cmsio0.c", "src/cmsio1.c", "src/cmslut.c",

0 commit comments

Comments
 (0)