Skip to content

Commit 44d9115

Browse files
committed
First commit
Signed-off-by: Pablo Alessandro Santos Hugen <[email protected]>
0 parents  commit 44d9115

File tree

6 files changed

+124
-0
lines changed

6 files changed

+124
-0
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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-freebsd-none
24+
- aarch64-freebsd-none
25+
runs-on: ${{ matrix.os }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Zig
31+
uses: mlugg/setup-zig@v2
32+
with:
33+
version: ${{ matrix.zig-version }}
34+
35+
- name: Check Formatting
36+
run: zig fmt --ast-check --check .
37+
38+
- name: Build
39+
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Simon Ser
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# libliftoff zig
2+
3+
[libliftoff](https://gitlab.freedesktop.org/emersion/libliftoff), 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/libliftoff.git
11+
```
12+
13+
Then in your `build.zig`:
14+
15+
```zig
16+
const libliftoff = b.dependency("libliftoff", .{ .target = target, .optimize = optimize });
17+
exe.linkLibrary(libliftoff.artifact("liftoff"));
18+
```

build.zig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 libdrm_dep = b.dependency("libdrm", .{ .target = target, .optimize = optimize });
10+
const src = upstream.path("");
11+
12+
const mod = b.createModule(.{ .target = target, .optimize = optimize, .link_libc = true });
13+
mod.addIncludePath(src.path(b, "include"));
14+
mod.linkLibrary(libdrm_dep.artifact("drm"));
15+
mod.addCSourceFiles(.{ .root = src, .files = sources, .flags = &.{ "-fvisibility=hidden", "-std=c11" } });
16+
17+
const lib = b.addLibrary(.{ .name = "liftoff", .root_module = mod, .linkage = linkage });
18+
lib.installHeader(src.path(b, "include/libliftoff.h"), "libliftoff.h");
19+
b.installArtifact(lib);
20+
}
21+
22+
const sources: []const []const u8 = &.{
23+
"alloc.c", "device.c", "layer.c", "list.c",
24+
"log.c", "output.c", "plane.c",
25+
};

build.zig.zon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.{
2+
.name = .libliftoff,
3+
.version = "0.5.0",
4+
.dependencies = .{
5+
.libdrm = .{
6+
.url = "https://github.com/allyourcodebase/libdrm/archive/refs/tags/v2.4.131.tar.gz",
7+
.hash = "libdrm-2.4.131-J31yV1seAACDMd23VpNJpqZj4mdzgJKpHFtorUdZIxxR",
8+
},
9+
.upstream = .{
10+
.url = "https://gitlab.freedesktop.org/emersion/libliftoff/-/archive/v0.5.0/libliftoff-v0.5.0.tar.gz",
11+
.hash = "N-V-__8AAEjbAgCuPNCj_EGXAOHAsZcowvxh2aYGpvmVEP8m",
12+
},
13+
},
14+
.minimum_zig_version = "0.16.0-dev.2653+784e89fd4",
15+
.paths = .{ "build.zig", "build.zig.zon", "README.md", "LICENSE" },
16+
.fingerprint = 0xf6055c5924a5810,
17+
}

0 commit comments

Comments
 (0)