2020-05-25 01:22:39 +01:00
|
|
|
const root = @import("build.zig");
|
|
|
|
const std = @import("std");
|
|
|
|
const io = std.io;
|
|
|
|
const fmt = std.fmt;
|
|
|
|
const Builder = std.build.Builder;
|
|
|
|
const Pkg = std.build.Pkg;
|
2020-05-25 09:28:38 +01:00
|
|
|
const InstallArtifactStep = std.build.InstallArtifactStep;
|
2020-05-25 01:22:39 +01:00
|
|
|
const ArrayList = std.ArrayList;
|
|
|
|
|
2020-05-25 09:28:38 +01:00
|
|
|
///! This is a modified build runner to extract information out of build.zig
|
|
|
|
///! Modified from the std.special.build_runner
|
2020-05-25 01:22:39 +01:00
|
|
|
|
|
|
|
pub fn main() !void {
|
|
|
|
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
|
|
|
defer arena.deinit();
|
|
|
|
|
2020-05-25 09:28:38 +01:00
|
|
|
const allocator = &arena.allocator;
|
2020-05-25 01:22:39 +01:00
|
|
|
|
|
|
|
const builder = try Builder.create(allocator, "", "", "");
|
|
|
|
defer builder.destroy();
|
|
|
|
|
|
|
|
try runBuild(builder);
|
|
|
|
|
|
|
|
const stdout_stream = io.getStdOut().outStream();
|
|
|
|
|
2020-05-25 09:28:38 +01:00
|
|
|
for (builder.getInstallStep().dependencies.items) |step| {
|
|
|
|
std.debug.warn("step.id {}\n", .{step.id});
|
|
|
|
if (step.cast(InstallArtifactStep)) |install_exe| {
|
|
|
|
std.debug.warn("libexeobj!\n", .{});
|
|
|
|
for (install_exe.artifact.packages.items) |pkg| {
|
|
|
|
try processPackage(stdout_stream, pkg);
|
|
|
|
}
|
2020-05-25 01:22:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn processPackage(out_stream: var, pkg: Pkg) anyerror!void {
|
|
|
|
try out_stream.print("{}\x00{}\n", .{ pkg.name, pkg.path });
|
|
|
|
if (pkg.dependencies) |dependencies| {
|
|
|
|
for (dependencies) |dep| {
|
|
|
|
try processPackage(out_stream, dep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn runBuild(builder: *Builder) anyerror!void {
|
|
|
|
switch (@typeInfo(@TypeOf(root.build).ReturnType)) {
|
|
|
|
.Void => root.build(builder),
|
|
|
|
.ErrorUnion => try root.build(builder),
|
|
|
|
else => @compileError("expected return type of build to be 'void' or '!void'"),
|
|
|
|
}
|
|
|
|
}
|