-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
47 lines (36 loc) · 1.56 KB
/
build.zig
File metadata and controls
47 lines (36 loc) · 1.56 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
// SPDX-License-Identifier: BSD-2-Clause
const std = @import("std");
const Targets = struct {
target: std.Build.ResolvedTarget,
name: []const u8,
};
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
// Define all targets to build
const targets: [4]Targets = .{
.{ .target = b.resolveTargetQuery(.{ .os_tag = .windows, .cpu_arch = .x86_64 }), .name = "helper" },
.{ .target = b.resolveTargetQuery(.{ .os_tag = .linux, .cpu_arch = .x86_64 }), .name = "helper-linux" },
.{ .target = b.resolveTargetQuery(.{ .os_tag = .macos, .cpu_arch = .aarch64 }), .name = "helper-macos-arm64" },
.{ .target = b.resolveTargetQuery(.{ .os_tag = .macos, .cpu_arch = .x86_64 }), .name = "helper-macos-x64" },
};
const version = b.option([]const u8, "version", "application version string") orelse "0.0.0";
for (targets) |target_info| {
const root_module = b.createModule(.{
.root_source_file = b.path("helper.zig"),
.target = target_info.target,
.optimize = optimize,
});
const exe = b.addExecutable(.{
.name = target_info.name,
.root_module = root_module,
});
// Add space for codesign for macOS builds
if (target_info.target.result.os.tag == .macos) {
exe.headerpad_max_install_names = true;
}
const options = b.addOptions();
options.addOption([]const u8, "version", version);
root_module.addOptions("config", options);
b.installArtifact(exe);
}
}