Skip to content

Commit 1b2e917

Browse files
authored
Merge pull request #4 from Syndica/0.14.0
update to zig 0.14.0 and remove `usingnamespace`
2 parents 8e7c270 + d19e5c2 commit 1b2e917

File tree

10 files changed

+39
-36
lines changed

10 files changed

+39
-36
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- master
1010

1111
jobs:
12-
lint:
12+
test:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: checkout
@@ -18,22 +18,10 @@ jobs:
1818
- name: setup-zig
1919
uses: mlugg/setup-zig@v1
2020
with:
21-
version: 0.13.0
22-
23-
- name: lint
24-
run: |
25-
zig fmt --check src/ build.zig build.zig.zon
21+
version: 0.14.0
2622

27-
test:
28-
runs-on: ubuntu-latest
29-
steps:
30-
- name: checkout
31-
uses: actions/checkout@v2
23+
- name: lint
24+
run: zig fmt --check src/ build.zig build.zig.zon
3225

33-
- name: setup-zig
34-
uses: mlugg/setup-zig@v1
35-
with:
36-
version: 0.13.0
37-
3826
- name: build
3927
run: zig build test

build.zig

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@ pub fn build(b: *std.Build) void {
88

99
const zstd_dep = b.dependency("zstd", .{});
1010

11-
const zstd_lib = b.addStaticLibrary(.{
12-
.name = "zstd",
11+
const translate_c = b.addTranslateC(.{
12+
.root_source_file = b.path("src/headers.h"),
1313
.target = target,
1414
.optimize = optimize,
1515
});
16+
translate_c.addIncludePath(zstd_dep.path("lib"));
17+
18+
const force_pic = b.option(bool, "force_pic", "Forces PIC enabled for this library");
19+
const zstd_lib = b.addLibrary(.{
20+
.name = "zstd",
21+
.linkage = .static,
22+
.root_module = b.createModule(.{
23+
.target = target,
24+
.optimize = optimize,
25+
.pic = force_pic,
26+
}),
27+
});
1628
b.installArtifact(zstd_lib);
29+
1730
zstd_lib.linkLibC();
18-
zstd_lib.addIncludePath(zstd_dep.path("lib"));
1931
zstd_lib.installHeader(zstd_dep.path("lib/zstd.h"), "zstd.h");
2032
zstd_lib.installHeader(zstd_dep.path("lib/zstd_errors.h"), "zstd_errors.h");
2133

@@ -60,6 +72,7 @@ pub fn build(b: *std.Build) void {
6072
.root_source_file = b.path("src/lib.zig"),
6173
});
6274
zstd_mod.linkLibrary(zstd_lib);
75+
zstd_mod.addAnonymousImport("c", .{ .root_source_file = translate_c.getOutput() });
6376

6477
const tests_exe = b.addTest(.{
6578
.target = target,

build.zig.zon

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
.{
2-
.name = "zstd",
2+
.name = .zstd,
3+
.fingerprint = 0x72fd505e092a0bf1,
34
.version = "0.0.1",
45
.dependencies = .{
56
.zstd = .{
6-
.url = "https://github.com/facebook/zstd/archive/794ea1b0afca0f020f4e57b6732332231fb23c70.tar.gz",
7-
.hash = "1220cc97075e331a87cb201c03a018a1522325d6aa844619a461462fbfdaedb38c42",
7+
.url = "git+https://github.com/facebook/zstd#794ea1b0afca0f020f4e57b6732332231fb23c70",
8+
.hash = "N-V-__8AAGHFfQBd9HkISearYAEoBRuWI2GQG3Bvdcv_4uuN",
89
},
910
},
1011
.paths = .{

libzstd.a

Whitespace-only changes.

src/c.zig

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/compress.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const c = @import("c.zig");
2+
const c = @import("c");
33
const InBuffer = @import("types.zig").InBuffer;
44
const OutBuffer = @import("types.zig").OutBuffer;
55
const ResetDirective = @import("types.zig").ResetDirective;

src/decompress.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const c = @import("c.zig");
2+
const c = @import("c");
33
const InBuffer = @import("types.zig").InBuffer;
44
const OutBuffer = @import("types.zig").OutBuffer;
55
const ResetDirective = @import("types.zig").ResetDirective;

src/error.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const c = @import("c.zig");
1+
const c = @import("c");
22

33
pub const Error = error{
44
Generic,

src/headers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "zstd.h"
2+
#include "zstd_errors.h"

src/lib.zig

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
pub const c = @import("c.zig");
2-
pub usingnamespace @import("compress.zig");
3-
pub usingnamespace @import("decompress.zig");
4-
pub usingnamespace @import("types.zig");
5-
pub usingnamespace @import("error.zig");
6-
pub usingnamespace @import("reader.zig");
7-
pub usingnamespace @import("writer.zig");
1+
const compress = @import("compress.zig");
2+
const decompress = @import("decompress.zig");
3+
const types = @import("types.zig");
4+
const errors = @import("error.zig");
5+
const reader = @import("reader.zig");
6+
const writer = @import("writer.zig");
7+
8+
pub const Compressor = compress.Compressor;
9+
pub const writerCtx = writer.writerCtx;
10+
pub const Reader = reader.Reader;

0 commit comments

Comments
 (0)