authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-17 03:20:56-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-17 06:47:20-04:00
loge4ec2d10c67542589e10e1eaf569157284171159
treecec0f0c5d5d14601f6dd48251b856b5ab305bcd2
parent47336abae3992ef343bd9cb6099b89bad1dfb634

zig build system: implement custom command step


1 files changed, 13 insertions(+), 6 deletions(-)

std/build.zig+13-6
......@@ -397,6 +397,10 @@ pub const Builder = struct {
397397 }
398398
399399 fn spawnChild(self: &Builder, exe_path: []const u8, args: []const []const u8) {
400 return self.spawnChildEnvMap(&self.env_map, exe_path, args);
401 }
402
403 fn spawnChildEnvMap(self: &Builder, env_map: &const BufMap, exe_path: []const u8, args: []const []const u8) {
400404 if (self.verbose) {
401405 %%io.stderr.printf("{}", exe_path);
402406 for (args) |arg| {
......@@ -405,7 +409,7 @@ pub const Builder = struct {
405409 %%io.stderr.printf("\n");
406410 }
407411
408 var child = os.ChildProcess.spawn(exe_path, args, &self.env_map,
412 var child = os.ChildProcess.spawn(exe_path, args, env_map,
409413 StdIo.Ignore, StdIo.Inherit, StdIo.Inherit, self.allocator)
410414 %% |err| debug.panic("Unable to spawn {}: {}\n", exe_path, @errorName(err));
411415
......@@ -905,17 +909,19 @@ const CExecutable = struct {
905909
906910const CommandStep = struct {
907911 step: Step,
908 path: []const u8,
912 builder: &Builder,
913 exe_path: []const u8,
909914 args: []const []const u8,
910915 cwd: []const u8,
911916 env_map: &const BufMap,
912917
913918 pub fn init(builder: &Builder, cwd: []const u8, env_map: &const BufMap,
914 path: []const u8, args: []const []const u8) -> CommandStep
919 exe_path: []const u8, args: []const []const u8) -> CommandStep
915920 {
916921 CommandStep {
917 .step = Step.init(path, builder.allocator, make),
918 .path = path,
922 .builder = builder,
923 .step = Step.init(exe_path, builder.allocator, make),
924 .exe_path = exe_path,
919925 .args = args,
920926 .cwd = cwd,
921927 .env_map = env_map,
......@@ -927,7 +933,8 @@ const CommandStep = struct {
927933 //const self = @fieldParentPtr(CExecutable, "step", step);
928934 const self = @ptrcast(&CommandStep, step);
929935
930 %%io.stderr.printf("TODO: exec command\n");
936 // TODO set cwd
937 self.builder.spawnChildEnvMap(self.env_map, self.exe_path, self.args);
931938 }
932939};
933940