64 lines
2.0 KiB
Zig
64 lines
2.0 KiB
Zig
// Based on allyourcodebase/lz4 commit 41f52ab227caf9d48cf88c89a4d2946caa12b102.
|
|
// LZ4 v1.10.0 sources: ebb370ca83af193212df4dcbadcc5d87bc0de2f0.
|
|
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const linkage = b.option(std.lang.LinkMode, "linkage", "Link mode") orelse .static;
|
|
const strip = b.option(bool, "strip", "Omit debug information");
|
|
const pic = b.option(bool, "pie", "Produce Position Independent Code");
|
|
|
|
const lz4 = b.addLibrary(.{
|
|
.linkage = linkage,
|
|
.name = "lz4",
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.pic = pic,
|
|
.strip = strip,
|
|
.link_libc = true,
|
|
}),
|
|
});
|
|
b.installArtifact(lz4);
|
|
lz4.root_module.addIncludePath(b.path("src"));
|
|
lz4.root_module.addCMacro("XXH_NAMESPACE", "LZ4_");
|
|
lz4.installHeader(b.path("src/lz4.h"), "lz4.h");
|
|
lz4.installHeader(b.path("src/lz4hc.h"), "lz4hc.h");
|
|
lz4.installHeader(b.path("src/lz4frame.h"), "lz4frame.h");
|
|
lz4.root_module.addCSourceFiles(.{
|
|
.root = b.path("src"),
|
|
.files = &.{
|
|
"lz4.c",
|
|
"lz4frame.c",
|
|
"lz4hc.c",
|
|
"xxhash.c",
|
|
},
|
|
});
|
|
|
|
const bindings = b.addTranslateC(.{
|
|
.root_source_file = b.path("src/bindings.h"),
|
|
.optimize = optimize,
|
|
.target = target,
|
|
});
|
|
|
|
const lz4_zig = b.addModule("lz4_zig", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.pic = pic,
|
|
.strip = strip,
|
|
.link_libc = true,
|
|
.root_source_file = b.path("src/lz4.zig"),
|
|
});
|
|
lz4_zig.linkLibrary(lz4);
|
|
lz4_zig.addImport("c", bindings.createModule());
|
|
|
|
const tests = b.addTest(.{ .root_module = lz4_zig });
|
|
|
|
const run_tests = b.addRunArtifact(tests);
|
|
run_tests.addPassthruArgs();
|
|
|
|
b.step("test", "runs lz4_zig tests").dependOn(&run_tests.step);
|
|
}
|