Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
64 lines (52 loc) · 2.25 KB
/
Copy pathbuild.zig
File metadata and controls
64 lines (52 loc) · 2.25 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
const std = @import("std");
const zon = @import("build.zig.zon");
const zigweld = @import("zigweld");
pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run test suite");
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
// ############ zigweld USAGE ############## //
const wheels_step = b.step("wheels", "Build Python wheels");
const volt = zigweld.buildWheels(b, mod, @tagName(zon.name), zon.version);
wheels_step.dependOn(&volt.lib_file.step); // Want the lib
// wheels_step.dependOn(&volt.stub_file.step); // Want the stubs
wheels_step.dependOn(&volt.wheel_file.step); // Want the wheel
// wheels_step.dependOn(&volt.wrapped_lib_file.step); // NEW
// ############ zigweld USAGE ############## //
const add_file = b.addInstallFile(volt.lib_file.source, "hi");
test_step.dependOn(&add_file.step);
const tests = b.addTest(.{
.root_module = mod,
});
const run_tests = b.addRunArtifact(tests);
run_tests.setName("run root zig tests");
test_step.dependOn(&run_tests.step);
const pip_install = b.addSystemCommand(&.{
"python",
"-m",
"pip",
"install",
"--no-index",
"--force-reinstall",
});
pip_install.setName("pip install module");
pip_install.addFileArg2(volt.wheel_file.source, .{});
pip_install.addFileInput(volt.wheel_file.source);
pip_install.stdio = .{ .check = .empty };
pip_install.stdio.check.append(b.allocator, .{ .expect_stdout_match = "Successfully installed" }) catch @panic("OOM");
pip_install.step.dependOn(&volt.wheel_file.step);
const py_test = b.addSystemCommand(&.{"python"});
py_test.setName("run python unit tests");
py_test.addFileArg2(b.path("main.py"), .{});
py_test.addFileInput(volt.wheel_file.source);
py_test.stdio = .{ .check = .empty };
py_test.stdio.check.append(b.allocator, .{ .expect_stderr_match = "OK" }) catch @panic("OOM");
py_test.step.dependOn(&pip_install.step);
py_test.step.dependOn(&run_tests.step);
test_step.dependOn(&py_test.step);
}