-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
61 lines (52 loc) · 2.01 KB
/
build.zig
File metadata and controls
61 lines (52 loc) · 2.01 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
const std = @import("std");
pub fn build(b: *std.Build) void {
// Common options: x86_64-windows, x86_64-linux, x86_64-macos, aarch64-macos.
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib_mod = b.createModule(.{
.root_source_file = null,
.target = target,
.optimize = optimize,
});
const lib = b.addLibrary(.{
.linkage = .dynamic,
.name = "Wireworld",
.root_module = lib_mod,
});
const cflags = [_][]const u8{
"-std=c99",
"-Wall",
"-Wextra",
"-Werror",
"-Wno-unused-parameter",
};
lib.addCSourceFile(.{ .file = b.path("libWireworld/libWireworld.c"), .flags = &cflags });
lib.linkLibC();
// Modify these paths if needed.
lib.addIncludePath(std.Build.LazyPath{ .cwd_relative = "/Applications/Wolfram.app/Contents/SystemFiles/IncludeFiles/C" });
lib.addLibraryPath(std.Build.LazyPath{ .cwd_relative = "/Applications/Wolfram.app/Contents/SystemFiles/Libraries/MacOSX-ARM64" });
const lib_install = b.addInstallArtifact(lib, .{});
switch (target.result.os.tag) {
.windows => {
switch (target.result.cpu.arch) {
.x86_64 => lib_install.dest_dir = .{ .custom = "../LibraryResources/Windows-x86-64" },
else => unreachable,
}
},
.macos => {
switch (target.result.cpu.arch) {
.x86_64 => lib_install.dest_dir = .{ .custom = "../LibraryResources/MacOSX-x86-64" },
.aarch64 => lib_install.dest_dir = .{ .custom = "../LibraryResources/MacOSX-ARM64" },
else => unreachable,
}
},
.linux => {
switch (target.result.cpu.arch) {
.x86_64 => lib_install.dest_dir = .{ .custom = "../LibraryResources/Linux-x86-64" },
else => unreachable,
}
},
else => unreachable,
}
b.getInstallStep().dependOn(&lib_install.step);
}