Skip to content

Commit

Permalink
update zstd (#1)
Browse files Browse the repository at this point in the history
* don't vendor zstd

* remove `.vscode` folder

* add a super basic ci
  • Loading branch information
Rexicon226 authored Oct 24, 2024
1 parent c6cde4f commit 5d1bd20
Show file tree
Hide file tree
Showing 70 changed files with 83 additions and 42,363 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ci

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2

- 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
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2

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

- name: build
run: zig build test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.zig-cache/
zig-cache/
zig-out/
.vscode/
16 changes: 0 additions & 16 deletions .vscode/launch.json

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

18 changes: 0 additions & 18 deletions .vscode/tasks.json

This file was deleted.

72 changes: 37 additions & 35 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,60 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});

const ZSTD_C_PATH = "vendor/lib";
const zstd_dep = b.dependency("zstd", .{});

const zstd_lib = b.addStaticLibrary(.{
.name = package_name,
.target = target,
.optimize = optimize,
});
zstd_lib.linkLibC();
zstd_lib.addIncludePath(b.path(ZSTD_C_PATH));
zstd_lib.installHeader(b.path(ZSTD_C_PATH ++ "/zstd.h"), "zstd.h");
zstd_lib.installHeader(b.path(ZSTD_C_PATH ++ "/zstd_errors.h"), "zstd_errors.h");
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");

const config_header = b.addConfigHeader(
.{
.style = .blank,
},
.{ .style = .blank },
.{
.ZSTD_CONFIG_H = {},
.ZSTD_MULTITHREAD_SUPPORT_DEFAULT = null,
.ZSTD_LEGACY_SUPPORT = null,
},
);
zstd_lib.addConfigHeader(config_header);
zstd_lib.addCSourceFiles(.{ .files = &.{
ZSTD_C_PATH ++ "/common/debug.c",
ZSTD_C_PATH ++ "/common/entropy_common.c",
ZSTD_C_PATH ++ "/common/error_private.c",
ZSTD_C_PATH ++ "/common/fse_decompress.c",
ZSTD_C_PATH ++ "/common/pool.c",
ZSTD_C_PATH ++ "/common/threading.c",
ZSTD_C_PATH ++ "/common/xxhash.c",
ZSTD_C_PATH ++ "/common/zstd_common.c",
zstd_lib.addCSourceFiles(.{
.root = zstd_dep.path("lib"),
.files = &.{
"common/debug.c",
"common/entropy_common.c",
"common/error_private.c",
"common/fse_decompress.c",
"common/pool.c",
"common/threading.c",
"common/xxhash.c",
"common/zstd_common.c",

ZSTD_C_PATH ++ "/compress/zstd_double_fast.c",
ZSTD_C_PATH ++ "/compress/zstd_compress_literals.c",
ZSTD_C_PATH ++ "/compress/zstdmt_compress.c",
ZSTD_C_PATH ++ "/compress/zstd_opt.c",
ZSTD_C_PATH ++ "/compress/zstd_compress_sequences.c",
ZSTD_C_PATH ++ "/compress/zstd_lazy.c",
ZSTD_C_PATH ++ "/compress/hist.c",
ZSTD_C_PATH ++ "/compress/zstd_ldm.c",
ZSTD_C_PATH ++ "/compress/huf_compress.c",
ZSTD_C_PATH ++ "/compress/zstd_compress_superblock.c",
ZSTD_C_PATH ++ "/compress/zstd_compress.c",
ZSTD_C_PATH ++ "/compress/fse_compress.c",
ZSTD_C_PATH ++ "/compress/zstd_fast.c",
"compress/zstd_double_fast.c",
"compress/zstd_compress_literals.c",
"compress/zstdmt_compress.c",
"compress/zstd_opt.c",
"compress/zstd_compress_sequences.c",
"compress/zstd_lazy.c",
"compress/hist.c",
"compress/zstd_ldm.c",
"compress/huf_compress.c",
"compress/zstd_compress_superblock.c",
"compress/zstd_compress.c",
"compress/fse_compress.c",
"compress/zstd_fast.c",

ZSTD_C_PATH ++ "/decompress/zstd_decompress.c",
ZSTD_C_PATH ++ "/decompress/zstd_ddict.c",
ZSTD_C_PATH ++ "/decompress/zstd_decompress_block.c",
ZSTD_C_PATH ++ "/decompress/huf_decompress.c",
} });
zstd_lib.addAssemblyFile(b.path(ZSTD_C_PATH ++ "/decompress/huf_decompress_amd64.S"));
"decompress/zstd_decompress.c",
"decompress/zstd_ddict.c",
"decompress/zstd_decompress_block.c",
"decompress/huf_decompress.c",
},
});
zstd_lib.addAssemblyFile(zstd_dep.path("lib/decompress/huf_decompress_amd64.S"));
b.installArtifact(zstd_lib);

const module = b.addModule(package_name, .{
Expand Down
7 changes: 6 additions & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.{
.name = "zstd",
.version = "0.0.1",
.dependencies = .{},
.dependencies = .{
.zstd = .{
.url = "https://github.com/facebook/zstd/archive/794ea1b0afca0f020f4e57b6732332231fb23c70.tar.gz",
.hash = "1220cc97075e331a87cb201c03a018a1522325d6aa844619a461462fbfdaedb38c42",
},
},
.paths = .{
"build.zig.zon",
"build.zig",
Expand Down
Loading

0 comments on commit 5d1bd20

Please sign in to comment.