59 lines
1.7 KiB
Zig
59 lines
1.7 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) !void {
|
|
const beacon = b.option([]const u8, "beacon", "path to beacon to load") orelse std.debug.panic("Expected a path to a beacon to be provided with -Dbeacon", .{});
|
|
const beacon_path = std.Build.LazyPath{ .cwd_relative = beacon };
|
|
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const tool = b.addExecutable(.{
|
|
.name = "beacon-compress",
|
|
.root_source_file = b.path("src/gzip.zig"),
|
|
.target = b.host,
|
|
});
|
|
|
|
const tool_step = b.addRunArtifact(tool);
|
|
tool_step.addFileArg(beacon_path);
|
|
const compressed_beacon = tool_step.addOutputFileArg("beacon.gz");
|
|
|
|
const libloader = b.addObject(.{
|
|
.name = "libloader",
|
|
.root_source_file = b.path("src/libloader.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.strip = true,
|
|
.pic = true,
|
|
});
|
|
|
|
libloader.addIncludePath(b.path("src"));
|
|
libloader.root_module.addAnonymousImport("beacon", .{ .root_source_file = compressed_beacon });
|
|
libloader.linkLibC();
|
|
|
|
libloader.step.dependOn(&tool_step.step);
|
|
|
|
var lib = b.addSharedLibrary(.{
|
|
.name = "unix-loader",
|
|
.root_source_file = b.path("src/loader.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.strip = true,
|
|
});
|
|
|
|
const exe = b.addExecutable(.{
|
|
.name = "test-loader",
|
|
.root_source_file = b.path("src/test_run.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.strip = true,
|
|
});
|
|
|
|
lib.addIncludePath(b.path("src"));
|
|
lib.addObject(libloader);
|
|
exe.addIncludePath(b.path("src"));
|
|
exe.addObject(libloader);
|
|
|
|
b.installArtifact(lib);
|
|
b.installArtifact(exe);
|
|
}
|