zig/std/special/build_runner.zig

27 lines
759 B
Zig
Raw Normal View History

const root = @import("@build");
const std = @import("std");
const io = std.io;
2017-04-04 05:17:24 +01:00
const os = std.os;
const Builder = std.build.Builder;
const mem = std.mem;
2017-04-03 01:44:04 +01:00
error InvalidArgs;
2017-04-04 05:17:24 +01:00
pub fn main() -> %void {
if (os.args.count() < 2) {
2017-04-03 01:44:04 +01:00
%%io.stderr.printf("Expected first argument to be path to zig compiler\n");
return error.InvalidArgs;
}
2017-04-04 05:17:24 +01:00
const zig_exe = os.args.at(1);
const leftover_arg_index = 2;
// TODO use a more general purpose allocator here
var inc_allocator = %%mem.IncrementingAllocator.init(10 * 1024 * 1024);
defer inc_allocator.deinit();
var builder = Builder.init(zig_exe, &inc_allocator.allocator);
defer builder.deinit();
root.build(&builder);
2017-04-04 05:17:24 +01:00
%return builder.make(leftover_arg_index);
}