authorgravatar for xq@random-projects.netFelix "xq" Queißner <xq@random-projects.net> 2023-07-19 10:49:34+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-30 11:18:50-07:00
logce95a3b153e9f3e83232e641c26a41e7dbd01165
treed2bd5a15abfb77cbb8d79539767cdccbde1e79d3
parent235e6ac05df95e5dc2656cfb1a33d7b18c45a603

Build.zig rename orgy (aka: #16353). Renames FileSource to LazyPath and removes functions that take literal paths instead of LazyPath.


55 files changed, 337 insertions(+), 329 deletions(-)

build.zig+17-18
...@@ -45,9 +45,9 @@ pub fn build(b: *std.Build) !void {...@@ -45,9 +45,9 @@ pub fn build(b: *std.Build) !void {
45 const docgen_cmd = b.addRunArtifact(docgen_exe);45 const docgen_cmd = b.addRunArtifact(docgen_exe);
46 docgen_cmd.addArgs(&.{ "--zig", b.zig_exe });46 docgen_cmd.addArgs(&.{ "--zig", b.zig_exe });
47 if (b.zig_lib_dir) |p| {47 if (b.zig_lib_dir) |p| {
48 docgen_cmd.addArgs(&.{ "--zig-lib-dir", p });48 docgen_cmd.addArgs(&.{ "--zig-lib-dir", b.pathFromRoot(p) });
49 }49 }
50 docgen_cmd.addFileSourceArg(.{ .path = "doc/langref.html.in" });50 docgen_cmd.addFileArg(.{ .path = "doc/langref.html.in" });
51 const langref_file = docgen_cmd.addOutputFileArg("langref.html");51 const langref_file = docgen_cmd.addOutputFileArg("langref.html");
52 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");52 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
53 if (!skip_install_langref) {53 if (!skip_install_langref) {
...@@ -58,7 +58,7 @@ pub fn build(b: *std.Build) !void {...@@ -58,7 +58,7 @@ pub fn build(b: *std.Build) !void {
58 .root_source_file = .{ .path = "lib/std/std.zig" },58 .root_source_file = .{ .path = "lib/std/std.zig" },
59 .target = target,59 .target = target,
60 });60 });
61 autodoc_test.overrideZigLibDir("lib");61 autodoc_test.overrideZigLibDir(.{ .path = "lib" });
62 autodoc_test.emit_bin = .no_emit; // https://github.com/ziglang/zig/issues/1635162 autodoc_test.emit_bin = .no_emit; // https://github.com/ziglang/zig/issues/16351
63 const install_std_docs = b.addInstallDirectory(.{63 const install_std_docs = b.addInstallDirectory(.{
64 .source_dir = autodoc_test.getEmittedDocs(),64 .source_dir = autodoc_test.getEmittedDocs(),
...@@ -89,7 +89,7 @@ pub fn build(b: *std.Build) !void {...@@ -89,7 +89,7 @@ pub fn build(b: *std.Build) !void {
89 .root_source_file = .{ .path = "test/src/Cases.zig" },89 .root_source_file = .{ .path = "test/src/Cases.zig" },
90 .optimize = optimize,90 .optimize = optimize,
91 });91 });
92 check_case_exe.main_pkg_path = ".";92 check_case_exe.setMainPkgPath(.{ .path = "." });
93 check_case_exe.stack_size = stack_size;93 check_case_exe.stack_size = stack_size;
94 check_case_exe.single_threaded = single_threaded;94 check_case_exe.single_threaded = single_threaded;
9595
...@@ -352,10 +352,9 @@ pub fn build(b: *std.Build) !void {...@@ -352,10 +352,9 @@ pub fn build(b: *std.Build) !void {
352 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);352 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
353 exe_options.addOption(bool, "value_tracing", value_tracing);353 exe_options.addOption(bool, "value_tracing", value_tracing);
354 if (tracy) |tracy_path| {354 if (tracy) |tracy_path| {
355 const client_cpp = fs.path.join(355 const client_cpp = b.pathJoin(
356 b.allocator,
357 &[_][]const u8{ tracy_path, "public", "TracyClient.cpp" },356 &[_][]const u8{ tracy_path, "public", "TracyClient.cpp" },
358 ) catch unreachable;357 );
359358
360 // On mingw, we need to opt into windows 7+ to get some features required by tracy.359 // On mingw, we need to opt into windows 7+ to get some features required by tracy.
361 const tracy_c_flags: []const []const u8 = if (target.isWindows() and target.getAbi() == .gnu)360 const tracy_c_flags: []const []const u8 = if (target.isWindows() and target.getAbi() == .gnu)
...@@ -363,8 +362,8 @@ pub fn build(b: *std.Build) !void {...@@ -363,8 +362,8 @@ pub fn build(b: *std.Build) !void {
363 else362 else
364 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };363 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
365364
366 exe.addIncludePath(tracy_path);365 exe.addIncludePath(.{ .path = tracy_path });
367 exe.addCSourceFile(client_cpp, tracy_c_flags);366 exe.addCSourceFile(.{ .file = .{ .path = client_cpp }, .flags = tracy_c_flags });
368 if (!enable_llvm) {367 if (!enable_llvm) {
369 exe.linkSystemLibraryName("c++");368 exe.linkSystemLibraryName("c++");
370 }369 }
...@@ -554,7 +553,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {...@@ -554,7 +553,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
554 });553 });
555 run_opt.addArtifactArg(exe);554 run_opt.addArtifactArg(exe);
556 run_opt.addArg("-o");555 run_opt.addArg("-o");
557 run_opt.addFileSourceArg(.{ .path = "stage1/zig1.wasm" });556 run_opt.addFileArg(.{ .path = "stage1/zig1.wasm" });
558557
559 const copy_zig_h = b.addWriteFiles();558 const copy_zig_h = b.addWriteFiles();
560 copy_zig_h.addCopyFileToSource(.{ .path = "lib/zig.h" }, "stage1/zig.h");559 copy_zig_h.addCopyFileToSource(.{ .path = "lib/zig.h" }, "stage1/zig.h");
...@@ -603,7 +602,7 @@ fn addCmakeCfgOptionsToExe(...@@ -603,7 +602,7 @@ fn addCmakeCfgOptionsToExe(
603 // useful for package maintainers602 // useful for package maintainers
604 exe.headerpad_max_install_names = true;603 exe.headerpad_max_install_names = true;
605 }604 }
606 exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{605 exe.addObjectFile(.{ .path = b.pathJoin(&[_][]const u8{
607 cfg.cmake_binary_dir,606 cfg.cmake_binary_dir,
608 "zigcpp",607 "zigcpp",
609 b.fmt("{s}{s}{s}", .{608 b.fmt("{s}{s}{s}", .{
...@@ -611,11 +610,11 @@ fn addCmakeCfgOptionsToExe(...@@ -611,11 +610,11 @@ fn addCmakeCfgOptionsToExe(
611 "zigcpp",610 "zigcpp",
612 cfg.cmake_static_library_suffix,611 cfg.cmake_static_library_suffix,
613 }),612 }),
614 }) catch unreachable);613 }) });
615 assert(cfg.lld_include_dir.len != 0);614 assert(cfg.lld_include_dir.len != 0);
616 exe.addIncludePath(cfg.lld_include_dir);615 exe.addIncludePath(.{ .path = cfg.lld_include_dir });
617 exe.addIncludePath(cfg.llvm_include_dir);616 exe.addIncludePath(.{ .path = cfg.llvm_include_dir });
618 exe.addLibraryPath(cfg.llvm_lib_dir);617 exe.addLibraryPath(.{ .path = cfg.llvm_lib_dir });
619 addCMakeLibraryList(exe, cfg.clang_libraries);618 addCMakeLibraryList(exe, cfg.clang_libraries);
620 addCMakeLibraryList(exe, cfg.lld_libraries);619 addCMakeLibraryList(exe, cfg.lld_libraries);
621 addCMakeLibraryList(exe, cfg.llvm_libraries);620 addCMakeLibraryList(exe, cfg.llvm_libraries);
...@@ -671,7 +670,7 @@ fn addCmakeCfgOptionsToExe(...@@ -671,7 +670,7 @@ fn addCmakeCfgOptionsToExe(
671 }670 }
672671
673 if (cfg.dia_guids_lib.len != 0) {672 if (cfg.dia_guids_lib.len != 0) {
674 exe.addObjectFile(cfg.dia_guids_lib);673 exe.addObjectFile(.{ .path = cfg.dia_guids_lib });
675 }674 }
676}675}
677676
...@@ -732,7 +731,7 @@ fn addCxxKnownPath(...@@ -732,7 +731,7 @@ fn addCxxKnownPath(
732 }731 }
733 return error.RequiredLibraryNotFound;732 return error.RequiredLibraryNotFound;
734 }733 }
735 exe.addObjectFile(path_unpadded);734 exe.addObjectFile(.{ .path = path_unpadded });
736735
737 // TODO a way to integrate with system c++ include files here736 // TODO a way to integrate with system c++ include files here
738 // c++ -E -Wp,-v -xc++ /dev/null737 // c++ -E -Wp,-v -xc++ /dev/null
...@@ -752,7 +751,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {...@@ -752,7 +751,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
752 } else if (exe.target.isWindows() and mem.endsWith(u8, lib, ".lib") and !fs.path.isAbsolute(lib)) {751 } else if (exe.target.isWindows() and mem.endsWith(u8, lib, ".lib") and !fs.path.isAbsolute(lib)) {
753 exe.linkSystemLibrary(lib[0 .. lib.len - ".lib".len]);752 exe.linkSystemLibrary(lib[0 .. lib.len - ".lib".len]);
754 } else {753 } else {
755 exe.addObjectFile(lib);754 exe.addObjectFile(.{ .path = lib });
756 }755 }
757 }756 }
758}757}
lib/std/Build.zig+26-24
...@@ -471,7 +471,7 @@ pub fn addOptions(self: *Build) *Step.Options {...@@ -471,7 +471,7 @@ pub fn addOptions(self: *Build) *Step.Options {
471471
472pub const ExecutableOptions = struct {472pub const ExecutableOptions = struct {
473 name: []const u8,473 name: []const u8,
474 root_source_file: ?FileSource = null,474 root_source_file: ?LazyPath = null,
475 version: ?std.SemanticVersion = null,475 version: ?std.SemanticVersion = null,
476 target: CrossTarget = .{},476 target: CrossTarget = .{},
477 optimize: std.builtin.Mode = .Debug,477 optimize: std.builtin.Mode = .Debug,
...@@ -502,7 +502,7 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *Step.Compile {...@@ -502,7 +502,7 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *Step.Compile {
502502
503pub const ObjectOptions = struct {503pub const ObjectOptions = struct {
504 name: []const u8,504 name: []const u8,
505 root_source_file: ?FileSource = null,505 root_source_file: ?LazyPath = null,
506 target: CrossTarget,506 target: CrossTarget,
507 optimize: std.builtin.Mode,507 optimize: std.builtin.Mode,
508 max_rss: usize = 0,508 max_rss: usize = 0,
...@@ -529,7 +529,7 @@ pub fn addObject(b: *Build, options: ObjectOptions) *Step.Compile {...@@ -529,7 +529,7 @@ pub fn addObject(b: *Build, options: ObjectOptions) *Step.Compile {
529529
530pub const SharedLibraryOptions = struct {530pub const SharedLibraryOptions = struct {
531 name: []const u8,531 name: []const u8,
532 root_source_file: ?FileSource = null,532 root_source_file: ?LazyPath = null,
533 version: ?std.SemanticVersion = null,533 version: ?std.SemanticVersion = null,
534 target: CrossTarget,534 target: CrossTarget,
535 optimize: std.builtin.Mode,535 optimize: std.builtin.Mode,
...@@ -559,7 +559,7 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *Step.Compile...@@ -559,7 +559,7 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *Step.Compile
559559
560pub const StaticLibraryOptions = struct {560pub const StaticLibraryOptions = struct {
561 name: []const u8,561 name: []const u8,
562 root_source_file: ?FileSource = null,562 root_source_file: ?LazyPath = null,
563 target: CrossTarget,563 target: CrossTarget,
564 optimize: std.builtin.Mode,564 optimize: std.builtin.Mode,
565 version: ?std.SemanticVersion = null,565 version: ?std.SemanticVersion = null,
...@@ -589,7 +589,7 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *Step.Compile...@@ -589,7 +589,7 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *Step.Compile
589589
590pub const TestOptions = struct {590pub const TestOptions = struct {
591 name: []const u8 = "test",591 name: []const u8 = "test",
592 root_source_file: FileSource,592 root_source_file: LazyPath,
593 target: CrossTarget = .{},593 target: CrossTarget = .{},
594 optimize: std.builtin.Mode = .Debug,594 optimize: std.builtin.Mode = .Debug,
595 version: ?std.SemanticVersion = null,595 version: ?std.SemanticVersion = null,
...@@ -621,7 +621,7 @@ pub fn addTest(b: *Build, options: TestOptions) *Step.Compile {...@@ -621,7 +621,7 @@ pub fn addTest(b: *Build, options: TestOptions) *Step.Compile {
621621
622pub const AssemblyOptions = struct {622pub const AssemblyOptions = struct {
623 name: []const u8,623 name: []const u8,
624 source_file: FileSource,624 source_file: LazyPath,
625 target: CrossTarget,625 target: CrossTarget,
626 optimize: std.builtin.Mode,626 optimize: std.builtin.Mode,
627 max_rss: usize = 0,627 max_rss: usize = 0,
...@@ -636,7 +636,7 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *Step.Compile {...@@ -636,7 +636,7 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *Step.Compile {
636 .optimize = options.optimize,636 .optimize = options.optimize,
637 .max_rss = options.max_rss,637 .max_rss = options.max_rss,
638 });638 });
639 obj_step.addAssemblyFileSource(options.source_file.dupe(b));639 obj_step.addAssemblyLazyPath(options.source_file.dupe(b));
640 return obj_step;640 return obj_step;
641}641}
642642
...@@ -655,7 +655,7 @@ pub const ModuleDependency = struct {...@@ -655,7 +655,7 @@ pub const ModuleDependency = struct {
655};655};
656656
657pub const CreateModuleOptions = struct {657pub const CreateModuleOptions = struct {
658 source_file: FileSource,658 source_file: LazyPath,
659 dependencies: []const ModuleDependency = &.{},659 dependencies: []const ModuleDependency = &.{},
660};660};
661661
...@@ -1284,22 +1284,22 @@ pub fn installLibFile(self: *Build, src_path: []const u8, dest_rel_path: []const...@@ -1284,22 +1284,22 @@ pub fn installLibFile(self: *Build, src_path: []const u8, dest_rel_path: []const
1284 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .lib, dest_rel_path).step);1284 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .lib, dest_rel_path).step);
1285}1285}
12861286
1287pub fn addObjCopy(b: *Build, source: FileSource, options: Step.ObjCopy.Options) *Step.ObjCopy {1287pub fn addObjCopy(b: *Build, source: LazyPath, options: Step.ObjCopy.Options) *Step.ObjCopy {
1288 return Step.ObjCopy.create(b, source, options);1288 return Step.ObjCopy.create(b, source, options);
1289}1289}
12901290
1291///`dest_rel_path` is relative to install prefix path1291///`dest_rel_path` is relative to install prefix path
1292pub fn addInstallFile(self: *Build, source: FileSource, dest_rel_path: []const u8) *Step.InstallFile {1292pub fn addInstallFile(self: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
1293 return self.addInstallFileWithDir(source.dupe(self), .prefix, dest_rel_path);1293 return self.addInstallFileWithDir(source.dupe(self), .prefix, dest_rel_path);
1294}1294}
12951295
1296///`dest_rel_path` is relative to bin path1296///`dest_rel_path` is relative to bin path
1297pub fn addInstallBinFile(self: *Build, source: FileSource, dest_rel_path: []const u8) *Step.InstallFile {1297pub fn addInstallBinFile(self: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
1298 return self.addInstallFileWithDir(source.dupe(self), .bin, dest_rel_path);1298 return self.addInstallFileWithDir(source.dupe(self), .bin, dest_rel_path);
1299}1299}
13001300
1301///`dest_rel_path` is relative to lib path1301///`dest_rel_path` is relative to lib path
1302pub fn addInstallLibFile(self: *Build, source: FileSource, dest_rel_path: []const u8) *Step.InstallFile {1302pub fn addInstallLibFile(self: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
1303 return self.addInstallFileWithDir(source.dupe(self), .lib, dest_rel_path);1303 return self.addInstallFileWithDir(source.dupe(self), .lib, dest_rel_path);
1304}1304}
13051305
...@@ -1309,7 +1309,7 @@ pub fn addInstallHeaderFile(b: *Build, src_path: []const u8, dest_rel_path: []co...@@ -1309,7 +1309,7 @@ pub fn addInstallHeaderFile(b: *Build, src_path: []const u8, dest_rel_path: []co
13091309
1310pub fn addInstallFileWithDir(1310pub fn addInstallFileWithDir(
1311 self: *Build,1311 self: *Build,
1312 source: FileSource,1312 source: LazyPath,
1313 install_dir: InstallDir,1313 install_dir: InstallDir,
1314 dest_rel_path: []const u8,1314 dest_rel_path: []const u8,
1315) *Step.InstallFile {1315) *Step.InstallFile {
...@@ -1322,7 +1322,7 @@ pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *Step...@@ -1322,7 +1322,7 @@ pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *Step
13221322
1323pub fn addCheckFile(1323pub fn addCheckFile(
1324 b: *Build,1324 b: *Build,
1325 file_source: FileSource,1325 file_source: LazyPath,
1326 options: Step.CheckFile.Options,1326 options: Step.CheckFile.Options,
1327) *Step.CheckFile {1327) *Step.CheckFile {
1328 return Step.CheckFile.create(b, file_source, options);1328 return Step.CheckFile.create(b, file_source, options);
...@@ -1608,7 +1608,7 @@ pub const Module = struct {...@@ -1608,7 +1608,7 @@ pub const Module = struct {
1608 /// This could either be a generated file, in which case the module1608 /// This could either be a generated file, in which case the module
1609 /// contains exactly one file, or it could be a path to the root source1609 /// contains exactly one file, or it could be a path to the root source
1610 /// file of directory of files which constitute the module.1610 /// file of directory of files which constitute the module.
1611 source_file: FileSource,1611 source_file: LazyPath,
1612 dependencies: std.StringArrayHashMap(*Module),1612 dependencies: std.StringArrayHashMap(*Module),
1613};1613};
16141614
...@@ -1630,8 +1630,10 @@ pub const GeneratedFile = struct {...@@ -1630,8 +1630,10 @@ pub const GeneratedFile = struct {
1630 }1630 }
1631};1631};
16321632
1633/// A file source is a reference to an existing or future file.1633pub const FileSource = LazyPath; // DEPRECATED, use LazyPath now
1634pub const FileSource = union(enum) {1634
1635/// A reference to an existing or future path.
1636pub const LazyPath = union(enum) {
1635 /// A plain file path, relative to build root or absolute.1637 /// A plain file path, relative to build root or absolute.
1636 path: []const u8,1638 path: []const u8,
16371639
...@@ -1641,14 +1643,14 @@ pub const FileSource = union(enum) {...@@ -1641,14 +1643,14 @@ pub const FileSource = union(enum) {
16411643
1642 /// Returns a new file source that will have a relative path to the build root guaranteed.1644 /// Returns a new file source that will have a relative path to the build root guaranteed.
1643 /// This should be preferred over setting `.path` directly as it documents that the files are in the project directory.1645 /// This should be preferred over setting `.path` directly as it documents that the files are in the project directory.
1644 pub fn relative(path: []const u8) FileSource {1646 pub fn relative(path: []const u8) LazyPath {
1645 std.debug.assert(!std.fs.path.isAbsolute(path));1647 std.debug.assert(!std.fs.path.isAbsolute(path));
1646 return FileSource{ .path = path };1648 return LazyPath{ .path = path };
1647 }1649 }
16481650
1649 /// Returns a string that can be shown to represent the file source.1651 /// Returns a string that can be shown to represent the file source.
1650 /// Either returns the path or `"generated"`.1652 /// Either returns the path or `"generated"`.
1651 pub fn getDisplayName(self: FileSource) []const u8 {1653 pub fn getDisplayName(self: LazyPath) []const u8 {
1652 return switch (self) {1654 return switch (self) {
1653 .path => self.path,1655 .path => self.path,
1654 .generated => "generated",1656 .generated => "generated",
...@@ -1656,7 +1658,7 @@ pub const FileSource = union(enum) {...@@ -1656,7 +1658,7 @@ pub const FileSource = union(enum) {
1656 }1658 }
16571659
1658 /// Adds dependencies this file source implies to the given step.1660 /// Adds dependencies this file source implies to the given step.
1659 pub fn addStepDependencies(self: FileSource, other_step: *Step) void {1661 pub fn addStepDependencies(self: LazyPath, other_step: *Step) void {
1660 switch (self) {1662 switch (self) {
1661 .path => {},1663 .path => {},
1662 .generated => |gen| other_step.dependOn(gen.step),1664 .generated => |gen| other_step.dependOn(gen.step),
...@@ -1664,14 +1666,14 @@ pub const FileSource = union(enum) {...@@ -1664,14 +1666,14 @@ pub const FileSource = union(enum) {
1664 }1666 }
16651667
1666 /// Should only be called during make(), returns a path relative to the build root or absolute.1668 /// Should only be called during make(), returns a path relative to the build root or absolute.
1667 pub fn getPath(self: FileSource, src_builder: *Build) []const u8 {1669 pub fn getPath(self: LazyPath, src_builder: *Build) []const u8 {
1668 return getPath2(self, src_builder, null);1670 return getPath2(self, src_builder, null);
1669 }1671 }
16701672
1671 /// Should only be called during make(), returns a path relative to the build root or absolute.1673 /// Should only be called during make(), returns a path relative to the build root or absolute.
1672 /// asking_step is only used for debugging purposes; it's the step being run that is asking for1674 /// asking_step is only used for debugging purposes; it's the step being run that is asking for
1673 /// the path.1675 /// the path.
1674 pub fn getPath2(self: FileSource, src_builder: *Build, asking_step: ?*Step) []const u8 {1676 pub fn getPath2(self: LazyPath, src_builder: *Build, asking_step: ?*Step) []const u8 {
1675 switch (self) {1677 switch (self) {
1676 .path => |p| return src_builder.pathFromRoot(p),1678 .path => |p| return src_builder.pathFromRoot(p),
1677 .generated => |gen| return gen.path orelse {1679 .generated => |gen| return gen.path orelse {
...@@ -1684,7 +1686,7 @@ pub const FileSource = union(enum) {...@@ -1684,7 +1686,7 @@ pub const FileSource = union(enum) {
1684 }1686 }
16851687
1686 /// Duplicates the file source for a given builder.1688 /// Duplicates the file source for a given builder.
1687 pub fn dupe(self: FileSource, b: *Build) FileSource {1689 pub fn dupe(self: LazyPath, b: *Build) LazyPath {
1688 return switch (self) {1690 return switch (self) {
1689 .path => |p| .{ .path = b.dupePath(p) },1691 .path => |p| .{ .path = b.dupePath(p) },
1690 .generated => |gen| .{ .generated = gen },1692 .generated => |gen| .{ .generated = gen },
lib/std/Build/Step/CheckFile.zig+2-2
...@@ -11,7 +11,7 @@ const mem = std.mem;...@@ -11,7 +11,7 @@ const mem = std.mem;
11step: Step,11step: Step,
12expected_matches: []const []const u8,12expected_matches: []const []const u8,
13expected_exact: ?[]const u8,13expected_exact: ?[]const u8,
14source: std.Build.FileSource,14source: std.Build.LazyPath,
15max_bytes: usize = 20 * 1024 * 1024,15max_bytes: usize = 20 * 1024 * 1024,
1616
17pub const base_id = .check_file;17pub const base_id = .check_file;
...@@ -23,7 +23,7 @@ pub const Options = struct {...@@ -23,7 +23,7 @@ pub const Options = struct {
2323
24pub fn create(24pub fn create(
25 owner: *std.Build,25 owner: *std.Build,
26 source: std.Build.FileSource,26 source: std.Build.LazyPath,
27 options: Options,27 options: Options,
28) *CheckFile {28) *CheckFile {
29 const self = owner.allocator.create(CheckFile) catch @panic("OOM");29 const self = owner.allocator.create(CheckFile) catch @panic("OOM");
lib/std/Build/Step/CheckObject.zig+7-7
...@@ -15,14 +15,14 @@ const Step = std.Build.Step;...@@ -15,14 +15,14 @@ const Step = std.Build.Step;
15pub const base_id = .check_object;15pub const base_id = .check_object;
1616
17step: Step,17step: Step,
18source: std.Build.FileSource,18source: std.Build.LazyPath,
19max_bytes: usize = 20 * 1024 * 1024,19max_bytes: usize = 20 * 1024 * 1024,
20checks: std.ArrayList(Check),20checks: std.ArrayList(Check),
21obj_format: std.Target.ObjectFormat,21obj_format: std.Target.ObjectFormat,
2222
23pub fn create(23pub fn create(
24 owner: *std.Build,24 owner: *std.Build,
25 source: std.Build.FileSource,25 source: std.Build.LazyPath,
26 obj_format: std.Target.ObjectFormat,26 obj_format: std.Target.ObjectFormat,
27) *CheckObject {27) *CheckObject {
28 const gpa = owner.allocator;28 const gpa = owner.allocator;
...@@ -44,7 +44,7 @@ pub fn create(...@@ -44,7 +44,7 @@ pub fn create(
4444
45const SearchPhrase = struct {45const SearchPhrase = struct {
46 string: []const u8,46 string: []const u8,
47 file_source: ?std.Build.FileSource = null,47 file_source: ?std.Build.LazyPath = null,
4848
49 fn resolve(phrase: SearchPhrase, b: *std.Build, step: *Step) []const u8 {49 fn resolve(phrase: SearchPhrase, b: *std.Build, step: *Step) []const u8 {
50 const file_source = phrase.file_source orelse return phrase.string;50 const file_source = phrase.file_source orelse return phrase.string;
...@@ -302,13 +302,13 @@ pub fn checkExact(self: *CheckObject, phrase: []const u8) void {...@@ -302,13 +302,13 @@ pub fn checkExact(self: *CheckObject, phrase: []const u8) void {
302 self.checkExactInner(phrase, null);302 self.checkExactInner(phrase, null);
303}303}
304304
305/// Like `checkExact()` but takes an additional argument `FileSource` which will be305/// Like `checkExact()` but takes an additional argument `LazyPath` which will be
306/// resolved to a full search query in `make()`.306/// resolved to a full search query in `make()`.
307pub fn checkExactFileSource(self: *CheckObject, phrase: []const u8, file_source: std.Build.FileSource) void {307pub fn checkExactPath(self: *CheckObject, phrase: []const u8, file_source: std.Build.LazyPath) void {
308 self.checkExactInner(phrase, file_source);308 self.checkExactInner(phrase, file_source);
309}309}
310310
311fn checkExactInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.FileSource) void {311fn checkExactInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.LazyPath) void {
312 assert(self.checks.items.len > 0);312 assert(self.checks.items.len > 0);
313 const last = &self.checks.items[self.checks.items.len - 1];313 const last = &self.checks.items[self.checks.items.len - 1];
314 last.exact(.{ .string = self.step.owner.dupe(phrase), .file_source = file_source });314 last.exact(.{ .string = self.step.owner.dupe(phrase), .file_source = file_source });
...@@ -321,7 +321,7 @@ pub fn checkContains(self: *CheckObject, phrase: []const u8) void {...@@ -321,7 +321,7 @@ pub fn checkContains(self: *CheckObject, phrase: []const u8) void {
321321
322/// Like `checkContains()` but takes an additional argument `FileSource` which will be322/// Like `checkContains()` but takes an additional argument `FileSource` which will be
323/// resolved to a full search query in `make()`.323/// resolved to a full search query in `make()`.
324pub fn checkContainsFileSource(self: *CheckObject, phrase: []const u8, file_source: std.Build.FileSource) void {324pub fn checkContainsPath(self: *CheckObject, phrase: []const u8, file_source: std.Build.LazyPath) void {
325 self.checkContainsInner(phrase, file_source);325 self.checkContainsInner(phrase, file_source);
326}326}
327327
lib/std/Build/Step/Compile.zig+76-95
...@@ -11,7 +11,7 @@ const Allocator = mem.Allocator;...@@ -11,7 +11,7 @@ const Allocator = mem.Allocator;
11const Step = std.Build.Step;11const Step = std.Build.Step;
12const CrossTarget = std.zig.CrossTarget;12const CrossTarget = std.zig.CrossTarget;
13const NativeTargetInfo = std.zig.system.NativeTargetInfo;13const NativeTargetInfo = std.zig.system.NativeTargetInfo;
14const FileSource = std.Build.FileSource;14const LazyPath = std.Build.LazyPath;
15const PkgConfigPkg = std.Build.PkgConfigPkg;15const PkgConfigPkg = std.Build.PkgConfigPkg;
16const PkgConfigError = std.Build.PkgConfigError;16const PkgConfigError = std.Build.PkgConfigError;
17const ExecError = std.Build.ExecError;17const ExecError = std.Build.ExecError;
...@@ -28,7 +28,7 @@ name: []const u8,...@@ -28,7 +28,7 @@ name: []const u8,
28target: CrossTarget,28target: CrossTarget,
29target_info: NativeTargetInfo,29target_info: NativeTargetInfo,
30optimize: std.builtin.Mode,30optimize: std.builtin.Mode,
31linker_script: ?FileSource = null,31linker_script: ?LazyPath = null,
32version_script: ?[]const u8 = null,32version_script: ?[]const u8 = null,
33out_filename: []const u8,33out_filename: []const u8,
34linkage: ?Linkage = null,34linkage: ?Linkage = null,
...@@ -40,9 +40,9 @@ strip: ?bool,...@@ -40,9 +40,9 @@ strip: ?bool,
40unwind_tables: ?bool,40unwind_tables: ?bool,
41// keep in sync with src/link.zig:CompressDebugSections41// keep in sync with src/link.zig:CompressDebugSections
42compress_debug_sections: enum { none, zlib } = .none,42compress_debug_sections: enum { none, zlib } = .none,
43lib_paths: ArrayList(FileSource),43lib_paths: ArrayList(LazyPath),
44rpaths: ArrayList(FileSource),44rpaths: ArrayList(LazyPath),
45framework_dirs: ArrayList(FileSource),45framework_dirs: ArrayList(LazyPath),
46frameworks: StringHashMap(FrameworkLinkInfo),46frameworks: StringHashMap(FrameworkLinkInfo),
47verbose_link: bool,47verbose_link: bool,
48verbose_cc: bool,48verbose_cc: bool,
...@@ -74,8 +74,8 @@ max_memory: ?u64 = null,...@@ -74,8 +74,8 @@ max_memory: ?u64 = null,
74shared_memory: bool = false,74shared_memory: bool = false,
75global_base: ?u64 = null,75global_base: ?u64 = null,
76c_std: std.Build.CStd,76c_std: std.Build.CStd,
77zig_lib_dir: ?[]const u8,77zig_lib_dir: ?LazyPath,
78main_pkg_path: ?[]const u8,78main_pkg_path: ?LazyPath,
79exec_cmd_args: ?[]const ?[]const u8,79exec_cmd_args: ?[]const ?[]const u8,
80filter: ?[]const u8,80filter: ?[]const u8,
81test_evented_io: bool = false,81test_evented_io: bool = false,
...@@ -85,7 +85,7 @@ wasi_exec_model: ?std.builtin.WasiExecModel = null,...@@ -85,7 +85,7 @@ wasi_exec_model: ?std.builtin.WasiExecModel = null,
85/// Symbols to be exported when compiling to wasm85/// Symbols to be exported when compiling to wasm
86export_symbol_names: []const []const u8 = &.{},86export_symbol_names: []const []const u8 = &.{},
8787
88root_src: ?FileSource,88root_src: ?LazyPath,
89out_h_filename: []const u8,89out_h_filename: []const u8,
90out_lib_filename: []const u8,90out_lib_filename: []const u8,
91out_pdb_filename: []const u8,91out_pdb_filename: []const u8,
...@@ -106,7 +106,7 @@ installed_path: ?[]const u8,...@@ -106,7 +106,7 @@ installed_path: ?[]const u8,
106/// Base address for an executable image.106/// Base address for an executable image.
107image_base: ?u64 = null,107image_base: ?u64 = null,
108108
109libc_file: ?FileSource = null,109libc_file: ?LazyPath = null,
110110
111valgrind_support: ?bool = null,111valgrind_support: ?bool = null,
112each_lib_rpath: ?bool = null,112each_lib_rpath: ?bool = null,
...@@ -223,22 +223,22 @@ pub const CSourceFiles = struct {...@@ -223,22 +223,22 @@ pub const CSourceFiles = struct {
223};223};
224224
225pub const CSourceFile = struct {225pub const CSourceFile = struct {
226 source: FileSource,226 file: LazyPath,
227 args: []const []const u8,227 flags: []const []const u8,
228228
229 pub fn dupe(self: CSourceFile, b: *std.Build) CSourceFile {229 pub fn dupe(self: CSourceFile, b: *std.Build) CSourceFile {
230 return .{230 return .{
231 .source = self.source.dupe(b),231 .file = self.file.dupe(b),
232 .args = b.dupeStrings(self.args),232 .flags = b.dupeStrings(self.flags),
233 };233 };
234 }234 }
235};235};
236236
237pub const LinkObject = union(enum) {237pub const LinkObject = union(enum) {
238 static_path: FileSource,238 static_path: LazyPath,
239 other_step: *Compile,239 other_step: *Compile,
240 system_lib: SystemLib,240 system_lib: SystemLib,
241 assembly_file: FileSource,241 assembly_file: LazyPath,
242 c_source_file: *CSourceFile,242 c_source_file: *CSourceFile,
243 c_source_files: *CSourceFiles,243 c_source_files: *CSourceFiles,
244};244};
...@@ -265,15 +265,15 @@ const FrameworkLinkInfo = struct {...@@ -265,15 +265,15 @@ const FrameworkLinkInfo = struct {
265};265};
266266
267pub const IncludeDir = union(enum) {267pub const IncludeDir = union(enum) {
268 raw_path: []const u8,268 path: LazyPath,
269 raw_path_system: []const u8,269 path_system: LazyPath,
270 other_step: *Compile,270 other_step: *Compile,
271 config_header_step: *Step.ConfigHeader,271 config_header_step: *Step.ConfigHeader,
272};272};
273273
274pub const Options = struct {274pub const Options = struct {
275 name: []const u8,275 name: []const u8,
276 root_source_file: ?FileSource = null,276 root_source_file: ?LazyPath = null,
277 target: CrossTarget,277 target: CrossTarget,
278 optimize: std.builtin.Mode,278 optimize: std.builtin.Mode,
279 kind: Kind,279 kind: Kind,
...@@ -391,7 +391,7 @@ pub const EmitOption = union(enum) {...@@ -391,7 +391,7 @@ pub const EmitOption = union(enum) {
391391
392pub fn create(owner: *std.Build, options: Options) *Compile {392pub fn create(owner: *std.Build, options: Options) *Compile {
393 const name = owner.dupe(options.name);393 const name = owner.dupe(options.name);
394 const root_src: ?FileSource = if (options.root_source_file) |rsrc| rsrc.dupe(owner) else null;394 const root_src: ?LazyPath = if (options.root_source_file) |rsrc| rsrc.dupe(owner) else null;
395 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {395 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
396 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});396 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
397 }397 }
...@@ -462,9 +462,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile {...@@ -462,9 +462,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
462 .include_dirs = ArrayList(IncludeDir).init(owner.allocator),462 .include_dirs = ArrayList(IncludeDir).init(owner.allocator),
463 .link_objects = ArrayList(LinkObject).init(owner.allocator),463 .link_objects = ArrayList(LinkObject).init(owner.allocator),
464 .c_macros = ArrayList([]const u8).init(owner.allocator),464 .c_macros = ArrayList([]const u8).init(owner.allocator),
465 .lib_paths = ArrayList(FileSource).init(owner.allocator),465 .lib_paths = ArrayList(LazyPath).init(owner.allocator),
466 .rpaths = ArrayList(FileSource).init(owner.allocator),466 .rpaths = ArrayList(LazyPath).init(owner.allocator),
467 .framework_dirs = ArrayList(FileSource).init(owner.allocator),467 .framework_dirs = ArrayList(LazyPath).init(owner.allocator),
468 .installed_headers = ArrayList(*Step).init(owner.allocator),468 .installed_headers = ArrayList(*Step).init(owner.allocator),
469 .c_std = std.Build.CStd.C99,469 .c_std = std.Build.CStd.C99,
470 .zig_lib_dir = null,470 .zig_lib_dir = null,
...@@ -614,7 +614,7 @@ pub fn addObjCopy(cs: *Compile, options: Step.ObjCopy.Options) *Step.ObjCopy {...@@ -614,7 +614,7 @@ pub fn addObjCopy(cs: *Compile, options: Step.ObjCopy.Options) *Step.ObjCopy {
614 copy.basename = cs.name;614 copy.basename = cs.name;
615 }615 }
616 }616 }
617 return b.addObjCopy(cs.getOutputSource(), copy);617 return b.addObjCopy(cs.getEmittedBin(), copy);
618}618}
619619
620/// This function would run in the context of the package that created the executable,620/// This function would run in the context of the package that created the executable,
...@@ -626,10 +626,12 @@ pub const run = @compileError("deprecated; use std.Build.addRunArtifact");...@@ -626,10 +626,12 @@ pub const run = @compileError("deprecated; use std.Build.addRunArtifact");
626pub const install = @compileError("deprecated; use std.Build.installArtifact");626pub const install = @compileError("deprecated; use std.Build.installArtifact");
627627
628pub fn checkObject(self: *Compile) *Step.CheckObject {628pub fn checkObject(self: *Compile) *Step.CheckObject {
629 return Step.CheckObject.create(self.step.owner, self.getOutputSource(), self.target_info.target.ofmt);629 return Step.CheckObject.create(self.step.owner, self.getEmittedBin(), self.target_info.target.ofmt);
630}630}
631631
632pub fn setLinkerScriptPath(self: *Compile, source: FileSource) void {632pub const setLinkerScriptPath = setLinkerScript; // DEPRECATED, use setLinkerScript
633
634pub fn setLinkerScript(self: *Compile, source: LazyPath) void {
633 const b = self.step.owner;635 const b = self.step.owner;
634 self.linker_script = source.dupe(b);636 self.linker_script = source.dupe(b);
635 source.addStepDependencies(&self.step);637 source.addStepDependencies(&self.step);
...@@ -935,19 +937,12 @@ pub fn addCSourceFiles(self: *Compile, files: []const []const u8, flags: []const...@@ -935,19 +937,12 @@ pub fn addCSourceFiles(self: *Compile, files: []const []const u8, flags: []const
935 self.link_objects.append(.{ .c_source_files = c_source_files }) catch @panic("OOM");937 self.link_objects.append(.{ .c_source_files = c_source_files }) catch @panic("OOM");
936}938}
937939
938pub fn addCSourceFile(self: *Compile, file: []const u8, flags: []const []const u8) void {940pub fn addCSourceFile(self: *Compile, source: CSourceFile) void {
939 self.addCSourceFileSource(.{
940 .args = flags,
941 .source = .{ .path = file },
942 });
943}
944
945pub fn addCSourceFileSource(self: *Compile, source: CSourceFile) void {
946 const b = self.step.owner;941 const b = self.step.owner;
947 const c_source_file = b.allocator.create(CSourceFile) catch @panic("OOM");942 const c_source_file = b.allocator.create(CSourceFile) catch @panic("OOM");
948 c_source_file.* = source.dupe(b);943 c_source_file.* = source.dupe(b);
949 self.link_objects.append(.{ .c_source_file = c_source_file }) catch @panic("OOM");944 self.link_objects.append(.{ .c_source_file = c_source_file }) catch @panic("OOM");
950 source.source.addStepDependencies(&self.step);945 source.file.addStepDependencies(&self.step);
951}946}
952947
953pub fn setVerboseLink(self: *Compile, value: bool) void {948pub fn setVerboseLink(self: *Compile, value: bool) void {
...@@ -958,53 +953,63 @@ pub fn setVerboseCC(self: *Compile, value: bool) void {...@@ -958,53 +953,63 @@ pub fn setVerboseCC(self: *Compile, value: bool) void {
958 self.verbose_cc = value;953 self.verbose_cc = value;
959}954}
960955
961pub fn overrideZigLibDir(self: *Compile, dir_path: []const u8) void {956pub fn overrideZigLibDir(self: *Compile, dir_path: LazyPath) void {
962 const b = self.step.owner;957 self.zig_lib_dir = dir_path.dupe(self.step.owner);
963 self.zig_lib_dir = b.dupePath(dir_path);958 dir_path.addStepDependencies(&self.step);
964}959}
965960
966pub fn setMainPkgPath(self: *Compile, dir_path: []const u8) void {961pub fn setMainPkgPath(self: *Compile, dir_path: LazyPath) void {
967 const b = self.step.owner;962 self.main_pkg_path = dir_path.dupe(self.step.owner);
968 self.main_pkg_path = b.dupePath(dir_path);963 dir_path.addStepDependencies(&self.step);
969}964}
970965
971pub fn setLibCFile(self: *Compile, libc_file: ?FileSource) void {966pub fn setLibCFile(self: *Compile, libc_file: ?LazyPath) void {
972 const b = self.step.owner;967 const b = self.step.owner;
973 self.libc_file = if (libc_file) |f| f.dupe(b) else null;968 self.libc_file = if (libc_file) |f| f.dupe(b) else null;
974}969}
975970
971pub const getOutputSource = getEmittedBin; // DEPRECATED, use getEmittedBin
972
976/// Returns the generated executable, library or object file.973/// Returns the generated executable, library or object file.
977/// To run an executable built with zig build, use `run`, or create an install step and invoke it.974/// To run an executable built with zig build, use `run`, or create an install step and invoke it.
978pub fn getOutputSource(self: *Compile) FileSource {975pub fn getEmittedBin(self: *Compile) LazyPath {
979 return .{ .generated = &self.output_path_source };976 return .{ .generated = &self.output_path_source };
980}977}
981978
982pub fn getOutputDirectorySource(self: *Compile) FileSource {979pub const getOutputDirectorySource = getEmitDirectory; // DEPRECATED, use getEmitDirectory
980
981pub fn getEmitDirectory(self: *Compile) LazyPath {
983 return .{ .generated = &self.output_dirname_source };982 return .{ .generated = &self.output_dirname_source };
984}983}
985984
985pub const getOutputLibSource = getEmittedImplib; // DEPRECATED, use getEmittedImplib
986
986/// Returns the generated import library. This function can only be called for libraries.987/// Returns the generated import library. This function can only be called for libraries.
987pub fn getOutputLibSource(self: *Compile) FileSource {988pub fn getEmittedImplib(self: *Compile) LazyPath {
988 assert(self.kind == .lib);989 assert(self.kind == .lib);
989 return .{ .generated = &self.output_lib_path_source };990 return .{ .generated = &self.output_lib_path_source };
990}991}
991992
993pub const getOutputHSource = getEmittedH; // DEPRECATED, use getEmittedH
994
992/// Returns the generated header file.995/// Returns the generated header file.
993/// This function can only be called for libraries or object files which have `emit_h` set.996/// This function can only be called for libraries or object files which have `emit_h` set.
994pub fn getOutputHSource(self: *Compile) FileSource {997pub fn getEmittedH(self: *Compile) LazyPath {
995 assert(self.kind != .exe and self.kind != .@"test");998 assert(self.kind != .exe and self.kind != .@"test");
996 assert(self.emit_h);999 assert(self.emit_h);
997 return .{ .generated = &self.output_h_path_source };1000 return .{ .generated = &self.output_h_path_source };
998}1001}
9991002
1003pub const getOutputPdbSource = getEmittedPdb; // DEPRECATED, use getEmittedPdb
1004
1000/// Returns the generated PDB file. This function can only be called for Windows and UEFI.1005/// Returns the generated PDB file. This function can only be called for Windows and UEFI.
1001pub fn getOutputPdbSource(self: *Compile) FileSource {1006pub fn getEmittedPdb(self: *Compile) LazyPath {
1002 // TODO: Is this right? Isn't PDB for *any* PE/COFF file?1007 // TODO: Is this right? Isn't PDB for *any* PE/COFF file?
1003 assert(self.target.isWindows() or self.target.isUefi());1008 assert(self.target.isWindows() or self.target.isUefi());
1004 return .{ .generated = &self.output_pdb_path_source };1009 return .{ .generated = &self.output_pdb_path_source };
1005}1010}
10061011
1007pub fn getEmittedDocs(self: *Compile) FileSource {1012pub fn getEmittedDocs(self: *Compile) LazyPath {
1008 if (self.generated_docs) |g| return .{ .generated = g };1013 if (self.generated_docs) |g| return .{ .generated = g };
1009 const arena = self.step.owner.allocator;1014 const arena = self.step.owner.allocator;
1010 const generated_file = arena.create(GeneratedFile) catch @panic("OOM");1015 const generated_file = arena.create(GeneratedFile) catch @panic("OOM");
...@@ -1013,25 +1018,14 @@ pub fn getEmittedDocs(self: *Compile) FileSource {...@@ -1013,25 +1018,14 @@ pub fn getEmittedDocs(self: *Compile) FileSource {
1013 return .{ .generated = generated_file };1018 return .{ .generated = generated_file };
1014}1019}
10151020
1016pub fn addAssemblyFile(self: *Compile, path: []const u8) void {1021pub fn addAssemblyFile(self: *Compile, source: LazyPath) void {
1017 const b = self.step.owner;
1018 self.link_objects.append(.{
1019 .assembly_file = .{ .path = b.dupe(path) },
1020 }) catch @panic("OOM");
1021}
1022
1023pub fn addAssemblyFileSource(self: *Compile, source: FileSource) void {
1024 const b = self.step.owner;1022 const b = self.step.owner;
1025 const source_duped = source.dupe(b);1023 const source_duped = source.dupe(b);
1026 self.link_objects.append(.{ .assembly_file = source_duped }) catch @panic("OOM");1024 self.link_objects.append(.{ .assembly_file = source_duped }) catch @panic("OOM");
1027 source_duped.addStepDependencies(&self.step);1025 source_duped.addStepDependencies(&self.step);
1028}1026}
10291027
1030pub fn addObjectFile(self: *Compile, source_file: []const u8) void {1028pub fn addObjectFile(self: *Compile, source: LazyPath) void {
1031 self.addObjectFileSource(.{ .path = source_file });
1032}
1033
1034pub fn addObjectFileSource(self: *Compile, source: FileSource) void {
1035 const b = self.step.owner;1029 const b = self.step.owner;
1036 self.link_objects.append(.{ .static_path = source.dupe(b) }) catch @panic("OOM");1030 self.link_objects.append(.{ .static_path = source.dupe(b) }) catch @panic("OOM");
1037 source.addStepDependencies(&self.step);1031 source.addStepDependencies(&self.step);
...@@ -1042,14 +1036,16 @@ pub fn addObject(self: *Compile, obj: *Compile) void {...@@ -1042,14 +1036,16 @@ pub fn addObject(self: *Compile, obj: *Compile) void {
1042 self.linkLibraryOrObject(obj);1036 self.linkLibraryOrObject(obj);
1043}1037}
10441038
1045pub fn addSystemIncludePath(self: *Compile, path: []const u8) void {1039pub fn addSystemIncludePath(self: *Compile, path: LazyPath) void {
1046 const b = self.step.owner;1040 const b = self.step.owner;
1047 self.include_dirs.append(IncludeDir{ .raw_path_system = b.dupe(path) }) catch @panic("OOM");1041 self.include_dirs.append(IncludeDir{ .path_system = path.dupe(b) }) catch @panic("OOM");
1042 path.addStepDependencies(&self.step);
1048}1043}
10491044
1050pub fn addIncludePath(self: *Compile, path: []const u8) void {1045pub fn addIncludePath(self: *Compile, path: LazyPath) void {
1051 const b = self.step.owner;1046 const b = self.step.owner;
1052 self.include_dirs.append(IncludeDir{ .raw_path = b.dupe(path) }) catch @panic("OOM");1047 self.include_dirs.append(IncludeDir{ .path = path.dupe(b) }) catch @panic("OOM");
1048 path.addStepDependencies(&self.step);
1053}1049}
10541050
1055pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {1051pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {
...@@ -1057,32 +1053,17 @@ pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {...@@ -1057,32 +1053,17 @@ pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {
1057 self.include_dirs.append(.{ .config_header_step = config_header }) catch @panic("OOM");1053 self.include_dirs.append(.{ .config_header_step = config_header }) catch @panic("OOM");
1058}1054}
10591055
1060pub fn addLibraryPath(self: *Compile, path: []const u8) void {1056pub fn addLibraryPath(self: *Compile, directory_source: LazyPath) void {
1061 const b = self.step.owner;
1062 self.lib_paths.append(.{ .path = b.dupe(path) }) catch @panic("OOM");
1063}
1064
1065pub fn addLibraryPathDirectorySource(self: *Compile, directory_source: FileSource) void {
1066 self.lib_paths.append(directory_source) catch @panic("OOM");1057 self.lib_paths.append(directory_source) catch @panic("OOM");
1067 directory_source.addStepDependencies(&self.step);1058 directory_source.addStepDependencies(&self.step);
1068}1059}
10691060
1070pub fn addRPath(self: *Compile, path: []const u8) void {1061pub fn addRPath(self: *Compile, directory_source: LazyPath) void {
1071 const b = self.step.owner;
1072 self.rpaths.append(.{ .path = b.dupe(path) }) catch @panic("OOM");
1073}
1074
1075pub fn addRPathDirectorySource(self: *Compile, directory_source: FileSource) void {
1076 self.rpaths.append(directory_source) catch @panic("OOM");1062 self.rpaths.append(directory_source) catch @panic("OOM");
1077 directory_source.addStepDependencies(&self.step);1063 directory_source.addStepDependencies(&self.step);
1078}1064}
10791065
1080pub fn addFrameworkPath(self: *Compile, dir_path: []const u8) void {1066pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void {
1081 const b = self.step.owner;
1082 self.framework_dirs.append(.{ .path = b.dupe(dir_path) }) catch @panic("OOM");
1083}
1084
1085pub fn addFrameworkPathDirectorySource(self: *Compile, directory_source: FileSource) void {
1086 self.framework_dirs.append(directory_source) catch @panic("OOM");1067 self.framework_dirs.append(directory_source) catch @panic("OOM");
1087 directory_source.addStepDependencies(&self.step);1068 directory_source.addStepDependencies(&self.step);
1088}1069}
...@@ -1364,7 +1345,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1364,7 +1345,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1364 .exe => @panic("Cannot link with an executable build artifact"),1345 .exe => @panic("Cannot link with an executable build artifact"),
1365 .@"test" => @panic("Cannot link with a test"),1346 .@"test" => @panic("Cannot link with a test"),
1366 .obj => {1347 .obj => {
1367 try zig_args.append(other.getOutputSource().getPath(b));1348 try zig_args.append(other.getEmittedBin().getPath(b));
1368 },1349 },
1369 .lib => l: {1350 .lib => l: {
1370 if (self.isStaticLibrary() and other.isStaticLibrary()) {1351 if (self.isStaticLibrary() and other.isStaticLibrary()) {
...@@ -1372,7 +1353,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1372,7 +1353,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1372 break :l;1353 break :l;
1373 }1354 }
13741355
1375 const full_path_lib = other.getOutputLibSource().getPath(b);1356 const full_path_lib = other.getEmittedImplib().getPath(b);
1376 try zig_args.append(full_path_lib);1357 try zig_args.append(full_path_lib);
13771358
1378 if (other.linkage == Linkage.dynamic and !self.target.isWindows()) {1359 if (other.linkage == Linkage.dynamic and !self.target.isWindows()) {
...@@ -1432,7 +1413,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1432,7 +1413,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1432 },1413 },
14331414
1434 .c_source_file => |c_source_file| {1415 .c_source_file => |c_source_file| {
1435 if (c_source_file.args.len == 0) {1416 if (c_source_file.flags.len == 0) {
1436 if (prev_has_cflags) {1417 if (prev_has_cflags) {
1437 try zig_args.append("-cflags");1418 try zig_args.append("-cflags");
1438 try zig_args.append("--");1419 try zig_args.append("--");
...@@ -1440,13 +1421,13 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1440,13 +1421,13 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1440 }1421 }
1441 } else {1422 } else {
1442 try zig_args.append("-cflags");1423 try zig_args.append("-cflags");
1443 for (c_source_file.args) |arg| {1424 for (c_source_file.flags) |arg| {
1444 try zig_args.append(arg);1425 try zig_args.append(arg);
1445 }1426 }
1446 try zig_args.append("--");1427 try zig_args.append("--");
1447 prev_has_cflags = true;1428 prev_has_cflags = true;
1448 }1429 }
1449 try zig_args.append(c_source_file.source.getPath(b));1430 try zig_args.append(c_source_file.file.getPath(b));
1450 },1431 },
14511432
1452 .c_source_files => |c_source_files| {1433 .c_source_files => |c_source_files| {
...@@ -1746,18 +1727,18 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1746,18 +1727,18 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
17461727
1747 for (self.include_dirs.items) |include_dir| {1728 for (self.include_dirs.items) |include_dir| {
1748 switch (include_dir) {1729 switch (include_dir) {
1749 .raw_path => |include_path| {1730 .path => |include_path| {
1750 try zig_args.append("-I");1731 try zig_args.append("-I");
1751 try zig_args.append(b.pathFromRoot(include_path));1732 try zig_args.append(include_path.getPath(b));
1752 },1733 },
1753 .raw_path_system => |include_path| {1734 .path_system => |include_path| {
1754 if (b.sysroot != null) {1735 if (b.sysroot != null) {
1755 try zig_args.append("-iwithsysroot");1736 try zig_args.append("-iwithsysroot");
1756 } else {1737 } else {
1757 try zig_args.append("-isystem");1738 try zig_args.append("-isystem");
1758 }1739 }
17591740
1760 const resolved_include_path = b.pathFromRoot(include_path);1741 const resolved_include_path = include_path.getPath(b);
17611742
1762 const common_include_path = if (builtin.os.tag == .windows and b.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: {1743 const common_include_path = if (builtin.os.tag == .windows and b.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: {
1763 // We need to check for disk designator and strip it out from dir path so1744 // We need to check for disk designator and strip it out from dir path so
...@@ -1775,7 +1756,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1775,7 +1756,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1775 },1756 },
1776 .other_step => |other| {1757 .other_step => |other| {
1777 if (other.emit_h) {1758 if (other.emit_h) {
1778 const h_path = other.getOutputHSource().getPath(b);1759 const h_path = other.getEmittedH().getPath(b);
1779 try zig_args.append("-isystem");1760 try zig_args.append("-isystem");
1780 try zig_args.append(fs.path.dirname(h_path).?);1761 try zig_args.append(fs.path.dirname(h_path).?);
1781 }1762 }
...@@ -1907,7 +1888,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1907,7 +1888,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
19071888
1908 if (self.zig_lib_dir) |dir| {1889 if (self.zig_lib_dir) |dir| {
1909 try zig_args.append("--zig-lib-dir");1890 try zig_args.append("--zig-lib-dir");
1910 try zig_args.append(b.pathFromRoot(dir));1891 try zig_args.append(dir.getPath(b));
1911 } else if (b.zig_lib_dir) |dir| {1892 } else if (b.zig_lib_dir) |dir| {
1912 try zig_args.append("--zig-lib-dir");1893 try zig_args.append("--zig-lib-dir");
1913 try zig_args.append(dir);1894 try zig_args.append(dir);
...@@ -1915,7 +1896,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1915,7 +1896,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
19151896
1916 if (self.main_pkg_path) |dir| {1897 if (self.main_pkg_path) |dir| {
1917 try zig_args.append("--main-pkg-path");1898 try zig_args.append("--main-pkg-path");
1918 try zig_args.append(b.pathFromRoot(dir));1899 try zig_args.append(dir.getPath(b));
1919 }1900 }
19201901
1921 try addFlag(&zig_args, "PIC", self.force_pic);1902 try addFlag(&zig_args, "PIC", self.force_pic);
...@@ -2042,7 +2023,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -2042,7 +2023,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
2042 {2023 {
2043 try doAtomicSymLinks(2024 try doAtomicSymLinks(
2044 step,2025 step,
2045 self.getOutputSource().getPath(b),2026 self.getEmittedBin().getPath(b),
2046 self.major_only_filename.?,2027 self.major_only_filename.?,
2047 self.name_only_filename.?,2028 self.name_only_filename.?,
2048 );2029 );
lib/std/Build/Step/ConfigHeader.zig+10-6
...@@ -6,16 +6,18 @@ const Allocator = std.mem.Allocator;...@@ -6,16 +6,18 @@ const Allocator = std.mem.Allocator;
6pub const Style = union(enum) {6pub const Style = union(enum) {
7 /// The configure format supported by autotools. It uses `#undef foo` to7 /// The configure format supported by autotools. It uses `#undef foo` to
8 /// mark lines that can be substituted with different values.8 /// mark lines that can be substituted with different values.
9 autoconf: std.Build.FileSource,9 autoconf: std.Build.LazyPath,
10 /// The configure format supported by CMake. It uses `@@FOO@@` and10 /// The configure format supported by CMake. It uses `@@FOO@@` and
11 /// `#cmakedefine` for template substitution.11 /// `#cmakedefine` for template substitution.
12 cmake: std.Build.FileSource,12 cmake: std.Build.LazyPath,
13 /// Instead of starting with an input file, start with nothing.13 /// Instead of starting with an input file, start with nothing.
14 blank,14 blank,
15 /// Start with nothing, like blank, and output a nasm .asm file.15 /// Start with nothing, like blank, and output a nasm .asm file.
16 nasm,16 nasm,
1717
18 pub fn getFileSource(style: Style) ?std.Build.FileSource {18 pub const getFileSource = getPath; // DEPRECATED, use getPath
19
20 pub fn getPath(style: Style) ?std.Build.LazyPath {
19 switch (style) {21 switch (style) {
20 .autoconf, .cmake => |s| return s,22 .autoconf, .cmake => |s| return s,
21 .blank, .nasm => return null,23 .blank, .nasm => return null,
...@@ -54,7 +56,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {...@@ -54,7 +56,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
5456
55 var include_path: []const u8 = "config.h";57 var include_path: []const u8 = "config.h";
5658
57 if (options.style.getFileSource()) |s| switch (s) {59 if (options.style.getPath()) |s| switch (s) {
58 .path => |p| {60 .path => |p| {
59 const basename = std.fs.path.basename(p);61 const basename = std.fs.path.basename(p);
60 if (std.mem.endsWith(u8, basename, ".h.in")) {62 if (std.mem.endsWith(u8, basename, ".h.in")) {
...@@ -68,7 +70,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {...@@ -68,7 +70,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
68 include_path = p;70 include_path = p;
69 }71 }
7072
71 const name = if (options.style.getFileSource()) |s|73 const name = if (options.style.getPath()) |s|
72 owner.fmt("configure {s} header {s} to {s}", .{74 owner.fmt("configure {s} header {s} to {s}", .{
73 @tagName(options.style), s.getDisplayName(), include_path,75 @tagName(options.style), s.getDisplayName(), include_path,
74 })76 })
...@@ -98,7 +100,9 @@ pub fn addValues(self: *ConfigHeader, values: anytype) void {...@@ -98,7 +100,9 @@ pub fn addValues(self: *ConfigHeader, values: anytype) void {
98 return addValuesInner(self, values) catch @panic("OOM");100 return addValuesInner(self, values) catch @panic("OOM");
99}101}
100102
101pub fn getFileSource(self: *ConfigHeader) std.Build.FileSource {103pub const getFileSource = getTemplate; // DEPRECATED, use getOutput
104
105pub fn getTemplate(self: *ConfigHeader) std.Build.LazyPath {
102 return .{ .generated = &self.output_file };106 return .{ .generated = &self.output_file };
103}107}
104108
lib/std/Build/Step/InstallArtifact.zig+4-4
...@@ -76,7 +76,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -76,7 +76,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
76 var all_cached = true;76 var all_cached = true;
7777
78 {78 {
79 const full_src_path = self.artifact.getOutputSource().getPath(src_builder);79 const full_src_path = self.artifact.getEmittedBin().getPath(src_builder);
80 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {80 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {
81 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{81 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{
82 full_src_path, full_dest_path, @errorName(err),82 full_src_path, full_dest_path, @errorName(err),
...@@ -95,7 +95,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -95,7 +95,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
95 self.artifact.target.isWindows() and95 self.artifact.target.isWindows() and
96 self.artifact.emit_implib != .no_emit)96 self.artifact.emit_implib != .no_emit)
97 {97 {
98 const full_src_path = self.artifact.getOutputLibSource().getPath(src_builder);98 const full_src_path = self.artifact.getEmittedImplib().getPath(src_builder);
99 const full_implib_path = dest_builder.getInstallPath(self.dest_dir, self.artifact.out_lib_filename);99 const full_implib_path = dest_builder.getInstallPath(self.dest_dir, self.artifact.out_lib_filename);
100 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_implib_path, .{}) catch |err| {100 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_implib_path, .{}) catch |err| {
101 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{101 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{
...@@ -105,7 +105,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -105,7 +105,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
105 all_cached = all_cached and p == .fresh;105 all_cached = all_cached and p == .fresh;
106 }106 }
107 if (self.pdb_dir) |pdb_dir| {107 if (self.pdb_dir) |pdb_dir| {
108 const full_src_path = self.artifact.getOutputPdbSource().getPath(src_builder);108 const full_src_path = self.artifact.getEmittedPdb().getPath(src_builder);
109 const full_pdb_path = dest_builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename);109 const full_pdb_path = dest_builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename);
110 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_pdb_path, .{}) catch |err| {110 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_pdb_path, .{}) catch |err| {
111 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{111 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{
...@@ -115,7 +115,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -115,7 +115,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
115 all_cached = all_cached and p == .fresh;115 all_cached = all_cached and p == .fresh;
116 }116 }
117 if (self.h_dir) |h_dir| {117 if (self.h_dir) |h_dir| {
118 const full_src_path = self.artifact.getOutputHSource().getPath(src_builder);118 const full_src_path = self.artifact.getEmittedH().getPath(src_builder);
119 const full_h_path = dest_builder.getInstallPath(h_dir, self.artifact.out_h_filename);119 const full_h_path = dest_builder.getInstallPath(h_dir, self.artifact.out_h_filename);
120 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_h_path, .{}) catch |err| {120 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_h_path, .{}) catch |err| {
121 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{121 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{
lib/std/Build/Step/InstallDir.zig+2-2
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const mem = std.mem;2const mem = std.mem;
3const fs = std.fs;3const fs = std.fs;
4const Step = std.Build.Step;4const Step = std.Build.Step;
5const FileSource = std.Build.FileSource;5const LazyPath = std.Build.LazyPath;
6const InstallDir = std.Build.InstallDir;6const InstallDir = std.Build.InstallDir;
7const InstallDirStep = @This();7const InstallDirStep = @This();
88
...@@ -15,7 +15,7 @@ dest_builder: *std.Build,...@@ -15,7 +15,7 @@ dest_builder: *std.Build,
15pub const base_id = .install_dir;15pub const base_id = .install_dir;
1616
17pub const Options = struct {17pub const Options = struct {
18 source_dir: FileSource,18 source_dir: LazyPath,
19 install_dir: InstallDir,19 install_dir: InstallDir,
20 install_subdir: []const u8,20 install_subdir: []const u8,
21 /// File paths which end in any of these suffixes will be excluded21 /// File paths which end in any of these suffixes will be excluded
lib/std/Build/Step/InstallFile.zig+3-3
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
2const Step = std.Build.Step;2const Step = std.Build.Step;
3const FileSource = std.Build.FileSource;3const LazyPath = std.Build.LazyPath;
4const InstallDir = std.Build.InstallDir;4const InstallDir = std.Build.InstallDir;
5const InstallFile = @This();5const InstallFile = @This();
6const assert = std.debug.assert;6const assert = std.debug.assert;
...@@ -8,7 +8,7 @@ const assert = std.debug.assert;...@@ -8,7 +8,7 @@ const assert = std.debug.assert;
8pub const base_id = .install_file;8pub const base_id = .install_file;
99
10step: Step,10step: Step,
11source: FileSource,11source: LazyPath,
12dir: InstallDir,12dir: InstallDir,
13dest_rel_path: []const u8,13dest_rel_path: []const u8,
14/// This is used by the build system when a file being installed comes from one14/// This is used by the build system when a file being installed comes from one
...@@ -17,7 +17,7 @@ dest_builder: *std.Build,...@@ -17,7 +17,7 @@ dest_builder: *std.Build,
1717
18pub fn create(18pub fn create(
19 owner: *std.Build,19 owner: *std.Build,
20 source: FileSource,20 source: LazyPath,
21 dir: InstallDir,21 dir: InstallDir,
22 dest_rel_path: []const u8,22 dest_rel_path: []const u8,
23) *InstallFile {23) *InstallFile {
lib/std/Build/Step/ObjCopy.zig+10-8
...@@ -20,7 +20,7 @@ pub const RawFormat = enum {...@@ -20,7 +20,7 @@ pub const RawFormat = enum {
20};20};
2121
22step: Step,22step: Step,
23file_source: std.Build.FileSource,23input_file: std.Build.LazyPath,
24basename: []const u8,24basename: []const u8,
25output_file: std.Build.GeneratedFile,25output_file: std.Build.GeneratedFile,
2626
...@@ -37,30 +37,32 @@ pub const Options = struct {...@@ -37,30 +37,32 @@ pub const Options = struct {
3737
38pub fn create(38pub fn create(
39 owner: *std.Build,39 owner: *std.Build,
40 file_source: std.Build.FileSource,40 input_file: std.Build.LazyPath,
41 options: Options,41 options: Options,
42) *ObjCopy {42) *ObjCopy {
43 const self = owner.allocator.create(ObjCopy) catch @panic("OOM");43 const self = owner.allocator.create(ObjCopy) catch @panic("OOM");
44 self.* = ObjCopy{44 self.* = ObjCopy{
45 .step = Step.init(.{45 .step = Step.init(.{
46 .id = base_id,46 .id = base_id,
47 .name = owner.fmt("objcopy {s}", .{file_source.getDisplayName()}),47 .name = owner.fmt("objcopy {s}", .{input_file.getDisplayName()}),
48 .owner = owner,48 .owner = owner,
49 .makeFn = make,49 .makeFn = make,
50 }),50 }),
51 .file_source = file_source,51 .input_file = input_file,
52 .basename = options.basename orelse file_source.getDisplayName(),52 .basename = options.basename orelse input_file.getDisplayName(),
53 .output_file = std.Build.GeneratedFile{ .step = &self.step },53 .output_file = std.Build.GeneratedFile{ .step = &self.step },
5454
55 .format = options.format,55 .format = options.format,
56 .only_section = options.only_section,56 .only_section = options.only_section,
57 .pad_to = options.pad_to,57 .pad_to = options.pad_to,
58 };58 };
59 file_source.addStepDependencies(&self.step);59 input_file.addStepDependencies(&self.step);
60 return self;60 return self;
61}61}
6262
63pub fn getOutputSource(self: *const ObjCopy) std.Build.FileSource {63pub const getOutputSource = getOutput; // DEPRECATED, use getOutput
64
65pub fn getOutput(self: *const ObjCopy) std.Build.LazyPath {
64 return .{ .generated = &self.output_file };66 return .{ .generated = &self.output_file };
65}67}
6668
...@@ -75,7 +77,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -75,7 +77,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
75 // bytes when ObjCopy implementation is modified incompatibly.77 // bytes when ObjCopy implementation is modified incompatibly.
76 man.hash.add(@as(u32, 0xe18b7baf));78 man.hash.add(@as(u32, 0xe18b7baf));
7779
78 const full_src_path = self.file_source.getPath(b);80 const full_src_path = self.input_file.getPath(b);
79 _ = try man.addFile(full_src_path, null);81 _ = try man.addFile(full_src_path, null);
80 man.hash.addOptionalBytes(self.only_section);82 man.hash.addOptionalBytes(self.only_section);
81 man.hash.addOptional(self.pad_to);83 man.hash.addOptional(self.pad_to);
lib/std/Build/Step/Options.zig+23-31
...@@ -3,7 +3,7 @@ const builtin = @import("builtin");...@@ -3,7 +3,7 @@ const builtin = @import("builtin");
3const fs = std.fs;3const fs = std.fs;
4const Step = std.Build.Step;4const Step = std.Build.Step;
5const GeneratedFile = std.Build.GeneratedFile;5const GeneratedFile = std.Build.GeneratedFile;
6const FileSource = std.Build.FileSource;6const LazyPath = std.Build.LazyPath;
77
8const Options = @This();8const Options = @This();
99
...@@ -13,8 +13,7 @@ step: Step,...@@ -13,8 +13,7 @@ step: Step,
13generated_file: GeneratedFile,13generated_file: GeneratedFile,
1414
15contents: std.ArrayList(u8),15contents: std.ArrayList(u8),
16artifact_args: std.ArrayList(OptionArtifactArg),16args: std.ArrayList(OptionLazyPathArg),
17file_source_args: std.ArrayList(OptionFileSourceArg),
1817
19pub fn create(owner: *std.Build) *Options {18pub fn create(owner: *std.Build) *Options {
20 const self = owner.allocator.create(Options) catch @panic("OOM");19 const self = owner.allocator.create(Options) catch @panic("OOM");
...@@ -27,8 +26,7 @@ pub fn create(owner: *std.Build) *Options {...@@ -27,8 +26,7 @@ pub fn create(owner: *std.Build) *Options {
27 }),26 }),
28 .generated_file = undefined,27 .generated_file = undefined,
29 .contents = std.ArrayList(u8).init(owner.allocator),28 .contents = std.ArrayList(u8).init(owner.allocator),
30 .artifact_args = std.ArrayList(OptionArtifactArg).init(owner.allocator),29 .args = std.ArrayList(OptionLazyPathArg).init(owner.allocator),
31 .file_source_args = std.ArrayList(OptionFileSourceArg).init(owner.allocator),
32 };30 };
33 self.generated_file = .{ .step = &self.step };31 self.generated_file = .{ .step = &self.step };
3432
...@@ -168,35 +166,42 @@ fn printLiteral(out: anytype, val: anytype, indent: u8) !void {...@@ -168,35 +166,42 @@ fn printLiteral(out: anytype, val: anytype, indent: u8) !void {
168 }166 }
169}167}
170168
169pub const addOptionFileSource = addOptionPath; // DEPRECATED, use addPathOption
170
171/// The value is the path in the cache dir.171/// The value is the path in the cache dir.
172/// Adds a dependency automatically.172/// Adds a dependency automatically.
173pub fn addOptionFileSource(173pub fn addOptionPath(
174 self: *Options,174 self: *Options,
175 name: []const u8,175 name: []const u8,
176 source: FileSource,176 path: LazyPath,
177) void {177) void {
178 self.file_source_args.append(.{178 self.args.append(.{
179 .name = name,179 .name = self.step.owner.dupe(name),
180 .source = source.dupe(self.step.owner),180 .path = path.dupe(self.step.owner),
181 }) catch @panic("OOM");181 }) catch @panic("OOM");
182 source.addStepDependencies(&self.step);182 path.addStepDependencies(&self.step);
183}183}
184184
185/// The value is the path in the cache dir.185/// The value is the path in the cache dir.
186/// Adds a dependency automatically.186/// Adds a dependency automatically.
187pub fn addOptionArtifact(self: *Options, name: []const u8, artifact: *Step.Compile) void {187pub fn addOptionArtifact(self: *Options, name: []const u8, artifact: *Step.Compile) void {
188 self.artifact_args.append(.{ .name = self.step.owner.dupe(name), .artifact = artifact }) catch @panic("OOM");188 self.args.append(.{
189 .name = self.step.owner.dupe(name),
190 .artifact = artifact.getEmittedBin,
191 }) catch @panic("OOM");
189 self.step.dependOn(&artifact.step);192 self.step.dependOn(&artifact.step);
190}193}
191194
192pub fn createModule(self: *Options) *std.Build.Module {195pub fn createModule(self: *Options) *std.Build.Module {
193 return self.step.owner.createModule(.{196 return self.step.owner.createModule(.{
194 .source_file = self.getSource(),197 .source_file = self.getOutput(),
195 .dependencies = &.{},198 .dependencies = &.{},
196 });199 });
197}200}
198201
199pub fn getSource(self: *Options) FileSource {202pub const getSource = getOutput; // DEPRECATED, use getOutput
203
204pub fn getOutput(self: *Options) LazyPath {
200 return .{ .generated = &self.generated_file };205 return .{ .generated = &self.generated_file };
201}206}
202207
...@@ -207,19 +212,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -207,19 +212,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
207 const b = step.owner;212 const b = step.owner;
208 const self = @fieldParentPtr(Options, "step", step);213 const self = @fieldParentPtr(Options, "step", step);
209214
210 for (self.artifact_args.items) |item| {215 for (self.args.items) |item| {
211 self.addOption(
212 []const u8,
213 item.name,
214 b.pathFromRoot(item.artifact.getOutputSource().getPath(b)),
215 );
216 }
217
218 for (self.file_source_args.items) |item| {
219 self.addOption(216 self.addOption(
220 []const u8,217 []const u8,
221 item.name,218 item.name,
222 item.source.getPath(b),219 item.path.getPath(b),
223 );220 );
224 }221 }
225222
...@@ -294,14 +291,9 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -294,14 +291,9 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
294 }291 }
295}292}
296293
297const OptionArtifactArg = struct {294const OptionLazyPathArg = struct {
298 name: []const u8,
299 artifact: *Step.Compile,
300};
301
302const OptionFileSourceArg = struct {
303 name: []const u8,295 name: []const u8,
304 source: FileSource,296 path: LazyPath,
305};297};
306298
307test Options {299test Options {
lib/std/Build/Step/Run.zig+28-20
...@@ -82,7 +82,7 @@ has_side_effects: bool = false,...@@ -82,7 +82,7 @@ has_side_effects: bool = false,
82pub const StdIn = union(enum) {82pub const StdIn = union(enum) {
83 none,83 none,
84 bytes: []const u8,84 bytes: []const u8,
85 file_source: std.Build.FileSource,85 file_source: std.Build.LazyPath,
86};86};
8787
88pub const StdIo = union(enum) {88pub const StdIo = union(enum) {
...@@ -120,15 +120,15 @@ pub const StdIo = union(enum) {...@@ -120,15 +120,15 @@ pub const StdIo = union(enum) {
120120
121pub const Arg = union(enum) {121pub const Arg = union(enum) {
122 artifact: *Step.Compile,122 artifact: *Step.Compile,
123 file_source: PrefixedFileSource,123 file_source: PrefixedLazyPath,
124 directory_source: PrefixedFileSource,124 directory_source: PrefixedLazyPath,
125 bytes: []u8,125 bytes: []u8,
126 output: *Output,126 output: *Output,
127};127};
128128
129pub const PrefixedFileSource = struct {129pub const PrefixedLazyPath = struct {
130 prefix: []const u8,130 prefix: []const u8,
131 file_source: std.Build.FileSource,131 file_source: std.Build.LazyPath,
132};132};
133133
134pub const Output = struct {134pub const Output = struct {
...@@ -169,9 +169,9 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void {...@@ -169,9 +169,9 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void {
169}169}
170170
171/// This provides file path as a command line argument to the command being171/// This provides file path as a command line argument to the command being
172/// run, and returns a FileSource which can be used as inputs to other APIs172/// run, and returns a LazyPath which can be used as inputs to other APIs
173/// throughout the build system.173/// throughout the build system.
174pub fn addOutputFileArg(self: *Run, basename: []const u8) std.Build.FileSource {174pub fn addOutputFileArg(self: *Run, basename: []const u8) std.Build.LazyPath {
175 return self.addPrefixedOutputFileArg("", basename);175 return self.addPrefixedOutputFileArg("", basename);
176}176}
177177
...@@ -179,7 +179,7 @@ pub fn addPrefixedOutputFileArg(...@@ -179,7 +179,7 @@ pub fn addPrefixedOutputFileArg(
179 self: *Run,179 self: *Run,
180 prefix: []const u8,180 prefix: []const u8,
181 basename: []const u8,181 basename: []const u8,
182) std.Build.FileSource {182) std.Build.LazyPath {
183 const b = self.step.owner;183 const b = self.step.owner;
184184
185 const output = b.allocator.create(Output) catch @panic("OOM");185 const output = b.allocator.create(Output) catch @panic("OOM");
...@@ -197,14 +197,18 @@ pub fn addPrefixedOutputFileArg(...@@ -197,14 +197,18 @@ pub fn addPrefixedOutputFileArg(
197 return .{ .generated = &output.generated_file };197 return .{ .generated = &output.generated_file };
198}198}
199199
200pub fn addFileSourceArg(self: *Run, file_source: std.Build.FileSource) void {200pub const addFileSourceArg = addFileArg; // DEPRECATED, use addFileArg
201 self.addPrefixedFileSourceArg("", file_source);201
202pub fn addFileArg(self: *Run, file_source: std.Build.LazyPath) void {
203 self.addPrefixedFileArg("", file_source);
202}204}
203205
204pub fn addPrefixedFileSourceArg(self: *Run, prefix: []const u8, file_source: std.Build.FileSource) void {206pub const addPrefixedFileSourceArg = addPrefixedFileArg; // DEPRECATED, use addPrefixedFileArg
207
208pub fn addPrefixedFileArg(self: *Run, prefix: []const u8, file_source: std.Build.LazyPath) void {
205 const b = self.step.owner;209 const b = self.step.owner;
206210
207 const prefixed_file_source: PrefixedFileSource = .{211 const prefixed_file_source: PrefixedLazyPath = .{
208 .prefix = b.dupe(prefix),212 .prefix = b.dupe(prefix),
209 .file_source = file_source.dupe(b),213 .file_source = file_source.dupe(b),
210 };214 };
...@@ -212,14 +216,18 @@ pub fn addPrefixedFileSourceArg(self: *Run, prefix: []const u8, file_source: std...@@ -212,14 +216,18 @@ pub fn addPrefixedFileSourceArg(self: *Run, prefix: []const u8, file_source: std
212 file_source.addStepDependencies(&self.step);216 file_source.addStepDependencies(&self.step);
213}217}
214218
215pub fn addDirectorySourceArg(self: *Run, directory_source: std.Build.FileSource) void {219pub const addDirectorySourceArg = addDirectoryArg; // DEPRECATED, use addDirectoryArg
216 self.addPrefixedDirectorySourceArg("", directory_source);220
221pub fn addDirectoryArg(self: *Run, directory_source: std.Build.LazyPath) void {
222 self.addPrefixedDirectoryArg("", directory_source);
217}223}
218224
219pub fn addPrefixedDirectorySourceArg(self: *Run, prefix: []const u8, directory_source: std.Build.FileSource) void {225pub const addPrefixedDirectorySourceArg = addPrefixedDirectoryArg; // DEPRECATED, use addPrefixedDirectoryArg
226
227pub fn addPrefixedDirectoryArg(self: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void {
220 const b = self.step.owner;228 const b = self.step.owner;
221229
222 const prefixed_directory_source: PrefixedFileSource = .{230 const prefixed_directory_source: PrefixedLazyPath = .{
223 .prefix = b.dupe(prefix),231 .prefix = b.dupe(prefix),
224 .file_source = directory_source.dupe(b),232 .file_source = directory_source.dupe(b),
225 };233 };
...@@ -331,7 +339,7 @@ pub fn addCheck(self: *Run, new_check: StdIo.Check) void {...@@ -331,7 +339,7 @@ pub fn addCheck(self: *Run, new_check: StdIo.Check) void {
331 }339 }
332}340}
333341
334pub fn captureStdErr(self: *Run) std.Build.FileSource {342pub fn captureStdErr(self: *Run) std.Build.LazyPath {
335 assert(self.stdio != .inherit);343 assert(self.stdio != .inherit);
336344
337 if (self.captured_stderr) |output| return .{ .generated = &output.generated_file };345 if (self.captured_stderr) |output| return .{ .generated = &output.generated_file };
...@@ -346,7 +354,7 @@ pub fn captureStdErr(self: *Run) std.Build.FileSource {...@@ -346,7 +354,7 @@ pub fn captureStdErr(self: *Run) std.Build.FileSource {
346 return .{ .generated = &output.generated_file };354 return .{ .generated = &output.generated_file };
347}355}
348356
349pub fn captureStdOut(self: *Run) std.Build.FileSource {357pub fn captureStdOut(self: *Run) std.Build.LazyPath {
350 assert(self.stdio != .inherit);358 assert(self.stdio != .inherit);
351359
352 if (self.captured_stdout) |output| return .{ .generated = &output.generated_file };360 if (self.captured_stdout) |output| return .{ .generated = &output.generated_file };
...@@ -449,7 +457,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -449,7 +457,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
449 self.addPathForDynLibs(artifact);457 self.addPathForDynLibs(artifact);
450 }458 }
451 const file_path = artifact.installed_path orelse459 const file_path = artifact.installed_path orelse
452 artifact.getOutputSource().getPath(b);460 artifact.getEmittedBin().getPath(b);
453461
454 try argv_list.append(file_path);462 try argv_list.append(file_path);
455463
...@@ -1241,7 +1249,7 @@ fn addPathForDynLibs(self: *Run, artifact: *Step.Compile) void {...@@ -1241,7 +1249,7 @@ fn addPathForDynLibs(self: *Run, artifact: *Step.Compile) void {
1241 switch (link_object) {1249 switch (link_object) {
1242 .other_step => |other| {1250 .other_step => |other| {
1243 if (other.target.isWindows() and other.isDynamicLibrary()) {1251 if (other.target.isWindows() and other.isDynamicLibrary()) {
1244 addPathDir(self, fs.path.dirname(other.getOutputSource().getPath(b)).?);1252 addPathDir(self, fs.path.dirname(other.getEmittedBin().getPath(b)).?);
1245 addPathForDynLibs(self, other);1253 addPathForDynLibs(self, other);
1246 }1254 }
1247 },1255 },
lib/std/Build/Step/TranslateC.zig+10-6
...@@ -9,7 +9,7 @@ const TranslateC = @This();...@@ -9,7 +9,7 @@ const TranslateC = @This();
9pub const base_id = .translate_c;9pub const base_id = .translate_c;
1010
11step: Step,11step: Step,
12source: std.Build.FileSource,12source: std.Build.LazyPath,
13include_dirs: std.ArrayList([]const u8),13include_dirs: std.ArrayList([]const u8),
14c_macros: std.ArrayList([]const u8),14c_macros: std.ArrayList([]const u8),
15out_basename: []const u8,15out_basename: []const u8,
...@@ -18,7 +18,7 @@ optimize: std.builtin.OptimizeMode,...@@ -18,7 +18,7 @@ optimize: std.builtin.OptimizeMode,
18output_file: std.Build.GeneratedFile,18output_file: std.Build.GeneratedFile,
1919
20pub const Options = struct {20pub const Options = struct {
21 source_file: std.Build.FileSource,21 source_file: std.Build.LazyPath,
22 target: CrossTarget,22 target: CrossTarget,
23 optimize: std.builtin.OptimizeMode,23 optimize: std.builtin.OptimizeMode,
24};24};
...@@ -53,10 +53,14 @@ pub const AddExecutableOptions = struct {...@@ -53,10 +53,14 @@ pub const AddExecutableOptions = struct {
53 linkage: ?Step.Compile.Linkage = null,53 linkage: ?Step.Compile.Linkage = null,
54};54};
5555
56pub fn getOutput(self: *TranslateC) std.Build.LazyPath {
57 return .{ .generated = &self.output_file };
58}
59
56/// Creates a step to build an executable from the translated source.60/// Creates a step to build an executable from the translated source.
57pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Compile {61pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Compile {
58 return self.step.owner.addExecutable(.{62 return self.step.owner.addExecutable(.{
59 .root_source_file = .{ .generated = &self.output_file },63 .root_source_file = self.getOutput(),
60 .name = options.name orelse "translated_c",64 .name = options.name orelse "translated_c",
61 .version = options.version,65 .version = options.version,
62 .target = options.target orelse self.target,66 .target = options.target orelse self.target,
...@@ -70,7 +74,7 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com...@@ -70,7 +74,7 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com
70/// `createModule` can be used instead to create a private module.74/// `createModule` can be used instead to create a private module.
71pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module {75pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module {
72 return self.step.owner.addModule(name, .{76 return self.step.owner.addModule(name, .{
73 .source_file = .{ .generated = &self.output_file },77 .source_file = self.getOutput(),
74 });78 });
75}79}
7680
...@@ -83,7 +87,7 @@ pub fn createModule(self: *TranslateC) *std.Build.Module {...@@ -83,7 +87,7 @@ pub fn createModule(self: *TranslateC) *std.Build.Module {
8387
84 module.* = .{88 module.* = .{
85 .builder = b,89 .builder = b,
86 .source_file = .{ .generated = &self.output_file },90 .source_file = self.getOutput(),
87 .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator),91 .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator),
88 };92 };
89 return module;93 return module;
...@@ -96,7 +100,7 @@ pub fn addIncludeDir(self: *TranslateC, include_dir: []const u8) void {...@@ -96,7 +100,7 @@ pub fn addIncludeDir(self: *TranslateC, include_dir: []const u8) void {
96pub fn addCheckFile(self: *TranslateC, expected_matches: []const []const u8) *Step.CheckFile {100pub fn addCheckFile(self: *TranslateC, expected_matches: []const []const u8) *Step.CheckFile {
97 return Step.CheckFile.create(101 return Step.CheckFile.create(
98 self.step.owner,102 self.step.owner,
99 .{ .generated = &self.output_file },103 self.getOutput(),
100 .{ .expected_matches = expected_matches },104 .{ .expected_matches = expected_matches },
101 );105 );
102}106}
lib/std/Build/Step/WriteFile.zig+14-10
...@@ -28,7 +28,9 @@ pub const File = struct {...@@ -28,7 +28,9 @@ pub const File = struct {
28 sub_path: []const u8,28 sub_path: []const u8,
29 contents: Contents,29 contents: Contents,
3030
31 pub fn getFileSource(self: *File) std.Build.FileSource {31 pub const getFileSource = getPath; // DEPRECATED, use getPath
32
33 pub fn getPath(self: *File) std.Build.LazyPath {
32 return .{ .generated = &self.generated_file };34 return .{ .generated = &self.generated_file };
33 }35 }
34};36};
...@@ -40,7 +42,7 @@ pub const OutputSourceFile = struct {...@@ -40,7 +42,7 @@ pub const OutputSourceFile = struct {
4042
41pub const Contents = union(enum) {43pub const Contents = union(enum) {
42 bytes: []const u8,44 bytes: []const u8,
43 copy: std.Build.FileSource,45 copy: std.Build.LazyPath,
44};46};
4547
46pub fn create(owner: *std.Build) *WriteFile {48pub fn create(owner: *std.Build) *WriteFile {
...@@ -59,7 +61,7 @@ pub fn create(owner: *std.Build) *WriteFile {...@@ -59,7 +61,7 @@ pub fn create(owner: *std.Build) *WriteFile {
59 return wf;61 return wf;
60}62}
6163
62pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.FileSource {64pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.LazyPath {
63 const b = wf.step.owner;65 const b = wf.step.owner;
64 const gpa = b.allocator;66 const gpa = b.allocator;
65 const file = gpa.create(File) catch @panic("OOM");67 const file = gpa.create(File) catch @panic("OOM");
...@@ -70,7 +72,7 @@ pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.Fi...@@ -70,7 +72,7 @@ pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.Fi
70 };72 };
71 wf.files.append(gpa, file) catch @panic("OOM");73 wf.files.append(gpa, file) catch @panic("OOM");
72 wf.maybeUpdateName();74 wf.maybeUpdateName();
73 return file.getFileSource();75 return file.getPath();
74}76}
7577
76/// Place the file into the generated directory within the local cache,78/// Place the file into the generated directory within the local cache,
...@@ -80,7 +82,7 @@ pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.Fi...@@ -80,7 +82,7 @@ pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.Fi
80/// include sub-directories, in which case this step will ensure the82/// include sub-directories, in which case this step will ensure the
81/// required sub-path exists.83/// required sub-path exists.
82/// This is the option expected to be used most commonly with `addCopyFile`.84/// This is the option expected to be used most commonly with `addCopyFile`.
83pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []const u8) std.Build.FileSource {85pub fn addCopyFile(wf: *WriteFile, source: std.Build.LazyPath, sub_path: []const u8) std.Build.LazyPath {
84 const b = wf.step.owner;86 const b = wf.step.owner;
85 const gpa = b.allocator;87 const gpa = b.allocator;
86 const file = gpa.create(File) catch @panic("OOM");88 const file = gpa.create(File) catch @panic("OOM");
...@@ -93,7 +95,7 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []con...@@ -93,7 +95,7 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []con
9395
94 wf.maybeUpdateName();96 wf.maybeUpdateName();
95 source.addStepDependencies(&wf.step);97 source.addStepDependencies(&wf.step);
96 return file.getFileSource();98 return file.getLazyPath();
97}99}
98100
99/// A path relative to the package root.101/// A path relative to the package root.
...@@ -101,7 +103,7 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []con...@@ -101,7 +103,7 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []con
101/// used as part of the normal build process, but as a utility occasionally103/// used as part of the normal build process, but as a utility occasionally
102/// run by a developer with intent to modify source files and then commit104/// run by a developer with intent to modify source files and then commit
103/// those changes to version control.105/// those changes to version control.
104pub fn addCopyFileToSource(wf: *WriteFile, source: std.Build.FileSource, sub_path: []const u8) void {106pub fn addCopyFileToSource(wf: *WriteFile, source: std.Build.LazyPath, sub_path: []const u8) void {
105 const b = wf.step.owner;107 const b = wf.step.owner;
106 wf.output_source_files.append(b.allocator, .{108 wf.output_source_files.append(b.allocator, .{
107 .contents = .{ .copy = source },109 .contents = .{ .copy = source },
...@@ -123,11 +125,13 @@ pub fn addBytesToSource(wf: *WriteFile, bytes: []const u8, sub_path: []const u8)...@@ -123,11 +125,13 @@ pub fn addBytesToSource(wf: *WriteFile, bytes: []const u8, sub_path: []const u8)
123 }) catch @panic("OOM");125 }) catch @panic("OOM");
124}126}
125127
126pub const getFileSource = @compileError("Deprecated; use the return value from add()/addCopyFile(), or use files[i].getFileSource()");128pub const getFileSource = @compileError("Deprecated; use the return value from add()/addCopyFile(), or use files[i].getPath()");
129
130pub const getDirectorySource = getDirectory;
127131
128/// Returns a `FileSource` representing the base directory that contains all the132/// Returns a `LazyPath` representing the base directory that contains all the
129/// files from this `WriteFile`.133/// files from this `WriteFile`.
130pub fn getDirectorySource(wf: *WriteFile) std.Build.FileSource {134pub fn getDirectory(wf: *WriteFile) std.Build.LazyPath {
131 return .{ .generated = &wf.generated_directory };135 return .{ .generated = &wf.generated_directory };
132}136}
133137
test/link/interdependent_static_c_libs/build.zig+5-5
...@@ -16,16 +16,16 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -16,16 +16,16 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
16 .optimize = optimize,16 .optimize = optimize,
17 .target = .{},17 .target = .{},
18 });18 });
19 lib_a.addCSourceFile("a.c", &[_][]const u8{});19 lib_a.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &[_][]const u8{} });
20 lib_a.addIncludePath(".");20 lib_a.addIncludePath(.{ .path = "." });
2121
22 const lib_b = b.addStaticLibrary(.{22 const lib_b = b.addStaticLibrary(.{
23 .name = "b",23 .name = "b",
24 .optimize = optimize,24 .optimize = optimize,
25 .target = .{},25 .target = .{},
26 });26 });
27 lib_b.addCSourceFile("b.c", &[_][]const u8{});27 lib_b.addCSourceFile(.{ .file = .{ .path = "b.c" }, .flags = &[_][]const u8{} });
28 lib_b.addIncludePath(".");28 lib_b.addIncludePath(.{ .path = "." });
2929
30 const test_exe = b.addTest(.{30 const test_exe = b.addTest(.{
31 .root_source_file = .{ .path = "main.zig" },31 .root_source_file = .{ .path = "main.zig" },
...@@ -33,7 +33,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -33,7 +33,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
33 });33 });
34 test_exe.linkLibrary(lib_a);34 test_exe.linkLibrary(lib_a);
35 test_exe.linkLibrary(lib_b);35 test_exe.linkLibrary(lib_b);
36 test_exe.addIncludePath(".");36 test_exe.addIncludePath(.{ .path = "." });
3737
38 test_step.dependOn(&b.addRunArtifact(test_exe).step);38 test_step.dependOn(&b.addRunArtifact(test_exe).step);
39}39}
test/link/macho/bugs/13056/build.zig+5-5
...@@ -23,13 +23,13 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -23,13 +23,13 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
23 .name = "test",23 .name = "test",
24 .optimize = optimize,24 .optimize = optimize,
25 });25 });
26 exe.addSystemIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include" }) catch unreachable);26 exe.addSystemIncludePath(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/include" }) });
27 exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include/c++/v1" }) catch unreachable);27 exe.addIncludePath(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/include/c++/v1" }) });
28 exe.addCSourceFile("test.cpp", &.{28 exe.addCSourceFile(.{ .file = .{ .path = "test.cpp" }, .flags = &.{
29 "-nostdlib++",29 "-nostdlib++",
30 "-nostdinc++",30 "-nostdinc++",
31 });31 } });
32 exe.addObjectFile(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/lib/libc++.tbd" }) catch unreachable);32 exe.addObjectFile(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/lib/libc++.tbd" }) });
3333
34 const run_cmd = b.addRunArtifact(exe);34 const run_cmd = b.addRunArtifact(exe);
35 run_cmd.expectStdErrEqual("x: 5\n");35 run_cmd.expectStdErrEqual("x: 5\n");
test/link/macho/dead_strip/build.zig+1-1
...@@ -52,7 +52,7 @@ fn createScenario(...@@ -52,7 +52,7 @@ fn createScenario(
52 .optimize = optimize,52 .optimize = optimize,
53 .target = target,53 .target = target,
54 });54 });
55 exe.addCSourceFile("main.c", &[0][]const u8{});55 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
56 exe.linkLibC();56 exe.linkLibC();
57 return exe;57 return exe;
58}58}
test/link/macho/dead_strip_dylibs/build.zig+1-1
...@@ -53,7 +53,7 @@ fn createScenario(...@@ -53,7 +53,7 @@ fn createScenario(
53 .name = name,53 .name = name,
54 .optimize = optimize,54 .optimize = optimize,
55 });55 });
56 exe.addCSourceFile("main.c", &[0][]const u8{});56 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
57 exe.linkLibC();57 exe.linkLibC();
58 exe.linkFramework("Cocoa");58 exe.linkFramework("Cocoa");
59 return exe;59 return exe;
test/link/macho/dylib/build.zig+5-5
...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
21 .optimize = optimize,21 .optimize = optimize,
22 .target = target,22 .target = target,
23 });23 });
24 dylib.addCSourceFile("a.c", &.{});24 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
25 dylib.linkLibC();25 dylib.linkLibC();
2626
27 const check_dylib = dylib.checkObject();27 const check_dylib = dylib.checkObject();
...@@ -39,10 +39,10 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -39,10 +39,10 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
39 .optimize = optimize,39 .optimize = optimize,
40 .target = target,40 .target = target,
41 });41 });
42 exe.addCSourceFile("main.c", &.{});42 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
43 exe.linkSystemLibrary("a");43 exe.linkSystemLibrary("a");
44 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());44 exe.addLibraryPath(dylib.getEmitDirectory());
45 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());45 exe.addRPath(dylib.getEmitDirectory());
46 exe.linkLibC();46 exe.linkLibC();
4747
48 const check_exe = exe.checkObject();48 const check_exe = exe.checkObject();
...@@ -55,7 +55,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -55,7 +55,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
5555
56 check_exe.checkStart();56 check_exe.checkStart();
57 check_exe.checkExact("cmd RPATH");57 check_exe.checkExact("cmd RPATH");
58 check_exe.checkExactFileSource("path", dylib.getOutputDirectorySource());58 check_exe.checkExactPath("path", dylib.getOutputDirectorySource());
59 test_step.dependOn(&check_exe.step);59 test_step.dependOn(&check_exe.step);
6060
61 const run = b.addRunArtifact(exe);61 const run = b.addRunArtifact(exe);
test/link/macho/empty/build.zig+2-2
...@@ -20,8 +20,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -20,8 +20,8 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
20 .optimize = optimize,20 .optimize = optimize,
21 .target = target,21 .target = target,
22 });22 });
23 exe.addCSourceFile("main.c", &[0][]const u8{});23 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
24 exe.addCSourceFile("empty.c", &[0][]const u8{});24 exe.addCSourceFile(.{ .file = .{ .path = "empty.c" }, .flags = &[0][]const u8{} });
25 exe.linkLibC();25 exe.linkLibC();
2626
27 const run_cmd = b.addRunArtifact(exe);27 const run_cmd = b.addRunArtifact(exe);
test/link/macho/entry/build.zig+1-1
...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
18 .optimize = optimize,18 .optimize = optimize,
19 .target = .{ .os_tag = .macos },19 .target = .{ .os_tag = .macos },
20 });20 });
21 exe.addCSourceFile("main.c", &.{});21 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
22 exe.linkLibC();22 exe.linkLibC();
23 exe.entry_symbol_name = "_non_main";23 exe.entry_symbol_name = "_non_main";
2424
test/link/macho/entry_in_archive/build.zig+1-1
...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
18 .optimize = optimize,18 .optimize = optimize,
19 .target = .{ .os_tag = .macos },19 .target = .{ .os_tag = .macos },
20 });20 });
21 lib.addCSourceFile("main.c", &.{});21 lib.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
22 lib.linkLibC();22 lib.linkLibC();
2323
24 const exe = b.addExecutable(.{24 const exe = b.addExecutable(.{
test/link/macho/entry_in_dylib/build.zig+2-2
...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
18 .optimize = optimize,18 .optimize = optimize,
19 .target = .{ .os_tag = .macos },19 .target = .{ .os_tag = .macos },
20 });20 });
21 lib.addCSourceFile("bootstrap.c", &.{});21 lib.addCSourceFile(.{ .file = .{ .path = "bootstrap.c" }, .flags = &.{} });
22 lib.linkLibC();22 lib.linkLibC();
23 lib.linker_allow_shlib_undefined = true;23 lib.linker_allow_shlib_undefined = true;
2424
...@@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
27 .optimize = optimize,27 .optimize = optimize,
28 .target = .{ .os_tag = .macos },28 .target = .{ .os_tag = .macos },
29 });29 });
30 exe.addCSourceFile("main.c", &.{});30 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
31 exe.linkLibrary(lib);31 exe.linkLibrary(lib);
32 exe.linkLibC();32 exe.linkLibC();
33 exe.entry_symbol_name = "_bootstrap";33 exe.entry_symbol_name = "_bootstrap";
test/link/macho/headerpad/build.zig+1-1
...@@ -113,7 +113,7 @@ fn simpleExe(...@@ -113,7 +113,7 @@ fn simpleExe(
113 .name = name,113 .name = name,
114 .optimize = optimize,114 .optimize = optimize,
115 });115 });
116 exe.addCSourceFile("main.c", &.{});116 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
117 exe.linkLibC();117 exe.linkLibC();
118 exe.linkFramework("CoreFoundation");118 exe.linkFramework("CoreFoundation");
119 exe.linkFramework("Foundation");119 exe.linkFramework("Foundation");
test/link/macho/needed_framework/build.zig+1-1
...@@ -20,7 +20,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -20,7 +20,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
20 .name = "test",20 .name = "test",
21 .optimize = optimize,21 .optimize = optimize,
22 });22 });
23 exe.addCSourceFile("main.c", &[0][]const u8{});23 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
24 exe.linkLibC();24 exe.linkLibC();
25 exe.linkFrameworkNeeded("Cocoa");25 exe.linkFrameworkNeeded("Cocoa");
26 exe.dead_strip_dylibs = true;26 exe.dead_strip_dylibs = true;
test/link/macho/needed_library/build.zig+4-4
...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
21 .optimize = optimize,21 .optimize = optimize,
22 .target = target,22 .target = target,
23 });23 });
24 dylib.addCSourceFile("a.c", &.{});24 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
25 dylib.linkLibC();25 dylib.linkLibC();
2626
27 // -dead_strip_dylibs27 // -dead_strip_dylibs
...@@ -31,11 +31,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -31,11 +31,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
31 .optimize = optimize,31 .optimize = optimize,
32 .target = target,32 .target = target,
33 });33 });
34 exe.addCSourceFile("main.c", &[0][]const u8{});34 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
35 exe.linkLibC();35 exe.linkLibC();
36 exe.linkSystemLibraryNeeded("a");36 exe.linkSystemLibraryNeeded("a");
37 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());37 exe.addLibraryPath(dylib.getEmitDirectory());
38 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());38 exe.addRPath(dylib.getEmitDirectory());
39 exe.dead_strip_dylibs = true;39 exe.dead_strip_dylibs = true;
4040
41 const check = exe.checkObject();41 const check = exe.checkObject();
test/link/macho/objc/build.zig+3-3
...@@ -18,9 +18,9 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -18,9 +18,9 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
18 .name = "test",18 .name = "test",
19 .optimize = optimize,19 .optimize = optimize,
20 });20 });
21 exe.addIncludePath(".");21 exe.addIncludePath(.{ .path = "." });
22 exe.addCSourceFile("Foo.m", &[0][]const u8{});22 exe.addCSourceFile(.{ .file = .{ .path = "Foo.m" }, .flags = &[0][]const u8{} });
23 exe.addCSourceFile("test.m", &[0][]const u8{});23 exe.addCSourceFile(.{ .file = .{ .path = "test.m" }, .flags = &[0][]const u8{} });
24 exe.linkLibC();24 exe.linkLibC();
25 // TODO when we figure out how to ship framework stubs for cross-compilation,25 // TODO when we figure out how to ship framework stubs for cross-compilation,
26 // populate paths to the sysroot here.26 // populate paths to the sysroot here.
test/link/macho/objcpp/build.zig+3-3
...@@ -19,9 +19,9 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -19,9 +19,9 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
19 .optimize = optimize,19 .optimize = optimize,
20 });20 });
21 b.default_step.dependOn(&exe.step);21 b.default_step.dependOn(&exe.step);
22 exe.addIncludePath(".");22 exe.addIncludePath(.{ .path = "." });
23 exe.addCSourceFile("Foo.mm", &[0][]const u8{});23 exe.addCSourceFile(.{ .file = .{ .path = "Foo.mm" }, .flags = &[0][]const u8{} });
24 exe.addCSourceFile("test.mm", &[0][]const u8{});24 exe.addCSourceFile(.{ .file = .{ .path = "test.mm" }, .flags = &[0][]const u8{} });
25 exe.linkLibCpp();25 exe.linkLibCpp();
26 // TODO when we figure out how to ship framework stubs for cross-compilation,26 // TODO when we figure out how to ship framework stubs for cross-compilation,
27 // populate paths to the sysroot here.27 // populate paths to the sysroot here.
test/link/macho/pagezero/build.zig+2-2
...@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {...@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
15 .optimize = optimize,15 .optimize = optimize,
16 .target = target,16 .target = target,
17 });17 });
18 exe.addCSourceFile("main.c", &.{});18 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
19 exe.linkLibC();19 exe.linkLibC();
20 exe.pagezero_size = 0x4000;20 exe.pagezero_size = 0x4000;
2121
...@@ -39,7 +39,7 @@ pub fn build(b: *std.Build) void {...@@ -39,7 +39,7 @@ pub fn build(b: *std.Build) void {
39 .optimize = optimize,39 .optimize = optimize,
40 .target = target,40 .target = target,
41 });41 });
42 exe.addCSourceFile("main.c", &.{});42 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
43 exe.linkLibC();43 exe.linkLibC();
44 exe.pagezero_size = 0;44 exe.pagezero_size = 0;
4545
test/link/macho/search_strategy/build.zig+6-6
...@@ -55,7 +55,7 @@ fn createScenario(...@@ -55,7 +55,7 @@ fn createScenario(
55 .optimize = optimize,55 .optimize = optimize,
56 .target = target,56 .target = target,
57 });57 });
58 static.addCSourceFile("a.c", &.{});58 static.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
59 static.linkLibC();59 static.linkLibC();
60 static.override_dest_dir = std.Build.InstallDir{60 static.override_dest_dir = std.Build.InstallDir{
61 .custom = "static",61 .custom = "static",
...@@ -67,7 +67,7 @@ fn createScenario(...@@ -67,7 +67,7 @@ fn createScenario(
67 .optimize = optimize,67 .optimize = optimize,
68 .target = target,68 .target = target,
69 });69 });
70 dylib.addCSourceFile("a.c", &.{});70 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
71 dylib.linkLibC();71 dylib.linkLibC();
72 dylib.override_dest_dir = std.Build.InstallDir{72 dylib.override_dest_dir = std.Build.InstallDir{
73 .custom = "dynamic",73 .custom = "dynamic",
...@@ -78,11 +78,11 @@ fn createScenario(...@@ -78,11 +78,11 @@ fn createScenario(
78 .optimize = optimize,78 .optimize = optimize,
79 .target = target,79 .target = target,
80 });80 });
81 exe.addCSourceFile("main.c", &.{});81 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
82 exe.linkSystemLibraryName(name);82 exe.linkSystemLibraryName(name);
83 exe.linkLibC();83 exe.linkLibC();
84 exe.addLibraryPathDirectorySource(static.getOutputDirectorySource());84 exe.addLibraryPath(static.getEmitDirectory());
85 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());85 exe.addLibraryPath(dylib.getEmitDirectory());
86 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());86 exe.addRPath(dylib.getEmitDirectory());
87 return exe;87 return exe;
88}88}
test/link/macho/stack_size/build.zig+1-1
...@@ -20,7 +20,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -20,7 +20,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
20 .optimize = optimize,20 .optimize = optimize,
21 .target = target,21 .target = target,
22 });22 });
23 exe.addCSourceFile("main.c", &.{});23 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
24 exe.linkLibC();24 exe.linkLibC();
25 exe.stack_size = 0x100000000;25 exe.stack_size = 0x100000000;
2626
test/link/macho/tls/build.zig+1-1
...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
21 .optimize = optimize,21 .optimize = optimize,
22 .target = target,22 .target = target,
23 });23 });
24 lib.addCSourceFile("a.c", &.{});24 lib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
25 lib.linkLibC();25 lib.linkLibC();
2626
27 const test_exe = b.addTest(.{27 const test_exe = b.addTest(.{
test/link/macho/unwind_info/build.zig+1-1
...@@ -75,7 +75,7 @@ fn createScenario(...@@ -75,7 +75,7 @@ fn createScenario(
75 .target = target,75 .target = target,
76 });76 });
77 b.default_step.dependOn(&exe.step);77 b.default_step.dependOn(&exe.step);
78 exe.addIncludePath(".");78 exe.addIncludePath(.{ .path = "." });
79 exe.addCSourceFiles(&[_][]const u8{79 exe.addCSourceFiles(&[_][]const u8{
80 "main.cpp",80 "main.cpp",
81 "simple_string.cpp",81 "simple_string.cpp",
test/link/macho/weak_framework/build.zig+1-1
...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -18,7 +18,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
18 .name = "test",18 .name = "test",
19 .optimize = optimize,19 .optimize = optimize,
20 });20 });
21 exe.addCSourceFile("main.c", &[0][]const u8{});21 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
22 exe.linkLibC();22 exe.linkLibC();
23 exe.linkFrameworkWeak("Cocoa");23 exe.linkFrameworkWeak("Cocoa");
2424
test/link/macho/weak_library/build.zig+4-4
...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
21 .target = target,21 .target = target,
22 .optimize = optimize,22 .optimize = optimize,
23 });23 });
24 dylib.addCSourceFile("a.c", &.{});24 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
25 dylib.linkLibC();25 dylib.linkLibC();
26 b.installArtifact(dylib);26 b.installArtifact(dylib);
2727
...@@ -30,11 +30,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -30,11 +30,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
30 .target = target,30 .target = target,
31 .optimize = optimize,31 .optimize = optimize,
32 });32 });
33 exe.addCSourceFile("main.c", &[0][]const u8{});33 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
34 exe.linkLibC();34 exe.linkLibC();
35 exe.linkSystemLibraryWeak("a");35 exe.linkSystemLibraryWeak("a");
36 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());36 exe.addLibraryPath(dylib.getEmitDirectory());
37 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());37 exe.addRPath(dylib.getEmitDirectory());
3838
39 const check = exe.checkObject();39 const check = exe.checkObject();
40 check.checkStart();40 check.checkStart();
test/link/static_libs_from_object_files/build.zig+6-6
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4const Build = std.Build;4const Build = std.Build;
5const FileSource = Build.FileSource;5const LazyPath = Build.LazyPath;
6const Step = Build.Step;6const Step = Build.Step;
7const Run = Step.Run;7const Run = Step.Run;
8const WriteFile = Step.WriteFile;8const WriteFile = Step.WriteFile;
...@@ -14,7 +14,7 @@ pub fn build(b: *Build) void {...@@ -14,7 +14,7 @@ pub fn build(b: *Build) void {
14 b.default_step = test_step;14 b.default_step = test_step;
1515
16 // generate c files16 // generate c files
17 const files = b.allocator.alloc(std.Build.FileSource, nb_files) catch unreachable;17 const files = b.allocator.alloc(LazyPath, nb_files) catch unreachable;
18 defer b.allocator.free(files);18 defer b.allocator.free(files);
19 {19 {
20 for (files[0 .. nb_files - 1], 1..nb_files) |*file, i| {20 for (files[0 .. nb_files - 1], 1..nb_files) |*file, i| {
...@@ -47,7 +47,7 @@ pub fn build(b: *Build) void {...@@ -47,7 +47,7 @@ pub fn build(b: *Build) void {
47 add(b, test_step, files, .ReleaseFast);47 add(b, test_step, files, .ReleaseFast);
48}48}
4949
50fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimize: std.builtin.OptimizeMode) void {50fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.builtin.OptimizeMode) void {
51 const flags = [_][]const u8{51 const flags = [_][]const u8{
52 "-Wall",52 "-Wall",
53 "-std=c11",53 "-std=c11",
...@@ -63,7 +63,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz...@@ -63,7 +63,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz
63 });63 });
6464
65 for (files) |file| {65 for (files) |file| {
66 exe.addCSourceFileSource(.{ .source = file, .args = &flags });66 exe.addCSourceFile(.{ .file = file, .flags = &flags });
67 }67 }
6868
69 const run_cmd = b.addRunArtifact(exe);69 const run_cmd = b.addRunArtifact(exe);
...@@ -88,7 +88,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz...@@ -88,7 +88,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz
8888
89 for (files, 1..) |file, i| {89 for (files, 1..) |file, i| {
90 const lib = if (i & 1 == 0) lib_a else lib_b;90 const lib = if (i & 1 == 0) lib_a else lib_b;
91 lib.addCSourceFileSource(.{ .source = file, .args = &flags });91 lib.addCSourceFile(.{ .file = file, .flags = &flags });
92 }92 }
9393
94 const exe = b.addExecutable(.{94 const exe = b.addExecutable(.{
...@@ -125,7 +125,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz...@@ -125,7 +125,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz
125 .target = .{},125 .target = .{},
126 .optimize = optimize,126 .optimize = optimize,
127 });127 });
128 obj.addCSourceFileSource(.{ .source = file, .args = &flags });128 obj.addCSourceFile(.{ .file = file, .flags = &flags });
129129
130 const lib = if (i & 1 == 0) lib_a else lib_b;130 const lib = if (i & 1 == 0) lib_a else lib_b;
131 lib.addObject(obj);131 lib.addObject(obj);
test/link/wasm/extern/build.zig+1-1
...@@ -19,7 +19,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -19,7 +19,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
19 .optimize = optimize,19 .optimize = optimize,
20 .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi },20 .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi },
21 });21 });
22 exe.addCSourceFile("foo.c", &.{});22 exe.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} });
23 exe.use_llvm = false;23 exe.use_llvm = false;
24 exe.use_lld = false;24 exe.use_lld = false;
2525
test/link/wasm/infer-features/build.zig+1-1
...@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {...@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void {
13 .os_tag = .freestanding,13 .os_tag = .freestanding,
14 },14 },
15 });15 });
16 c_obj.addCSourceFile("foo.c", &.{});16 c_obj.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} });
1717
18 // Wasm library that doesn't have any features specified. This will18 // Wasm library that doesn't have any features specified. This will
19 // infer its featureset from other linked object files.19 // infer its featureset from other linked object files.
test/src/Cases.zig+3-3
...@@ -518,12 +518,12 @@ pub fn lowerToBuildSteps(...@@ -518,12 +518,12 @@ pub fn lowerToBuildSteps(
518 }518 }
519519
520 const writefiles = b.addWriteFiles();520 const writefiles = b.addWriteFiles();
521 var file_sources = std.StringHashMap(std.Build.FileSource).init(b.allocator);521 var file_sources = std.StringHashMap(std.Build.LazyPath).init(b.allocator);
522 defer file_sources.deinit();522 defer file_sources.deinit();
523 for (update.files.items) |file| {523 for (update.files.items) |file| {
524 file_sources.put(file.path, writefiles.add(file.path, file.src)) catch @panic("OOM");524 file_sources.put(file.path, writefiles.add(file.path, file.src)) catch @panic("OOM");
525 }525 }
526 const root_source_file = writefiles.files.items[0].getFileSource();526 const root_source_file = writefiles.files.items[0].getPath();
527527
528 const artifact = if (case.is_test) b.addTest(.{528 const artifact = if (case.is_test) b.addTest(.{
529 .root_source_file = root_source_file,529 .root_source_file = root_source_file,
...@@ -577,7 +577,7 @@ pub fn lowerToBuildSteps(...@@ -577,7 +577,7 @@ pub fn lowerToBuildSteps(
577 parent_step.dependOn(&artifact.step);577 parent_step.dependOn(&artifact.step);
578 },578 },
579 .CompareObjectFile => |expected_output| {579 .CompareObjectFile => |expected_output| {
580 const check = b.addCheckFile(artifact.getOutputSource(), .{580 const check = b.addCheckFile(artifact.getEmittedBin(), .{
581 .expected_exact = expected_output,581 .expected_exact = expected_output,
582 });582 });
583583
test/src/CompareOutput.zig+3-3
...@@ -99,7 +99,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -99,7 +99,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
99 .target = .{},99 .target = .{},
100 .optimize = .Debug,100 .optimize = .Debug,
101 });101 });
102 exe.addAssemblyFileSource(write_src.files.items[0].getFileSource());102 exe.addAssemblyFile(write_src.files.items[0].getPath());
103103
104 const run = b.addRunArtifact(exe);104 const run = b.addRunArtifact(exe);
105 run.setName(annotated_case_name);105 run.setName(annotated_case_name);
...@@ -119,7 +119,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -119,7 +119,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
119119
120 const exe = b.addExecutable(.{120 const exe = b.addExecutable(.{
121 .name = "test",121 .name = "test",
122 .root_source_file = write_src.files.items[0].getFileSource(),122 .root_source_file = write_src.files.items[0].getPath(),
123 .optimize = optimize,123 .optimize = optimize,
124 .target = .{},124 .target = .{},
125 });125 });
...@@ -145,7 +145,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -145,7 +145,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
145145
146 const exe = b.addExecutable(.{146 const exe = b.addExecutable(.{
147 .name = "test",147 .name = "test",
148 .root_source_file = write_src.files.items[0].getFileSource(),148 .root_source_file = write_src.files.items[0].getPath(),
149 .target = .{},149 .target = .{},
150 .optimize = .Debug,150 .optimize = .Debug,
151 });151 });
test/src/StackTrace.zig+2-2
...@@ -75,7 +75,7 @@ fn addExpect(...@@ -75,7 +75,7 @@ fn addExpect(
75 const write_src = b.addWriteFile("source.zig", source);75 const write_src = b.addWriteFile("source.zig", source);
76 const exe = b.addExecutable(.{76 const exe = b.addExecutable(.{
77 .name = "test",77 .name = "test",
78 .root_source_file = write_src.files.items[0].getFileSource(),78 .root_source_file = write_src.files.items[0].getPath(),
79 .optimize = optimize_mode,79 .optimize = optimize_mode,
80 .target = .{},80 .target = .{},
81 });81 });
...@@ -88,7 +88,7 @@ fn addExpect(...@@ -88,7 +88,7 @@ fn addExpect(
8888
89 const check_run = b.addRunArtifact(self.check_exe);89 const check_run = b.addRunArtifact(self.check_exe);
90 check_run.setName(annotated_case_name);90 check_run.setName(annotated_case_name);
91 check_run.addFileSourceArg(run.captureStdErr());91 check_run.addFileArg(run.captureStdErr());
92 check_run.addArgs(&.{92 check_run.addArgs(&.{
93 @tagName(optimize_mode),93 @tagName(optimize_mode),
94 });94 });
test/src/run_translated_c.zig+1-1
...@@ -85,7 +85,7 @@ pub const RunTranslatedCContext = struct {...@@ -85,7 +85,7 @@ pub const RunTranslatedCContext = struct {
85 _ = write_src.add(src_file.filename, src_file.source);85 _ = write_src.add(src_file.filename, src_file.source);
86 }86 }
87 const translate_c = b.addTranslateC(.{87 const translate_c = b.addTranslateC(.{
88 .source_file = write_src.files.items[0].getFileSource(),88 .source_file = write_src.files.items[0].getPath(),
89 .target = .{},89 .target = .{},
90 .optimize = .Debug,90 .optimize = .Debug,
91 });91 });
test/src/translate_c.zig+1-1
...@@ -108,7 +108,7 @@ pub const TranslateCContext = struct {...@@ -108,7 +108,7 @@ pub const TranslateCContext = struct {
108 }108 }
109109
110 const translate_c = b.addTranslateC(.{110 const translate_c = b.addTranslateC(.{
111 .source_file = write_src.files.items[0].getFileSource(),111 .source_file = write_src.files.items[0].getPath(),
112 .target = case.target,112 .target = case.target,
113 .optimize = .Debug,113 .optimize = .Debug,
114 });114 });
test/standalone/c_compiler/build.zig+2-2
...@@ -19,7 +19,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -19,7 +19,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
19 .optimize = optimize,19 .optimize = optimize,
20 .target = target,20 .target = target,
21 });21 });
22 exe_c.addCSourceFile("test.c", &[0][]const u8{});22 exe_c.addCSourceFile(.{ .file = .{ .path = "test.c" }, .flags = &[0][]const u8{} });
23 exe_c.linkLibC();23 exe_c.linkLibC();
2424
25 const exe_cpp = b.addExecutable(.{25 const exe_cpp = b.addExecutable(.{
...@@ -28,7 +28,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -28,7 +28,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
28 .target = target,28 .target = target,
29 });29 });
30 b.default_step.dependOn(&exe_cpp.step);30 b.default_step.dependOn(&exe_cpp.step);
31 exe_cpp.addCSourceFile("test.cpp", &[0][]const u8{});31 exe_cpp.addCSourceFile(.{ .file = .{ .path = "test.cpp" }, .flags = &[0][]const u8{} });
32 exe_cpp.linkLibCpp();32 exe_cpp.linkLibCpp();
3333
34 switch (target.getOsTag()) {34 switch (target.getOsTag()) {
test/standalone/embed_generated_file/build.zig+1-1
...@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {...@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
19 .optimize = .Debug,19 .optimize = .Debug,
20 });20 });
21 exe.addAnonymousModule("bootloader.elf", .{21 exe.addAnonymousModule("bootloader.elf", .{
22 .source_file = bootloader.getOutputSource(),22 .source_file = bootloader.getEmittedBin(),
23 });23 });
2424
25 test_step.dependOn(&exe.step);25 test_step.dependOn(&exe.step);
test/standalone/issue_794/build.zig+1-1
...@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {...@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
7 const test_artifact = b.addTest(.{7 const test_artifact = b.addTest(.{
8 .root_source_file = .{ .path = "main.zig" },8 .root_source_file = .{ .path = "main.zig" },
9 });9 });
10 test_artifact.addIncludePath("a_directory");10 test_artifact.addIncludePath(.{ .path = "a_directory" });
1111
12 test_step.dependOn(&test_artifact.step);12 test_step.dependOn(&test_artifact.step);
13}13}
test/standalone/issue_8550/build.zig+2-2
...@@ -19,8 +19,8 @@ pub fn build(b: *std.Build) !void {...@@ -19,8 +19,8 @@ pub fn build(b: *std.Build) !void {
19 .optimize = optimize,19 .optimize = optimize,
20 .target = target,20 .target = target,
21 });21 });
22 kernel.addObjectFile("./boot.S");22 kernel.addObjectFile(.{ .path = "./boot.S" });
23 kernel.setLinkerScriptPath(.{ .path = "./linker.ld" });23 kernel.setLinkerScript(.{ .path = "./linker.ld" });
24 b.installArtifact(kernel);24 b.installArtifact(kernel);
2525
26 test_step.dependOn(&kernel.step);26 test_step.dependOn(&kernel.step);
test/standalone/main_pkg_path/build.zig+1-1
...@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {...@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
7 const test_exe = b.addTest(.{7 const test_exe = b.addTest(.{
8 .root_source_file = .{ .path = "a/test.zig" },8 .root_source_file = .{ .path = "a/test.zig" },
9 });9 });
10 test_exe.setMainPkgPath(".");10 test_exe.setMainPkgPath(.{.path="."});
1111
12 test_step.dependOn(&b.addRunArtifact(test_exe).step);12 test_step.dependOn(&b.addRunArtifact(test_exe).step);
13}13}
test/standalone/mix_c_files/build.zig+1-1
...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize...@@ -21,7 +21,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
21 .root_source_file = .{ .path = "main.zig" },21 .root_source_file = .{ .path = "main.zig" },
22 .optimize = optimize,22 .optimize = optimize,
23 });23 });
24 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c11"});24 exe.addCSourceFile(.{ .file = .{ .path = "test.c" }, .flags = &[_][]const u8{"-std=c11"} });
25 exe.linkLibC();25 exe.linkLibC();
2626
27 const run_cmd = b.addRunArtifact(exe);27 const run_cmd = b.addRunArtifact(exe);
test/standalone/mix_o_files/build.zig+4-1
...@@ -19,7 +19,10 @@ pub fn build(b: *std.Build) void {...@@ -19,7 +19,10 @@ pub fn build(b: *std.Build) void {
19 .optimize = optimize,19 .optimize = optimize,
20 .target = target,20 .target = target,
21 });21 });
22 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});22 exe.addCSourceFile(.{
23 .file = .{ .path = "test.c" },
24 .flags = &[_][]const u8{"-std=c99"},
25 });
23 exe.addObject(obj);26 exe.addObject(obj);
24 exe.linkSystemLibrary("c");27 exe.linkSystemLibrary("c");
2528
test/standalone/shared_library/build.zig+4-1
...@@ -19,7 +19,10 @@ pub fn build(b: *std.Build) void {...@@ -19,7 +19,10 @@ pub fn build(b: *std.Build) void {
19 .target = target,19 .target = target,
20 .optimize = optimize,20 .optimize = optimize,
21 });21 });
22 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});22 exe.addCSourceFile(.{
23 .file = .{ .path = "test.c" },
24 .flags = &[_][]const u8{"-std=c99"},
25 });
23 exe.linkLibrary(lib);26 exe.linkLibrary(lib);
24 exe.linkSystemLibrary("c");27 exe.linkSystemLibrary("c");
2528
test/standalone/stack_iterator/build.zig+4-1
...@@ -74,7 +74,10 @@ pub fn build(b: *std.Build) void {...@@ -74,7 +74,10 @@ pub fn build(b: *std.Build) void {
74 if (target.isWindows()) c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");74 if (target.isWindows()) c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");
7575
76 c_shared_lib.strip = false;76 c_shared_lib.strip = false;
77 c_shared_lib.addCSourceFile("shared_lib.c", &.{"-fomit-frame-pointer"});77 c_shared_lib.addCSourceFile(.{
78 .file = .{ .path = "shared_lib.c" },
79 .flags = &.{"-fomit-frame-pointer"},
80 });
78 c_shared_lib.linkLibC();81 c_shared_lib.linkLibC();
7982
80 const exe = b.addExecutable(.{83 const exe = b.addExecutable(.{
test/standalone/static_c_lib/build.zig+3-3
...@@ -11,15 +11,15 @@ pub fn build(b: *std.Build) void {...@@ -11,15 +11,15 @@ pub fn build(b: *std.Build) void {
11 .optimize = optimize,11 .optimize = optimize,
12 .target = .{},12 .target = .{},
13 });13 });
14 foo.addCSourceFile("foo.c", &[_][]const u8{});14 foo.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &[_][]const u8{} });
15 foo.addIncludePath(".");15 foo.addIncludePath(.{ .path = "." });
1616
17 const test_exe = b.addTest(.{17 const test_exe = b.addTest(.{
18 .root_source_file = .{ .path = "foo.zig" },18 .root_source_file = .{ .path = "foo.zig" },
19 .optimize = optimize,19 .optimize = optimize,
20 });20 });
21 test_exe.linkLibrary(foo);21 test_exe.linkLibrary(foo);
22 test_exe.addIncludePath(".");22 test_exe.addIncludePath(.{ .path = "." });
2323
24 test_step.dependOn(&b.addRunArtifact(test_exe).step);24 test_step.dependOn(&b.addRunArtifact(test_exe).step);
25}25}
test/standalone/use_alias/build.zig+1-1
...@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {...@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {
10 .root_source_file = .{ .path = "main.zig" },10 .root_source_file = .{ .path = "main.zig" },
11 .optimize = optimize,11 .optimize = optimize,
12 });12 });
13 main.addIncludePath(".");13 main.addIncludePath(.{.path="."});
1414
15 test_step.dependOn(&b.addRunArtifact(main).step);15 test_step.dependOn(&b.addRunArtifact(main).step);
16}16}
test/tests.zig+12-9
...@@ -759,7 +759,7 @@ pub fn addCliTests(b: *std.Build) *Step {...@@ -759,7 +759,7 @@ pub fn addCliTests(b: *std.Build) *Step {
759 "-fno-emit-bin", "-fno-emit-h",759 "-fno-emit-bin", "-fno-emit-h",
760 "-fstrip", "-OReleaseFast",760 "-fstrip", "-OReleaseFast",
761 });761 });
762 run.addFileSourceArg(writefile.files.items[0].getFileSource());762 run.addFileArg(writefile.files.items[0].getPath());
763 const example_s = run.addPrefixedOutputFileArg("-femit-asm=", "example.s");763 const example_s = run.addPrefixedOutputFileArg("-femit-asm=", "example.s");
764764
765 const checkfile = b.addCheckFile(example_s, .{765 const checkfile = b.addCheckFile(example_s, .{
...@@ -1017,8 +1017,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1017,8 +1017,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1017 else1017 else
1018 "";1018 "";
10191019
1020 these_tests.overrideZigLibDir("lib");1020 these_tests.overrideZigLibDir(.{ .path = "lib" });
1021 these_tests.addIncludePath("test");1021 these_tests.addIncludePath(.{ .path = "test" });
10221022
1023 const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{1023 const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{
1024 options.name,1024 options.name,
...@@ -1038,10 +1038,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1038,10 +1038,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1038 .link_libc = test_target.link_libc,1038 .link_libc = test_target.link_libc,
1039 .target = altered_target,1039 .target = altered_target,
1040 });1040 });
1041 compile_c.overrideZigLibDir("lib");1041 compile_c.overrideZigLibDir(.{ .path = "lib" });
1042 compile_c.addCSourceFileSource(.{1042 compile_c.addCSourceFile(.{
1043 .source = these_tests.getOutputSource(),1043 .file = these_tests.getEmittedBin(),
1044 .args = &.{1044 .flags = &.{
1045 // TODO output -std=c89 compatible C code1045 // TODO output -std=c89 compatible C code
1046 "-std=c99",1046 "-std=c99",
1047 "-pedantic",1047 "-pedantic",
...@@ -1058,7 +1058,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1058,7 +1058,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1058 "-Wno-absolute-value",1058 "-Wno-absolute-value",
1059 },1059 },
1060 });1060 });
1061 compile_c.addIncludePath("lib"); // for zig.h1061 compile_c.addIncludePath(.{ .path = "lib" }); // for zig.h
1062 if (test_target.target.getOsTag() == .windows) {1062 if (test_target.target.getOsTag() == .windows) {
1063 if (true) {1063 if (true) {
1064 // Unfortunately this requires about 8G of RAM for clang to compile1064 // Unfortunately this requires about 8G of RAM for clang to compile
...@@ -1131,7 +1131,10 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S...@@ -1131,7 +1131,10 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
1131 test_step.target_info.dynamic_linker.max_byte = null;1131 test_step.target_info.dynamic_linker.max_byte = null;
1132 }1132 }
1133 test_step.linkLibC();1133 test_step.linkLibC();
1134 test_step.addCSourceFile("test/c_abi/cfuncs.c", &.{"-std=c99"});1134 test_step.addCSourceFile(.{
1135 .file = .{ .path = "test/c_abi/cfuncs.c" },
1136 .flags = &.{"-std=c99"},
1137 });
11351138
1136 // This test is intentionally trying to check if the external ABI is1139 // This test is intentionally trying to check if the external ABI is
1137 // done properly. LTO would be a hindrance to this.1140 // done properly. LTO would be a hindrance to this.