-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
61 lines (57 loc) · 2.1 KB
/
build.zig
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 {
b.exe_dir = "";
b.lib_dir = "";
b.dest_dir = "";
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib = b.addSharedLibrary(.{
.name = "brv",
.target = target,
.optimize = optimize,
});
lib.addCSourceFiles(.{
.files = &.{
//
"source/parser.c",
"source/analyzer.c",
"source/builder.c",
},
});
lib.linkLibC();
const lib_artifact = b.addInstallArtifact(lib, .{});
lib_artifact.dest_dir = .{ .custom = "../lib/" };
if (target.result.os.tag == .windows) lib_artifact.pdb_dir = lib_artifact.dest_dir;
if (target.result.os.tag == .windows) lib_artifact.h_dir = lib_artifact.dest_dir;
if (target.result.os.tag == .windows) lib_artifact.implib_dir = lib_artifact.dest_dir;
b.getInstallStep().dependOn(&lib_artifact.step);
const slib = b.addStaticLibrary(.{
.name = "brv_static",
.target = target,
.optimize = optimize,
});
slib.addCSourceFiles(.{
.files = &.{
//
"source/parser.c",
"source/analyzer.c",
"source/builder.c",
},
});
slib.linkLibC();
const slib_artifact = b.addInstallArtifact(slib, .{});
slib_artifact.dest_dir = .{ .custom = "../lib/" };
b.getInstallStep().dependOn(&slib_artifact.step);
// build examples
const parsing = b.addExecutable(.{ .name = "parsing", .target = target, .optimize = optimize });
parsing.addCSourceFile(.{ .file = b.path("examples/parsing/main.c") });
if (target.result.os.tag == .windows) { // getopt fix
//parsing.addCSourceFile(.{ .file = b.path("") });
}
parsing.linkLibC();
parsing.linkLibrary(slib);
const parsing_artifact = b.addInstallArtifact(parsing, .{});
parsing_artifact.dest_dir = .{ .custom = "../bin/parsing" };
if (target.result.os.tag == .windows) parsing_artifact.pdb_dir = .{ .custom = "../bin/parsing" };
b.getInstallStep().dependOn(&parsing_artifact.step);
}