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 {
4545 const docgen_cmd = b.addRunArtifact(docgen_exe);
4646 docgen_cmd.addArgs(&.{ "--zig", b.zig_exe });
4747 if (b.zig_lib_dir) |p| {
48 docgen_cmd.addArgs(&.{ "--zig-lib-dir", p });
48 docgen_cmd.addArgs(&.{ "--zig-lib-dir", b.pathFromRoot(p) });
4949 }
50 docgen_cmd.addFileSourceArg(.{ .path = "doc/langref.html.in" });
50 docgen_cmd.addFileArg(.{ .path = "doc/langref.html.in" });
5151 const langref_file = docgen_cmd.addOutputFileArg("langref.html");
5252 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
5353 if (!skip_install_langref) {
......@@ -58,7 +58,7 @@ pub fn build(b: *std.Build) !void {
5858 .root_source_file = .{ .path = "lib/std/std.zig" },
5959 .target = target,
6060 });
61 autodoc_test.overrideZigLibDir("lib");
61 autodoc_test.overrideZigLibDir(.{ .path = "lib" });
6262 autodoc_test.emit_bin = .no_emit; // https://github.com/ziglang/zig/issues/16351
6363 const install_std_docs = b.addInstallDirectory(.{
6464 .source_dir = autodoc_test.getEmittedDocs(),
......@@ -89,7 +89,7 @@ pub fn build(b: *std.Build) !void {
8989 .root_source_file = .{ .path = "test/src/Cases.zig" },
9090 .optimize = optimize,
9191 });
92 check_case_exe.main_pkg_path = ".";
92 check_case_exe.setMainPkgPath(.{ .path = "." });
9393 check_case_exe.stack_size = stack_size;
9494 check_case_exe.single_threaded = single_threaded;
9595
......@@ -352,10 +352,9 @@ pub fn build(b: *std.Build) !void {
352352 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
353353 exe_options.addOption(bool, "value_tracing", value_tracing);
354354 if (tracy) |tracy_path| {
355 const client_cpp = fs.path.join(
356 b.allocator,
355 const client_cpp = b.pathJoin(
357356 &[_][]const u8{ tracy_path, "public", "TracyClient.cpp" },
358 ) catch unreachable;
357 );
359358
360359 // On mingw, we need to opt into windows 7+ to get some features required by tracy.
361360 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 {
363362 else
364363 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
365364
366 exe.addIncludePath(tracy_path);
367 exe.addCSourceFile(client_cpp, tracy_c_flags);
365 exe.addIncludePath(.{ .path = tracy_path });
366 exe.addCSourceFile(.{ .file = .{ .path = client_cpp }, .flags = tracy_c_flags });
368367 if (!enable_llvm) {
369368 exe.linkSystemLibraryName("c++");
370369 }
......@@ -554,7 +553,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
554553 });
555554 run_opt.addArtifactArg(exe);
556555 run_opt.addArg("-o");
557 run_opt.addFileSourceArg(.{ .path = "stage1/zig1.wasm" });
556 run_opt.addFileArg(.{ .path = "stage1/zig1.wasm" });
558557
559558 const copy_zig_h = b.addWriteFiles();
560559 copy_zig_h.addCopyFileToSource(.{ .path = "lib/zig.h" }, "stage1/zig.h");
......@@ -603,7 +602,7 @@ fn addCmakeCfgOptionsToExe(
603602 // useful for package maintainers
604603 exe.headerpad_max_install_names = true;
605604 }
606 exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
605 exe.addObjectFile(.{ .path = b.pathJoin(&[_][]const u8{
607606 cfg.cmake_binary_dir,
608607 "zigcpp",
609608 b.fmt("{s}{s}{s}", .{
......@@ -611,11 +610,11 @@ fn addCmakeCfgOptionsToExe(
611610 "zigcpp",
612611 cfg.cmake_static_library_suffix,
613612 }),
614 }) catch unreachable);
613 }) });
615614 assert(cfg.lld_include_dir.len != 0);
616 exe.addIncludePath(cfg.lld_include_dir);
617 exe.addIncludePath(cfg.llvm_include_dir);
618 exe.addLibraryPath(cfg.llvm_lib_dir);
615 exe.addIncludePath(.{ .path = cfg.lld_include_dir });
616 exe.addIncludePath(.{ .path = cfg.llvm_include_dir });
617 exe.addLibraryPath(.{ .path = cfg.llvm_lib_dir });
619618 addCMakeLibraryList(exe, cfg.clang_libraries);
620619 addCMakeLibraryList(exe, cfg.lld_libraries);
621620 addCMakeLibraryList(exe, cfg.llvm_libraries);
......@@ -671,7 +670,7 @@ fn addCmakeCfgOptionsToExe(
671670 }
672671
673672 if (cfg.dia_guids_lib.len != 0) {
674 exe.addObjectFile(cfg.dia_guids_lib);
673 exe.addObjectFile(.{ .path = cfg.dia_guids_lib });
675674 }
676675}
677676
......@@ -732,7 +731,7 @@ fn addCxxKnownPath(
732731 }
733732 return error.RequiredLibraryNotFound;
734733 }
735 exe.addObjectFile(path_unpadded);
734 exe.addObjectFile(.{ .path = path_unpadded });
736735
737736 // TODO a way to integrate with system c++ include files here
738737 // c++ -E -Wp,-v -xc++ /dev/null
......@@ -752,7 +751,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
752751 } else if (exe.target.isWindows() and mem.endsWith(u8, lib, ".lib") and !fs.path.isAbsolute(lib)) {
753752 exe.linkSystemLibrary(lib[0 .. lib.len - ".lib".len]);
754753 } else {
755 exe.addObjectFile(lib);
754 exe.addObjectFile(.{ .path = lib });
756755 }
757756 }
758757}
lib/std/Build.zig+26-24
......@@ -471,7 +471,7 @@ pub fn addOptions(self: *Build) *Step.Options {
471471
472472pub const ExecutableOptions = struct {
473473 name: []const u8,
474 root_source_file: ?FileSource = null,
474 root_source_file: ?LazyPath = null,
475475 version: ?std.SemanticVersion = null,
476476 target: CrossTarget = .{},
477477 optimize: std.builtin.Mode = .Debug,
......@@ -502,7 +502,7 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *Step.Compile {
502502
503503pub const ObjectOptions = struct {
504504 name: []const u8,
505 root_source_file: ?FileSource = null,
505 root_source_file: ?LazyPath = null,
506506 target: CrossTarget,
507507 optimize: std.builtin.Mode,
508508 max_rss: usize = 0,
......@@ -529,7 +529,7 @@ pub fn addObject(b: *Build, options: ObjectOptions) *Step.Compile {
529529
530530pub const SharedLibraryOptions = struct {
531531 name: []const u8,
532 root_source_file: ?FileSource = null,
532 root_source_file: ?LazyPath = null,
533533 version: ?std.SemanticVersion = null,
534534 target: CrossTarget,
535535 optimize: std.builtin.Mode,
......@@ -559,7 +559,7 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *Step.Compile
559559
560560pub const StaticLibraryOptions = struct {
561561 name: []const u8,
562 root_source_file: ?FileSource = null,
562 root_source_file: ?LazyPath = null,
563563 target: CrossTarget,
564564 optimize: std.builtin.Mode,
565565 version: ?std.SemanticVersion = null,
......@@ -589,7 +589,7 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *Step.Compile
589589
590590pub const TestOptions = struct {
591591 name: []const u8 = "test",
592 root_source_file: FileSource,
592 root_source_file: LazyPath,
593593 target: CrossTarget = .{},
594594 optimize: std.builtin.Mode = .Debug,
595595 version: ?std.SemanticVersion = null,
......@@ -621,7 +621,7 @@ pub fn addTest(b: *Build, options: TestOptions) *Step.Compile {
621621
622622pub const AssemblyOptions = struct {
623623 name: []const u8,
624 source_file: FileSource,
624 source_file: LazyPath,
625625 target: CrossTarget,
626626 optimize: std.builtin.Mode,
627627 max_rss: usize = 0,
......@@ -636,7 +636,7 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *Step.Compile {
636636 .optimize = options.optimize,
637637 .max_rss = options.max_rss,
638638 });
639 obj_step.addAssemblyFileSource(options.source_file.dupe(b));
639 obj_step.addAssemblyLazyPath(options.source_file.dupe(b));
640640 return obj_step;
641641}
642642
......@@ -655,7 +655,7 @@ pub const ModuleDependency = struct {
655655};
656656
657657pub const CreateModuleOptions = struct {
658 source_file: FileSource,
658 source_file: LazyPath,
659659 dependencies: []const ModuleDependency = &.{},
660660};
661661
......@@ -1284,22 +1284,22 @@ pub fn installLibFile(self: *Build, src_path: []const u8, dest_rel_path: []const
12841284 self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .lib, dest_rel_path).step);
12851285}
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 {
12881288 return Step.ObjCopy.create(b, source, options);
12891289}
12901290
12911291///`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 {
12931293 return self.addInstallFileWithDir(source.dupe(self), .prefix, dest_rel_path);
12941294}
12951295
12961296///`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 {
12981298 return self.addInstallFileWithDir(source.dupe(self), .bin, dest_rel_path);
12991299}
13001300
13011301///`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 {
13031303 return self.addInstallFileWithDir(source.dupe(self), .lib, dest_rel_path);
13041304}
13051305
......@@ -1309,7 +1309,7 @@ pub fn addInstallHeaderFile(b: *Build, src_path: []const u8, dest_rel_path: []co
13091309
13101310pub fn addInstallFileWithDir(
13111311 self: *Build,
1312 source: FileSource,
1312 source: LazyPath,
13131313 install_dir: InstallDir,
13141314 dest_rel_path: []const u8,
13151315) *Step.InstallFile {
......@@ -1322,7 +1322,7 @@ pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *Step
13221322
13231323pub fn addCheckFile(
13241324 b: *Build,
1325 file_source: FileSource,
1325 file_source: LazyPath,
13261326 options: Step.CheckFile.Options,
13271327) *Step.CheckFile {
13281328 return Step.CheckFile.create(b, file_source, options);
......@@ -1608,7 +1608,7 @@ pub const Module = struct {
16081608 /// This could either be a generated file, in which case the module
16091609 /// contains exactly one file, or it could be a path to the root source
16101610 /// file of directory of files which constitute the module.
1611 source_file: FileSource,
1611 source_file: LazyPath,
16121612 dependencies: std.StringArrayHashMap(*Module),
16131613};
16141614
......@@ -1630,8 +1630,10 @@ pub const GeneratedFile = struct {
16301630 }
16311631};
16321632
1633/// A file source is a reference to an existing or future file.
1634pub const FileSource = union(enum) {
1633pub const FileSource = LazyPath; // DEPRECATED, use LazyPath now
1634
1635/// A reference to an existing or future path.
1636pub const LazyPath = union(enum) {
16351637 /// A plain file path, relative to build root or absolute.
16361638 path: []const u8,
16371639
......@@ -1641,14 +1643,14 @@ pub const FileSource = union(enum) {
16411643
16421644 /// Returns a new file source that will have a relative path to the build root guaranteed.
16431645 /// 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 {
16451647 std.debug.assert(!std.fs.path.isAbsolute(path));
1646 return FileSource{ .path = path };
1648 return LazyPath{ .path = path };
16471649 }
16481650
16491651 /// Returns a string that can be shown to represent the file source.
16501652 /// Either returns the path or `"generated"`.
1651 pub fn getDisplayName(self: FileSource) []const u8 {
1653 pub fn getDisplayName(self: LazyPath) []const u8 {
16521654 return switch (self) {
16531655 .path => self.path,
16541656 .generated => "generated",
......@@ -1656,7 +1658,7 @@ pub const FileSource = union(enum) {
16561658 }
16571659
16581660 /// 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 {
16601662 switch (self) {
16611663 .path => {},
16621664 .generated => |gen| other_step.dependOn(gen.step),
......@@ -1664,14 +1666,14 @@ pub const FileSource = union(enum) {
16641666 }
16651667
16661668 /// 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 {
16681670 return getPath2(self, src_builder, null);
16691671 }
16701672
16711673 /// Should only be called during make(), returns a path relative to the build root or absolute.
16721674 /// asking_step is only used for debugging purposes; it's the step being run that is asking for
16731675 /// 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 {
16751677 switch (self) {
16761678 .path => |p| return src_builder.pathFromRoot(p),
16771679 .generated => |gen| return gen.path orelse {
......@@ -1684,7 +1686,7 @@ pub const FileSource = union(enum) {
16841686 }
16851687
16861688 /// 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 {
16881690 return switch (self) {
16891691 .path => |p| .{ .path = b.dupePath(p) },
16901692 .generated => |gen| .{ .generated = gen },
lib/std/Build/Step/CheckFile.zig+2-2
......@@ -11,7 +11,7 @@ const mem = std.mem;
1111step: Step,
1212expected_matches: []const []const u8,
1313expected_exact: ?[]const u8,
14source: std.Build.FileSource,
14source: std.Build.LazyPath,
1515max_bytes: usize = 20 * 1024 * 1024,
1616
1717pub const base_id = .check_file;
......@@ -23,7 +23,7 @@ pub const Options = struct {
2323
2424pub fn create(
2525 owner: *std.Build,
26 source: std.Build.FileSource,
26 source: std.Build.LazyPath,
2727 options: Options,
2828) *CheckFile {
2929 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;
1515pub const base_id = .check_object;
1616
1717step: Step,
18source: std.Build.FileSource,
18source: std.Build.LazyPath,
1919max_bytes: usize = 20 * 1024 * 1024,
2020checks: std.ArrayList(Check),
2121obj_format: std.Target.ObjectFormat,
2222
2323pub fn create(
2424 owner: *std.Build,
25 source: std.Build.FileSource,
25 source: std.Build.LazyPath,
2626 obj_format: std.Target.ObjectFormat,
2727) *CheckObject {
2828 const gpa = owner.allocator;
......@@ -44,7 +44,7 @@ pub fn create(
4444
4545const SearchPhrase = struct {
4646 string: []const u8,
47 file_source: ?std.Build.FileSource = null,
47 file_source: ?std.Build.LazyPath = null,
4848
4949 fn resolve(phrase: SearchPhrase, b: *std.Build, step: *Step) []const u8 {
5050 const file_source = phrase.file_source orelse return phrase.string;
......@@ -302,13 +302,13 @@ pub fn checkExact(self: *CheckObject, phrase: []const u8) void {
302302 self.checkExactInner(phrase, null);
303303}
304304
305/// Like `checkExact()` but takes an additional argument `FileSource` which will be
305/// Like `checkExact()` but takes an additional argument `LazyPath` which will be
306306/// 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 {
308308 self.checkExactInner(phrase, file_source);
309309}
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 {
312312 assert(self.checks.items.len > 0);
313313 const last = &self.checks.items[self.checks.items.len - 1];
314314 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 {
321321
322322/// Like `checkContains()` but takes an additional argument `FileSource` which will be
323323/// 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 {
325325 self.checkContainsInner(phrase, file_source);
326326}
327327
lib/std/Build/Step/Compile.zig+76-95
......@@ -11,7 +11,7 @@ const Allocator = mem.Allocator;
1111const Step = std.Build.Step;
1212const CrossTarget = std.zig.CrossTarget;
1313const NativeTargetInfo = std.zig.system.NativeTargetInfo;
14const FileSource = std.Build.FileSource;
14const LazyPath = std.Build.LazyPath;
1515const PkgConfigPkg = std.Build.PkgConfigPkg;
1616const PkgConfigError = std.Build.PkgConfigError;
1717const ExecError = std.Build.ExecError;
......@@ -28,7 +28,7 @@ name: []const u8,
2828target: CrossTarget,
2929target_info: NativeTargetInfo,
3030optimize: std.builtin.Mode,
31linker_script: ?FileSource = null,
31linker_script: ?LazyPath = null,
3232version_script: ?[]const u8 = null,
3333out_filename: []const u8,
3434linkage: ?Linkage = null,
......@@ -40,9 +40,9 @@ strip: ?bool,
4040unwind_tables: ?bool,
4141// keep in sync with src/link.zig:CompressDebugSections
4242compress_debug_sections: enum { none, zlib } = .none,
43lib_paths: ArrayList(FileSource),
44rpaths: ArrayList(FileSource),
45framework_dirs: ArrayList(FileSource),
43lib_paths: ArrayList(LazyPath),
44rpaths: ArrayList(LazyPath),
45framework_dirs: ArrayList(LazyPath),
4646frameworks: StringHashMap(FrameworkLinkInfo),
4747verbose_link: bool,
4848verbose_cc: bool,
......@@ -74,8 +74,8 @@ max_memory: ?u64 = null,
7474shared_memory: bool = false,
7575global_base: ?u64 = null,
7676c_std: std.Build.CStd,
77zig_lib_dir: ?[]const u8,
78main_pkg_path: ?[]const u8,
77zig_lib_dir: ?LazyPath,
78main_pkg_path: ?LazyPath,
7979exec_cmd_args: ?[]const ?[]const u8,
8080filter: ?[]const u8,
8181test_evented_io: bool = false,
......@@ -85,7 +85,7 @@ wasi_exec_model: ?std.builtin.WasiExecModel = null,
8585/// Symbols to be exported when compiling to wasm
8686export_symbol_names: []const []const u8 = &.{},
8787
88root_src: ?FileSource,
88root_src: ?LazyPath,
8989out_h_filename: []const u8,
9090out_lib_filename: []const u8,
9191out_pdb_filename: []const u8,
......@@ -106,7 +106,7 @@ installed_path: ?[]const u8,
106106/// Base address for an executable image.
107107image_base: ?u64 = null,
108108
109libc_file: ?FileSource = null,
109libc_file: ?LazyPath = null,
110110
111111valgrind_support: ?bool = null,
112112each_lib_rpath: ?bool = null,
......@@ -223,22 +223,22 @@ pub const CSourceFiles = struct {
223223};
224224
225225pub const CSourceFile = struct {
226 source: FileSource,
227 args: []const []const u8,
226 file: LazyPath,
227 flags: []const []const u8,
228228
229229 pub fn dupe(self: CSourceFile, b: *std.Build) CSourceFile {
230230 return .{
231 .source = self.source.dupe(b),
232 .args = b.dupeStrings(self.args),
231 .file = self.file.dupe(b),
232 .flags = b.dupeStrings(self.flags),
233233 };
234234 }
235235};
236236
237237pub const LinkObject = union(enum) {
238 static_path: FileSource,
238 static_path: LazyPath,
239239 other_step: *Compile,
240240 system_lib: SystemLib,
241 assembly_file: FileSource,
241 assembly_file: LazyPath,
242242 c_source_file: *CSourceFile,
243243 c_source_files: *CSourceFiles,
244244};
......@@ -265,15 +265,15 @@ const FrameworkLinkInfo = struct {
265265};
266266
267267pub const IncludeDir = union(enum) {
268 raw_path: []const u8,
269 raw_path_system: []const u8,
268 path: LazyPath,
269 path_system: LazyPath,
270270 other_step: *Compile,
271271 config_header_step: *Step.ConfigHeader,
272272};
273273
274274pub const Options = struct {
275275 name: []const u8,
276 root_source_file: ?FileSource = null,
276 root_source_file: ?LazyPath = null,
277277 target: CrossTarget,
278278 optimize: std.builtin.Mode,
279279 kind: Kind,
......@@ -391,7 +391,7 @@ pub const EmitOption = union(enum) {
391391
392392pub fn create(owner: *std.Build, options: Options) *Compile {
393393 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;
395395 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
396396 panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
397397 }
......@@ -462,9 +462,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
462462 .include_dirs = ArrayList(IncludeDir).init(owner.allocator),
463463 .link_objects = ArrayList(LinkObject).init(owner.allocator),
464464 .c_macros = ArrayList([]const u8).init(owner.allocator),
465 .lib_paths = ArrayList(FileSource).init(owner.allocator),
466 .rpaths = ArrayList(FileSource).init(owner.allocator),
467 .framework_dirs = ArrayList(FileSource).init(owner.allocator),
465 .lib_paths = ArrayList(LazyPath).init(owner.allocator),
466 .rpaths = ArrayList(LazyPath).init(owner.allocator),
467 .framework_dirs = ArrayList(LazyPath).init(owner.allocator),
468468 .installed_headers = ArrayList(*Step).init(owner.allocator),
469469 .c_std = std.Build.CStd.C99,
470470 .zig_lib_dir = null,
......@@ -614,7 +614,7 @@ pub fn addObjCopy(cs: *Compile, options: Step.ObjCopy.Options) *Step.ObjCopy {
614614 copy.basename = cs.name;
615615 }
616616 }
617 return b.addObjCopy(cs.getOutputSource(), copy);
617 return b.addObjCopy(cs.getEmittedBin(), copy);
618618}
619619
620620/// 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");
626626pub const install = @compileError("deprecated; use std.Build.installArtifact");
627627
628628pub 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);
630630}
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 {
633635 const b = self.step.owner;
634636 self.linker_script = source.dupe(b);
635637 source.addStepDependencies(&self.step);
......@@ -935,19 +937,12 @@ pub fn addCSourceFiles(self: *Compile, files: []const []const u8, flags: []const
935937 self.link_objects.append(.{ .c_source_files = c_source_files }) catch @panic("OOM");
936938}
937939
938pub fn addCSourceFile(self: *Compile, file: []const u8, flags: []const []const u8) void {
939 self.addCSourceFileSource(.{
940 .args = flags,
941 .source = .{ .path = file },
942 });
943}
944
945pub fn addCSourceFileSource(self: *Compile, source: CSourceFile) void {
940pub fn addCSourceFile(self: *Compile, source: CSourceFile) void {
946941 const b = self.step.owner;
947942 const c_source_file = b.allocator.create(CSourceFile) catch @panic("OOM");
948943 c_source_file.* = source.dupe(b);
949944 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);
951946}
952947
953948pub fn setVerboseLink(self: *Compile, value: bool) void {
......@@ -958,53 +953,63 @@ pub fn setVerboseCC(self: *Compile, value: bool) void {
958953 self.verbose_cc = value;
959954}
960955
961pub fn overrideZigLibDir(self: *Compile, dir_path: []const u8) void {
962 const b = self.step.owner;
963 self.zig_lib_dir = b.dupePath(dir_path);
956pub fn overrideZigLibDir(self: *Compile, dir_path: LazyPath) void {
957 self.zig_lib_dir = dir_path.dupe(self.step.owner);
958 dir_path.addStepDependencies(&self.step);
964959}
965960
966pub fn setMainPkgPath(self: *Compile, dir_path: []const u8) void {
967 const b = self.step.owner;
968 self.main_pkg_path = b.dupePath(dir_path);
961pub fn setMainPkgPath(self: *Compile, dir_path: LazyPath) void {
962 self.main_pkg_path = dir_path.dupe(self.step.owner);
963 dir_path.addStepDependencies(&self.step);
969964}
970965
971pub fn setLibCFile(self: *Compile, libc_file: ?FileSource) void {
966pub fn setLibCFile(self: *Compile, libc_file: ?LazyPath) void {
972967 const b = self.step.owner;
973968 self.libc_file = if (libc_file) |f| f.dupe(b) else null;
974969}
975970
971pub const getOutputSource = getEmittedBin; // DEPRECATED, use getEmittedBin
972
976973/// Returns the generated executable, library or object file.
977974/// 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 {
979976 return .{ .generated = &self.output_path_source };
980977}
981978
982pub fn getOutputDirectorySource(self: *Compile) FileSource {
979pub const getOutputDirectorySource = getEmitDirectory; // DEPRECATED, use getEmitDirectory
980
981pub fn getEmitDirectory(self: *Compile) LazyPath {
983982 return .{ .generated = &self.output_dirname_source };
984983}
985984
985pub const getOutputLibSource = getEmittedImplib; // DEPRECATED, use getEmittedImplib
986
986987/// 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 {
988989 assert(self.kind == .lib);
989990 return .{ .generated = &self.output_lib_path_source };
990991}
991992
993pub const getOutputHSource = getEmittedH; // DEPRECATED, use getEmittedH
994
992995/// Returns the generated header file.
993996/// 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 {
995998 assert(self.kind != .exe and self.kind != .@"test");
996999 assert(self.emit_h);
9971000 return .{ .generated = &self.output_h_path_source };
9981001}
9991002
1003pub const getOutputPdbSource = getEmittedPdb; // DEPRECATED, use getEmittedPdb
1004
10001005/// 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 {
10021007 // TODO: Is this right? Isn't PDB for *any* PE/COFF file?
10031008 assert(self.target.isWindows() or self.target.isUefi());
10041009 return .{ .generated = &self.output_pdb_path_source };
10051010}
10061011
1007pub fn getEmittedDocs(self: *Compile) FileSource {
1012pub fn getEmittedDocs(self: *Compile) LazyPath {
10081013 if (self.generated_docs) |g| return .{ .generated = g };
10091014 const arena = self.step.owner.allocator;
10101015 const generated_file = arena.create(GeneratedFile) catch @panic("OOM");
......@@ -1013,25 +1018,14 @@ pub fn getEmittedDocs(self: *Compile) FileSource {
10131018 return .{ .generated = generated_file };
10141019}
10151020
1016pub fn addAssemblyFile(self: *Compile, path: []const u8) 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 {
1021pub fn addAssemblyFile(self: *Compile, source: LazyPath) void {
10241022 const b = self.step.owner;
10251023 const source_duped = source.dupe(b);
10261024 self.link_objects.append(.{ .assembly_file = source_duped }) catch @panic("OOM");
10271025 source_duped.addStepDependencies(&self.step);
10281026}
10291027
1030pub fn addObjectFile(self: *Compile, source_file: []const u8) void {
1031 self.addObjectFileSource(.{ .path = source_file });
1032}
1033
1034pub fn addObjectFileSource(self: *Compile, source: FileSource) void {
1028pub fn addObjectFile(self: *Compile, source: LazyPath) void {
10351029 const b = self.step.owner;
10361030 self.link_objects.append(.{ .static_path = source.dupe(b) }) catch @panic("OOM");
10371031 source.addStepDependencies(&self.step);
......@@ -1042,14 +1036,16 @@ pub fn addObject(self: *Compile, obj: *Compile) void {
10421036 self.linkLibraryOrObject(obj);
10431037}
10441038
1045pub fn addSystemIncludePath(self: *Compile, path: []const u8) void {
1039pub fn addSystemIncludePath(self: *Compile, path: LazyPath) void {
10461040 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);
10481043}
10491044
1050pub fn addIncludePath(self: *Compile, path: []const u8) void {
1045pub fn addIncludePath(self: *Compile, path: LazyPath) void {
10511046 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);
10531049}
10541050
10551051pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {
......@@ -1057,32 +1053,17 @@ pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {
10571053 self.include_dirs.append(.{ .config_header_step = config_header }) catch @panic("OOM");
10581054}
10591055
1060pub fn addLibraryPath(self: *Compile, path: []const u8) 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 {
1056pub fn addLibraryPath(self: *Compile, directory_source: LazyPath) void {
10661057 self.lib_paths.append(directory_source) catch @panic("OOM");
10671058 directory_source.addStepDependencies(&self.step);
10681059}
10691060
1070pub fn addRPath(self: *Compile, path: []const u8) 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 {
1061pub fn addRPath(self: *Compile, directory_source: LazyPath) void {
10761062 self.rpaths.append(directory_source) catch @panic("OOM");
10771063 directory_source.addStepDependencies(&self.step);
10781064}
10791065
1080pub fn addFrameworkPath(self: *Compile, dir_path: []const u8) 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 {
1066pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void {
10861067 self.framework_dirs.append(directory_source) catch @panic("OOM");
10871068 directory_source.addStepDependencies(&self.step);
10881069}
......@@ -1364,7 +1345,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
13641345 .exe => @panic("Cannot link with an executable build artifact"),
13651346 .@"test" => @panic("Cannot link with a test"),
13661347 .obj => {
1367 try zig_args.append(other.getOutputSource().getPath(b));
1348 try zig_args.append(other.getEmittedBin().getPath(b));
13681349 },
13691350 .lib => l: {
13701351 if (self.isStaticLibrary() and other.isStaticLibrary()) {
......@@ -1372,7 +1353,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
13721353 break :l;
13731354 }
13741355
1375 const full_path_lib = other.getOutputLibSource().getPath(b);
1356 const full_path_lib = other.getEmittedImplib().getPath(b);
13761357 try zig_args.append(full_path_lib);
13771358
13781359 if (other.linkage == Linkage.dynamic and !self.target.isWindows()) {
......@@ -1432,7 +1413,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
14321413 },
14331414
14341415 .c_source_file => |c_source_file| {
1435 if (c_source_file.args.len == 0) {
1416 if (c_source_file.flags.len == 0) {
14361417 if (prev_has_cflags) {
14371418 try zig_args.append("-cflags");
14381419 try zig_args.append("--");
......@@ -1440,13 +1421,13 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
14401421 }
14411422 } else {
14421423 try zig_args.append("-cflags");
1443 for (c_source_file.args) |arg| {
1424 for (c_source_file.flags) |arg| {
14441425 try zig_args.append(arg);
14451426 }
14461427 try zig_args.append("--");
14471428 prev_has_cflags = true;
14481429 }
1449 try zig_args.append(c_source_file.source.getPath(b));
1430 try zig_args.append(c_source_file.file.getPath(b));
14501431 },
14511432
14521433 .c_source_files => |c_source_files| {
......@@ -1746,18 +1727,18 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
17461727
17471728 for (self.include_dirs.items) |include_dir| {
17481729 switch (include_dir) {
1749 .raw_path => |include_path| {
1730 .path => |include_path| {
17501731 try zig_args.append("-I");
1751 try zig_args.append(b.pathFromRoot(include_path));
1732 try zig_args.append(include_path.getPath(b));
17521733 },
1753 .raw_path_system => |include_path| {
1734 .path_system => |include_path| {
17541735 if (b.sysroot != null) {
17551736 try zig_args.append("-iwithsysroot");
17561737 } else {
17571738 try zig_args.append("-isystem");
17581739 }
17591740
1760 const resolved_include_path = b.pathFromRoot(include_path);
1741 const resolved_include_path = include_path.getPath(b);
17611742
17621743 const common_include_path = if (builtin.os.tag == .windows and b.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: {
17631744 // 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 {
17751756 },
17761757 .other_step => |other| {
17771758 if (other.emit_h) {
1778 const h_path = other.getOutputHSource().getPath(b);
1759 const h_path = other.getEmittedH().getPath(b);
17791760 try zig_args.append("-isystem");
17801761 try zig_args.append(fs.path.dirname(h_path).?);
17811762 }
......@@ -1907,7 +1888,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
19071888
19081889 if (self.zig_lib_dir) |dir| {
19091890 try zig_args.append("--zig-lib-dir");
1910 try zig_args.append(b.pathFromRoot(dir));
1891 try zig_args.append(dir.getPath(b));
19111892 } else if (b.zig_lib_dir) |dir| {
19121893 try zig_args.append("--zig-lib-dir");
19131894 try zig_args.append(dir);
......@@ -1915,7 +1896,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
19151896
19161897 if (self.main_pkg_path) |dir| {
19171898 try zig_args.append("--main-pkg-path");
1918 try zig_args.append(b.pathFromRoot(dir));
1899 try zig_args.append(dir.getPath(b));
19191900 }
19201901
19211902 try addFlag(&zig_args, "PIC", self.force_pic);
......@@ -2042,7 +2023,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
20422023 {
20432024 try doAtomicSymLinks(
20442025 step,
2045 self.getOutputSource().getPath(b),
2026 self.getEmittedBin().getPath(b),
20462027 self.major_only_filename.?,
20472028 self.name_only_filename.?,
20482029 );
lib/std/Build/Step/ConfigHeader.zig+10-6
......@@ -6,16 +6,18 @@ const Allocator = std.mem.Allocator;
66pub const Style = union(enum) {
77 /// The configure format supported by autotools. It uses `#undef foo` to
88 /// mark lines that can be substituted with different values.
9 autoconf: std.Build.FileSource,
9 autoconf: std.Build.LazyPath,
1010 /// The configure format supported by CMake. It uses `@@FOO@@` and
1111 /// `#cmakedefine` for template substitution.
12 cmake: std.Build.FileSource,
12 cmake: std.Build.LazyPath,
1313 /// Instead of starting with an input file, start with nothing.
1414 blank,
1515 /// Start with nothing, like blank, and output a nasm .asm file.
1616 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 {
1921 switch (style) {
2022 .autoconf, .cmake => |s| return s,
2123 .blank, .nasm => return null,
......@@ -54,7 +56,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
5456
5557 var include_path: []const u8 = "config.h";
5658
57 if (options.style.getFileSource()) |s| switch (s) {
59 if (options.style.getPath()) |s| switch (s) {
5860 .path => |p| {
5961 const basename = std.fs.path.basename(p);
6062 if (std.mem.endsWith(u8, basename, ".h.in")) {
......@@ -68,7 +70,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
6870 include_path = p;
6971 }
7072
71 const name = if (options.style.getFileSource()) |s|
73 const name = if (options.style.getPath()) |s|
7274 owner.fmt("configure {s} header {s} to {s}", .{
7375 @tagName(options.style), s.getDisplayName(), include_path,
7476 })
......@@ -98,7 +100,9 @@ pub fn addValues(self: *ConfigHeader, values: anytype) void {
98100 return addValuesInner(self, values) catch @panic("OOM");
99101}
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 {
102106 return .{ .generated = &self.output_file };
103107}
104108
lib/std/Build/Step/InstallArtifact.zig+4-4
......@@ -76,7 +76,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
7676 var all_cached = true;
7777
7878 {
79 const full_src_path = self.artifact.getOutputSource().getPath(src_builder);
79 const full_src_path = self.artifact.getEmittedBin().getPath(src_builder);
8080 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {
8181 return step.fail("unable to update file from '{s}' to '{s}': {s}", .{
8282 full_src_path, full_dest_path, @errorName(err),
......@@ -95,7 +95,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
9595 self.artifact.target.isWindows() and
9696 self.artifact.emit_implib != .no_emit)
9797 {
98 const full_src_path = self.artifact.getOutputLibSource().getPath(src_builder);
98 const full_src_path = self.artifact.getEmittedImplib().getPath(src_builder);
9999 const full_implib_path = dest_builder.getInstallPath(self.dest_dir, self.artifact.out_lib_filename);
100100 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_implib_path, .{}) catch |err| {
101101 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 {
105105 all_cached = all_cached and p == .fresh;
106106 }
107107 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);
109109 const full_pdb_path = dest_builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename);
110110 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_pdb_path, .{}) catch |err| {
111111 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 {
115115 all_cached = all_cached and p == .fresh;
116116 }
117117 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);
119119 const full_h_path = dest_builder.getInstallPath(h_dir, self.artifact.out_h_filename);
120120 const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_h_path, .{}) catch |err| {
121121 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");
22const mem = std.mem;
33const fs = std.fs;
44const Step = std.Build.Step;
5const FileSource = std.Build.FileSource;
5const LazyPath = std.Build.LazyPath;
66const InstallDir = std.Build.InstallDir;
77const InstallDirStep = @This();
88
......@@ -15,7 +15,7 @@ dest_builder: *std.Build,
1515pub const base_id = .install_dir;
1616
1717pub const Options = struct {
18 source_dir: FileSource,
18 source_dir: LazyPath,
1919 install_dir: InstallDir,
2020 install_subdir: []const u8,
2121 /// File paths which end in any of these suffixes will be excluded
lib/std/Build/Step/InstallFile.zig+3-3
......@@ -1,6 +1,6 @@
11const std = @import("std");
22const Step = std.Build.Step;
3const FileSource = std.Build.FileSource;
3const LazyPath = std.Build.LazyPath;
44const InstallDir = std.Build.InstallDir;
55const InstallFile = @This();
66const assert = std.debug.assert;
......@@ -8,7 +8,7 @@ const assert = std.debug.assert;
88pub const base_id = .install_file;
99
1010step: Step,
11source: FileSource,
11source: LazyPath,
1212dir: InstallDir,
1313dest_rel_path: []const u8,
1414/// This is used by the build system when a file being installed comes from one
......@@ -17,7 +17,7 @@ dest_builder: *std.Build,
1717
1818pub fn create(
1919 owner: *std.Build,
20 source: FileSource,
20 source: LazyPath,
2121 dir: InstallDir,
2222 dest_rel_path: []const u8,
2323) *InstallFile {
lib/std/Build/Step/ObjCopy.zig+10-8
......@@ -20,7 +20,7 @@ pub const RawFormat = enum {
2020};
2121
2222step: Step,
23file_source: std.Build.FileSource,
23input_file: std.Build.LazyPath,
2424basename: []const u8,
2525output_file: std.Build.GeneratedFile,
2626
......@@ -37,30 +37,32 @@ pub const Options = struct {
3737
3838pub fn create(
3939 owner: *std.Build,
40 file_source: std.Build.FileSource,
40 input_file: std.Build.LazyPath,
4141 options: Options,
4242) *ObjCopy {
4343 const self = owner.allocator.create(ObjCopy) catch @panic("OOM");
4444 self.* = ObjCopy{
4545 .step = Step.init(.{
4646 .id = base_id,
47 .name = owner.fmt("objcopy {s}", .{file_source.getDisplayName()}),
47 .name = owner.fmt("objcopy {s}", .{input_file.getDisplayName()}),
4848 .owner = owner,
4949 .makeFn = make,
5050 }),
51 .file_source = file_source,
52 .basename = options.basename orelse file_source.getDisplayName(),
51 .input_file = input_file,
52 .basename = options.basename orelse input_file.getDisplayName(),
5353 .output_file = std.Build.GeneratedFile{ .step = &self.step },
5454
5555 .format = options.format,
5656 .only_section = options.only_section,
5757 .pad_to = options.pad_to,
5858 };
59 file_source.addStepDependencies(&self.step);
59 input_file.addStepDependencies(&self.step);
6060 return self;
6161}
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 {
6466 return .{ .generated = &self.output_file };
6567}
6668
......@@ -75,7 +77,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
7577 // bytes when ObjCopy implementation is modified incompatibly.
7678 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);
7981 _ = try man.addFile(full_src_path, null);
8082 man.hash.addOptionalBytes(self.only_section);
8183 man.hash.addOptional(self.pad_to);
lib/std/Build/Step/Options.zig+23-31
......@@ -3,7 +3,7 @@ const builtin = @import("builtin");
33const fs = std.fs;
44const Step = std.Build.Step;
55const GeneratedFile = std.Build.GeneratedFile;
6const FileSource = std.Build.FileSource;
6const LazyPath = std.Build.LazyPath;
77
88const Options = @This();
99
......@@ -13,8 +13,7 @@ step: Step,
1313generated_file: GeneratedFile,
1414
1515contents: std.ArrayList(u8),
16artifact_args: std.ArrayList(OptionArtifactArg),
17file_source_args: std.ArrayList(OptionFileSourceArg),
16args: std.ArrayList(OptionLazyPathArg),
1817
1918pub fn create(owner: *std.Build) *Options {
2019 const self = owner.allocator.create(Options) catch @panic("OOM");
......@@ -27,8 +26,7 @@ pub fn create(owner: *std.Build) *Options {
2726 }),
2827 .generated_file = undefined,
2928 .contents = std.ArrayList(u8).init(owner.allocator),
30 .artifact_args = std.ArrayList(OptionArtifactArg).init(owner.allocator),
31 .file_source_args = std.ArrayList(OptionFileSourceArg).init(owner.allocator),
29 .args = std.ArrayList(OptionLazyPathArg).init(owner.allocator),
3230 };
3331 self.generated_file = .{ .step = &self.step };
3432
......@@ -168,35 +166,42 @@ fn printLiteral(out: anytype, val: anytype, indent: u8) !void {
168166 }
169167}
170168
169pub const addOptionFileSource = addOptionPath; // DEPRECATED, use addPathOption
170
171171/// The value is the path in the cache dir.
172172/// Adds a dependency automatically.
173pub fn addOptionFileSource(
173pub fn addOptionPath(
174174 self: *Options,
175175 name: []const u8,
176 source: FileSource,
176 path: LazyPath,
177177) void {
178 self.file_source_args.append(.{
179 .name = name,
180 .source = source.dupe(self.step.owner),
178 self.args.append(.{
179 .name = self.step.owner.dupe(name),
180 .path = path.dupe(self.step.owner),
181181 }) catch @panic("OOM");
182 source.addStepDependencies(&self.step);
182 path.addStepDependencies(&self.step);
183183}
184184
185185/// The value is the path in the cache dir.
186186/// Adds a dependency automatically.
187187pub 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");
189192 self.step.dependOn(&artifact.step);
190193}
191194
192195pub fn createModule(self: *Options) *std.Build.Module {
193196 return self.step.owner.createModule(.{
194 .source_file = self.getSource(),
197 .source_file = self.getOutput(),
195198 .dependencies = &.{},
196199 });
197200}
198201
199pub fn getSource(self: *Options) FileSource {
202pub const getSource = getOutput; // DEPRECATED, use getOutput
203
204pub fn getOutput(self: *Options) LazyPath {
200205 return .{ .generated = &self.generated_file };
201206}
202207
......@@ -207,19 +212,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
207212 const b = step.owner;
208213 const self = @fieldParentPtr(Options, "step", step);
209214
210 for (self.artifact_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| {
215 for (self.args.items) |item| {
219216 self.addOption(
220217 []const u8,
221218 item.name,
222 item.source.getPath(b),
219 item.path.getPath(b),
223220 );
224221 }
225222
......@@ -294,14 +291,9 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
294291 }
295292}
296293
297const OptionArtifactArg = struct {
298 name: []const u8,
299 artifact: *Step.Compile,
300};
301
302const OptionFileSourceArg = struct {
294const OptionLazyPathArg = struct {
303295 name: []const u8,
304 source: FileSource,
296 path: LazyPath,
305297};
306298
307299test Options {
lib/std/Build/Step/Run.zig+28-20
......@@ -82,7 +82,7 @@ has_side_effects: bool = false,
8282pub const StdIn = union(enum) {
8383 none,
8484 bytes: []const u8,
85 file_source: std.Build.FileSource,
85 file_source: std.Build.LazyPath,
8686};
8787
8888pub const StdIo = union(enum) {
......@@ -120,15 +120,15 @@ pub const StdIo = union(enum) {
120120
121121pub const Arg = union(enum) {
122122 artifact: *Step.Compile,
123 file_source: PrefixedFileSource,
124 directory_source: PrefixedFileSource,
123 file_source: PrefixedLazyPath,
124 directory_source: PrefixedLazyPath,
125125 bytes: []u8,
126126 output: *Output,
127127};
128128
129pub const PrefixedFileSource = struct {
129pub const PrefixedLazyPath = struct {
130130 prefix: []const u8,
131 file_source: std.Build.FileSource,
131 file_source: std.Build.LazyPath,
132132};
133133
134134pub const Output = struct {
......@@ -169,9 +169,9 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void {
169169}
170170
171171/// 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 APIs
172/// run, and returns a LazyPath which can be used as inputs to other APIs
173173/// 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 {
175175 return self.addPrefixedOutputFileArg("", basename);
176176}
177177
......@@ -179,7 +179,7 @@ pub fn addPrefixedOutputFileArg(
179179 self: *Run,
180180 prefix: []const u8,
181181 basename: []const u8,
182) std.Build.FileSource {
182) std.Build.LazyPath {
183183 const b = self.step.owner;
184184
185185 const output = b.allocator.create(Output) catch @panic("OOM");
......@@ -197,14 +197,18 @@ pub fn addPrefixedOutputFileArg(
197197 return .{ .generated = &output.generated_file };
198198}
199199
200pub fn addFileSourceArg(self: *Run, file_source: std.Build.FileSource) void {
201 self.addPrefixedFileSourceArg("", file_source);
200pub const addFileSourceArg = addFileArg; // DEPRECATED, use addFileArg
201
202pub fn addFileArg(self: *Run, file_source: std.Build.LazyPath) void {
203 self.addPrefixedFileArg("", file_source);
202204}
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 {
205209 const b = self.step.owner;
206210
207 const prefixed_file_source: PrefixedFileSource = .{
211 const prefixed_file_source: PrefixedLazyPath = .{
208212 .prefix = b.dupe(prefix),
209213 .file_source = file_source.dupe(b),
210214 };
......@@ -212,14 +216,18 @@ pub fn addPrefixedFileSourceArg(self: *Run, prefix: []const u8, file_source: std
212216 file_source.addStepDependencies(&self.step);
213217}
214218
215pub fn addDirectorySourceArg(self: *Run, directory_source: std.Build.FileSource) void {
216 self.addPrefixedDirectorySourceArg("", directory_source);
219pub const addDirectorySourceArg = addDirectoryArg; // DEPRECATED, use addDirectoryArg
220
221pub fn addDirectoryArg(self: *Run, directory_source: std.Build.LazyPath) void {
222 self.addPrefixedDirectoryArg("", directory_source);
217223}
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 {
220228 const b = self.step.owner;
221229
222 const prefixed_directory_source: PrefixedFileSource = .{
230 const prefixed_directory_source: PrefixedLazyPath = .{
223231 .prefix = b.dupe(prefix),
224232 .file_source = directory_source.dupe(b),
225233 };
......@@ -331,7 +339,7 @@ pub fn addCheck(self: *Run, new_check: StdIo.Check) void {
331339 }
332340}
333341
334pub fn captureStdErr(self: *Run) std.Build.FileSource {
342pub fn captureStdErr(self: *Run) std.Build.LazyPath {
335343 assert(self.stdio != .inherit);
336344
337345 if (self.captured_stderr) |output| return .{ .generated = &output.generated_file };
......@@ -346,7 +354,7 @@ pub fn captureStdErr(self: *Run) std.Build.FileSource {
346354 return .{ .generated = &output.generated_file };
347355}
348356
349pub fn captureStdOut(self: *Run) std.Build.FileSource {
357pub fn captureStdOut(self: *Run) std.Build.LazyPath {
350358 assert(self.stdio != .inherit);
351359
352360 if (self.captured_stdout) |output| return .{ .generated = &output.generated_file };
......@@ -449,7 +457,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
449457 self.addPathForDynLibs(artifact);
450458 }
451459 const file_path = artifact.installed_path orelse
452 artifact.getOutputSource().getPath(b);
460 artifact.getEmittedBin().getPath(b);
453461
454462 try argv_list.append(file_path);
455463
......@@ -1241,7 +1249,7 @@ fn addPathForDynLibs(self: *Run, artifact: *Step.Compile) void {
12411249 switch (link_object) {
12421250 .other_step => |other| {
12431251 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)).?);
12451253 addPathForDynLibs(self, other);
12461254 }
12471255 },
lib/std/Build/Step/TranslateC.zig+10-6
......@@ -9,7 +9,7 @@ const TranslateC = @This();
99pub const base_id = .translate_c;
1010
1111step: Step,
12source: std.Build.FileSource,
12source: std.Build.LazyPath,
1313include_dirs: std.ArrayList([]const u8),
1414c_macros: std.ArrayList([]const u8),
1515out_basename: []const u8,
......@@ -18,7 +18,7 @@ optimize: std.builtin.OptimizeMode,
1818output_file: std.Build.GeneratedFile,
1919
2020pub const Options = struct {
21 source_file: std.Build.FileSource,
21 source_file: std.Build.LazyPath,
2222 target: CrossTarget,
2323 optimize: std.builtin.OptimizeMode,
2424};
......@@ -53,10 +53,14 @@ pub const AddExecutableOptions = struct {
5353 linkage: ?Step.Compile.Linkage = null,
5454};
5555
56pub fn getOutput(self: *TranslateC) std.Build.LazyPath {
57 return .{ .generated = &self.output_file };
58}
59
5660/// Creates a step to build an executable from the translated source.
5761pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Compile {
5862 return self.step.owner.addExecutable(.{
59 .root_source_file = .{ .generated = &self.output_file },
63 .root_source_file = self.getOutput(),
6064 .name = options.name orelse "translated_c",
6165 .version = options.version,
6266 .target = options.target orelse self.target,
......@@ -70,7 +74,7 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com
7074/// `createModule` can be used instead to create a private module.
7175pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module {
7276 return self.step.owner.addModule(name, .{
73 .source_file = .{ .generated = &self.output_file },
77 .source_file = self.getOutput(),
7478 });
7579}
7680
......@@ -83,7 +87,7 @@ pub fn createModule(self: *TranslateC) *std.Build.Module {
8387
8488 module.* = .{
8589 .builder = b,
86 .source_file = .{ .generated = &self.output_file },
90 .source_file = self.getOutput(),
8791 .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator),
8892 };
8993 return module;
......@@ -96,7 +100,7 @@ pub fn addIncludeDir(self: *TranslateC, include_dir: []const u8) void {
96100pub fn addCheckFile(self: *TranslateC, expected_matches: []const []const u8) *Step.CheckFile {
97101 return Step.CheckFile.create(
98102 self.step.owner,
99 .{ .generated = &self.output_file },
103 self.getOutput(),
100104 .{ .expected_matches = expected_matches },
101105 );
102106}
lib/std/Build/Step/WriteFile.zig+14-10
......@@ -28,7 +28,9 @@ pub const File = struct {
2828 sub_path: []const u8,
2929 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 {
3234 return .{ .generated = &self.generated_file };
3335 }
3436};
......@@ -40,7 +42,7 @@ pub const OutputSourceFile = struct {
4042
4143pub const Contents = union(enum) {
4244 bytes: []const u8,
43 copy: std.Build.FileSource,
45 copy: std.Build.LazyPath,
4446};
4547
4648pub fn create(owner: *std.Build) *WriteFile {
......@@ -59,7 +61,7 @@ pub fn create(owner: *std.Build) *WriteFile {
5961 return wf;
6062}
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 {
6365 const b = wf.step.owner;
6466 const gpa = b.allocator;
6567 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
7072 };
7173 wf.files.append(gpa, file) catch @panic("OOM");
7274 wf.maybeUpdateName();
73 return file.getFileSource();
75 return file.getPath();
7476}
7577
7678/// 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
8082/// include sub-directories, in which case this step will ensure the
8183/// required sub-path exists.
8284/// 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 {
8486 const b = wf.step.owner;
8587 const gpa = b.allocator;
8688 const file = gpa.create(File) catch @panic("OOM");
......@@ -93,7 +95,7 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []con
9395
9496 wf.maybeUpdateName();
9597 source.addStepDependencies(&wf.step);
96 return file.getFileSource();
98 return file.getLazyPath();
9799}
98100
99101/// A path relative to the package root.
......@@ -101,7 +103,7 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []con
101103/// used as part of the normal build process, but as a utility occasionally
102104/// run by a developer with intent to modify source files and then commit
103105/// 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 {
105107 const b = wf.step.owner;
106108 wf.output_source_files.append(b.allocator, .{
107109 .contents = .{ .copy = source },
......@@ -123,11 +125,13 @@ pub fn addBytesToSource(wf: *WriteFile, bytes: []const u8, sub_path: []const u8)
123125 }) catch @panic("OOM");
124126}
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 the
132/// Returns a `LazyPath` representing the base directory that contains all the
129133/// files from this `WriteFile`.
130pub fn getDirectorySource(wf: *WriteFile) std.Build.FileSource {
134pub fn getDirectory(wf: *WriteFile) std.Build.LazyPath {
131135 return .{ .generated = &wf.generated_directory };
132136}
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
1616 .optimize = optimize,
1717 .target = .{},
1818 });
19 lib_a.addCSourceFile("a.c", &[_][]const u8{});
20 lib_a.addIncludePath(".");
19 lib_a.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &[_][]const u8{} });
20 lib_a.addIncludePath(.{ .path = "." });
2121
2222 const lib_b = b.addStaticLibrary(.{
2323 .name = "b",
2424 .optimize = optimize,
2525 .target = .{},
2626 });
27 lib_b.addCSourceFile("b.c", &[_][]const u8{});
28 lib_b.addIncludePath(".");
27 lib_b.addCSourceFile(.{ .file = .{ .path = "b.c" }, .flags = &[_][]const u8{} });
28 lib_b.addIncludePath(.{ .path = "." });
2929
3030 const test_exe = b.addTest(.{
3131 .root_source_file = .{ .path = "main.zig" },
......@@ -33,7 +33,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3333 });
3434 test_exe.linkLibrary(lib_a);
3535 test_exe.linkLibrary(lib_b);
36 test_exe.addIncludePath(".");
36 test_exe.addIncludePath(.{ .path = "." });
3737
3838 test_step.dependOn(&b.addRunArtifact(test_exe).step);
3939}
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
2323 .name = "test",
2424 .optimize = optimize,
2525 });
26 exe.addSystemIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include" }) catch unreachable);
27 exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include/c++/v1" }) catch unreachable);
28 exe.addCSourceFile("test.cpp", &.{
26 exe.addSystemIncludePath(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/include" }) });
27 exe.addIncludePath(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/include/c++/v1" }) });
28 exe.addCSourceFile(.{ .file = .{ .path = "test.cpp" }, .flags = &.{
2929 "-nostdlib++",
3030 "-nostdinc++",
31 });
32 exe.addObjectFile(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/lib/libc++.tbd" }) catch unreachable);
31 } });
32 exe.addObjectFile(.{ .path = b.pathJoin(&.{ sdk.path, "/usr/lib/libc++.tbd" }) });
3333
3434 const run_cmd = b.addRunArtifact(exe);
3535 run_cmd.expectStdErrEqual("x: 5\n");
test/link/macho/dead_strip/build.zig+1-1
......@@ -52,7 +52,7 @@ fn createScenario(
5252 .optimize = optimize,
5353 .target = target,
5454 });
55 exe.addCSourceFile("main.c", &[0][]const u8{});
55 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
5656 exe.linkLibC();
5757 return exe;
5858}
test/link/macho/dead_strip_dylibs/build.zig+1-1
......@@ -53,7 +53,7 @@ fn createScenario(
5353 .name = name,
5454 .optimize = optimize,
5555 });
56 exe.addCSourceFile("main.c", &[0][]const u8{});
56 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
5757 exe.linkLibC();
5858 exe.linkFramework("Cocoa");
5959 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
2121 .optimize = optimize,
2222 .target = target,
2323 });
24 dylib.addCSourceFile("a.c", &.{});
24 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
2525 dylib.linkLibC();
2626
2727 const check_dylib = dylib.checkObject();
......@@ -39,10 +39,10 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3939 .optimize = optimize,
4040 .target = target,
4141 });
42 exe.addCSourceFile("main.c", &.{});
42 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
4343 exe.linkSystemLibrary("a");
44 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());
45 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());
44 exe.addLibraryPath(dylib.getEmitDirectory());
45 exe.addRPath(dylib.getEmitDirectory());
4646 exe.linkLibC();
4747
4848 const check_exe = exe.checkObject();
......@@ -55,7 +55,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
5555
5656 check_exe.checkStart();
5757 check_exe.checkExact("cmd RPATH");
58 check_exe.checkExactFileSource("path", dylib.getOutputDirectorySource());
58 check_exe.checkExactPath("path", dylib.getOutputDirectorySource());
5959 test_step.dependOn(&check_exe.step);
6060
6161 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
2020 .optimize = optimize,
2121 .target = target,
2222 });
23 exe.addCSourceFile("main.c", &[0][]const u8{});
24 exe.addCSourceFile("empty.c", &[0][]const u8{});
23 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
24 exe.addCSourceFile(.{ .file = .{ .path = "empty.c" }, .flags = &[0][]const u8{} });
2525 exe.linkLibC();
2626
2727 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
1818 .optimize = optimize,
1919 .target = .{ .os_tag = .macos },
2020 });
21 exe.addCSourceFile("main.c", &.{});
21 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
2222 exe.linkLibC();
2323 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
1818 .optimize = optimize,
1919 .target = .{ .os_tag = .macos },
2020 });
21 lib.addCSourceFile("main.c", &.{});
21 lib.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
2222 lib.linkLibC();
2323
2424 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
1818 .optimize = optimize,
1919 .target = .{ .os_tag = .macos },
2020 });
21 lib.addCSourceFile("bootstrap.c", &.{});
21 lib.addCSourceFile(.{ .file = .{ .path = "bootstrap.c" }, .flags = &.{} });
2222 lib.linkLibC();
2323 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
2727 .optimize = optimize,
2828 .target = .{ .os_tag = .macos },
2929 });
30 exe.addCSourceFile("main.c", &.{});
30 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
3131 exe.linkLibrary(lib);
3232 exe.linkLibC();
3333 exe.entry_symbol_name = "_bootstrap";
test/link/macho/headerpad/build.zig+1-1
......@@ -113,7 +113,7 @@ fn simpleExe(
113113 .name = name,
114114 .optimize = optimize,
115115 });
116 exe.addCSourceFile("main.c", &.{});
116 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
117117 exe.linkLibC();
118118 exe.linkFramework("CoreFoundation");
119119 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
2020 .name = "test",
2121 .optimize = optimize,
2222 });
23 exe.addCSourceFile("main.c", &[0][]const u8{});
23 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
2424 exe.linkLibC();
2525 exe.linkFrameworkNeeded("Cocoa");
2626 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
2121 .optimize = optimize,
2222 .target = target,
2323 });
24 dylib.addCSourceFile("a.c", &.{});
24 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
2525 dylib.linkLibC();
2626
2727 // -dead_strip_dylibs
......@@ -31,11 +31,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3131 .optimize = optimize,
3232 .target = target,
3333 });
34 exe.addCSourceFile("main.c", &[0][]const u8{});
34 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
3535 exe.linkLibC();
3636 exe.linkSystemLibraryNeeded("a");
37 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());
38 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());
37 exe.addLibraryPath(dylib.getEmitDirectory());
38 exe.addRPath(dylib.getEmitDirectory());
3939 exe.dead_strip_dylibs = true;
4040
4141 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
1818 .name = "test",
1919 .optimize = optimize,
2020 });
21 exe.addIncludePath(".");
22 exe.addCSourceFile("Foo.m", &[0][]const u8{});
23 exe.addCSourceFile("test.m", &[0][]const u8{});
21 exe.addIncludePath(.{ .path = "." });
22 exe.addCSourceFile(.{ .file = .{ .path = "Foo.m" }, .flags = &[0][]const u8{} });
23 exe.addCSourceFile(.{ .file = .{ .path = "test.m" }, .flags = &[0][]const u8{} });
2424 exe.linkLibC();
2525 // TODO when we figure out how to ship framework stubs for cross-compilation,
2626 // 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
1919 .optimize = optimize,
2020 });
2121 b.default_step.dependOn(&exe.step);
22 exe.addIncludePath(".");
23 exe.addCSourceFile("Foo.mm", &[0][]const u8{});
24 exe.addCSourceFile("test.mm", &[0][]const u8{});
22 exe.addIncludePath(.{ .path = "." });
23 exe.addCSourceFile(.{ .file = .{ .path = "Foo.mm" }, .flags = &[0][]const u8{} });
24 exe.addCSourceFile(.{ .file = .{ .path = "test.mm" }, .flags = &[0][]const u8{} });
2525 exe.linkLibCpp();
2626 // TODO when we figure out how to ship framework stubs for cross-compilation,
2727 // 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 {
1515 .optimize = optimize,
1616 .target = target,
1717 });
18 exe.addCSourceFile("main.c", &.{});
18 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
1919 exe.linkLibC();
2020 exe.pagezero_size = 0x4000;
2121
......@@ -39,7 +39,7 @@ pub fn build(b: *std.Build) void {
3939 .optimize = optimize,
4040 .target = target,
4141 });
42 exe.addCSourceFile("main.c", &.{});
42 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
4343 exe.linkLibC();
4444 exe.pagezero_size = 0;
4545
test/link/macho/search_strategy/build.zig+6-6
......@@ -55,7 +55,7 @@ fn createScenario(
5555 .optimize = optimize,
5656 .target = target,
5757 });
58 static.addCSourceFile("a.c", &.{});
58 static.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
5959 static.linkLibC();
6060 static.override_dest_dir = std.Build.InstallDir{
6161 .custom = "static",
......@@ -67,7 +67,7 @@ fn createScenario(
6767 .optimize = optimize,
6868 .target = target,
6969 });
70 dylib.addCSourceFile("a.c", &.{});
70 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
7171 dylib.linkLibC();
7272 dylib.override_dest_dir = std.Build.InstallDir{
7373 .custom = "dynamic",
......@@ -78,11 +78,11 @@ fn createScenario(
7878 .optimize = optimize,
7979 .target = target,
8080 });
81 exe.addCSourceFile("main.c", &.{});
81 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
8282 exe.linkSystemLibraryName(name);
8383 exe.linkLibC();
84 exe.addLibraryPathDirectorySource(static.getOutputDirectorySource());
85 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());
86 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());
84 exe.addLibraryPath(static.getEmitDirectory());
85 exe.addLibraryPath(dylib.getEmitDirectory());
86 exe.addRPath(dylib.getEmitDirectory());
8787 return exe;
8888}
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
2020 .optimize = optimize,
2121 .target = target,
2222 });
23 exe.addCSourceFile("main.c", &.{});
23 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
2424 exe.linkLibC();
2525 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
2121 .optimize = optimize,
2222 .target = target,
2323 });
24 lib.addCSourceFile("a.c", &.{});
24 lib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
2525 lib.linkLibC();
2626
2727 const test_exe = b.addTest(.{
test/link/macho/unwind_info/build.zig+1-1
......@@ -75,7 +75,7 @@ fn createScenario(
7575 .target = target,
7676 });
7777 b.default_step.dependOn(&exe.step);
78 exe.addIncludePath(".");
78 exe.addIncludePath(.{ .path = "." });
7979 exe.addCSourceFiles(&[_][]const u8{
8080 "main.cpp",
8181 "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
1818 .name = "test",
1919 .optimize = optimize,
2020 });
21 exe.addCSourceFile("main.c", &[0][]const u8{});
21 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
2222 exe.linkLibC();
2323 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
2121 .target = target,
2222 .optimize = optimize,
2323 });
24 dylib.addCSourceFile("a.c", &.{});
24 dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} });
2525 dylib.linkLibC();
2626 b.installArtifact(dylib);
2727
......@@ -30,11 +30,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
3030 .target = target,
3131 .optimize = optimize,
3232 });
33 exe.addCSourceFile("main.c", &[0][]const u8{});
33 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
3434 exe.linkLibC();
3535 exe.linkSystemLibraryWeak("a");
36 exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource());
37 exe.addRPathDirectorySource(dylib.getOutputDirectorySource());
36 exe.addLibraryPath(dylib.getEmitDirectory());
37 exe.addRPath(dylib.getEmitDirectory());
3838
3939 const check = exe.checkObject();
4040 check.checkStart();
test/link/static_libs_from_object_files/build.zig+6-6
......@@ -2,7 +2,7 @@ const std = @import("std");
22const builtin = @import("builtin");
33
44const Build = std.Build;
5const FileSource = Build.FileSource;
5const LazyPath = Build.LazyPath;
66const Step = Build.Step;
77const Run = Step.Run;
88const WriteFile = Step.WriteFile;
......@@ -14,7 +14,7 @@ pub fn build(b: *Build) void {
1414 b.default_step = test_step;
1515
1616 // 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;
1818 defer b.allocator.free(files);
1919 {
2020 for (files[0 .. nb_files - 1], 1..nb_files) |*file, i| {
......@@ -47,7 +47,7 @@ pub fn build(b: *Build) void {
4747 add(b, test_step, files, .ReleaseFast);
4848}
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 {
5151 const flags = [_][]const u8{
5252 "-Wall",
5353 "-std=c11",
......@@ -63,7 +63,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz
6363 });
6464
6565 for (files) |file| {
66 exe.addCSourceFileSource(.{ .source = file, .args = &flags });
66 exe.addCSourceFile(.{ .file = file, .flags = &flags });
6767 }
6868
6969 const run_cmd = b.addRunArtifact(exe);
......@@ -88,7 +88,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz
8888
8989 for (files, 1..) |file, i| {
9090 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 });
9292 }
9393
9494 const exe = b.addExecutable(.{
......@@ -125,7 +125,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz
125125 .target = .{},
126126 .optimize = optimize,
127127 });
128 obj.addCSourceFileSource(.{ .source = file, .args = &flags });
128 obj.addCSourceFile(.{ .file = file, .flags = &flags });
129129
130130 const lib = if (i & 1 == 0) lib_a else lib_b;
131131 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
1919 .optimize = optimize,
2020 .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi },
2121 });
22 exe.addCSourceFile("foo.c", &.{});
22 exe.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} });
2323 exe.use_llvm = false;
2424 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 {
1313 .os_tag = .freestanding,
1414 },
1515 });
16 c_obj.addCSourceFile("foo.c", &.{});
16 c_obj.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} });
1717
1818 // Wasm library that doesn't have any features specified. This will
1919 // infer its featureset from other linked object files.
test/src/Cases.zig+3-3
......@@ -518,12 +518,12 @@ pub fn lowerToBuildSteps(
518518 }
519519
520520 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);
522522 defer file_sources.deinit();
523523 for (update.files.items) |file| {
524524 file_sources.put(file.path, writefiles.add(file.path, file.src)) catch @panic("OOM");
525525 }
526 const root_source_file = writefiles.files.items[0].getFileSource();
526 const root_source_file = writefiles.files.items[0].getPath();
527527
528528 const artifact = if (case.is_test) b.addTest(.{
529529 .root_source_file = root_source_file,
......@@ -577,7 +577,7 @@ pub fn lowerToBuildSteps(
577577 parent_step.dependOn(&artifact.step);
578578 },
579579 .CompareObjectFile => |expected_output| {
580 const check = b.addCheckFile(artifact.getOutputSource(), .{
580 const check = b.addCheckFile(artifact.getEmittedBin(), .{
581581 .expected_exact = expected_output,
582582 });
583583
test/src/CompareOutput.zig+3-3
......@@ -99,7 +99,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
9999 .target = .{},
100100 .optimize = .Debug,
101101 });
102 exe.addAssemblyFileSource(write_src.files.items[0].getFileSource());
102 exe.addAssemblyFile(write_src.files.items[0].getPath());
103103
104104 const run = b.addRunArtifact(exe);
105105 run.setName(annotated_case_name);
......@@ -119,7 +119,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
119119
120120 const exe = b.addExecutable(.{
121121 .name = "test",
122 .root_source_file = write_src.files.items[0].getFileSource(),
122 .root_source_file = write_src.files.items[0].getPath(),
123123 .optimize = optimize,
124124 .target = .{},
125125 });
......@@ -145,7 +145,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
145145
146146 const exe = b.addExecutable(.{
147147 .name = "test",
148 .root_source_file = write_src.files.items[0].getFileSource(),
148 .root_source_file = write_src.files.items[0].getPath(),
149149 .target = .{},
150150 .optimize = .Debug,
151151 });
test/src/StackTrace.zig+2-2
......@@ -75,7 +75,7 @@ fn addExpect(
7575 const write_src = b.addWriteFile("source.zig", source);
7676 const exe = b.addExecutable(.{
7777 .name = "test",
78 .root_source_file = write_src.files.items[0].getFileSource(),
78 .root_source_file = write_src.files.items[0].getPath(),
7979 .optimize = optimize_mode,
8080 .target = .{},
8181 });
......@@ -88,7 +88,7 @@ fn addExpect(
8888
8989 const check_run = b.addRunArtifact(self.check_exe);
9090 check_run.setName(annotated_case_name);
91 check_run.addFileSourceArg(run.captureStdErr());
91 check_run.addFileArg(run.captureStdErr());
9292 check_run.addArgs(&.{
9393 @tagName(optimize_mode),
9494 });
test/src/run_translated_c.zig+1-1
......@@ -85,7 +85,7 @@ pub const RunTranslatedCContext = struct {
8585 _ = write_src.add(src_file.filename, src_file.source);
8686 }
8787 const translate_c = b.addTranslateC(.{
88 .source_file = write_src.files.items[0].getFileSource(),
88 .source_file = write_src.files.items[0].getPath(),
8989 .target = .{},
9090 .optimize = .Debug,
9191 });
test/src/translate_c.zig+1-1
......@@ -108,7 +108,7 @@ pub const TranslateCContext = struct {
108108 }
109109
110110 const translate_c = b.addTranslateC(.{
111 .source_file = write_src.files.items[0].getFileSource(),
111 .source_file = write_src.files.items[0].getPath(),
112112 .target = case.target,
113113 .optimize = .Debug,
114114 });
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
1919 .optimize = optimize,
2020 .target = target,
2121 });
22 exe_c.addCSourceFile("test.c", &[0][]const u8{});
22 exe_c.addCSourceFile(.{ .file = .{ .path = "test.c" }, .flags = &[0][]const u8{} });
2323 exe_c.linkLibC();
2424
2525 const exe_cpp = b.addExecutable(.{
......@@ -28,7 +28,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
2828 .target = target,
2929 });
3030 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{} });
3232 exe_cpp.linkLibCpp();
3333
3434 switch (target.getOsTag()) {
test/standalone/embed_generated_file/build.zig+1-1
......@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
1919 .optimize = .Debug,
2020 });
2121 exe.addAnonymousModule("bootloader.elf", .{
22 .source_file = bootloader.getOutputSource(),
22 .source_file = bootloader.getEmittedBin(),
2323 });
2424
2525 test_step.dependOn(&exe.step);
test/standalone/issue_794/build.zig+1-1
......@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
77 const test_artifact = b.addTest(.{
88 .root_source_file = .{ .path = "main.zig" },
99 });
10 test_artifact.addIncludePath("a_directory");
10 test_artifact.addIncludePath(.{ .path = "a_directory" });
1111
1212 test_step.dependOn(&test_artifact.step);
1313}
test/standalone/issue_8550/build.zig+2-2
......@@ -19,8 +19,8 @@ pub fn build(b: *std.Build) !void {
1919 .optimize = optimize,
2020 .target = target,
2121 });
22 kernel.addObjectFile("./boot.S");
23 kernel.setLinkerScriptPath(.{ .path = "./linker.ld" });
22 kernel.addObjectFile(.{ .path = "./boot.S" });
23 kernel.setLinkerScript(.{ .path = "./linker.ld" });
2424 b.installArtifact(kernel);
2525
2626 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 {
77 const test_exe = b.addTest(.{
88 .root_source_file = .{ .path = "a/test.zig" },
99 });
10 test_exe.setMainPkgPath(".");
10 test_exe.setMainPkgPath(.{.path="."});
1111
1212 test_step.dependOn(&b.addRunArtifact(test_exe).step);
1313}
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
2121 .root_source_file = .{ .path = "main.zig" },
2222 .optimize = optimize,
2323 });
24 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c11"});
24 exe.addCSourceFile(.{ .file = .{ .path = "test.c" }, .flags = &[_][]const u8{"-std=c11"} });
2525 exe.linkLibC();
2626
2727 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 {
1919 .optimize = optimize,
2020 .target = target,
2121 });
22 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
22 exe.addCSourceFile(.{
23 .file = .{ .path = "test.c" },
24 .flags = &[_][]const u8{"-std=c99"},
25 });
2326 exe.addObject(obj);
2427 exe.linkSystemLibrary("c");
2528
test/standalone/shared_library/build.zig+4-1
......@@ -19,7 +19,10 @@ pub fn build(b: *std.Build) void {
1919 .target = target,
2020 .optimize = optimize,
2121 });
22 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
22 exe.addCSourceFile(.{
23 .file = .{ .path = "test.c" },
24 .flags = &[_][]const u8{"-std=c99"},
25 });
2326 exe.linkLibrary(lib);
2427 exe.linkSystemLibrary("c");
2528
test/standalone/stack_iterator/build.zig+4-1
......@@ -74,7 +74,10 @@ pub fn build(b: *std.Build) void {
7474 if (target.isWindows()) c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");
7575
7676 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 });
7881 c_shared_lib.linkLibC();
7982
8083 const exe = b.addExecutable(.{
test/standalone/static_c_lib/build.zig+3-3
......@@ -11,15 +11,15 @@ pub fn build(b: *std.Build) void {
1111 .optimize = optimize,
1212 .target = .{},
1313 });
14 foo.addCSourceFile("foo.c", &[_][]const u8{});
15 foo.addIncludePath(".");
14 foo.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &[_][]const u8{} });
15 foo.addIncludePath(.{ .path = "." });
1616
1717 const test_exe = b.addTest(.{
1818 .root_source_file = .{ .path = "foo.zig" },
1919 .optimize = optimize,
2020 });
2121 test_exe.linkLibrary(foo);
22 test_exe.addIncludePath(".");
22 test_exe.addIncludePath(.{ .path = "." });
2323
2424 test_step.dependOn(&b.addRunArtifact(test_exe).step);
2525}
test/standalone/use_alias/build.zig+1-1
......@@ -10,7 +10,7 @@ pub fn build(b: *std.Build) void {
1010 .root_source_file = .{ .path = "main.zig" },
1111 .optimize = optimize,
1212 });
13 main.addIncludePath(".");
13 main.addIncludePath(.{.path="."});
1414
1515 test_step.dependOn(&b.addRunArtifact(main).step);
1616}
test/tests.zig+12-9
......@@ -759,7 +759,7 @@ pub fn addCliTests(b: *std.Build) *Step {
759759 "-fno-emit-bin", "-fno-emit-h",
760760 "-fstrip", "-OReleaseFast",
761761 });
762 run.addFileSourceArg(writefile.files.items[0].getFileSource());
762 run.addFileArg(writefile.files.items[0].getPath());
763763 const example_s = run.addPrefixedOutputFileArg("-femit-asm=", "example.s");
764764
765765 const checkfile = b.addCheckFile(example_s, .{
......@@ -1017,8 +1017,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10171017 else
10181018 "";
10191019
1020 these_tests.overrideZigLibDir("lib");
1021 these_tests.addIncludePath("test");
1020 these_tests.overrideZigLibDir(.{ .path = "lib" });
1021 these_tests.addIncludePath(.{ .path = "test" });
10221022
10231023 const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{
10241024 options.name,
......@@ -1038,10 +1038,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10381038 .link_libc = test_target.link_libc,
10391039 .target = altered_target,
10401040 });
1041 compile_c.overrideZigLibDir("lib");
1042 compile_c.addCSourceFileSource(.{
1043 .source = these_tests.getOutputSource(),
1044 .args = &.{
1041 compile_c.overrideZigLibDir(.{ .path = "lib" });
1042 compile_c.addCSourceFile(.{
1043 .file = these_tests.getEmittedBin(),
1044 .flags = &.{
10451045 // TODO output -std=c89 compatible C code
10461046 "-std=c99",
10471047 "-pedantic",
......@@ -1058,7 +1058,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10581058 "-Wno-absolute-value",
10591059 },
10601060 });
1061 compile_c.addIncludePath("lib"); // for zig.h
1061 compile_c.addIncludePath(.{ .path = "lib" }); // for zig.h
10621062 if (test_target.target.getOsTag() == .windows) {
10631063 if (true) {
10641064 // 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
11311131 test_step.target_info.dynamic_linker.max_byte = null;
11321132 }
11331133 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
11361139 // This test is intentionally trying to check if the external ABI is
11371140 // done properly. LTO would be a hindrance to this.