feat: added loader and appropriate build scripts
This commit is contained in:
+33
-4
@@ -1,26 +1,55 @@
|
||||
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.root_module.addAnonymousImport("beacon", .{ .root_source_file = compressed_beacon });
|
||||
libloader.linkLibC();
|
||||
|
||||
libloader.step.dependOn(&tool_step.step);
|
||||
|
||||
const 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 = "unix-loader",
|
||||
.name = "test-loader",
|
||||
.root_source_file = b.path("src/test_run.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.strip = true,
|
||||
});
|
||||
|
||||
lib.linkLibC();
|
||||
b.installArtifact(lib);
|
||||
lib.addObject(libloader);
|
||||
exe.addObject(libloader);
|
||||
|
||||
exe.linkLibC();
|
||||
b.installArtifact(lib);
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user