r/o

assert a bunch of things! 35595d69 parent c3257634

authored by ~talya

1
const std = @import("std");
2
3
pub fn build(b: *std.Build) void {
4
const yosys_data_dir =
5
b.option([]const u8, "yosys_data_dir", "yosys data dir (per yosys-config --datdir)") orelse
6
guessYosysDataDir(b);
7
8
const target = b.standardTargetOptions(.{});
9
const optimize = b.standardOptimizeOption(.{});
10
11
const mod = b.addModule("zxxrtl", .{
12
.root_source_file = b.path("src/root.zig"),
13
.target = target,
14
.optimize = optimize,
15
});
16
mod.addIncludePath(.{
17
.cwd_relative = b.fmt("{s}/include/backends/cxxrtl/runtime", .{yosys_data_dir}),
18
});
19
20
const lib = b.addLibrary(.{
21
.name = "zxxrtl",
22
.root_module = mod,
23
});
24
25
b.installArtifact(lib);
26
}
27
28
pub fn guessYosysDataDir(b: *std.Build) []const u8 {
29
const result = std.process.Child.run(.{
30
.allocator = b.allocator,
31
.argv = &.{ "yosys-config", "--datdir" },
32
.expand_arg0 = .expand,
33
}) catch @panic("couldn't run yosys-config; please supply -Dyosys_data_dir");
34
return std.mem.trim(u8, result.stdout, "\n");
35
}
36