zig/std/special/build_runner.zig
Andrew Kelley 1c6000d047 zig build system improvements, add some std API
* add std.buf_map.BufMap
 * add std.buf_set.BufSet
 * add std.mem.split
 * zig build system improvements (See #204)
   - automatically parses NIX_CFLAGS_COMPILE and NIX_LDFLAGS
   - add builder.addCIncludePath
   - add builder.addRPath
   - add builder.addLibPath
   - add exe.linkLibrary
2017-04-04 01:52:20 -04:00

27 lines
759 B
Zig

const root = @import("@build");
const std = @import("std");
const io = std.io;
const os = std.os;
const Builder = std.build.Builder;
const mem = std.mem;
error InvalidArgs;
pub fn main() -> %void {
if (os.args.count() < 2) {
%%io.stderr.printf("Expected first argument to be path to zig compiler\n");
return error.InvalidArgs;
}
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);
%return builder.make(leftover_arg_index);
}