63 lines
1.9 KiB
Zig
63 lines
1.9 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const use_llvm = b.option(bool, "use-llvm", "LLVM build") orelse (b.release_mode != .off);
|
|
|
|
const c_includes = b.addTranslateC(.{
|
|
.root_source_file = b.path("third_party/miclib.h"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
});
|
|
|
|
const miclib_c = c_includes.createModule();
|
|
|
|
const module = b.addModule("miclib", .{
|
|
.root_source_file = b.path("src/lib.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
.imports = &.{.{ .name = "miclib_c", .module = miclib_c }},
|
|
});
|
|
module.linkSystemLibrary("dl", .{});
|
|
|
|
const test_module = b.createModule(.{
|
|
.root_source_file = b.path("src/lib.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
.imports = &.{.{ .name = "miclib_c", .module = miclib_c }},
|
|
});
|
|
test_module.linkSystemLibrary("dl", .{});
|
|
|
|
const lib_tests = b.addTest(.{
|
|
.root_module = test_module,
|
|
.use_llvm = use_llvm,
|
|
});
|
|
const run_tests = b.addRunArtifact(lib_tests);
|
|
const test_step = b.step("test", "Run unit tests");
|
|
test_step.dependOn(&run_tests.step);
|
|
|
|
const enumerate_module = b.createModule(.{
|
|
.root_source_file = b.path("examples/enumerate.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.imports = &.{.{ .name = "miclib", .module = module }},
|
|
});
|
|
|
|
const enumerate = b.addExecutable(.{
|
|
.name = "miclib-enumerate",
|
|
.root_module = enumerate_module,
|
|
.use_llvm = use_llvm,
|
|
});
|
|
|
|
b.installArtifact(enumerate);
|
|
|
|
const run_enumerate = b.addRunArtifact(enumerate);
|
|
const run_step = b.step("example", "Run examples/enumerate.zig");
|
|
run_step.dependOn(&run_enumerate.step);
|
|
}
|