authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-11 23:35:51-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-04-11 23:35:51-07:00
log10ff81c26457ff02b7a7ed580aaf773297ad8025
tree1b303c864ace3e76ac716ab7ed23ddbddc3521f9
parent3bafc4400a40b497b3b3f8113f72c4b80969f13f
parent499a202a13c2a61f3cb2535c1bd63a9b6b30bfb7
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #19623 from ziglang/LazyPath

std.Build.LazyPath: upgrade API usages of source-relative path

68 files changed, 173 insertions(+), 203 deletions(-)

build.zig+13-13
......@@ -34,7 +34,7 @@ pub fn build(b: *std.Build) !void {
3434
3535 const docgen_exe = b.addExecutable(.{
3636 .name = "docgen",
37 .root_source_file = .{ .path = "tools/docgen.zig" },
37 .root_source_file = b.path("tools/docgen.zig"),
3838 .target = b.host,
3939 .optimize = .Debug,
4040 .single_threaded = single_threaded,
......@@ -46,7 +46,7 @@ pub fn build(b: *std.Build) !void {
4646 docgen_cmd.addArg("--zig-lib-dir");
4747 docgen_cmd.addDirectoryArg(p);
4848 }
49 docgen_cmd.addFileArg(.{ .path = "doc/langref.html.in" });
49 docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
5050 const langref_file = docgen_cmd.addOutputFileArg("langref.html");
5151 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
5252 if (!skip_install_langref) {
......@@ -55,9 +55,9 @@ pub fn build(b: *std.Build) !void {
5555
5656 const autodoc_test = b.addObject(.{
5757 .name = "std",
58 .root_source_file = .{ .path = "lib/std/std.zig" },
58 .root_source_file = b.path("lib/std/std.zig"),
5959 .target = target,
60 .zig_lib_dir = .{ .path = "lib" },
60 .zig_lib_dir = b.path("lib"),
6161 .optimize = .Debug,
6262 });
6363 const install_std_docs = b.addInstallDirectory(.{
......@@ -86,7 +86,7 @@ pub fn build(b: *std.Build) !void {
8686
8787 const check_case_exe = b.addExecutable(.{
8888 .name = "check-case",
89 .root_source_file = .{ .path = "test/src/Cases.zig" },
89 .root_source_file = b.path("test/src/Cases.zig"),
9090 .target = b.host,
9191 .optimize = optimize,
9292 .single_threaded = single_threaded,
......@@ -135,7 +135,7 @@ pub fn build(b: *std.Build) !void {
135135
136136 if (!skip_install_lib_files) {
137137 b.installDirectory(.{
138 .source_dir = .{ .path = "lib" },
138 .source_dir = b.path("lib"),
139139 .install_dir = if (flat) .prefix else .lib,
140140 .install_subdir = if (flat) "lib" else "zig",
141141 .exclude_extensions = &[_][]const u8{
......@@ -552,10 +552,10 @@ pub fn build(b: *std.Build) !void {
552552 const update_mingw_exe = b.addExecutable(.{
553553 .name = "update_mingw",
554554 .target = b.host,
555 .root_source_file = .{ .path = "tools/update_mingw.zig" },
555 .root_source_file = b.path("tools/update_mingw.zig"),
556556 });
557557 const update_mingw_run = b.addRunArtifact(update_mingw_exe);
558 update_mingw_run.addDirectoryArg(.{ .path = "lib" });
558 update_mingw_run.addDirectoryArg(b.path("lib"));
559559 if (opt_mingw_src_path) |mingw_src_path| {
560560 update_mingw_run.addDirectoryArg(.{ .cwd_relative = mingw_src_path });
561561 } else {
......@@ -606,10 +606,10 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
606606 });
607607 run_opt.addArtifactArg(exe);
608608 run_opt.addArg("-o");
609 run_opt.addFileArg(.{ .path = "stage1/zig1.wasm" });
609 run_opt.addFileArg(b.path("stage1/zig1.wasm"));
610610
611611 const copy_zig_h = b.addWriteFiles();
612 copy_zig_h.addCopyFileToSource(.{ .path = "lib/zig.h" }, "stage1/zig.h");
612 copy_zig_h.addCopyFileToSource(b.path("lib/zig.h"), "stage1/zig.h");
613613
614614 const update_zig1_step = b.step("update-zig1", "Update stage1/zig1.wasm");
615615 update_zig1_step.dependOn(&run_opt.step);
......@@ -627,7 +627,7 @@ const AddCompilerStepOptions = struct {
627627fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.Step.Compile {
628628 const exe = b.addExecutable(.{
629629 .name = "zig",
630 .root_source_file = .{ .path = "src/main.zig" },
630 .root_source_file = b.path("src/main.zig"),
631631 .target = options.target,
632632 .optimize = options.optimize,
633633 .max_rss = 7_000_000_000,
......@@ -638,11 +638,11 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
638638 exe.stack_size = stack_size;
639639
640640 const aro_module = b.createModule(.{
641 .root_source_file = .{ .path = "lib/compiler/aro/aro.zig" },
641 .root_source_file = b.path("lib/compiler/aro/aro.zig"),
642642 });
643643
644644 const aro_translate_c_module = b.createModule(.{
645 .root_source_file = .{ .path = "lib/compiler/aro_translate_c.zig" },
645 .root_source_file = b.path("lib/compiler/aro_translate_c.zig"),
646646 .imports = &.{
647647 .{
648648 .name = "aro",
lib/std/Build.zig+18-11
......@@ -1546,22 +1546,22 @@ pub fn addInstallArtifact(
15461546}
15471547
15481548///`dest_rel_path` is relative to prefix path
1549pub fn installFile(self: *Build, src_path: []const u8, dest_rel_path: []const u8) void {
1550 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .prefix, dest_rel_path).step);
1549pub fn installFile(b: *Build, src_path: []const u8, dest_rel_path: []const u8) void {
1550 b.getInstallStep().dependOn(&b.addInstallFileWithDir(b.path(src_path), .prefix, dest_rel_path).step);
15511551}
15521552
1553pub fn installDirectory(self: *Build, options: Step.InstallDir.Options) void {
1554 self.getInstallStep().dependOn(&self.addInstallDirectory(options).step);
1553pub fn installDirectory(b: *Build, options: Step.InstallDir.Options) void {
1554 b.getInstallStep().dependOn(&b.addInstallDirectory(options).step);
15551555}
15561556
15571557///`dest_rel_path` is relative to bin path
1558pub fn installBinFile(self: *Build, src_path: []const u8, dest_rel_path: []const u8) void {
1559 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .bin, dest_rel_path).step);
1558pub fn installBinFile(b: *Build, src_path: []const u8, dest_rel_path: []const u8) void {
1559 b.getInstallStep().dependOn(&b.addInstallFileWithDir(b.path(src_path), .bin, dest_rel_path).step);
15601560}
15611561
15621562///`dest_rel_path` is relative to lib path
1563pub fn installLibFile(self: *Build, src_path: []const u8, dest_rel_path: []const u8) void {
1564 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .lib, dest_rel_path).step);
1563pub fn installLibFile(b: *Build, src_path: []const u8, dest_rel_path: []const u8) void {
1564 b.getInstallStep().dependOn(&b.addInstallFileWithDir(b.path(src_path), .lib, dest_rel_path).step);
15651565}
15661566
15671567pub fn addObjCopy(b: *Build, source: LazyPath, options: Step.ObjCopy.Options) *Step.ObjCopy {
......@@ -1637,7 +1637,11 @@ pub fn truncateFile(self: *Build, dest_path: []const u8) !void {
16371637
16381638/// References a file or directory relative to the source root.
16391639pub fn path(b: *Build, sub_path: []const u8) LazyPath {
1640 assert(!fs.path.isAbsolute(sub_path));
1640 if (fs.path.isAbsolute(sub_path)) {
1641 std.debug.panic("sub_path is expected to be relative to the build root, but was this absolute path: '{s}'. It is best avoid absolute paths, but if you must, it is supported by LazyPath.cwd_relative", .{
1642 sub_path,
1643 });
1644 }
16411645 return .{ .src_path = .{
16421646 .owner = b,
16431647 .sub_path = sub_path,
......@@ -2315,12 +2319,15 @@ pub const LazyPath = union(enum) {
23152319 }
23162320 }
23172321
2318 /// Duplicates the file source for a given builder.
2322 /// Copies the internal strings.
2323 ///
2324 /// The `b` parameter is only used for its allocator. All *Build instances
2325 /// share the same allocator.
23192326 pub fn dupe(self: LazyPath, b: *Build) LazyPath {
23202327 return switch (self) {
23212328 .src_path => |sp| .{ .src_path = .{
23222329 .owner = sp.owner,
2323 .sub_path = b.dupePath(sp.sub_path),
2330 .sub_path = sp.owner.dupePath(sp.sub_path),
23242331 } },
23252332 .path => |p| .{ .path = b.dupePath(p) },
23262333 .cwd_relative => |p| .{ .cwd_relative = b.dupePath(p) },
lib/std/Build/Module.zig+2-13
......@@ -451,7 +451,7 @@ pub fn linkFramework(m: *Module, name: []const u8, options: LinkFrameworkOptions
451451pub const AddCSourceFilesOptions = struct {
452452 /// When provided, `files` are relative to `root` rather than the
453453 /// package that owns the `Compile` step.
454 root: LazyPath = .{ .path = "" },
454 root: ?LazyPath = null,
455455 files: []const []const u8,
456456 flags: []const []const u8 = &.{},
457457};
......@@ -472,7 +472,7 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
472472
473473 const c_source_files = allocator.create(CSourceFiles) catch @panic("OOM");
474474 c_source_files.* = .{
475 .root = options.root,
475 .root = options.root orelse b.path(""),
476476 .files = b.dupeStrings(options.files),
477477 .flags = b.dupeStrings(options.flags),
478478 };
......@@ -573,17 +573,6 @@ pub fn addLibraryPath(m: *Module, directory_path: LazyPath) void {
573573
574574pub fn addRPath(m: *Module, directory_path: LazyPath) void {
575575 const b = m.owner;
576 switch (directory_path) {
577 .path, .cwd_relative => |path| {
578 // TODO: remove this check after people upgrade and stop expecting it to work
579 if (std.mem.startsWith(u8, path, "@executable_path") or
580 std.mem.startsWith(u8, path, "@loader_path"))
581 {
582 @panic("this function is for adding directory paths. It does not support special rpaths. use addRPathSpecial for that.");
583 }
584 },
585 else => {},
586 }
587576 m.rpaths.append(b.allocator, .{ .lazy_path = directory_path.dupe(b) }) catch @panic("OOM");
588577 addLazyPathDependenciesOnly(m, directory_path);
589578}
lib/std/Build/Step/Compile.zig+2-26
......@@ -264,20 +264,8 @@ pub const HeaderInstallation = union(enum) {
264264 dest_rel_path: []const u8,
265265
266266 pub fn dupe(self: File, b: *std.Build) File {
267 // 'path' lazy paths are relative to the build root of some step, inferred from the step
268 // in which they are used. This means that we can't dupe such paths, because they may
269 // come from dependencies with their own build roots and duping the paths as is might
270 // cause the build script to search for the file relative to the wrong root.
271 // As a temporary workaround, we convert build root-relative paths to absolute paths.
272 // If/when the build-root relative paths are updated to encode which build root they are
273 // relative to, this workaround should be removed.
274 const duped_source: LazyPath = switch (self.source) {
275 .path => |root_rel| .{ .cwd_relative = b.pathFromRoot(root_rel) },
276 else => self.source.dupe(b),
277 };
278
279267 return .{
280 .source = duped_source,
268 .source = self.source.dupe(b),
281269 .dest_rel_path = b.dupePath(self.dest_rel_path),
282270 };
283271 }
......@@ -305,20 +293,8 @@ pub const HeaderInstallation = union(enum) {
305293 };
306294
307295 pub fn dupe(self: Directory, b: *std.Build) Directory {
308 // 'path' lazy paths are relative to the build root of some step, inferred from the step
309 // in which they are used. This means that we can't dupe such paths, because they may
310 // come from dependencies with their own build roots and duping the paths as is might
311 // cause the build script to search for the file relative to the wrong root.
312 // As a temporary workaround, we convert build root-relative paths to absolute paths.
313 // If/when the build-root relative paths are updated to encode which build root they are
314 // relative to, this workaround should be removed.
315 const duped_source: LazyPath = switch (self.source) {
316 .path => |root_rel| .{ .cwd_relative = b.pathFromRoot(root_rel) },
317 else => self.source.dupe(b),
318 };
319
320296 return .{
321 .source = duped_source,
297 .source = self.source.dupe(b),
322298 .dest_rel_path = b.dupePath(self.dest_rel_path),
323299 .options = self.options.dupe(b),
324300 };
test/link/bss/build.zig+1-1
......@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
66
77 const exe = b.addExecutable(.{
88 .name = "bss",
9 .root_source_file = .{ .path = "main.zig" },
9 .root_source_file = b.path("main.zig"),
1010 .target = b.host,
1111 .optimize = .Debug,
1212 });
test/link/common_symbols/build.zig+1-1
......@@ -22,7 +22,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2222 });
2323
2424 const test_exe = b.addTest(.{
25 .root_source_file = .{ .path = "main.zig" },
25 .root_source_file = b.path("main.zig"),
2626 .optimize = optimize,
2727 });
2828 test_exe.linkLibrary(lib_a);
test/link/common_symbols_alignment/build.zig+1-1
......@@ -22,7 +22,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2222 });
2323
2424 const test_exe = b.addTest(.{
25 .root_source_file = .{ .path = "main.zig" },
25 .root_source_file = b.path("main.zig"),
2626 .optimize = optimize,
2727 });
2828 test_exe.linkLibrary(lib_a);
test/link/glibc_compat/build.zig+2-2
......@@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void {
2121 .{ .arch_os_abi = t },
2222 ) catch unreachable),
2323 });
24 exe.addCSourceFile(.{ .file = .{ .path = "main.c" } });
24 exe.addCSourceFile(.{ .file = b.path("main.c") });
2525 exe.linkLibC();
2626 // TODO: actually test the output
2727 _ = exe.getEmittedBin();
......@@ -45,7 +45,7 @@ pub fn build(b: *std.Build) void {
4545
4646 const exe = b.addExecutable(.{
4747 .name = t,
48 .root_source_file = .{ .path = "glibc_runtime_check.zig" },
48 .root_source_file = b.path("glibc_runtime_check.zig"),
4949 .target = target,
5050 });
5151 exe.linkLibC();
test/link/interdependent_static_c_libs/build.zig+6-6
......@@ -16,24 +16,24 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
1616 .optimize = optimize,
1717 .target = b.host,
1818 });
19 lib_a.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &[_][]const u8{} });
20 lib_a.addIncludePath(.{ .path = "." });
19 lib_a.addCSourceFile(.{ .file = b.path("a.c"), .flags = &[_][]const u8{} });
20 lib_a.addIncludePath(b.path("."));
2121
2222 const lib_b = b.addStaticLibrary(.{
2323 .name = "b",
2424 .optimize = optimize,
2525 .target = b.host,
2626 });
27 lib_b.addCSourceFile(.{ .file = .{ .path = "b.c" }, .flags = &[_][]const u8{} });
28 lib_b.addIncludePath(.{ .path = "." });
27 lib_b.addCSourceFile(.{ .file = b.path("b.c"), .flags = &[_][]const u8{} });
28 lib_b.addIncludePath(b.path("."));
2929
3030 const test_exe = b.addTest(.{
31 .root_source_file = .{ .path = "main.zig" },
31 .root_source_file = b.path("main.zig"),
3232 .optimize = optimize,
3333 });
3434 test_exe.linkLibrary(lib_a);
3535 test_exe.linkLibrary(lib_b);
36 test_exe.addIncludePath(.{ .path = "." });
36 test_exe.addIncludePath(b.path("."));
3737
3838 test_step.dependOn(&b.addRunArtifact(test_exe).step);
3939}
test/link/macho.zig+3-3
......@@ -836,9 +836,9 @@ fn testLinkDirectlyCppTbd(b: *Build, opts: Options) *Step {
836836 ,
837837 .cpp_source_flags = &.{ "-nostdlib++", "-nostdinc++" },
838838 });
839 exe.root_module.addSystemIncludePath(.{ .path = b.pathJoin(&.{ sdk, "/usr/include" }) });
840 exe.root_module.addIncludePath(.{ .path = b.pathJoin(&.{ sdk, "/usr/include/c++/v1" }) });
841 exe.root_module.addObjectFile(.{ .path = b.pathJoin(&.{ sdk, "/usr/lib/libc++.tbd" }) });
839 exe.root_module.addSystemIncludePath(b.path(b.pathJoin(&.{ sdk, "/usr/include" })));
840 exe.root_module.addIncludePath(b.path(b.pathJoin(&.{ sdk, "/usr/include/c++/v1" })));
841 exe.root_module.addObjectFile(b.path(b.pathJoin(&.{ sdk, "/usr/lib/libc++.tbd" })));
842842
843843 const check = exe.checkObject();
844844 check.checkInSymtab();
test/link/static_libs_from_object_files/build.zig+3-3
......@@ -57,7 +57,7 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
5757 {
5858 const exe = b.addExecutable(.{
5959 .name = "test1",
60 .root_source_file = .{ .path = "main.zig" },
60 .root_source_file = b.path("main.zig"),
6161 .optimize = optimize,
6262 .target = b.host,
6363 });
......@@ -93,7 +93,7 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
9393
9494 const exe = b.addExecutable(.{
9595 .name = "test2",
96 .root_source_file = .{ .path = "main.zig" },
96 .root_source_file = b.path("main.zig"),
9797 .target = b.host,
9898 .optimize = optimize,
9999 });
......@@ -134,7 +134,7 @@ fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.built
134134
135135 const exe = b.addExecutable(.{
136136 .name = "test3",
137 .root_source_file = .{ .path = "main.zig" },
137 .root_source_file = b.path("main.zig"),
138138 .target = b.host,
139139 .optimize = optimize,
140140 });
test/link/wasm/archive/build.zig+1-1
......@@ -17,7 +17,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
1717 // and therefore link with its archive file.
1818 const lib = b.addExecutable(.{
1919 .name = "main",
20 .root_source_file = .{ .path = "main.zig" },
20 .root_source_file = b.path("main.zig"),
2121 .optimize = optimize,
2222 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2323 .strip = false,
test/link/wasm/basic-features/build.zig+1-1
......@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
66 // Library with explicitly set cpu features
77 const lib = b.addExecutable(.{
88 .name = "lib",
9 .root_source_file = .{ .path = "main.zig" },
9 .root_source_file = b.path("main.zig"),
1010 .optimize = .Debug,
1111 .target = b.resolveTargetQuery(.{
1212 .cpu_arch = .wasm32,
test/link/wasm/bss/build.zig+2-2
......@@ -16,7 +16,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize_mode: std.builtin.Opt
1616 {
1717 const lib = b.addExecutable(.{
1818 .name = "lib",
19 .root_source_file = .{ .path = "lib.zig" },
19 .root_source_file = b.path("lib.zig"),
2020 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2121 .optimize = optimize_mode,
2222 .strip = false,
......@@ -64,7 +64,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize_mode: std.builtin.Opt
6464 {
6565 const lib = b.addExecutable(.{
6666 .name = "lib",
67 .root_source_file = .{ .path = "lib2.zig" },
67 .root_source_file = b.path("lib2.zig"),
6868 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
6969 .optimize = optimize_mode,
7070 .strip = false,
test/link/wasm/export-data/build.zig+1-1
......@@ -11,7 +11,7 @@ pub fn build(b: *std.Build) void {
1111
1212 const lib = b.addExecutable(.{
1313 .name = "lib",
14 .root_source_file = .{ .path = "lib.zig" },
14 .root_source_file = b.path("lib.zig"),
1515 .optimize = .ReleaseSafe, // to make the output deterministic in address positions
1616 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
1717 });
test/link/wasm/export/build.zig+3-3
......@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1616 const no_export = b.addExecutable(.{
1717 .name = "no-export",
18 .root_source_file = .{ .path = "main.zig" },
18 .root_source_file = b.path("main.zig"),
1919 .optimize = optimize,
2020 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2121 });
......@@ -25,7 +25,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2525
2626 const dynamic_export = b.addExecutable(.{
2727 .name = "dynamic",
28 .root_source_file = .{ .path = "main.zig" },
28 .root_source_file = b.path("main.zig"),
2929 .optimize = optimize,
3030 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
3131 });
......@@ -36,7 +36,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3636
3737 const force_export = b.addExecutable(.{
3838 .name = "force",
39 .root_source_file = .{ .path = "main.zig" },
39 .root_source_file = b.path("main.zig"),
4040 .optimize = optimize,
4141 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
4242 });
test/link/wasm/extern-mangle/build.zig+1-1
......@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {
1313fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1414 const lib = b.addExecutable(.{
1515 .name = "lib",
16 .root_source_file = .{ .path = "lib.zig" },
16 .root_source_file = b.path("lib.zig"),
1717 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
1818 .optimize = optimize,
1919 });
test/link/wasm/extern/build.zig+2-2
......@@ -15,11 +15,11 @@ pub fn build(b: *std.Build) void {
1515fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1616 const exe = b.addExecutable(.{
1717 .name = "extern",
18 .root_source_file = .{ .path = "main.zig" },
18 .root_source_file = b.path("main.zig"),
1919 .optimize = optimize,
2020 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .wasi }),
2121 });
22 exe.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} });
22 exe.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &.{} });
2323 exe.use_llvm = false;
2424 exe.use_lld = false;
2525
test/link/wasm/function-table/build.zig+3-3
......@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1616 const import_table = b.addExecutable(.{
1717 .name = "import_table",
18 .root_source_file = .{ .path = "lib.zig" },
18 .root_source_file = b.path("lib.zig"),
1919 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2020 .optimize = optimize,
2121 });
......@@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2727
2828 const export_table = b.addExecutable(.{
2929 .name = "export_table",
30 .root_source_file = .{ .path = "lib.zig" },
30 .root_source_file = b.path("lib.zig"),
3131 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
3232 .optimize = optimize,
3333 });
......@@ -39,7 +39,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3939
4040 const regular_table = b.addExecutable(.{
4141 .name = "regular_table",
42 .root_source_file = .{ .path = "lib.zig" },
42 .root_source_file = b.path("lib.zig"),
4343 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
4444 .optimize = optimize,
4545 });
test/link/wasm/infer-features/build.zig+2-2
......@@ -13,13 +13,13 @@ pub fn build(b: *std.Build) void {
1313 .os_tag = .freestanding,
1414 }),
1515 });
16 c_obj.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} });
16 c_obj.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &.{} });
1717
1818 // Wasm library that doesn't have any features specified. This will
1919 // infer its featureset from other linked object files.
2020 const lib = b.addExecutable(.{
2121 .name = "lib",
22 .root_source_file = .{ .path = "main.zig" },
22 .root_source_file = b.path("main.zig"),
2323 .optimize = .Debug,
2424 .target = b.resolveTargetQuery(.{
2525 .cpu_arch = .wasm32,
test/link/wasm/producers/build.zig+1-1
......@@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void {
1616fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1717 const lib = b.addExecutable(.{
1818 .name = "lib",
19 .root_source_file = .{ .path = "lib.zig" },
19 .root_source_file = b.path("lib.zig"),
2020 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2121 .optimize = optimize,
2222 .strip = false,
test/link/wasm/segments/build.zig+1-1
......@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1616 const lib = b.addExecutable(.{
1717 .name = "lib",
18 .root_source_file = .{ .path = "lib.zig" },
18 .root_source_file = b.path("lib.zig"),
1919 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2020 .optimize = optimize,
2121 .strip = false,
test/link/wasm/shared-memory/build.zig+1-1
......@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {
1313fn add(b: *std.Build, test_step: *std.Build.Step, optimize_mode: std.builtin.OptimizeMode) void {
1414 const exe = b.addExecutable(.{
1515 .name = "lib",
16 .root_source_file = .{ .path = "lib.zig" },
16 .root_source_file = b.path("lib.zig"),
1717 .target = b.resolveTargetQuery(.{
1818 .cpu_arch = .wasm32,
1919 .cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp },
test/link/wasm/stack_pointer/build.zig+1-1
......@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1616 const lib = b.addExecutable(.{
1717 .name = "lib",
18 .root_source_file = .{ .path = "lib.zig" },
18 .root_source_file = b.path("lib.zig"),
1919 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2020 .optimize = optimize,
2121 .strip = false,
test/link/wasm/type/build.zig+1-1
......@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1616 const exe = b.addExecutable(.{
1717 .name = "lib",
18 .root_source_file = .{ .path = "lib.zig" },
18 .root_source_file = b.path("lib.zig"),
1919 .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
2020 .optimize = optimize,
2121 .strip = false,
test/standalone/build.zig+1-1
......@@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void {
4444 }) |tool_src_path| {
4545 const tool = b.addTest(.{
4646 .name = std.fs.path.stem(tool_src_path),
47 .root_source_file = .{ .path = tool_src_path },
47 .root_source_file = b.path(tool_src_path),
4848 .optimize = .Debug,
4949 .target = tools_target,
5050 });
test/standalone/c_compiler/build.zig+2-2
......@@ -30,7 +30,7 @@ fn add(
3030 .optimize = optimize,
3131 .target = target,
3232 });
33 exe_c.addCSourceFile(.{ .file = .{ .path = "test.c" }, .flags = &[0][]const u8{} });
33 exe_c.addCSourceFile(.{ .file = b.path("test.c"), .flags = &[0][]const u8{} });
3434 exe_c.linkLibC();
3535
3636 const exe_cpp = b.addExecutable(.{
......@@ -39,7 +39,7 @@ fn add(
3939 .target = target,
4040 });
4141 b.default_step.dependOn(&exe_cpp.step);
42 exe_cpp.addCSourceFile(.{ .file = .{ .path = "test.cpp" }, .flags = &[0][]const u8{} });
42 exe_cpp.addCSourceFile(.{ .file = b.path("test.cpp"), .flags = &[0][]const u8{} });
4343 exe_cpp.linkLibCpp();
4444
4545 switch (target.result.os.tag) {
test/standalone/child_process/build.zig+2-2
......@@ -12,14 +12,14 @@ pub fn build(b: *std.Build) void {
1212
1313 const child = b.addExecutable(.{
1414 .name = "child",
15 .root_source_file = .{ .path = "child.zig" },
15 .root_source_file = b.path("child.zig"),
1616 .optimize = optimize,
1717 .target = target,
1818 });
1919
2020 const main = b.addExecutable(.{
2121 .name = "main",
22 .root_source_file = .{ .path = "main.zig" },
22 .root_source_file = b.path("main.zig"),
2323 .optimize = optimize,
2424 .target = target,
2525 });
test/standalone/cmakedefine/build.zig+5-5
......@@ -4,7 +4,7 @@ const ConfigHeader = std.Build.Step.ConfigHeader;
44pub fn build(b: *std.Build) void {
55 const config_header = b.addConfigHeader(
66 .{
7 .style = .{ .cmake = .{ .path = "config.h.in" } },
7 .style = .{ .cmake = b.path("config.h.in") },
88 .include_path = "config.h",
99 },
1010 .{
......@@ -28,7 +28,7 @@ pub fn build(b: *std.Build) void {
2828
2929 const pwd_sh = b.addConfigHeader(
3030 .{
31 .style = .{ .cmake = .{ .path = "pwd.sh.in" } },
31 .style = .{ .cmake = b.path("pwd.sh.in") },
3232 .include_path = "pwd.sh",
3333 },
3434 .{ .DIR = "${PWD}" },
......@@ -36,7 +36,7 @@ pub fn build(b: *std.Build) void {
3636
3737 const sigil_header = b.addConfigHeader(
3838 .{
39 .style = .{ .cmake = .{ .path = "sigil.h.in" } },
39 .style = .{ .cmake = b.path("sigil.h.in") },
4040 .include_path = "sigil.h",
4141 },
4242 .{},
......@@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void {
4444
4545 const stack_header = b.addConfigHeader(
4646 .{
47 .style = .{ .cmake = .{ .path = "stack.h.in" } },
47 .style = .{ .cmake = b.path("stack.h.in") },
4848 .include_path = "stack.h",
4949 },
5050 .{
......@@ -57,7 +57,7 @@ pub fn build(b: *std.Build) void {
5757
5858 const wrapper_header = b.addConfigHeader(
5959 .{
60 .style = .{ .cmake = .{ .path = "wrapper.h.in" } },
60 .style = .{ .cmake = b.path("wrapper.h.in") },
6161 .include_path = "wrapper.h",
6262 },
6363 .{
test/standalone/compiler_rt_panic/build.zig+1-1
......@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
1717 });
1818 exe.linkLibC();
1919 exe.addCSourceFile(.{
20 .file = .{ .path = "main.c" },
20 .file = b.path("main.c"),
2121 .flags = &.{},
2222 });
2323 exe.link_gc_sections = false;
test/standalone/dep_diamond/build.zig+4-4
......@@ -7,21 +7,21 @@ pub fn build(b: *std.Build) void {
77 const optimize: std.builtin.OptimizeMode = .Debug;
88
99 const shared = b.createModule(.{
10 .root_source_file = .{ .path = "shared.zig" },
10 .root_source_file = b.path("shared.zig"),
1111 });
1212
1313 const exe = b.addExecutable(.{
1414 .name = "test",
15 .root_source_file = .{ .path = "test.zig" },
15 .root_source_file = b.path("test.zig"),
1616 .target = b.host,
1717 .optimize = optimize,
1818 });
1919 exe.root_module.addAnonymousImport("foo", .{
20 .root_source_file = .{ .path = "foo.zig" },
20 .root_source_file = b.path("foo.zig"),
2121 .imports = &.{.{ .name = "shared", .module = shared }},
2222 });
2323 exe.root_module.addAnonymousImport("bar", .{
24 .root_source_file = .{ .path = "bar.zig" },
24 .root_source_file = b.path("bar.zig"),
2525 .imports = &.{.{ .name = "shared", .module = shared }},
2626 });
2727
test/standalone/dep_mutually_recursive/build.zig+3-3
......@@ -7,17 +7,17 @@ pub fn build(b: *std.Build) void {
77 const optimize: std.builtin.OptimizeMode = .Debug;
88
99 const foo = b.createModule(.{
10 .root_source_file = .{ .path = "foo.zig" },
10 .root_source_file = b.path("foo.zig"),
1111 });
1212 const bar = b.createModule(.{
13 .root_source_file = .{ .path = "bar.zig" },
13 .root_source_file = b.path("bar.zig"),
1414 });
1515 foo.addImport("bar", bar);
1616 bar.addImport("foo", foo);
1717
1818 const exe = b.addExecutable(.{
1919 .name = "test",
20 .root_source_file = .{ .path = "test.zig" },
20 .root_source_file = b.path("test.zig"),
2121 .target = b.host,
2222 .optimize = optimize,
2323 });
test/standalone/dep_recursive/build.zig+2-2
......@@ -7,13 +7,13 @@ pub fn build(b: *std.Build) void {
77 const optimize: std.builtin.OptimizeMode = .Debug;
88
99 const foo = b.createModule(.{
10 .root_source_file = .{ .path = "foo.zig" },
10 .root_source_file = b.path("foo.zig"),
1111 });
1212 foo.addImport("foo", foo);
1313
1414 const exe = b.addExecutable(.{
1515 .name = "test",
16 .root_source_file = .{ .path = "test.zig" },
16 .root_source_file = b.path("test.zig"),
1717 .target = b.host,
1818 .optimize = optimize,
1919 });
test/standalone/dep_shared_builtin/build.zig+2-2
......@@ -8,12 +8,12 @@ pub fn build(b: *std.Build) void {
88
99 const exe = b.addExecutable(.{
1010 .name = "test",
11 .root_source_file = .{ .path = "test.zig" },
11 .root_source_file = b.path("test.zig"),
1212 .target = b.host,
1313 .optimize = optimize,
1414 });
1515 exe.root_module.addAnonymousImport("foo", .{
16 .root_source_file = .{ .path = "foo.zig" },
16 .root_source_file = b.path("foo.zig"),
1717 });
1818
1919 const run = b.addRunArtifact(exe);
test/standalone/dep_triangle/build.zig+3-3
......@@ -7,17 +7,17 @@ pub fn build(b: *std.Build) void {
77 const optimize: std.builtin.OptimizeMode = .Debug;
88
99 const shared = b.createModule(.{
10 .root_source_file = .{ .path = "shared.zig" },
10 .root_source_file = b.path("shared.zig"),
1111 });
1212
1313 const exe = b.addExecutable(.{
1414 .name = "test",
15 .root_source_file = .{ .path = "test.zig" },
15 .root_source_file = b.path("test.zig"),
1616 .target = b.host,
1717 .optimize = optimize,
1818 });
1919 exe.root_module.addAnonymousImport("foo", .{
20 .root_source_file = .{ .path = "foo.zig" },
20 .root_source_file = b.path("foo.zig"),
2121 .imports = &.{.{ .name = "shared", .module = shared }},
2222 });
2323 exe.root_module.addImport("shared", shared);
test/standalone/depend_on_main_mod/build.zig+2-2
......@@ -9,13 +9,13 @@ pub fn build(b: *std.Build) void {
99
1010 const exe = b.addExecutable(.{
1111 .name = "depend_on_main_mod",
12 .root_source_file = .{ .path = "src/main.zig" },
12 .root_source_file = b.path("src/main.zig"),
1313 .target = target,
1414 .optimize = optimize,
1515 });
1616
1717 const foo_module = b.addModule("foo", .{
18 .root_source_file = .{ .path = "src/foo.zig" },
18 .root_source_file = b.path("src/foo.zig"),
1919 });
2020
2121 foo_module.addImport("root2", &exe.root_module);
test/standalone/dirname/build.zig+3-5
......@@ -6,9 +6,7 @@ pub fn build(b: *std.Build) void {
66 const test_step = b.step("test", "Test it");
77 b.default_step = test_step;
88
9 const touch_src = std.Build.LazyPath{
10 .path = "touch.zig",
11 };
9 const touch_src = b.path("touch.zig");
1210
1311 const touch = b.addExecutable(.{
1412 .name = "touch",
......@@ -20,14 +18,14 @@ pub fn build(b: *std.Build) void {
2018
2119 const exists_in = b.addExecutable(.{
2220 .name = "exists_in",
23 .root_source_file = .{ .path = "exists_in.zig" },
21 .root_source_file = b.path("exists_in.zig"),
2422 .optimize = .Debug,
2523 .target = target,
2624 });
2725
2826 const has_basename = b.addExecutable(.{
2927 .name = "has_basename",
30 .root_source_file = .{ .path = "has_basename.zig" },
28 .root_source_file = b.path("has_basename.zig"),
3129 .optimize = .Debug,
3230 .target = target,
3331 });
test/standalone/embed_generated_file/build.zig+2-2
......@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
66
77 const bootloader = b.addExecutable(.{
88 .name = "bootloader",
9 .root_source_file = .{ .path = "bootloader.zig" },
9 .root_source_file = b.path("bootloader.zig"),
1010 .target = b.resolveTargetQuery(.{
1111 .cpu_arch = .x86,
1212 .os_tag = .freestanding,
......@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515 });
1616
1717 const exe = b.addTest(.{
18 .root_source_file = .{ .path = "main.zig" },
18 .root_source_file = b.path("main.zig"),
1919 .optimize = .Debug,
2020 });
2121 exe.root_module.addAnonymousImport("bootloader.elf", .{
test/standalone/empty_env/build.zig+1-1
......@@ -14,7 +14,7 @@ pub fn build(b: *std.Build) void {
1414
1515 const main = b.addExecutable(.{
1616 .name = "main",
17 .root_source_file = .{ .path = "main.zig" },
17 .root_source_file = b.path("main.zig"),
1818 .target = b.host,
1919 .optimize = optimize,
2020 });
test/standalone/extern/build.zig+2-2
......@@ -5,12 +5,12 @@ pub fn build(b: *std.Build) void {
55
66 const obj = b.addObject(.{
77 .name = "exports",
8 .root_source_file = .{ .path = "exports.zig" },
8 .root_source_file = b.path("exports.zig"),
99 .target = b.host,
1010 .optimize = optimize,
1111 });
1212 const main = b.addTest(.{
13 .root_source_file = .{ .path = "main.zig" },
13 .root_source_file = b.path("main.zig"),
1414 .optimize = optimize,
1515 });
1616 main.addObject(obj);
test/standalone/global_linkage/build.zig+3-3
......@@ -9,20 +9,20 @@ pub fn build(b: *std.Build) void {
99
1010 const obj1 = b.addStaticLibrary(.{
1111 .name = "obj1",
12 .root_source_file = .{ .path = "obj1.zig" },
12 .root_source_file = b.path("obj1.zig"),
1313 .optimize = optimize,
1414 .target = target,
1515 });
1616
1717 const obj2 = b.addStaticLibrary(.{
1818 .name = "obj2",
19 .root_source_file = .{ .path = "obj2.zig" },
19 .root_source_file = b.path("obj2.zig"),
2020 .optimize = optimize,
2121 .target = target,
2222 });
2323
2424 const main = b.addTest(.{
25 .root_source_file = .{ .path = "main.zig" },
25 .root_source_file = b.path("main.zig"),
2626 .optimize = optimize,
2727 });
2828 main.linkLibrary(obj1);
test/standalone/install_headers/build.zig+2-2
......@@ -32,7 +32,7 @@ pub fn build(b: *std.Build) void {
3232 \\}
3333 ) });
3434
35 libfoo.installHeadersDirectory(.{ .path = "include" }, "foo", .{ .exclude_extensions = &.{".ignore_me.h"} });
35 libfoo.installHeadersDirectory(b.path("include"), "foo", .{ .exclude_extensions = &.{".ignore_me.h"} });
3636 libfoo.installHeader(b.addWriteFiles().add("d.h",
3737 \\#define FOO_D "D"
3838 \\
......@@ -78,7 +78,7 @@ pub fn build(b: *std.Build) void {
7878 });
7979 const check_exists = b.addExecutable(.{
8080 .name = "check_exists",
81 .root_source_file = .{ .path = "check_exists.zig" },
81 .root_source_file = b.path("check_exists.zig"),
8282 .target = b.resolveTargetQuery(.{}),
8383 .optimize = .Debug,
8484 });
test/standalone/install_raw_hex/build.zig+1-1
......@@ -16,7 +16,7 @@ pub fn build(b: *std.Build) void {
1616
1717 const elf = b.addExecutable(.{
1818 .name = "zig-nrf52-blink.elf",
19 .root_source_file = .{ .path = "main.zig" },
19 .root_source_file = b.path("main.zig"),
2020 .target = target,
2121 .optimize = optimize,
2222 });
test/standalone/ios/build.zig+4-4
......@@ -21,10 +21,10 @@ pub fn build(b: *std.Build) void {
2121 .optimize = optimize,
2222 .target = target,
2323 });
24 exe.addCSourceFile(.{ .file = .{ .path = "main.m" }, .flags = &.{} });
25 exe.addSystemIncludePath(.{ .path = b.pathJoin(&.{ sdk, "/usr/include" }) });
26 exe.addSystemFrameworkPath(.{ .path = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
27 exe.addLibraryPath(.{ .path = b.pathJoin(&.{ sdk, "/usr/lib" }) });
24 exe.addCSourceFile(.{ .file = b.path("main.m"), .flags = &.{} });
25 exe.addSystemIncludePath(b.path(b.pathJoin(&.{ sdk, "/usr/include" })));
26 exe.addSystemFrameworkPath(b.path(b.pathJoin(&.{ sdk, "/System/Library/Frameworks" })));
27 exe.addLibraryPath(b.path(b.pathJoin(&.{ sdk, "/usr/lib" })));
2828 exe.linkFramework("Foundation");
2929 exe.linkFramework("UIKit");
3030 exe.linkLibC();
test/standalone/issue_11595/build.zig+1-1
......@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515
1616 const exe = b.addExecutable(.{
1717 .name = "zigtest",
18 .root_source_file = .{ .path = "main.zig" },
18 .root_source_file = b.path("main.zig"),
1919 .target = target,
2020 .optimize = optimize,
2121 });
test/standalone/issue_12706/build.zig+1-1
......@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {
1010
1111 const exe = b.addExecutable(.{
1212 .name = "main",
13 .root_source_file = .{ .path = "main.zig" },
13 .root_source_file = b.path("main.zig"),
1414 .optimize = optimize,
1515 .target = target,
1616 });
test/standalone/issue_339/build.zig+1-1
......@@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
99
1010 const obj = b.addObject(.{
1111 .name = "test",
12 .root_source_file = .{ .path = "test.zig" },
12 .root_source_file = b.path("test.zig"),
1313 .target = target,
1414 .optimize = optimize,
1515 });
test/standalone/issue_794/build.zig+2-2
......@@ -5,9 +5,9 @@ pub fn build(b: *std.Build) void {
55 b.default_step = test_step;
66
77 const test_artifact = b.addTest(.{
8 .root_source_file = .{ .path = "main.zig" },
8 .root_source_file = b.path("main.zig"),
99 });
10 test_artifact.addIncludePath(.{ .path = "a_directory" });
10 test_artifact.addIncludePath(b.path("a_directory"));
1111
1212 // TODO: actually check the output
1313 _ = test_artifact.getEmittedBin();
test/standalone/issue_8550/build.zig+3-3
......@@ -15,12 +15,12 @@ pub fn build(b: *std.Build) !void {
1515
1616 const kernel = b.addExecutable(.{
1717 .name = "kernel",
18 .root_source_file = .{ .path = "./main.zig" },
18 .root_source_file = b.path("./main.zig"),
1919 .optimize = optimize,
2020 .target = target,
2121 });
22 kernel.addObjectFile(.{ .path = "./boot.S" });
23 kernel.setLinkerScript(.{ .path = "./linker.ld" });
22 kernel.addObjectFile(b.path("./boot.S"));
23 kernel.setLinkerScript(b.path("./linker.ld"));
2424 b.installArtifact(kernel);
2525
2626 test_step.dependOn(&kernel.step);
test/standalone/load_dynamic_library/build.zig+2-2
......@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
1717
1818 const lib = b.addSharedLibrary(.{
1919 .name = "add",
20 .root_source_file = .{ .path = "add.zig" },
20 .root_source_file = b.path("add.zig"),
2121 .version = .{ .major = 1, .minor = 0, .patch = 0 },
2222 .optimize = optimize,
2323 .target = target,
......@@ -25,7 +25,7 @@ pub fn build(b: *std.Build) void {
2525
2626 const main = b.addExecutable(.{
2727 .name = "main",
28 .root_source_file = .{ .path = "main.zig" },
28 .root_source_file = b.path("main.zig"),
2929 .optimize = optimize,
3030 .target = target,
3131 });
test/standalone/mix_c_files/build.zig+2-2
......@@ -18,11 +18,11 @@ pub fn build(b: *std.Build) void {
1818fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1919 const exe = b.addExecutable(.{
2020 .name = "test",
21 .root_source_file = .{ .path = "main.zig" },
21 .root_source_file = b.path("main.zig"),
2222 .target = b.host,
2323 .optimize = optimize,
2424 });
25 exe.addCSourceFile(.{ .file = .{ .path = "test.c" }, .flags = &[_][]const u8{"-std=c11"} });
25 exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &[_][]const u8{"-std=c11"} });
2626 exe.linkLibC();
2727
2828 const run_cmd = b.addRunArtifact(exe);
test/standalone/mix_o_files/build.zig+2-2
......@@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
99
1010 const obj = b.addObject(.{
1111 .name = "base64",
12 .root_source_file = .{ .path = "base64.zig" },
12 .root_source_file = b.path("base64.zig"),
1313 .optimize = optimize,
1414 .target = target,
1515 });
......@@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void {
2020 .target = target,
2121 });
2222 exe.addCSourceFile(.{
23 .file = .{ .path = "test.c" },
23 .file = b.path("test.c"),
2424 .flags = &[_][]const u8{"-std=c99"},
2525 });
2626 exe.addObject(obj);
test/standalone/pie/build.zig+1-1
......@@ -11,7 +11,7 @@ pub fn build(b: *std.Build) void {
1111 });
1212
1313 const main = b.addTest(.{
14 .root_source_file = .{ .path = "main.zig" },
14 .root_source_file = b.path("main.zig"),
1515 .optimize = optimize,
1616 .target = target,
1717 });
test/standalone/pkg_import/build.zig+2-2
......@@ -8,11 +8,11 @@ pub fn build(b: *std.Build) void {
88
99 const exe = b.addExecutable(.{
1010 .name = "test",
11 .root_source_file = .{ .path = "test.zig" },
11 .root_source_file = b.path("test.zig"),
1212 .optimize = optimize,
1313 .target = b.host,
1414 });
15 exe.root_module.addAnonymousImport("my_pkg", .{ .root_source_file = .{ .path = "pkg.zig" } });
15 exe.root_module.addAnonymousImport("my_pkg", .{ .root_source_file = b.path("pkg.zig") });
1616
1717 const run = b.addRunArtifact(exe);
1818 test_step.dependOn(&run.step);
test/standalone/self_exe_symlink/build.zig+2-2
......@@ -15,14 +15,14 @@ pub fn build(b: *std.Build) void {
1515
1616 const main = b.addExecutable(.{
1717 .name = "main",
18 .root_source_file = .{ .path = "main.zig" },
18 .root_source_file = b.path("main.zig"),
1919 .optimize = optimize,
2020 .target = target,
2121 });
2222
2323 const create_symlink_exe = b.addExecutable(.{
2424 .name = "create-symlink",
25 .root_source_file = .{ .path = "create-symlink.zig" },
25 .root_source_file = b.path("create-symlink.zig"),
2626 .optimize = optimize,
2727 .target = target,
2828 });
test/standalone/shared_library/build.zig+2-2
......@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {
1313 const target = b.host;
1414 const lib = b.addSharedLibrary(.{
1515 .name = "mathtest",
16 .root_source_file = .{ .path = "mathtest.zig" },
16 .root_source_file = b.path("mathtest.zig"),
1717 .version = .{ .major = 1, .minor = 0, .patch = 0 },
1818 .target = target,
1919 .optimize = optimize,
......@@ -25,7 +25,7 @@ pub fn build(b: *std.Build) void {
2525 .optimize = optimize,
2626 });
2727 exe.addCSourceFile(.{
28 .file = .{ .path = "test.c" },
28 .file = b.path("test.c"),
2929 .flags = &[_][]const u8{"-std=c99"},
3030 });
3131 exe.linkLibrary(lib);
test/standalone/simple/build.zig+2-2
......@@ -42,7 +42,7 @@ pub fn build(b: *std.Build) void {
4242 if (case.is_exe) {
4343 const exe = b.addExecutable(.{
4444 .name = std.fs.path.stem(case.src_path),
45 .root_source_file = .{ .path = case.src_path },
45 .root_source_file = b.path(case.src_path),
4646 .optimize = optimize,
4747 .target = resolved_target,
4848 });
......@@ -56,7 +56,7 @@ pub fn build(b: *std.Build) void {
5656 if (case.is_test) {
5757 const exe = b.addTest(.{
5858 .name = std.fs.path.stem(case.src_path),
59 .root_source_file = .{ .path = case.src_path },
59 .root_source_file = b.path(case.src_path),
6060 .optimize = optimize,
6161 .target = resolved_target,
6262 });
test/standalone/stack_iterator/build.zig+4-4
......@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
1919 {
2020 const exe = b.addExecutable(.{
2121 .name = "unwind_fp",
22 .root_source_file = .{ .path = "unwind.zig" },
22 .root_source_file = b.path("unwind.zig"),
2323 .target = target,
2424 .optimize = optimize,
2525 .unwind_tables = if (target.result.isDarwin()) true else null,
......@@ -42,7 +42,7 @@ pub fn build(b: *std.Build) void {
4242 {
4343 const exe = b.addExecutable(.{
4444 .name = "unwind_nofp",
45 .root_source_file = .{ .path = "unwind.zig" },
45 .root_source_file = b.path("unwind.zig"),
4646 .target = target,
4747 .optimize = optimize,
4848 .unwind_tables = true,
......@@ -74,14 +74,14 @@ pub fn build(b: *std.Build) void {
7474 c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");
7575
7676 c_shared_lib.addCSourceFile(.{
77 .file = .{ .path = "shared_lib.c" },
77 .file = b.path("shared_lib.c"),
7878 .flags = &.{"-fomit-frame-pointer"},
7979 });
8080 c_shared_lib.linkLibC();
8181
8282 const exe = b.addExecutable(.{
8383 .name = "shared_lib_unwind",
84 .root_source_file = .{ .path = "shared_lib_unwind.zig" },
84 .root_source_file = b.path("shared_lib_unwind.zig"),
8585 .target = target,
8686 .optimize = optimize,
8787 .unwind_tables = if (target.result.isDarwin()) true else null,
test/standalone/static_c_lib/build.zig+4-4
......@@ -11,15 +11,15 @@ pub fn build(b: *std.Build) void {
1111 .optimize = optimize,
1212 .target = b.host,
1313 });
14 foo.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &[_][]const u8{} });
15 foo.addIncludePath(.{ .path = "." });
14 foo.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &[_][]const u8{} });
15 foo.addIncludePath(b.path("."));
1616
1717 const test_exe = b.addTest(.{
18 .root_source_file = .{ .path = "foo.zig" },
18 .root_source_file = b.path("foo.zig"),
1919 .optimize = optimize,
2020 });
2121 test_exe.linkLibrary(foo);
22 test_exe.addIncludePath(.{ .path = "." });
22 test_exe.addIncludePath(b.path("."));
2323
2424 test_step.dependOn(&b.addRunArtifact(test_exe).step);
2525}
test/standalone/strip_empty_loop/build.zig+1-1
......@@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
99
1010 const main = b.addExecutable(.{
1111 .name = "main",
12 .root_source_file = .{ .path = "main.zig" },
12 .root_source_file = b.path("main.zig"),
1313 .optimize = optimize,
1414 .target = target,
1515 .strip = true,
test/standalone/strip_struct_init/build.zig+1-1
......@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
77 const optimize: std.builtin.OptimizeMode = .Debug;
88
99 const main = b.addTest(.{
10 .root_source_file = .{ .path = "main.zig" },
10 .root_source_file = b.path("main.zig"),
1111 .optimize = optimize,
1212 .strip = true,
1313 });
test/standalone/test_runner_module_imports/build.zig+3-3
......@@ -2,13 +2,13 @@ const std = @import("std");
22
33pub fn build(b: *std.Build) void {
44 const t = b.addTest(.{
5 .root_source_file = .{ .path = "src/main.zig" },
5 .root_source_file = b.path("src/main.zig"),
66 .test_runner = b.path("test_runner/main.zig"),
77 });
88
9 const module1 = b.createModule(.{ .root_source_file = .{ .path = "module1/main.zig" } });
9 const module1 = b.createModule(.{ .root_source_file = b.path("module1/main.zig") });
1010 const module2 = b.createModule(.{
11 .root_source_file = .{ .path = "module2/main.zig" },
11 .root_source_file = b.path("module2/main.zig"),
1212 .imports = &.{.{ .name = "module1", .module = module1 }},
1313 });
1414
test/standalone/test_runner_path/build.zig+1-1
......@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
77 b.default_step = test_step;
88
99 const test_exe = b.addTest(.{
10 .root_source_file = .{ .path = "test.zig" },
10 .root_source_file = b.path("test.zig"),
1111 });
1212 test_exe.test_runner = b.path("test_runner.zig");
1313
test/standalone/use_alias/build.zig+2-2
......@@ -7,10 +7,10 @@ pub fn build(b: *std.Build) void {
77 const optimize: std.builtin.OptimizeMode = .Debug;
88
99 const main = b.addTest(.{
10 .root_source_file = .{ .path = "main.zig" },
10 .root_source_file = b.path("main.zig"),
1111 .optimize = optimize,
1212 });
13 main.addIncludePath(.{ .path = "." });
13 main.addIncludePath(b.path("."));
1414
1515 test_step.dependOn(&b.addRunArtifact(main).step);
1616}
test/standalone/windows_entry_points/build.zig+4-4
......@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
1717 .optimize = .Debug,
1818 .link_libc = true,
1919 });
20 exe.addCSourceFile(.{ .file = .{ .path = "main.c" } });
20 exe.addCSourceFile(.{ .file = b.path("main.c") });
2121
2222 _ = exe.getEmittedBin();
2323 test_step.dependOn(&exe.step);
......@@ -31,7 +31,7 @@ pub fn build(b: *std.Build) void {
3131 .link_libc = true,
3232 });
3333 exe.mingw_unicode_entry_point = true;
34 exe.addCSourceFile(.{ .file = .{ .path = "wmain.c" } });
34 exe.addCSourceFile(.{ .file = b.path("wmain.c") });
3535
3636 _ = exe.getEmittedBin();
3737 test_step.dependOn(&exe.step);
......@@ -45,7 +45,7 @@ pub fn build(b: *std.Build) void {
4545 .link_libc = true,
4646 });
4747 // Note: `exe.subsystem = .Windows;` is not necessary
48 exe.addCSourceFile(.{ .file = .{ .path = "winmain.c" } });
48 exe.addCSourceFile(.{ .file = b.path("winmain.c") });
4949
5050 _ = exe.getEmittedBin();
5151 test_step.dependOn(&exe.step);
......@@ -60,7 +60,7 @@ pub fn build(b: *std.Build) void {
6060 });
6161 exe.mingw_unicode_entry_point = true;
6262 // Note: `exe.subsystem = .Windows;` is not necessary
63 exe.addCSourceFile(.{ .file = .{ .path = "wwinmain.c" } });
63 exe.addCSourceFile(.{ .file = b.path("wwinmain.c") });
6464
6565 _ = exe.getEmittedBin();
6666 test_step.dependOn(&exe.step);
test/standalone/windows_resources/build.zig+2-2
......@@ -25,12 +25,12 @@ fn add(
2525) void {
2626 const exe = b.addExecutable(.{
2727 .name = "zig_resource_test",
28 .root_source_file = .{ .path = "main.zig" },
28 .root_source_file = b.path("main.zig"),
2929 .target = target,
3030 .optimize = .Debug,
3131 });
3232 exe.addWin32ResourceFile(.{
33 .file = .{ .path = "res/zig.rc" },
33 .file = b.path("res/zig.rc"),
3434 .flags = &.{"/c65001"}, // UTF-8 code page
3535 });
3636 exe.rc_includes = switch (rc_includes) {
test/standalone/zerolength_check/build.zig+1-1
......@@ -12,7 +12,7 @@ pub fn build(b: *std.Build) void {
1212
1313fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
1414 const unit_tests = b.addTest(.{
15 .root_source_file = .{ .path = "src/main.zig" },
15 .root_source_file = b.path("src/main.zig"),
1616 .target = b.resolveTargetQuery(.{
1717 .os_tag = .wasi,
1818 .cpu_arch = .wasm32,
test/tests.zig+9-9
......@@ -641,7 +641,7 @@ pub fn addStackTraceTests(
641641) *Step {
642642 const check_exe = b.addExecutable(.{
643643 .name = "check-stack-trace",
644 .root_source_file = .{ .path = "test/src/check-stack-trace.zig" },
644 .root_source_file = b.path("test/src/check-stack-trace.zig"),
645645 .target = b.host,
646646 .optimize = .Debug,
647647 });
......@@ -879,7 +879,7 @@ pub fn addCliTests(b: *std.Build) *Step {
879879 run6.step.dependOn(&write6.step);
880880
881881 // TODO change this to an exact match
882 const check6 = b.addCheckFile(.{ .path = fmt6_path }, .{
882 const check6 = b.addCheckFile(.{ .cwd_relative = fmt6_path }, .{
883883 .expected_matches = &.{
884884 "// no reason",
885885 },
......@@ -1037,7 +1037,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10371037 options.max_rss;
10381038
10391039 const these_tests = b.addTest(.{
1040 .root_source_file = .{ .path = options.root_src },
1040 .root_source_file = b.path(options.root_src),
10411041 .optimize = test_target.optimize_mode,
10421042 .target = resolved_target,
10431043 .max_rss = max_rss,
......@@ -1046,7 +1046,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10461046 .single_threaded = test_target.single_threaded,
10471047 .use_llvm = test_target.use_llvm,
10481048 .use_lld = test_target.use_lld,
1049 .zig_lib_dir = .{ .path = "lib" },
1049 .zig_lib_dir = b.path("lib"),
10501050 .pic = test_target.pic,
10511051 .strip = test_target.strip,
10521052 });
......@@ -1062,7 +1062,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10621062 const use_lld = if (test_target.use_lld == false) "-no-lld" else "";
10631063 const use_pic = if (test_target.pic == true) "-pic" else "";
10641064
1065 for (options.include_paths) |include_path| these_tests.addIncludePath(.{ .path = include_path });
1065 for (options.include_paths) |include_path| these_tests.addIncludePath(b.path(include_path));
10661066
10671067 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}", .{
10681068 options.name,
......@@ -1084,7 +1084,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10841084 .name = qualified_name,
10851085 .link_libc = test_target.link_libc,
10861086 .target = b.resolveTargetQuery(altered_query),
1087 .zig_lib_dir = .{ .path = "lib" },
1087 .zig_lib_dir = b.path("lib"),
10881088 });
10891089 compile_c.addCSourceFile(.{
10901090 .file = these_tests.getEmittedBin(),
......@@ -1113,7 +1113,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
11131113 "-Wno-absolute-value",
11141114 },
11151115 });
1116 compile_c.addIncludePath(.{ .path = "lib" }); // for zig.h
1116 compile_c.addIncludePath(b.path("lib")); // for zig.h
11171117 if (target.os.tag == .windows) {
11181118 if (true) {
11191119 // Unfortunately this requires about 8G of RAM for clang to compile
......@@ -1189,7 +1189,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
11891189 if (c_abi_target.use_lld == false) "-no-lld" else "",
11901190 if (c_abi_target.pic == true) "-pic" else "",
11911191 }),
1192 .root_source_file = .{ .path = "test/c_abi/main.zig" },
1192 .root_source_file = b.path("test/c_abi/main.zig"),
11931193 .target = resolved_target,
11941194 .optimize = optimize_mode,
11951195 .link_libc = true,
......@@ -1199,7 +1199,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
11991199 .strip = c_abi_target.strip,
12001200 });
12011201 test_step.addCSourceFile(.{
1202 .file = .{ .path = "test/c_abi/cfuncs.c" },
1202 .file = b.path("test/c_abi/cfuncs.c"),
12031203 .flags = &.{"-std=c99"},
12041204 });
12051205 for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null);