forked from alichraghi/zstd.zig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
73 lines (62 loc) · 2.36 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const test_step = b.step("test", "Run library tests");
const zstd_dep = b.dependency("zstd", .{});
const zstd_lib = b.addStaticLibrary(.{
.name = "zstd",
.target = target,
.optimize = optimize,
});
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");
zstd_lib.root_module.addCMacro("ZSTD_MULTITHREAD", "");
zstd_lib.root_module.addCMacro("ZSTD_STATIC_LINKING_ONLY", "");
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",
"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",
"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"));
const zstd_mod = b.addModule("zstd", .{
.root_source_file = b.path("src/lib.zig"),
});
zstd_mod.linkLibrary(zstd_lib);
const tests_exe = b.addTest(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/tests.zig"),
});
tests_exe.root_module.addImport("zstd", zstd_mod);
const tests_exe_run = b.addRunArtifact(tests_exe);
test_step.dependOn(&tests_exe_run.step);
}