Skip to content

Commit 1c7db6a

Browse files
committed
chore: update to Zig v0.14.0
1 parent 7233ece commit 1c7db6a

File tree

9 files changed

+48
-57
lines changed

9 files changed

+48
-57
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Zig recommends LF line endings
12
*.zig text eol=lf
23
*.zon text eol=lf

.github/workflows/cd.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99

1010
jobs:
1111
emit:
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
1214
runs-on: ubuntu-latest
1315

1416
steps:
@@ -17,14 +19,16 @@ jobs:
1719

1820
- name: Set up Zig
1921
uses: mlugg/setup-zig@v1
22+
with:
23+
version: master
2024

21-
- name: Run `doc`
25+
- name: Run doc step
2226
run: zig build doc
2327

2428
- name: Upload artifact for GitHub Pages
2529
uses: actions/upload-pages-artifact@v3
2630
with:
27-
path: zig-out/doc/
31+
path: zig-out/docs/
2832

2933
deploy:
3034
needs: emit

.github/workflows/ci.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ jobs:
1919

2020
- name: Set up Zig
2121
uses: mlugg/setup-zig@v1
22+
with:
23+
version: master
2224

23-
- name: Run `example`
25+
- name: Run example step
2426
run: zig build example
2527

2628
fmt:
@@ -32,6 +34,8 @@ jobs:
3234

3335
- name: Set up Zig
3436
uses: mlugg/setup-zig@v1
37+
with:
38+
version: master
3539

36-
- name: Run `fmt`
40+
- name: Run fmt step
3741
run: zig build fmt

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Zig artifacts
12
.zig-cache/
23
zig-out/

README.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# zig-quickphf
22

3-
[![CI][ci-shd]][ci-url]
4-
[![CD][cd-shd]][cd-url]
5-
[![DC][dc-shd]][dc-url]
6-
[![LC][lc-shd]][lc-url]
7-
83
## Zig port of [quickphf library](https://github.com/dtrifuno/quickphf) for static hash map generation.
94

105
### Usage
116

127
- Add `quickphf` dependency to `build.zig.zon`.
138

149
```sh
15-
zig fetch --save git+https://github.com/tensorush/zig-quickphf#<git_tag_or_commit_hash>
10+
zig fetch --save git+https://github.com/tensorush/zig-quickphf
1611
```
1712

