-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.zig
182 lines (155 loc) · 5.42 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
const std = @import("std");
pub fn build(b: *std.Build) void {
// 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 optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const cli = b.addExecutable(.{
.name = "zyg",
.root_source_file = b.path("src/cli/main.zig"),
.target = target,
.optimize = optimize,
});
const capi = b.addSharedLibrary(.{
.name = "zyg",
.root_source_file = b.path("src/capi/capi.zig"),
.target = target,
.optimize = optimize,
});
const it = b.addExecutable(.{
.name = "it",
.root_source_file = b.path("src/it/main.zig"),
.target = target,
.optimize = optimize,
});
cli.addIncludePath(b.path("thirdparty/include"));
cli.addIncludePath(b.path("src/cli"));
capi.addIncludePath(b.path("thirdparty/include"));
it.addIncludePath(b.path("thirdparty/include"));
const cflags = [_][]const u8{
"-std=c99",
"-Wall",
"-fno-sanitize=undefined",
};
const csources = [_][]const u8{
"thirdparty/include/miniz/miniz.c",
"thirdparty/include/arpraguesky/ArPragueSkyModelGround.c",
};
for (csources) |source| {
cli.addCSourceFile(.{ .file = b.path(source), .flags = &cflags });
capi.addCSourceFile(.{ .file = b.path(source), .flags = &cflags });
}
cli.addCSourceFile(.{ .file = b.path("src/cli/any_key.c"), .flags = &cflags });
it.addCSourceFile(.{ .file = b.path(csources[0]), .flags = &cflags });
const base = b.createModule(.{
.root_source_file = b.path("src/base/base.zig"),
});
const core = b.createModule(.{
.root_source_file = b.path("src/core/core.zig"),
.imports = &.{.{ .name = "base", .module = base }},
});
core.addIncludePath(b.path("thirdparty/include"));
cli.root_module.addImport("base", base);
cli.root_module.addImport("core", core);
cli.linkLibC();
// cli.sanitize_thread = true;
cli.root_module.strip = true;
b.installArtifact(cli);
capi.root_module.addImport("base", base);
capi.root_module.addImport("core", core);
capi.linkLibC();
capi.root_module.strip = true;
b.installArtifact(capi);
it.root_module.addImport("base", base);
it.root_module.addImport("core", core);
it.linkLibC();
// it.sanitize_thread = true;
it.root_module.strip = true;
b.installArtifact(it);
const run_exe = b.addRunArtifact(cli);
run_exe.step.dependOn(b.getInstallStep());
run_exe.setCwd(b.path("system"));
const run_step = b.step("run", "Run the application");
run_step.dependOn(&run_exe.step);
if (b.args) |args| {
run_exe.addArgs(args);
} else {
run_exe.addArgs(&[_][]const u8{
"-i",
//"takes/bistro_day.take",
//"takes/bistro_night.take",
//"takes/san_miguel.take",
"takes/cornell.take",
//"takes/cornell_nd.take",
//"takes/curve_test.take",
//"takes/imrod.take",
//"takes/model_test.take",
//"takes/furnace_test.take",
//"takes/animation_test.take",
//"takes/material_test.take",
//"takes/whirligig.take",
//"takes/candle.take",
//"takes/disney_cloud.take",
//"takes/rene.take",
//"takes/head.take",
//"takes/flakes.take",
//"takes/embergen.take",
//"takes/volume.take",
//"takes/nested_dielectrics.take",
//"takes/intel_sponza.take",
//"takes/sss.take",
//"scenes/island/shot_cam.take",
//"takes/shadow_catcher.take",
"-t",
"-1",
//"--no-tex",
//"--no-tex-dwim",
//"--debug-mat",
"-f",
"0",
"-n",
"1",
});
}
// const run_exe = b.addRunArtifact(it);
// run_exe.step.dependOn(b.getInstallStep());
// run_exe.setCwd(b.path("system"));
// const run_step = b.step("run", "Run the application");
// run_step.dependOn(&run_exe.step);
// if (b.args) |args| {
// run_exe.addArgs(args);
// } else {
// run_exe.addArgs(&[_][]const u8{
// "-i",
// "curtain_fabric_Roughnesscurtain_fabric_Metalness.png",
// "-t",
// "-1",
// "--max-value",
// "0.0 0.1 0.0 0.0",
// });
// }
// if (b.args) |args| {
// run_exe.addArgs(args);
// } else {
// run_exe.addArgs(&[_][]const u8{
// //"-d",
// "-i",
// "image_00_000000_l.png",
// "image_00_000000_r.png",
// "-t",
// "-1",
// "--anaglyph",
// //"--tone",
// //"agx",
// // "-e",
// // "-1.0",
// // "-f",
// // "png",
// });
// }
}