Skip to content

Commit 0e7a70d

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

File tree

6 files changed

+127
-0
lines changed

6 files changed

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

README.md

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

build.zig

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const std = @import("std");
2+
3+
const manifest = @import("build.zig.zon");
4+
5+
pub fn build(b: *std.Build) void {
6+
const target = b.standardTargetOptions(.{});
7+
const optimize = b.standardOptimizeOption(.{});
8+
const linkage = b.option(std.builtin.LinkMode, "linkage", "Library linkage type") orelse .static;
9+
10+
const upstream = b.dependency("upstream", .{});
11+
const src = upstream.path("");
12+
13+
const defaultpath: []const u8 = b.option([]const u8, "defaultpath", "seatd socket path") orelse
14+
if (target.result.os.tag == .linux) "/run/seatd.sock" else "/var/run/seatd.sock";
15+
16+
const mod = b.createModule(.{ .target = target, .optimize = optimize, .link_libc = true });
17+
mod.addIncludePath(src);
18+
mod.addIncludePath(src.path(b, "include"));
19+
mod.addCSourceFiles(.{ .root = src, .files = sources, .flags = &.{
20+
"-D_XOPEN_SOURCE=700",
21+
"-D__BSD_VISIBLE",
22+
"-D_NETBSD_SOURCE",
23+
"-DLIBSEAT=1",
24+
"-DSEATD_ENABLED=1",
25+
b.fmt("-DSEATD_VERSION=\"{s}\"", .{manifest.version}),
26+
b.fmt("-DSEATD_DEFAULTPATH=\"{s}\"", .{defaultpath}),
27+
"-Uunix",
28+
"-fvisibility=hidden",
29+
} });
30+
31+
const lib = b.addLibrary(.{ .name = "seat", .root_module = mod, .linkage = linkage });
32+
if (linkage == .dynamic) lib.version_script = src.path(b, "libseat/libseat.syms");
33+
lib.installHeader(src.path(b, "include/libseat.h"), "libseat.h");
34+
b.installArtifact(lib);
35+
}
36+
37+
const sources: []const []const u8 = &.{
38+
"common/connection.c",
39+
"common/linked_list.c",
40+
"common/log.c",
41+
"libseat/backend/seatd.c",
42+
"libseat/libseat.c",
43+
"libseat/backend/noop.c",
44+
};

build.zig.zon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.{
2+
.name = .libseat,
3+
.version = "0.9.3",
4+
.dependencies = .{
5+
.upstream = .{
6+
.url = "https://git.sr.ht/~kennylevinsen/seatd/archive/0.9.3.tar.gz",
7+
.hash = "N-V-__8AABzIAgBtVJw8-iXNBZm8lhH1cu7_MxjipGv7yt0D",
8+
},
9+
},
10+
.minimum_zig_version = "0.16.0-dev.2653+784e89fd4",
11+
.paths = .{ "build.zig", "build.zig.zon", "README.md", "LICENSE" },
12+
.fingerprint = 0x16b6a2ac2bd1b7a,
13+
}

0 commit comments

Comments
 (0)