mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
Merge pull request #23946 from mlugg/build-step-run-cwd
std.Build.Step.Run: inherit build runner cwd
This commit is contained in:
commit
ef92c156b5
@ -1334,9 +1334,6 @@ fn spawnChildAndCollect(
|
||||
var child = std.process.Child.init(argv, arena);
|
||||
if (run.cwd) |lazy_cwd| {
|
||||
child.cwd = lazy_cwd.getPath2(b, &run.step);
|
||||
} else {
|
||||
child.cwd = b.build_root.path;
|
||||
child.cwd_dir = b.build_root.handle;
|
||||
}
|
||||
child.env_map = run.env_map orelse &b.graph.env_map;
|
||||
child.request_resource_usage_statistics = true;
|
||||
|
||||
@ -8,7 +8,7 @@ pub fn build(b: *std.Build) void {
|
||||
}) });
|
||||
|
||||
const options = b.addOptions();
|
||||
main.addOptions("build_options", options);
|
||||
main.root_module.addOptions("build_options", options);
|
||||
options.addOption(bool, "bool_true", b.option(bool, "bool_true", "t").?);
|
||||
options.addOption(bool, "bool_false", b.option(bool, "bool_false", "f").?);
|
||||
options.addOption(u32, "int", b.option(u32, "int", "i").?);
|
||||
|
||||
@ -1657,16 +1657,23 @@ pub fn addCliTests(b: *std.Build) *Step {
|
||||
}
|
||||
|
||||
{
|
||||
// TODO this should move to become a CLI test rather than standalone
|
||||
// cases.addBuildFile("test/standalone/options/build.zig", .{
|
||||
// .extra_argv = &.{
|
||||
// "-Dbool_true",
|
||||
// "-Dbool_false=false",
|
||||
// "-Dint=1234",
|
||||
// "-De=two",
|
||||
// "-Dstring=hello",
|
||||
// },
|
||||
// });
|
||||
const run_test = b.addSystemCommand(&.{
|
||||
b.graph.zig_exe,
|
||||
"build",
|
||||
"test",
|
||||
"-Dbool_true",
|
||||
"-Dbool_false=false",
|
||||
"-Dint=1234",
|
||||
"-De=two",
|
||||
"-Dstring=hello",
|
||||
});
|
||||
run_test.addArg("--build-file");
|
||||
run_test.addFileArg(b.path("test/standalone/options/build.zig"));
|
||||
run_test.addArg("--cache-dir");
|
||||
run_test.addFileArg(.{ .cwd_relative = b.cache_root.join(b.allocator, &.{}) catch @panic("OOM") });
|
||||
run_test.setName("test build options");
|
||||
|
||||
step.dependOn(&run_test.step);
|
||||
}
|
||||
|
||||
return step;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user