-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.zig
67 lines (60 loc) · 3.25 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
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const cflags = [_][]const u8{ "-Wall", "-Wextra", "-Werror=return-type", "-std=gnu11", "-O2" };
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
if (target.getCpuArch() == .wasm32) {
const cflagslib = [_][]const u8{ "-Wall", "-Wextra", "-Werror=return-type", "-std=gnu11", "-O2", "-fPIC" };
const lib = b.addExecutable("olaf_c", null);
lib.addCSourceFile("src/hash-table.c", &cflagslib);
lib.addCSourceFile("src/pffft.c", &cflagslib);
lib.addCSourceFile("src/queue.c", &cflagslib);
lib.addCSourceFile("src/olaf_deque.c", &cflagslib);
lib.addCSourceFile("src/olaf_max_filter_perceptual_van_herk.c", &cflagslib);
lib.addCSourceFile("src/olaf.c", &cflagslib);
lib.addCSourceFile("src/olaf_config.c", &cflagslib);
lib.addCSourceFile("src/olaf_db_mem.c", &cflagslib);
lib.addCSourceFile("src/olaf_ep_extractor.c", &cflagslib);
lib.addCSourceFile("src/olaf_fp_db_writer.c", &cflagslib);
lib.addCSourceFile("src/olaf_fp_db_writer_cache.c", &cflagslib);
lib.addCSourceFile("src/olaf_fp_extractor.c", &cflagslib);
lib.addCSourceFile("src/olaf_fp_matcher.c", &cflagslib);
lib.addCSourceFile("src/olaf_reader_stream.c", &cflagslib);
lib.addCSourceFile("src/olaf_runner.c", &cflagslib);
lib.addCSourceFile("src/olaf_stream_processor.c", &cflagslib);
lib.linkLibC();
lib.setTarget(target);
lib.setBuildMode(mode);
lib.install();
} else {
const exe = b.addExecutable("olaf_c", null);
exe.addCSourceFile("src/hash-table.c", &cflags);
exe.addCSourceFile("src/mdb.c", &cflags);
exe.addCSourceFile("src/midl.c", &cflags);
exe.addCSourceFile("src/pffft.c", &cflags);
exe.addCSourceFile("src/queue.c", &cflags);
exe.addCSourceFile("src/olaf_deque.c", &cflags);
exe.addCSourceFile("src/olaf_max_filter_perceptual_van_herk.c", &cflags);
exe.addCSourceFile("src/olaf.c", &cflags);
exe.addCSourceFile("src/olaf_config.c", &cflags);
exe.addCSourceFile("src/olaf_db.c", &cflags);
exe.addCSourceFile("src/olaf_ep_extractor.c", &cflags);
exe.addCSourceFile("src/olaf_fp_db_writer.c", &cflags);
exe.addCSourceFile("src/olaf_fp_db_writer_cache.c", &cflags);
exe.addCSourceFile("src/olaf_fp_extractor.c", &cflags);
exe.addCSourceFile("src/olaf_fp_matcher.c", &cflags);
exe.addCSourceFile("src/olaf_reader_stream.c", &cflags);
exe.addCSourceFile("src/olaf_runner.c", &cflags);
exe.addCSourceFile("src/olaf_stream_processor.c", &cflags);
exe.linkLibC();
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();
}
}