-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.zig
More file actions
66 lines (58 loc) · 2.01 KB
/
Copy pathbuild.zig
File metadata and controls
66 lines (58 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
62
63
64
65
66
const std = @import("std");
const LazyPath = std.Build.LazyPath;
const print = std.debug.print;
const aprint = std.fmt.allocPrint;
pub fn build(b: *std.Build) !void {
const version: std.SemanticVersion = .{ // VERSION
.major = 2,
.minor = 2,
.patch = 0,
.pre = "dev.1",
};
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{
.preferred_optimize_mode = .ReleaseSmall,
});
const build_all = b.option(bool, "buildall", "Enable build-all mode") orelse false;
const target_name = try if (build_all)
aprint(b.allocator, "cmuscontrold-{s}-{s}", .{ @tagName(target.result.cpu.arch), target.result.cpu.model.name })
else
aprint(b.allocator, "cmuscontrold", .{});
print("target arch: {s}\n", .{@tagName(target.result.cpu.arch)});
print("target cpu: {s}\n", .{target.result.cpu.model.name});
print("target os: {s}\n", .{@tagName(target.result.os.tag)});
print("target name: {s}\n", .{target_name});
print("optimize: {s}\n", .{@tagName(optimize)});
print("build all: {any}\n", .{build_all});
const exe_mod = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.strip = optimize != .Debug,
});
exe_mod.addCSourceFiles(.{
.files = &[_][]const u8{
"src/main.m",
"src/CCApplication.m",
},
.flags = &.{
"-fobjc-arc",
},
.language = .objective_c,
});
exe_mod.linkFramework("AppKit", .{});
exe_mod.linkFramework("Foundation", .{});
const exe = b.addExecutable(.{
.name = target_name,
.version = version,
.root_module = exe_mod,
});
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);
}