-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
71 lines (61 loc) · 2.22 KB
/
build.zig
File metadata and controls
71 lines (61 loc) · 2.22 KB
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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const snappy_version = std.SemanticVersion.parse("1.2.2") catch unreachable;
const upstream = b.dependency("snappy", .{});
const lib = b.addLibrary(.{
.linkage = .static,
.name = "snappy",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
.link_libcpp = true,
}),
});
lib.addCSourceFiles(.{
.root = upstream.path("."),
.files = &[_][]const u8{
"snappy-sinksource.cc",
"snappy-stubs-internal.cc",
"snappy.cc",
"snappy-c.cc",
},
.flags = &[_][]const u8{
"-std=c++11",
"-Wall",
"-Wextra",
"-Werror",
"-Wno-sign-compare",
},
});
const snappy_stubs_public_h = b.addConfigHeader(.{
.style = .{ .cmake = upstream.path("snappy-stubs-public.h.in") },
}, .{
.HAVE_SYS_UIO_H_01 = target.result.os.tag != .windows,
.PROJECT_VERSION_MAJOR = @as(i64, @intCast(snappy_version.major)),
.PROJECT_VERSION_MINOR = @as(i64, @intCast(snappy_version.minor)),
.PROJECT_VERSION_PATCH = @as(i64, @intCast(snappy_version.patch)),
});
lib.addIncludePath(upstream.path("."));
lib.addConfigHeader(snappy_stubs_public_h);
lib.installHeader(upstream.path("snappy.h"), "snappy.h");
lib.installHeader(upstream.path("snappy-c.h"), "snappy-c.h");
lib.installHeader(snappy_stubs_public_h.getOutput(), "snappy-stubs-public.h");
b.installArtifact(lib);
const module = b.addModule("snappy", .{
.root_source_file = b.path("src/snappy.zig"),
.target = target,
.optimize = optimize,
});
module.linkLibrary(lib);
const test_snappy = b.addTest(.{
.name = "snappy",
.root_module = module,
.filters = &[_][]const u8{},
});
const run_test_snappy = b.addRunArtifact(test_snappy);
const tls_run_test_snappy = b.step("test", "Run the snappy test");
tls_run_test_snappy.dependOn(&run_test_snappy.step);
}