1813
- Use `quickphf` dependency in `build.zig`.
@@ -25,14 +20,3 @@ const quickphf_dep = b.dependency("quickphf", .{
2520
const quickphf_mod = quickphf_dep.module("quickphf");
2621
<compile>.root_module.addImport("quickphf", quickphf_mod);
2722
```
28-
29-
<!-- MARKDOWN LINKS -->
30-
31-
[ci-shd]: https://img.shields.io/github/actions/workflow/status/tensorush/zig-quickphf/ci.yaml?branch=main&style=for-the-badge&logo=github&label=CI&labelColor=black
32-
[ci-url]: https://github.com/tensorush/zig-quickphf/blob/main/.github/workflows/ci.yaml
33-
[cd-shd]: https://img.shields.io/github/actions/workflow/status/tensorush/zig-quickphf/cd.yaml?branch=main&style=for-the-badge&logo=github&label=CD&labelColor=black
34-
[cd-url]: https://github.com/tensorush/zig-quickphf/blob/main/.github/workflows/cd.yaml
35-
[dc-shd]: https://img.shields.io/badge/click-F6A516?style=for-the-badge&logo=zig&logoColor=F6A516&label=docs&labelColor=black
36-
[dc-url]: https://tensorush.github.io/zig-quickphf
37-
[lc-shd]: https://img.shields.io/github/license/tensorush/zig-quickphf.svg?style=for-the-badge&labelColor=black
38-
[lc-url]: https://github.com/tensorush/zig-quickphf/blob/main/LICENSE

build.zig

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,75 @@
11
const std = @import("std");
22

33
pub fn build(b: *std.Build) void {
4+
const install_step = b.getInstallStep();
45
const target = b.standardTargetOptions(.{});
56
const optimize = b.standardOptimizeOption(.{});
6-
const root_source_file = b.path("src/lib.zig");
7-
const version = std.SemanticVersion{ .major = 0, .minor = 2, .patch = 0 };
7+
const root_source_file = b.path("src/root.zig");
8+
const version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 1 };
89

910
// Module
10-
const quickphf_mod = b.addModule("quickphf", .{ .root_source_file = root_source_file });
11+
const mod = b.addModule("quickphf", .{
12+
.target = target,
13+
.optimize = optimize,
14+
.root_source_file = root_source_file,
15+
});
1116

1217
// Library
1318
const lib_step = b.step("lib", "Install library");
1419

15-
const lib = b.addStaticLibrary(.{
20+
const lib = b.addLibrary(.{
1621
.name = "quickphf",
17-
.target = target,
1822
.version = version,
19-
.optimize = optimize,
20-
.root_source_file = root_source_file,
23+
.root_module = mod,
2124
});
2225

2326
const lib_install = b.addInstallArtifact(lib, .{});
2427
lib_step.dependOn(&lib_install.step);
25-
b.default_step.dependOn(lib_step);
28+
install_step.dependOn(lib_step);
2629

2730
// Documentation
28-
const doc_step = b.step("doc", "Emit documentation");
29-
30-
const doc_install = b.addInstallDirectory(.{
31+
const docs_step = b.step("doc", "Emit documentation");
32+
const docs_install = b.addInstallDirectory(.{
3133
.install_dir = .prefix,
32-
.install_subdir = "doc",
34+
.install_subdir = "docs",
3335
.source_dir = lib.getEmittedDocs(),
3436
});
35-
doc_step.dependOn(&doc_install.step);
36-
b.default_step.dependOn(doc_step);
37+
docs_step.dependOn(&docs_install.step);
38+
install_step.dependOn(docs_step);
3739

3840
// Example
3941
const example_step = b.step("example", "Run example");
4042

4143
const example = b.addExecutable(.{
4244
.name = "example",
43-
.target = target,
4445
.version = version,
45-
.optimize = optimize,
46-
.root_source_file = b.path(EXAMPLE_DIR ++ "main.zig"),
46+
.root_module = b.createModule(.{
47+
.target = target,
48+
.optimize = optimize,
49+
.root_source_file = b.path(EXAMPLE_DIR ++ "main.zig"),
50+
}),
4751
});
48-
example.root_module.addImport("quickphf", quickphf_mod);
52+
example.root_module.addImport("quickphf", mod);
4953

5054
const example_run = b.addRunArtifact(example);
55+
example_step.dependOn(&example_run.step);
5156

52-
const example_test = b.addTest(.{
53-
.target = target,
54-
.root_source_file = b.path(EXAMPLE_DIR ++ "test.zig"),
55-
});
56-
example_test.root_module.addImport("quickphf", quickphf_mod);
57-
example_test.step.dependOn(&example_run.step);
58-
59-
const example_test_run = b.addRunArtifact(example_test);
60-
example_step.dependOn(&example_test_run.step);
61-
b.default_step.dependOn(example_step);
57+
install_step.dependOn(example_step);
6258

63-
// Formatting checks
64-
const fmt_step = b.step("fmt", "Run formatting checks");
59+
// Formatting check
60+
const fmt_step = b.step("fmt", "Check formatting");
6561

6662
const fmt = b.addFmt(.{
6763
.paths = &.{
6864
"src/",
6965
"build.zig",
66+
"build.zig.zon",
7067
EXAMPLE_DIR,
7168
},
7269
.check = true,
7370
});
7471
fmt_step.dependOn(&fmt.step);
75-
b.default_step.dependOn(fmt_step);
72+
install_step.dependOn(fmt_step);
7673
}
7774

7875
const EXAMPLE_DIR = "example/";

build.zig.zon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.{
2-
.name = "quickphf",
3-
.version = "0.2.0",
2+
.name = .quickphf,
3+
.fingerprint = 0xfbc2df748cb26bb1,
4+
.version = "0.2.1",
45
.paths = .{
56
"src/",
67
"example/",

src/quickdiv.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//! Unsigned divisor optimized for repeated division and modulo operations.
2-
31
const std = @import("std");
42

3+
/// Unsigned divisor optimized for repeated division and modulo operations.
54
pub fn Divisor(comptime T: type) type {
65
if (std.meta.activeTag(@typeInfo(T)) != .int or
76
@typeInfo(T).int.signedness != .unsigned or

src/lib.zig renamed to src/root.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Root library file that exposes the public API.
1+
//! Root source file that exposes the library's API to users and Autodoc.
22

33
const std = @import("std");
44

0 commit comments

Comments
 (0)