Skip to content

Commit 4921c0d

Browse files
committed
First commit
Signed-off-by: Pablo Alessandro Santos Hugen <phugen@redhat.com>
0 parents  commit 4921c0d

File tree

6 files changed

+138
-0
lines changed

6 files changed

+138
-0
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
zig-version: [master]
17+
os: [ubuntu-latest]
18+
target:
19+
- x86_64-linux-gnu
20+
- x86_64-linux-musl
21+
- aarch64-linux-gnu
22+
- aarch64-linux-musl
23+
- x86_64-macos-none
24+
- aarch64-macos-none
25+
- x86_64-windows-gnu
26+
- aarch64-windows-gnu
27+
- x86_64-freebsd-none
28+
- aarch64-freebsd-none
29+
runs-on: ${{ matrix.os }}
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Zig
35+
uses: mlugg/setup-zig@v2
36+
with:
37+
version: ${{ matrix.zig-version }}
38+
39+
- name: Check Formatting
40+
run: zig fmt --ast-check --check .
41+
42+
- name: Build
43+
run: zig build -Dtarget=${{ matrix.target }} --summary all

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.zig-cache/
2+
zig-cache/
3+
zig-out/
4+
zig-pkg/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Marti Maria Saguer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject
11+
to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# lcms2 zig
2+
3+
[Little CMS](https://github.com/mm2/Little-CMS), packaged for the Zig build system.
4+
5+
## Using
6+
7+
First, update your `build.zig.zon`:
8+
9+
```
10+
zig fetch --save git+https://github.com/allyourcodebase/lcms2.git
11+
```
12+
13+
Then in your `build.zig`:
14+
15+
```zig
16+
const lcms2 = b.dependency("lcms2", .{ .target = target, .optimize = optimize });
17+
exe.linkLibrary(lcms2.artifact("lcms2"));
18+
```

build.zig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const target = b.standardTargetOptions(.{});
5+
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+
11+
const os = target.result.os.tag;
12+
const arch = target.result.cpu.arch;
13+
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);
27+
b.installArtifact(lib);
28+
}
29+
30+
const sources: []const []const u8 = &.{
31+
"src/cmsalpha.c", "src/cmscam02.c", "src/cmscgats.c", "src/cmscnvrt.c",
32+
"src/cmserr.c", "src/cmsgamma.c", "src/cmsgmt.c", "src/cmshalf.c",
33+
"src/cmsintrp.c", "src/cmsio0.c", "src/cmsio1.c", "src/cmslut.c",
34+
"src/cmsmd5.c", "src/cmsmtrx.c", "src/cmsnamed.c", "src/cmsopt.c",
35+
"src/cmspack.c", "src/cmspcs.c", "src/cmsplugin.c", "src/cmsps2.c",
36+
"src/cmssamp.c", "src/cmssm.c", "src/cmstypes.c", "src/cmsvirt.c",
37+
"src/cmswtpnt.c", "src/cmsxform.c",
38+
};

build.zig.zon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.{
2+
.name = .lcms2,
3+
.version = "2.18.0",
4+
.dependencies = .{
5+
.upstream = .{
6+
.url = "https://github.com/mm2/Little-CMS/releases/download/lcms2.18/lcms2-2.18.tar.gz",
7+
.hash = "N-V-__8AAKyUrgA7ZZWoqTgGc1qEOWJHeQz5s2OsbbZj9881",
8+
},
9+
},
10+
.minimum_zig_version = "0.16.0-dev.2653+784e89fd4",
11+
.paths = .{ "build.zig", "build.zig.zon", "README.md", "LICENSE" },
12+
.fingerprint = 0x3fb9167ab30cdb08,
13+
}

0 commit comments

Comments
 (0)