~alva/zig-bare

ref: b06b45b4700c60a4868bd17644a5c0ec861885aa zig-bare/build.zig -rw-r--r-- 1.1 KiB
b06b45b4ugla Handle too-big HashMap capacity 3 months ago
                                                                                
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
const builtin = @import("builtin");
const std = @import("std");
const mem = std.mem;
const fs = std.fs;
const Builder = std.build.Builder;
const Target = std.build.Target;
const program_name = "bare";
const sep = fs.path.sep_str;

pub fn build(b: *Builder) !void {
    const mode = b.standardReleaseOptions();
    const lib = b.addStaticLibrary("zig" ++ program_name, "src" ++ sep ++ "bare.zig");
    const exe = b.addExecutable(program_name, "src" ++ sep ++ "main.zig");
    const _test = b.addTest("src" ++ sep ++ "test.zig");
    lib.setBuildMode(mode);
    lib.install();
    exe.setBuildMode(mode);
    //    exe.linkLibrary(lib);
    exe.single_threaded = true;
    exe.link_function_sections = true;
    exe.install();

    if (mode != .Debug)
        exe.strip = true;

    if (mode == .ReleaseSafe)
        exe.force_pic = true;

    b.default_step.dependOn(&exe.step);

    const run_cmd = exe.run();
    const run_step = b.step("run", "Run " ++ program_name);

    const test_step = b.step("test", "Run all " ++ program_name ++ " tests");
    test_step.dependOn(&_test.step);

    run_step.dependOn(&run_cmd.step);
}