Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- master

jobs:
lint:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
Expand All @@ -18,22 +18,10 @@ jobs:
- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: lint
run: |
zig fmt --check src/ build.zig build.zig.zon
version: 0.14.0

test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: lint
run: zig fmt --check src/ build.zig build.zig.zon

- name: setup-zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: build
run: zig build test
19 changes: 16 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,26 @@ pub fn build(b: *std.Build) void {

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

const zstd_lib = b.addStaticLibrary(.{
.name = "zstd",
const translate_c = b.addTranslateC(.{
.root_source_file = b.path("src/headers.h"),
.target = target,
.optimize = optimize,
});
translate_c.addIncludePath(zstd_dep.path("lib"));

const force_pic = b.option(bool, "force_pic", "Forces PIC enabled for this library");
const zstd_lib = b.addLibrary(.{
.name = "zstd",
.linkage = .static,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.pic = force_pic,
}),
});
b.installArtifact(zstd_lib);

zstd_lib.linkLibC();
zstd_lib.addIncludePath(zstd_dep.path("lib"));
zstd_lib.installHeader(zstd_dep.path("lib/zstd.h"), "zstd.h");
zstd_lib.installHeader(zstd_dep.path("lib/zstd_errors.h"), "zstd_errors.h");

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

const tests_exe = b.addTest(.{
.target = target,
Expand Down
7 changes: 4 additions & 3 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.{
.name = "zstd",
.name = .zstd,
.fingerprint = 0x72fd505e092a0bf1,
.version = "0.0.1",
.dependencies = .{
.zstd = .{
.url = "https://github.com/facebook/zstd/archive/794ea1b0afca0f020f4e57b6732332231fb23c70.tar.gz",
.hash = "1220cc97075e331a87cb201c03a018a1522325d6aa844619a461462fbfdaedb38c42",
.url = "git+https://github.com/facebook/zstd#794ea1b0afca0f020f4e57b6732332231fb23c70",
.hash = "N-V-__8AAGHFfQBd9HkISearYAEoBRuWI2GQG3Bvdcv_4uuN",
},
},
.paths = .{
Expand Down
Empty file added libzstd.a
Empty file.
4 changes: 0 additions & 4 deletions src/c.zig

This file was deleted.

2 changes: 1 addition & 1 deletion src/compress.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig");
const c = @import("c");
const InBuffer = @import("types.zig").InBuffer;
const OutBuffer = @import("types.zig").OutBuffer;
const ResetDirective = @import("types.zig").ResetDirective;
Expand Down
2 changes: 1 addition & 1 deletion src/decompress.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig");
const c = @import("c");
const InBuffer = @import("types.zig").InBuffer;
const OutBuffer = @import("types.zig").OutBuffer;
const ResetDirective = @import("types.zig").ResetDirective;
Expand Down
2 changes: 1 addition & 1 deletion src/error.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const c = @import("c.zig");
const c = @import("c");

pub const Error = error{
Generic,
Expand Down
2 changes: 2 additions & 0 deletions src/headers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "zstd.h"
#include "zstd_errors.h"
17 changes: 10 additions & 7 deletions src/lib.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
pub const c = @import("c.zig");
pub usingnamespace @import("compress.zig");
pub usingnamespace @import("decompress.zig");
pub usingnamespace @import("types.zig");
pub usingnamespace @import("error.zig");
pub usingnamespace @import("reader.zig");
pub usingnamespace @import("writer.zig");
const compress = @import("compress.zig");
const decompress = @import("decompress.zig");
const types = @import("types.zig");
const errors = @import("error.zig");
const reader = @import("reader.zig");
const writer = @import("writer.zig");

pub const Compressor = compress.Compressor;
pub const writerCtx = writer.writerCtx;
pub const Reader = reader.Reader;