-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
225 lines (179 loc) · 7.04 KB
/
build.zig
File metadata and controls
225 lines (179 loc) · 7.04 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "zig-evm",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// Parallel execution demo
const parallel_exe = b.addExecutable(.{
.name = "parallel-demo",
.root_module = b.createModule(.{
.root_source_file = b.path("src/parallel_example.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(parallel_exe);
const run_parallel_cmd = b.addRunArtifact(parallel_exe);
run_parallel_cmd.step.dependOn(b.getInstallStep());
const run_parallel_step = b.step("parallel", "Run parallel execution demo");
run_parallel_step.dependOn(&run_parallel_cmd.step);
// Optimized parallel execution demo
const parallel_opt_exe = b.addExecutable(.{
.name = "parallel-optimized",
.root_module = b.createModule(.{
.root_source_file = b.path("src/parallel_optimized_example.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(parallel_opt_exe);
const run_parallel_opt_cmd = b.addRunArtifact(parallel_opt_exe);
run_parallel_opt_cmd.step.dependOn(b.getInstallStep());
const run_parallel_opt_step = b.step("parallel-opt", "Run optimized parallel execution demo");
run_parallel_opt_step.dependOn(&run_parallel_opt_cmd.step);
// Quick benchmark
const benchmark_exe = b.addExecutable(.{
.name = "benchmark",
.root_module = b.createModule(.{
.root_source_file = b.path("src/quick_benchmark.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(benchmark_exe);
const run_benchmark_cmd = b.addRunArtifact(benchmark_exe);
run_benchmark_cmd.step.dependOn(b.getInstallStep());
const run_benchmark_step = b.step("benchmark", "Run quick optimization benchmarks");
run_benchmark_step.dependOn(&run_benchmark_cmd.step);
// Simple benchmark
const simple_benchmark_exe = b.addExecutable(.{
.name = "simple-benchmark",
.root_module = b.createModule(.{
.root_source_file = b.path("src/simple_benchmark.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(simple_benchmark_exe);
const run_simple_benchmark_cmd = b.addRunArtifact(simple_benchmark_exe);
run_simple_benchmark_cmd.step.dependOn(b.getInstallStep());
const run_simple_benchmark_step = b.step("bench", "Run simple optimization benchmark");
run_simple_benchmark_step.dependOn(&run_simple_benchmark_cmd.step);
// Standalone benchmark demo
const benchmark_demo_exe = b.addExecutable(.{
.name = "benchmark-demo",
.root_module = b.createModule(.{
.root_source_file = b.path("src/benchmark_demo.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(benchmark_demo_exe);
const run_benchmark_demo_cmd = b.addRunArtifact(benchmark_demo_exe);
run_benchmark_demo_cmd.step.dependOn(b.getInstallStep());
const run_benchmark_demo_step = b.step("demo", "Run optimization results demo");
run_benchmark_demo_step.dependOn(&run_benchmark_demo_cmd.step);
// Comprehensive benchmark suite
const full_benchmark_exe = b.addExecutable(.{
.name = "full-benchmark",
.root_module = b.createModule(.{
.root_source_file = b.path("src/benchmark.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(full_benchmark_exe);
const run_full_benchmark_cmd = b.addRunArtifact(full_benchmark_exe);
run_full_benchmark_cmd.step.dependOn(b.getInstallStep());
const run_full_benchmark_step = b.step("bench-full", "Run comprehensive benchmark suite");
run_full_benchmark_step.dependOn(&run_full_benchmark_cmd.step);
// Ethereum Compliance Test Runner
const compliance_exe = b.addExecutable(.{
.name = "compliance-tests",
.root_module = b.createModule(.{
.root_source_file = b.path("tests/run_compliance.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(compliance_exe);
const run_compliance_cmd = b.addRunArtifact(compliance_exe);
run_compliance_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_compliance_cmd.addArgs(args);
}
const run_compliance_step = b.step("compliance", "Run Ethereum compliance tests");
run_compliance_step.dependOn(&run_compliance_cmd.step);
// Web demo server
const web_exe = b.addExecutable(.{
.name = "zig-evm-web",
.root_module = b.createModule(.{
.root_source_file = b.path("src/web_server.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(web_exe);
const install_web = b.addInstallArtifact(web_exe, .{});
const build_web_step = b.step("build-web", "Build the web demo server");
build_web_step.dependOn(&install_web.step);
const run_web_cmd = b.addRunArtifact(web_exe);
const run_web_step = b.step("web", "Run the web demo server");
run_web_step.dependOn(&run_web_cmd.step);
// Shared library for FFI
const lib = b.addLibrary(.{
.linkage = .dynamic,
.name = "zigevm",
.root_module = b.createModule(.{
.root_source_file = b.path("src/ffi.zig"),
.target = target,
.optimize = optimize,
}),
});
lib.linkLibC();
b.installArtifact(lib);
// Also create static library
const static_lib = b.addLibrary(.{
.linkage = .static,
.name = "zigevm",
.root_module = b.createModule(.{
.root_source_file = b.path("src/ffi.zig"),
.target = target,
.optimize = optimize,
}),
});
static_lib.linkLibC();
b.installArtifact(static_lib);
// Install the header file
b.installFile("include/zigevm.h", "include/zigevm.h");
// Add lib step
const lib_step = b.step("lib", "Build shared and static libraries");
lib_step.dependOn(&lib.step);
lib_step.dependOn(&static_lib.step);
// Tests
const tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("test.zig"),
.target = target,
.optimize = optimize,
}),
});
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests.step);
}