Skip to content

Commit 66c7c0e

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

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

build.zig

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,55 @@
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;
7-
8-
const upstream = b.dependency("upstream", .{});
9-
const src = upstream.path("");
10-
119
const os = target.result.os.tag;
1210
const arch = target.result.cpu.arch;
1311

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);
12+
const options = .{
13+
.linkage = b.option(LinkMode, "linkage", "Library linkage type") orelse
14+
.static,
15+
};
16+
17+
const upstream = b.dependency("lcms2_c", .{});
18+
19+
const mod = b.createModule(.{
20+
.target = target,
21+
.optimize = optimize,
22+
.link_libc = true,
23+
});
24+
25+
mod.addIncludePath(upstream.path("include"));
26+
27+
mod.addCMacro("HasTHREADS", "1");
28+
mod.addCMacro("HAVE_TIMESPEC_GET", "1");
29+
if (os != .windows) {
30+
mod.addCMacro("HAVE_FUNC_ATTRIBUTE_VISIBILITY", "1");
31+
mod.addCMacro("HAVE_GMTIME_R", "1");
32+
}
33+
if (arch.endian() == .big) mod.addCMacro("WORDS_BIGENDIAN", "1");
34+
if (arch != .x86_64 and arch != .x86) mod.addCMacro("CMS_DONT_USE_SSE2", "1");
35+
36+
mod.addCSourceFiles(.{
37+
.root = upstream.path(""),
38+
.files = src,
39+
.flags = if (os != .windows) &.{"-fvisibility=hidden"} else &.{},
40+
});
41+
42+
const lib = b.addLibrary(.{
43+
.name = "lcms2",
44+
.root_module = mod,
45+
.linkage = options.linkage,
46+
.version = try .parse(manifest.version),
47+
});
48+
inline for (.{ "lcms2.h", "lcms2_plugin.h" }) |h| lib.installHeader(upstream.path("include/" ++ h), h);
2749
b.installArtifact(lib);
2850
}
2951

30-
const sources: []const []const u8 = &.{
52+
const src: []const []const u8 = &.{
3153
"src/cmsalpha.c", "src/cmscam02.c", "src/cmscgats.c", "src/cmscnvrt.c",
3254
"src/cmserr.c", "src/cmsgamma.c", "src/cmsgmt.c", "src/cmshalf.c",
3355
"src/cmsintrp.c", "src/cmsio0.c", "src/cmsio1.c", "src/cmslut.c",

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.name = .lcms2,
33
.version = "2.18.0",
44
.dependencies = .{
5-
.upstream = .{
5+
.lcms2_c = .{
66
.url = "https://github.com/mm2/Little-CMS/releases/download/lcms2.18/lcms2-2.18.tar.gz",
77
.hash = "N-V-__8AAKyUrgA7ZZWoqTgGc1qEOWJHeQz5s2OsbbZj9881",
88
},

0 commit comments

Comments
 (0)