2017-03-31 10:48:15 +01:00
|
|
|
const root = @import("@build");
|
|
|
|
const std = @import("std");
|
|
|
|
const io = std.io;
|
2017-04-04 05:17:24 +01:00
|
|
|
const os = std.os;
|
2017-03-31 10:48:15 +01:00
|
|
|
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;
|
2017-03-31 10:48:15 +01:00
|
|
|
|
|
|
|
// 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);
|
2017-04-04 06:52:20 +01:00
|
|
|
defer builder.deinit();
|
2017-03-31 10:48:15 +01:00
|
|
|
root.build(&builder);
|
2017-04-04 05:17:24 +01:00
|
|
|
%return builder.make(leftover_arg_index);
|
2017-03-31 10:48:15 +01:00
|
|
|
}
|