| author | |
| committer | |
| log | ce95a3b153e9f3e83232e641c26a41e7dbd01165 |
| tree | d2bd5a15abfb77cbb8d79539767cdccbde1e79d3 |
| parent | 235e6ac05df95e5dc2656cfb1a33d7b18c45a603 |
55 files changed, 337 insertions(+), 329 deletions(-)
build.zig+17-18| ... | ... | @@ -45,9 +45,9 @@ pub fn build(b: *std.Build) !void { |
| 45 | 45 | const docgen_cmd = b.addRunArtifact(docgen_exe); |
| 46 | 46 | docgen_cmd.addArgs(&.{ "--zig", b.zig_exe }); |
| 47 | 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 | 51 | const langref_file = docgen_cmd.addOutputFileArg("langref.html"); |
| 52 | 52 | const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html"); |
| 53 | 53 | if (!skip_install_langref) { |
| ... | ... | @@ -58,7 +58,7 @@ pub fn build(b: *std.Build) !void { |
| 58 | 58 | .root_source_file = .{ .path = "lib/std/std.zig" }, |
| 59 | 59 | .target = target, |
| 60 | 60 | }); |
| 61 | autodoc_test.overrideZigLibDir("lib"); | |
| 61 | autodoc_test.overrideZigLibDir(.{ .path = "lib" }); | |
| 62 | 62 | autodoc_test.emit_bin = .no_emit; // https://github.com/ziglang/zig/issues/16351 |
| 63 | 63 | const install_std_docs = b.addInstallDirectory(.{ |
| 64 | 64 | .source_dir = autodoc_test.getEmittedDocs(), |
| ... | ... | @@ -89,7 +89,7 @@ pub fn build(b: *std.Build) !void { |
| 89 | 89 | .root_source_file = .{ .path = "test/src/Cases.zig" }, |
| 90 | 90 | .optimize = optimize, |
| 91 | 91 | }); |
| 92 | check_case_exe.main_pkg_path = "."; | |
| 92 | check_case_exe.setMainPkgPath(.{ .path = "." }); | |
| 93 | 93 | check_case_exe.stack_size = stack_size; |
| 94 | 94 | check_case_exe.single_threaded = single_threaded; |
| 95 | 95 | |
| ... | ... | @@ -352,10 +352,9 @@ pub fn build(b: *std.Build) !void { |
| 352 | 352 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); |
| 353 | 353 | exe_options.addOption(bool, "value_tracing", value_tracing); |
| 354 | 354 | if (tracy) |tracy_path| { |
| 355 | const client_cpp = fs.path.join( | |
| 356 | b.allocator, | |
| 355 | const client_cpp = b.pathJoin( | |
| 357 | 356 | &[_][]const u8{ tracy_path, "public", "TracyClient.cpp" }, |
| 358 | ) catch unreachable; | |
| 357 | ); | |
| 359 | 358 | |
| 360 | 359 | // On mingw, we need to opt into windows 7+ to get some features required by tracy. |
| 361 | 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 | 362 | else |
| 364 | 363 | &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" }; |
| 365 | 364 | |
| 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 }); | |
| 368 | 367 | if (!enable_llvm) { |
| 369 | 368 | exe.linkSystemLibraryName("c++"); |
| 370 | 369 | } |
| ... | ... | @@ -554,7 +553,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { |
| 554 | 553 | }); |
| 555 | 554 | run_opt.addArtifactArg(exe); |
| 556 | 555 | run_opt.addArg("-o"); |
| 557 | run_opt.addFileSourceArg(.{ .path = "stage1/zig1.wasm" }); | |
| 556 | run_opt.addFileArg(.{ .path = "stage1/zig1.wasm" }); | |
| 558 | 557 | |
| 559 | 558 | const copy_zig_h = b.addWriteFiles(); |
| 560 | 559 | copy_zig_h.addCopyFileToSource(.{ .path = "lib/zig.h" }, "stage1/zig.h"); |
| ... | ... | @@ -603,7 +602,7 @@ fn addCmakeCfgOptionsToExe( |
| 603 | 602 | // useful for package maintainers |
| 604 | 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 | 606 | cfg.cmake_binary_dir, |
| 608 | 607 | "zigcpp", |
| 609 | 608 | b.fmt("{s}{s}{s}", .{ |
| ... | ... | @@ -611,11 +610,11 @@ fn addCmakeCfgOptionsToExe( |
| 611 | 610 | "zigcpp", |
| 612 | 611 | cfg.cmake_static_library_suffix, |
| 613 | 612 | }), |
| 614 | }) catch unreachable); | |
| 613 | }) }); | |
| 615 | 614 | 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 }); | |
| 619 | 618 | addCMakeLibraryList(exe, cfg.clang_libraries); |
| 620 | 619 | addCMakeLibraryList(exe, cfg.lld_libraries); |
| 621 | 620 | addCMakeLibraryList(exe, cfg.llvm_libraries); |
| ... | ... | @@ -671,7 +670,7 @@ fn addCmakeCfgOptionsToExe( |
| 671 | 670 | } |
| 672 | 671 | |
| 673 | 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 | } |
| 677 | 676 | |
| ... | ... | @@ -732,7 +731,7 @@ fn addCxxKnownPath( |
| 732 | 731 | } |
| 733 | 732 | return error.RequiredLibraryNotFound; |
| 734 | 733 | } |
| 735 | exe.addObjectFile(path_unpadded); | |
| 734 | exe.addObjectFile(.{ .path = path_unpadded }); | |
| 736 | 735 | |
| 737 | 736 | // TODO a way to integrate with system c++ include files here |
| 738 | 737 | // c++ -E -Wp,-v -xc++ /dev/null |
| ... | ... | @@ -752,7 +751,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void { |
| 752 | 751 | } else if (exe.target.isWindows() and mem.endsWith(u8, lib, ".lib") and !fs.path.isAbsolute(lib)) { |
| 753 | 752 | exe.linkSystemLibrary(lib[0 .. lib.len - ".lib".len]); |
| 754 | 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 | 471 | |
| 472 | 472 | pub const ExecutableOptions = struct { |
| 473 | 473 | name: []const u8, |
| 474 | root_source_file: ?FileSource = null, | |
| 474 | root_source_file: ?LazyPath = null, | |
| 475 | 475 | version: ?std.SemanticVersion = null, |
| 476 | 476 | target: CrossTarget = .{}, |
| 477 | 477 | optimize: std.builtin.Mode = .Debug, |
| ... | ... | @@ -502,7 +502,7 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *Step.Compile { |
| 502 | 502 | |
| 503 | 503 | pub const ObjectOptions = struct { |
| 504 | 504 | name: []const u8, |
| 505 | root_source_file: ?FileSource = null, | |
| 505 | root_source_file: ?LazyPath = null, | |
| 506 | 506 | target: CrossTarget, |
| 507 | 507 | optimize: std.builtin.Mode, |
| 508 | 508 | max_rss: usize = 0, |
| ... | ... | @@ -529,7 +529,7 @@ pub fn addObject(b: *Build, options: ObjectOptions) *Step.Compile { |
| 529 | 529 | |
| 530 | 530 | pub const SharedLibraryOptions = struct { |
| 531 | 531 | name: []const u8, |
| 532 | root_source_file: ?FileSource = null, | |
| 532 | root_source_file: ?LazyPath = null, | |
| 533 | 533 | version: ?std.SemanticVersion = null, |
| 534 | 534 | target: CrossTarget, |
| 535 | 535 | optimize: std.builtin.Mode, |
| ... | ... | @@ -559,7 +559,7 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *Step.Compile |
| 559 | 559 | |
| 560 | 560 | pub const StaticLibraryOptions = struct { |
| 561 | 561 | name: []const u8, |
| 562 | root_source_file: ?FileSource = null, | |
| 562 | root_source_file: ?LazyPath = null, | |
| 563 | 563 | target: CrossTarget, |
| 564 | 564 | optimize: std.builtin.Mode, |
| 565 | 565 | version: ?std.SemanticVersion = null, |
| ... | ... | @@ -589,7 +589,7 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *Step.Compile |
| 589 | 589 | |
| 590 | 590 | pub const TestOptions = struct { |
| 591 | 591 | name: []const u8 = "test", |
| 592 | root_source_file: FileSource, | |
| 592 | root_source_file: LazyPath, | |
| 593 | 593 | target: CrossTarget = .{}, |
| 594 | 594 | optimize: std.builtin.Mode = .Debug, |
| 595 | 595 | version: ?std.SemanticVersion = null, |
| ... | ... | @@ -621,7 +621,7 @@ pub fn addTest(b: *Build, options: TestOptions) *Step.Compile { |
| 621 | 621 | |
| 622 | 622 | pub const AssemblyOptions = struct { |
| 623 | 623 | name: []const u8, |
| 624 | source_file: FileSource, | |
| 624 | source_file: LazyPath, | |
| 625 | 625 | target: CrossTarget, |
| 626 | 626 | optimize: std.builtin.Mode, |
| 627 | 627 | max_rss: usize = 0, |
| ... | ... | @@ -636,7 +636,7 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *Step.Compile { |
| 636 | 636 | .optimize = options.optimize, |
| 637 | 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 | 640 | return obj_step; |
| 641 | 641 | } |
| 642 | 642 | |
| ... | ... | @@ -655,7 +655,7 @@ pub const ModuleDependency = struct { |
| 655 | 655 | }; |
| 656 | 656 | |
| 657 | 657 | pub const CreateModuleOptions = struct { |
| 658 | source_file: FileSource, | |
| 658 | source_file: LazyPath, | |
| 659 | 659 | dependencies: []const ModuleDependency = &.{}, |
| 660 | 660 | }; |
| 661 | 661 | |
| ... | ... | @@ -1284,22 +1284,22 @@ pub fn installLibFile(self: *Build, src_path: []const u8, dest_rel_path: []const |
| 1284 | 1284 | self.getInstallStep().dependOn(&self.addInstallFileWithDir(.{ .path = src_path }, .lib, dest_rel_path).step); |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | pub fn addObjCopy(b: *Build, source: FileSource, options: Step.ObjCopy.Options) *Step.ObjCopy { | |
| 1287 | pub fn addObjCopy(b: *Build, source: LazyPath, options: Step.ObjCopy.Options) *Step.ObjCopy { | |
| 1288 | 1288 | return Step.ObjCopy.create(b, source, options); |
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | ///`dest_rel_path` is relative to install prefix path |
| 1292 | pub fn addInstallFile(self: *Build, source: FileSource, dest_rel_path: []const u8) *Step.InstallFile { | |
| 1292 | pub fn addInstallFile(self: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile { | |
| 1293 | 1293 | return self.addInstallFileWithDir(source.dupe(self), .prefix, dest_rel_path); |
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | ///`dest_rel_path` is relative to bin path |
| 1297 | pub fn addInstallBinFile(self: *Build, source: FileSource, dest_rel_path: []const u8) *Step.InstallFile { | |
| 1297 | pub fn addInstallBinFile(self: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile { | |
| 1298 | 1298 | return self.addInstallFileWithDir(source.dupe(self), .bin, dest_rel_path); |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | ///`dest_rel_path` is relative to lib path |
| 1302 | pub fn addInstallLibFile(self: *Build, source: FileSource, dest_rel_path: []const u8) *Step.InstallFile { | |
| 1302 | pub fn addInstallLibFile(self: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile { | |
| 1303 | 1303 | return self.addInstallFileWithDir(source.dupe(self), .lib, dest_rel_path); |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| ... | ... | @@ -1309,7 +1309,7 @@ pub fn addInstallHeaderFile(b: *Build, src_path: []const u8, dest_rel_path: []co |
| 1309 | 1309 | |
| 1310 | 1310 | pub fn addInstallFileWithDir( |
| 1311 | 1311 | self: *Build, |
| 1312 | source: FileSource, | |
| 1312 | source: LazyPath, | |
| 1313 | 1313 | install_dir: InstallDir, |
| 1314 | 1314 | dest_rel_path: []const u8, |
| 1315 | 1315 | ) *Step.InstallFile { |
| ... | ... | @@ -1322,7 +1322,7 @@ pub fn addInstallDirectory(self: *Build, options: InstallDirectoryOptions) *Step |
| 1322 | 1322 | |
| 1323 | 1323 | pub fn addCheckFile( |
| 1324 | 1324 | b: *Build, |
| 1325 | file_source: FileSource, | |
| 1325 | file_source: LazyPath, | |
| 1326 | 1326 | options: Step.CheckFile.Options, |
| 1327 | 1327 | ) *Step.CheckFile { |
| 1328 | 1328 | return Step.CheckFile.create(b, file_source, options); |
| ... | ... | @@ -1608,7 +1608,7 @@ pub const Module = struct { |
| 1608 | 1608 | /// This could either be a generated file, in which case the module |
| 1609 | 1609 | /// contains exactly one file, or it could be a path to the root source |
| 1610 | 1610 | /// file of directory of files which constitute the module. |
| 1611 | source_file: FileSource, | |
| 1611 | source_file: LazyPath, | |
| 1612 | 1612 | dependencies: std.StringArrayHashMap(*Module), |
| 1613 | 1613 | }; |
| 1614 | 1614 | |
| ... | ... | @@ -1630,8 +1630,10 @@ pub const GeneratedFile = struct { |
| 1630 | 1630 | } |
| 1631 | 1631 | }; |
| 1632 | 1632 | |
| 1633 | /// A file source is a reference to an existing or future file. | |
| 1634 | pub const FileSource = union(enum) { | |
| 1633 | pub const FileSource = LazyPath; // DEPRECATED, use LazyPath now | |
| 1634 | ||
| 1635 | /// A reference to an existing or future path. | |
| 1636 | pub const LazyPath = union(enum) { | |
| 1635 | 1637 | /// A plain file path, relative to build root or absolute. |
| 1636 | 1638 | path: []const u8, |
| 1637 | 1639 | |
| ... | ... | @@ -1641,14 +1643,14 @@ pub const FileSource = union(enum) { |
| 1641 | 1643 | |
| 1642 | 1644 | /// Returns a new file source that will have a relative path to the build root guaranteed. |
| 1643 | 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 | 1647 | std.debug.assert(!std.fs.path.isAbsolute(path)); |
| 1646 | return FileSource{ .path = path }; | |
| 1648 | return LazyPath{ .path = path }; | |
| 1647 | 1649 | } |
| 1648 | 1650 | |
| 1649 | 1651 | /// Returns a string that can be shown to represent the file source. |
| 1650 | 1652 | /// Either returns the path or `"generated"`. |
| 1651 | pub fn getDisplayName(self: FileSource) []const u8 { | |
| 1653 | pub fn getDisplayName(self: LazyPath) []const u8 { | |
| 1652 | 1654 | return switch (self) { |
| 1653 | 1655 | .path => self.path, |
| 1654 | 1656 | .generated => "generated", |
| ... | ... | @@ -1656,7 +1658,7 @@ pub const FileSource = union(enum) { |
| 1656 | 1658 | } |
| 1657 | 1659 | |
| 1658 | 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 | 1662 | switch (self) { |
| 1661 | 1663 | .path => {}, |
| 1662 | 1664 | .generated => |gen| other_step.dependOn(gen.step), |
| ... | ... | @@ -1664,14 +1666,14 @@ pub const FileSource = union(enum) { |
| 1664 | 1666 | } |
| 1665 | 1667 | |
| 1666 | 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 | 1670 | return getPath2(self, src_builder, null); |
| 1669 | 1671 | } |
| 1670 | 1672 | |
| 1671 | 1673 | /// Should only be called during make(), returns a path relative to the build root or absolute. |
| 1672 | 1674 | /// asking_step is only used for debugging purposes; it's the step being run that is asking for |
| 1673 | 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 | 1677 | switch (self) { |
| 1676 | 1678 | .path => |p| return src_builder.pathFromRoot(p), |
| 1677 | 1679 | .generated => |gen| return gen.path orelse { |
| ... | ... | @@ -1684,7 +1686,7 @@ pub const FileSource = union(enum) { |
| 1684 | 1686 | } |
| 1685 | 1687 | |
| 1686 | 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 | 1690 | return switch (self) { |
| 1689 | 1691 | .path => |p| .{ .path = b.dupePath(p) }, |
| 1690 | 1692 | .generated => |gen| .{ .generated = gen }, |
lib/std/Build/Step/CheckFile.zig+2-2| ... | ... | @@ -11,7 +11,7 @@ const mem = std.mem; |
| 11 | 11 | step: Step, |
| 12 | 12 | expected_matches: []const []const u8, |
| 13 | 13 | expected_exact: ?[]const u8, |
| 14 | source: std.Build.FileSource, | |
| 14 | source: std.Build.LazyPath, | |
| 15 | 15 | max_bytes: usize = 20 * 1024 * 1024, |
| 16 | 16 | |
| 17 | 17 | pub const base_id = .check_file; |
| ... | ... | @@ -23,7 +23,7 @@ pub const Options = struct { |
| 23 | 23 | |
| 24 | 24 | pub fn create( |
| 25 | 25 | owner: *std.Build, |
| 26 | source: std.Build.FileSource, | |
| 26 | source: std.Build.LazyPath, | |
| 27 | 27 | options: Options, |
| 28 | 28 | ) *CheckFile { |
| 29 | 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 | 15 | pub const base_id = .check_object; |
| 16 | 16 | |
| 17 | 17 | step: Step, |
| 18 | source: std.Build.FileSource, | |
| 18 | source: std.Build.LazyPath, | |
| 19 | 19 | max_bytes: usize = 20 * 1024 * 1024, |
| 20 | 20 | checks: std.ArrayList(Check), |
| 21 | 21 | obj_format: std.Target.ObjectFormat, |
| 22 | 22 | |
| 23 | 23 | pub fn create( |
| 24 | 24 | owner: *std.Build, |
| 25 | source: std.Build.FileSource, | |
| 25 | source: std.Build.LazyPath, | |
| 26 | 26 | obj_format: std.Target.ObjectFormat, |
| 27 | 27 | ) *CheckObject { |
| 28 | 28 | const gpa = owner.allocator; |
| ... | ... | @@ -44,7 +44,7 @@ pub fn create( |
| 44 | 44 | |
| 45 | 45 | const SearchPhrase = struct { |
| 46 | 46 | string: []const u8, |
| 47 | file_source: ?std.Build.FileSource = null, | |
| 47 | file_source: ?std.Build.LazyPath = null, | |
| 48 | 48 | |
| 49 | 49 | fn resolve(phrase: SearchPhrase, b: *std.Build, step: *Step) []const u8 { |
| 50 | 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 | 302 | self.checkExactInner(phrase, null); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | /// Like `checkExact()` but takes an additional argument `FileSource` which will be | |
| 305 | /// Like `checkExact()` but takes an additional argument `LazyPath` which will be | |
| 306 | 306 | /// resolved to a full search query in `make()`. |
| 307 | pub fn checkExactFileSource(self: *CheckObject, phrase: []const u8, file_source: std.Build.FileSource) void { | |
| 307 | pub fn checkExactPath(self: *CheckObject, phrase: []const u8, file_source: std.Build.LazyPath) void { | |
| 308 | 308 | self.checkExactInner(phrase, file_source); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | fn checkExactInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.FileSource) void { | |
| 311 | fn checkExactInner(self: *CheckObject, phrase: []const u8, file_source: ?std.Build.LazyPath) void { | |
| 312 | 312 | assert(self.checks.items.len > 0); |
| 313 | 313 | const last = &self.checks.items[self.checks.items.len - 1]; |
| 314 | 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 | 321 | |
| 322 | 322 | /// Like `checkContains()` but takes an additional argument `FileSource` which will be |
| 323 | 323 | /// resolved to a full search query in `make()`. |
| 324 | pub fn checkContainsFileSource(self: *CheckObject, phrase: []const u8, file_source: std.Build.FileSource) void { | |
| 324 | pub fn checkContainsPath(self: *CheckObject, phrase: []const u8, file_source: std.Build.LazyPath) void { | |
| 325 | 325 | self.checkContainsInner(phrase, file_source); |
| 326 | 326 | } |
| 327 | 327 |
lib/std/Build/Step/Compile.zig+76-95| ... | ... | @@ -11,7 +11,7 @@ const Allocator = mem.Allocator; |
| 11 | 11 | const Step = std.Build.Step; |
| 12 | 12 | const CrossTarget = std.zig.CrossTarget; |
| 13 | 13 | const NativeTargetInfo = std.zig.system.NativeTargetInfo; |
| 14 | const FileSource = std.Build.FileSource; | |
| 14 | const LazyPath = std.Build.LazyPath; | |
| 15 | 15 | const PkgConfigPkg = std.Build.PkgConfigPkg; |
| 16 | 16 | const PkgConfigError = std.Build.PkgConfigError; |
| 17 | 17 | const ExecError = std.Build.ExecError; |
| ... | ... | @@ -28,7 +28,7 @@ name: []const u8, |
| 28 | 28 | target: CrossTarget, |
| 29 | 29 | target_info: NativeTargetInfo, |
| 30 | 30 | optimize: std.builtin.Mode, |
| 31 | linker_script: ?FileSource = null, | |
| 31 | linker_script: ?LazyPath = null, | |
| 32 | 32 | version_script: ?[]const u8 = null, |
| 33 | 33 | out_filename: []const u8, |
| 34 | 34 | linkage: ?Linkage = null, |
| ... | ... | @@ -40,9 +40,9 @@ strip: ?bool, |
| 40 | 40 | unwind_tables: ?bool, |
| 41 | 41 | // keep in sync with src/link.zig:CompressDebugSections |
| 42 | 42 | compress_debug_sections: enum { none, zlib } = .none, |
| 43 | lib_paths: ArrayList(FileSource), | |
| 44 | rpaths: ArrayList(FileSource), | |
| 45 | framework_dirs: ArrayList(FileSource), | |
| 43 | lib_paths: ArrayList(LazyPath), | |
| 44 | rpaths: ArrayList(LazyPath), | |
| 45 | framework_dirs: ArrayList(LazyPath), | |
| 46 | 46 | frameworks: StringHashMap(FrameworkLinkInfo), |
| 47 | 47 | verbose_link: bool, |
| 48 | 48 | verbose_cc: bool, |
| ... | ... | @@ -74,8 +74,8 @@ max_memory: ?u64 = null, |
| 74 | 74 | shared_memory: bool = false, |
| 75 | 75 | global_base: ?u64 = null, |
| 76 | 76 | c_std: std.Build.CStd, |
| 77 | zig_lib_dir: ?[]const u8, | |
| 78 | main_pkg_path: ?[]const u8, | |
| 77 | zig_lib_dir: ?LazyPath, | |
| 78 | main_pkg_path: ?LazyPath, | |
| 79 | 79 | exec_cmd_args: ?[]const ?[]const u8, |
| 80 | 80 | filter: ?[]const u8, |
| 81 | 81 | test_evented_io: bool = false, |
| ... | ... | @@ -85,7 +85,7 @@ wasi_exec_model: ?std.builtin.WasiExecModel = null, |
| 85 | 85 | /// Symbols to be exported when compiling to wasm |
| 86 | 86 | export_symbol_names: []const []const u8 = &.{}, |
| 87 | 87 | |
| 88 | root_src: ?FileSource, | |
| 88 | root_src: ?LazyPath, | |
| 89 | 89 | out_h_filename: []const u8, |
| 90 | 90 | out_lib_filename: []const u8, |
| 91 | 91 | out_pdb_filename: []const u8, |
| ... | ... | @@ -106,7 +106,7 @@ installed_path: ?[]const u8, |
| 106 | 106 | /// Base address for an executable image. |
| 107 | 107 | image_base: ?u64 = null, |
| 108 | 108 | |
| 109 | libc_file: ?FileSource = null, | |
| 109 | libc_file: ?LazyPath = null, | |
| 110 | 110 | |
| 111 | 111 | valgrind_support: ?bool = null, |
| 112 | 112 | each_lib_rpath: ?bool = null, |
| ... | ... | @@ -223,22 +223,22 @@ pub const CSourceFiles = struct { |
| 223 | 223 | }; |
| 224 | 224 | |
| 225 | 225 | pub const CSourceFile = struct { |
| 226 | source: FileSource, | |
| 227 | args: []const []const u8, | |
| 226 | file: LazyPath, | |
| 227 | flags: []const []const u8, | |
| 228 | 228 | |
| 229 | 229 | pub fn dupe(self: CSourceFile, b: *std.Build) CSourceFile { |
| 230 | 230 | 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), | |
| 233 | 233 | }; |
| 234 | 234 | } |
| 235 | 235 | }; |
| 236 | 236 | |
| 237 | 237 | pub const LinkObject = union(enum) { |
| 238 | static_path: FileSource, | |
| 238 | static_path: LazyPath, | |
| 239 | 239 | other_step: *Compile, |
| 240 | 240 | system_lib: SystemLib, |
| 241 | assembly_file: FileSource, | |
| 241 | assembly_file: LazyPath, | |
| 242 | 242 | c_source_file: *CSourceFile, |
| 243 | 243 | c_source_files: *CSourceFiles, |
| 244 | 244 | }; |
| ... | ... | @@ -265,15 +265,15 @@ const FrameworkLinkInfo = struct { |
| 265 | 265 | }; |
| 266 | 266 | |
| 267 | 267 | pub const IncludeDir = union(enum) { |
| 268 | raw_path: []const u8, | |
| 269 | raw_path_system: []const u8, | |
| 268 | path: LazyPath, | |
| 269 | path_system: LazyPath, | |
| 270 | 270 | other_step: *Compile, |
| 271 | 271 | config_header_step: *Step.ConfigHeader, |
| 272 | 272 | }; |
| 273 | 273 | |
| 274 | 274 | pub const Options = struct { |
| 275 | 275 | name: []const u8, |
| 276 | root_source_file: ?FileSource = null, | |
| 276 | root_source_file: ?LazyPath = null, | |
| 277 | 277 | target: CrossTarget, |
| 278 | 278 | optimize: std.builtin.Mode, |
| 279 | 279 | kind: Kind, |
| ... | ... | @@ -391,7 +391,7 @@ pub const EmitOption = union(enum) { |
| 391 | 391 | |
| 392 | 392 | pub fn create(owner: *std.Build, options: Options) *Compile { |
| 393 | 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 | 395 | if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) { |
| 396 | 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 | 462 | .include_dirs = ArrayList(IncludeDir).init(owner.allocator), |
| 463 | 463 | .link_objects = ArrayList(LinkObject).init(owner.allocator), |
| 464 | 464 | .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), | |
| 468 | 468 | .installed_headers = ArrayList(*Step).init(owner.allocator), |
| 469 | 469 | .c_std = std.Build.CStd.C99, |
| 470 | 470 | .zig_lib_dir = null, |
| ... | ... | @@ -614,7 +614,7 @@ pub fn addObjCopy(cs: *Compile, options: Step.ObjCopy.Options) *Step.ObjCopy { |
| 614 | 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 | } |
| 619 | 619 | |
| 620 | 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 | 626 | pub const install = @compileError("deprecated; use std.Build.installArtifact"); |
| 627 | 627 | |
| 628 | 628 | pub 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 | } |
| 631 | 631 | |
| 632 | pub fn setLinkerScriptPath(self: *Compile, source: FileSource) void { | |
| 632 | pub const setLinkerScriptPath = setLinkerScript; // DEPRECATED, use setLinkerScript | |
| 633 | ||
| 634 | pub fn setLinkerScript(self: *Compile, source: LazyPath) void { | |
| 633 | 635 | const b = self.step.owner; |
| 634 | 636 | self.linker_script = source.dupe(b); |
| 635 | 637 | source.addStepDependencies(&self.step); |
| ... | ... | @@ -935,19 +937,12 @@ pub fn addCSourceFiles(self: *Compile, files: []const []const u8, flags: []const |
| 935 | 937 | self.link_objects.append(.{ .c_source_files = c_source_files }) catch @panic("OOM"); |
| 936 | 938 | } |
| 937 | 939 | |
| 938 | pub 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 | ||
| 945 | pub fn addCSourceFileSource(self: *Compile, source: CSourceFile) void { | |
| 940 | pub fn addCSourceFile(self: *Compile, source: CSourceFile) void { | |
| 946 | 941 | const b = self.step.owner; |
| 947 | 942 | const c_source_file = b.allocator.create(CSourceFile) catch @panic("OOM"); |
| 948 | 943 | c_source_file.* = source.dupe(b); |
| 949 | 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 | } |
| 952 | 947 | |
| 953 | 948 | pub fn setVerboseLink(self: *Compile, value: bool) void { |
| ... | ... | @@ -958,53 +953,63 @@ pub fn setVerboseCC(self: *Compile, value: bool) void { |
| 958 | 953 | self.verbose_cc = value; |
| 959 | 954 | } |
| 960 | 955 | |
| 961 | pub fn overrideZigLibDir(self: *Compile, dir_path: []const u8) void { | |
| 962 | const b = self.step.owner; | |
| 963 | self.zig_lib_dir = b.dupePath(dir_path); | |
| 956 | pub 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); | |
| 964 | 959 | } |
| 965 | 960 | |
| 966 | pub fn setMainPkgPath(self: *Compile, dir_path: []const u8) void { | |
| 967 | const b = self.step.owner; | |
| 968 | self.main_pkg_path = b.dupePath(dir_path); | |
| 961 | pub 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); | |
| 969 | 964 | } |
| 970 | 965 | |
| 971 | pub fn setLibCFile(self: *Compile, libc_file: ?FileSource) void { | |
| 966 | pub fn setLibCFile(self: *Compile, libc_file: ?LazyPath) void { | |
| 972 | 967 | const b = self.step.owner; |
| 973 | 968 | self.libc_file = if (libc_file) |f| f.dupe(b) else null; |
| 974 | 969 | } |
| 975 | 970 | |
| 971 | pub const getOutputSource = getEmittedBin; // DEPRECATED, use getEmittedBin | |
| 972 | ||
| 976 | 973 | /// Returns the generated executable, library or object file. |
| 977 | 974 | /// To run an executable built with zig build, use `run`, or create an install step and invoke it. |
| 978 | pub fn getOutputSource(self: *Compile) FileSource { | |
| 975 | pub fn getEmittedBin(self: *Compile) LazyPath { | |
| 979 | 976 | return .{ .generated = &self.output_path_source }; |
| 980 | 977 | } |
| 981 | 978 | |
| 982 | pub fn getOutputDirectorySource(self: *Compile) FileSource { | |
| 979 | pub const getOutputDirectorySource = getEmitDirectory; // DEPRECATED, use getEmitDirectory | |
| 980 | ||
| 981 | pub fn getEmitDirectory(self: *Compile) LazyPath { | |
| 983 | 982 | return .{ .generated = &self.output_dirname_source }; |
| 984 | 983 | } |
| 985 | 984 | |
| 985 | pub const getOutputLibSource = getEmittedImplib; // DEPRECATED, use getEmittedImplib | |
| 986 | ||
| 986 | 987 | /// Returns the generated import library. This function can only be called for libraries. |
| 987 | pub fn getOutputLibSource(self: *Compile) FileSource { | |
| 988 | pub fn getEmittedImplib(self: *Compile) LazyPath { | |
| 988 | 989 | assert(self.kind == .lib); |
| 989 | 990 | return .{ .generated = &self.output_lib_path_source }; |
| 990 | 991 | } |
| 991 | 992 | |
| 993 | pub const getOutputHSource = getEmittedH; // DEPRECATED, use getEmittedH | |
| 994 | ||
| 992 | 995 | /// Returns the generated header file. |
| 993 | 996 | /// This function can only be called for libraries or object files which have `emit_h` set. |
| 994 | pub fn getOutputHSource(self: *Compile) FileSource { | |
| 997 | pub fn getEmittedH(self: *Compile) LazyPath { | |
| 995 | 998 | assert(self.kind != .exe and self.kind != .@"test"); |
| 996 | 999 | assert(self.emit_h); |
| 997 | 1000 | return .{ .generated = &self.output_h_path_source }; |
| 998 | 1001 | } |
| 999 | 1002 | |
| 1003 | pub const getOutputPdbSource = getEmittedPdb; // DEPRECATED, use getEmittedPdb | |
| 1004 | ||
| 1000 | 1005 | /// Returns the generated PDB file. This function can only be called for Windows and UEFI. |
| 1001 | pub fn getOutputPdbSource(self: *Compile) FileSource { | |
| 1006 | pub fn getEmittedPdb(self: *Compile) LazyPath { | |
| 1002 | 1007 | // TODO: Is this right? Isn't PDB for *any* PE/COFF file? |
| 1003 | 1008 | assert(self.target.isWindows() or self.target.isUefi()); |
| 1004 | 1009 | return .{ .generated = &self.output_pdb_path_source }; |
| 1005 | 1010 | } |
| 1006 | 1011 | |
| 1007 | pub fn getEmittedDocs(self: *Compile) FileSource { | |
| 1012 | pub fn getEmittedDocs(self: *Compile) LazyPath { | |
| 1008 | 1013 | if (self.generated_docs) |g| return .{ .generated = g }; |
| 1009 | 1014 | const arena = self.step.owner.allocator; |
| 1010 | 1015 | const generated_file = arena.create(GeneratedFile) catch @panic("OOM"); |
| ... | ... | @@ -1013,25 +1018,14 @@ pub fn getEmittedDocs(self: *Compile) FileSource { |
| 1013 | 1018 | return .{ .generated = generated_file }; |
| 1014 | 1019 | } |
| 1015 | 1020 | |
| 1016 | pub 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 | ||
| 1023 | pub fn addAssemblyFileSource(self: *Compile, source: FileSource) void { | |
| 1021 | pub fn addAssemblyFile(self: *Compile, source: LazyPath) void { | |
| 1024 | 1022 | const b = self.step.owner; |
| 1025 | 1023 | const source_duped = source.dupe(b); |
| 1026 | 1024 | self.link_objects.append(.{ .assembly_file = source_duped }) catch @panic("OOM"); |
| 1027 | 1025 | source_duped.addStepDependencies(&self.step); |
| 1028 | 1026 | } |
| 1029 | 1027 | |
| 1030 | pub fn addObjectFile(self: *Compile, source_file: []const u8) void { | |
| 1031 | self.addObjectFileSource(.{ .path = source_file }); | |
| 1032 | } | |
| 1033 | ||
| 1034 | pub fn addObjectFileSource(self: *Compile, source: FileSource) void { | |
| 1028 | pub fn addObjectFile(self: *Compile, source: LazyPath) void { | |
| 1035 | 1029 | const b = self.step.owner; |
| 1036 | 1030 | self.link_objects.append(.{ .static_path = source.dupe(b) }) catch @panic("OOM"); |
| 1037 | 1031 | source.addStepDependencies(&self.step); |
| ... | ... | @@ -1042,14 +1036,16 @@ pub fn addObject(self: *Compile, obj: *Compile) void { |
| 1042 | 1036 | self.linkLibraryOrObject(obj); |
| 1043 | 1037 | } |
| 1044 | 1038 | |
| 1045 | pub fn addSystemIncludePath(self: *Compile, path: []const u8) void { | |
| 1039 | pub fn addSystemIncludePath(self: *Compile, path: LazyPath) void { | |
| 1046 | 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 | } |
| 1049 | 1044 | |
| 1050 | pub fn addIncludePath(self: *Compile, path: []const u8) void { | |
| 1045 | pub fn addIncludePath(self: *Compile, path: LazyPath) void { | |
| 1051 | 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 | } |
| 1054 | 1050 | |
| 1055 | 1051 | 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 | 1053 | self.include_dirs.append(.{ .config_header_step = config_header }) catch @panic("OOM"); |
| 1058 | 1054 | } |
| 1059 | 1055 | |
| 1060 | pub 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 | ||
| 1065 | pub fn addLibraryPathDirectorySource(self: *Compile, directory_source: FileSource) void { | |
| 1056 | pub fn addLibraryPath(self: *Compile, directory_source: LazyPath) void { | |
| 1066 | 1057 | self.lib_paths.append(directory_source) catch @panic("OOM"); |
| 1067 | 1058 | directory_source.addStepDependencies(&self.step); |
| 1068 | 1059 | } |
| 1069 | 1060 | |
| 1070 | pub 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 | ||
| 1075 | pub fn addRPathDirectorySource(self: *Compile, directory_source: FileSource) void { | |
| 1061 | pub fn addRPath(self: *Compile, directory_source: LazyPath) void { | |
| 1076 | 1062 | self.rpaths.append(directory_source) catch @panic("OOM"); |
| 1077 | 1063 | directory_source.addStepDependencies(&self.step); |
| 1078 | 1064 | } |
| 1079 | 1065 | |
| 1080 | pub 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 | ||
| 1085 | pub fn addFrameworkPathDirectorySource(self: *Compile, directory_source: FileSource) void { | |
| 1066 | pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void { | |
| 1086 | 1067 | self.framework_dirs.append(directory_source) catch @panic("OOM"); |
| 1087 | 1068 | directory_source.addStepDependencies(&self.step); |
| 1088 | 1069 | } |
| ... | ... | @@ -1364,7 +1345,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1364 | 1345 | .exe => @panic("Cannot link with an executable build artifact"), |
| 1365 | 1346 | .@"test" => @panic("Cannot link with a test"), |
| 1366 | 1347 | .obj => { |
| 1367 | try zig_args.append(other.getOutputSource().getPath(b)); | |
| 1348 | try zig_args.append(other.getEmittedBin().getPath(b)); | |
| 1368 | 1349 | }, |
| 1369 | 1350 | .lib => l: { |
| 1370 | 1351 | if (self.isStaticLibrary() and other.isStaticLibrary()) { |
| ... | ... | @@ -1372,7 +1353,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1372 | 1353 | break :l; |
| 1373 | 1354 | } |
| 1374 | 1355 | |
| 1375 | const full_path_lib = other.getOutputLibSource().getPath(b); | |
| 1356 | const full_path_lib = other.getEmittedImplib().getPath(b); | |
| 1376 | 1357 | try zig_args.append(full_path_lib); |
| 1377 | 1358 | |
| 1378 | 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 | 1413 | }, |
| 1433 | 1414 | |
| 1434 | 1415 | .c_source_file => |c_source_file| { |
| 1435 | if (c_source_file.args.len == 0) { | |
| 1416 | if (c_source_file.flags.len == 0) { | |
| 1436 | 1417 | if (prev_has_cflags) { |
| 1437 | 1418 | try zig_args.append("-cflags"); |
| 1438 | 1419 | try zig_args.append("--"); |
| ... | ... | @@ -1440,13 +1421,13 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1440 | 1421 | } |
| 1441 | 1422 | } else { |
| 1442 | 1423 | try zig_args.append("-cflags"); |
| 1443 | for (c_source_file.args) |arg| { | |
| 1424 | for (c_source_file.flags) |arg| { | |
| 1444 | 1425 | try zig_args.append(arg); |
| 1445 | 1426 | } |
| 1446 | 1427 | try zig_args.append("--"); |
| 1447 | 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 | }, |
| 1451 | 1432 | |
| 1452 | 1433 | .c_source_files => |c_source_files| { |
| ... | ... | @@ -1746,18 +1727,18 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1746 | 1727 | |
| 1747 | 1728 | for (self.include_dirs.items) |include_dir| { |
| 1748 | 1729 | switch (include_dir) { |
| 1749 | .raw_path => |include_path| { | |
| 1730 | .path => |include_path| { | |
| 1750 | 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 | 1735 | if (b.sysroot != null) { |
| 1755 | 1736 | try zig_args.append("-iwithsysroot"); |
| 1756 | 1737 | } else { |
| 1757 | 1738 | try zig_args.append("-isystem"); |
| 1758 | 1739 | } |
| 1759 | 1740 | |
| 1760 | const resolved_include_path = b.pathFromRoot(include_path); | |
| 1741 | const resolved_include_path = include_path.getPath(b); | |
| 1761 | 1742 | |
| 1762 | 1743 | const common_include_path = if (builtin.os.tag == .windows and b.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: { |
| 1763 | 1744 | // 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 | 1756 | }, |
| 1776 | 1757 | .other_step => |other| { |
| 1777 | 1758 | if (other.emit_h) { |
| 1778 | const h_path = other.getOutputHSource().getPath(b); | |
| 1759 | const h_path = other.getEmittedH().getPath(b); | |
| 1779 | 1760 | try zig_args.append("-isystem"); |
| 1780 | 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 | 1888 | |
| 1908 | 1889 | if (self.zig_lib_dir) |dir| { |
| 1909 | 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 | 1892 | } else if (b.zig_lib_dir) |dir| { |
| 1912 | 1893 | try zig_args.append("--zig-lib-dir"); |
| 1913 | 1894 | try zig_args.append(dir); |
| ... | ... | @@ -1915,7 +1896,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1915 | 1896 | |
| 1916 | 1897 | if (self.main_pkg_path) |dir| { |
| 1917 | 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 | } |
| 1920 | 1901 | |
| 1921 | 1902 | try addFlag(&zig_args, "PIC", self.force_pic); |
| ... | ... | @@ -2042,7 +2023,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 2042 | 2023 | { |
| 2043 | 2024 | try doAtomicSymLinks( |
| 2044 | 2025 | step, |
| 2045 | self.getOutputSource().getPath(b), | |
| 2026 | self.getEmittedBin().getPath(b), | |
| 2046 | 2027 | self.major_only_filename.?, |
| 2047 | 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 | 6 | pub const Style = union(enum) { |
| 7 | 7 | /// The configure format supported by autotools. It uses `#undef foo` to |
| 8 | 8 | /// mark lines that can be substituted with different values. |
| 9 | autoconf: std.Build.FileSource, | |
| 9 | autoconf: std.Build.LazyPath, | |
| 10 | 10 | /// The configure format supported by CMake. It uses `@@FOO@@` and |
| 11 | 11 | /// `#cmakedefine` for template substitution. |
| 12 | cmake: std.Build.FileSource, | |
| 12 | cmake: std.Build.LazyPath, | |
| 13 | 13 | /// Instead of starting with an input file, start with nothing. |
| 14 | 14 | blank, |
| 15 | 15 | /// Start with nothing, like blank, and output a nasm .asm file. |
| 16 | 16 | nasm, |
| 17 | 17 | |
| 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 | 21 | switch (style) { |
| 20 | 22 | .autoconf, .cmake => |s| return s, |
| 21 | 23 | .blank, .nasm => return null, |
| ... | ... | @@ -54,7 +56,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader { |
| 54 | 56 | |
| 55 | 57 | var include_path: []const u8 = "config.h"; |
| 56 | 58 | |
| 57 | if (options.style.getFileSource()) |s| switch (s) { | |
| 59 | if (options.style.getPath()) |s| switch (s) { | |
| 58 | 60 | .path => |p| { |
| 59 | 61 | const basename = std.fs.path.basename(p); |
| 60 | 62 | if (std.mem.endsWith(u8, basename, ".h.in")) { |
| ... | ... | @@ -68,7 +70,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader { |
| 68 | 70 | include_path = p; |
| 69 | 71 | } |
| 70 | 72 | |
| 71 | const name = if (options.style.getFileSource()) |s| | |
| 73 | const name = if (options.style.getPath()) |s| | |
| 72 | 74 | owner.fmt("configure {s} header {s} to {s}", .{ |
| 73 | 75 | @tagName(options.style), s.getDisplayName(), include_path, |
| 74 | 76 | }) |
| ... | ... | @@ -98,7 +100,9 @@ pub fn addValues(self: *ConfigHeader, values: anytype) void { |
| 98 | 100 | return addValuesInner(self, values) catch @panic("OOM"); |
| 99 | 101 | } |
| 100 | 102 | |
| 101 | pub fn getFileSource(self: *ConfigHeader) std.Build.FileSource { | |
| 103 | pub const getFileSource = getTemplate; // DEPRECATED, use getOutput | |
| 104 | ||
| 105 | pub fn getTemplate(self: *ConfigHeader) std.Build.LazyPath { | |
| 102 | 106 | return .{ .generated = &self.output_file }; |
| 103 | 107 | } |
| 104 | 108 |
lib/std/Build/Step/InstallArtifact.zig+4-4| ... | ... | @@ -76,7 +76,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 76 | 76 | var all_cached = true; |
| 77 | 77 | |
| 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 | 80 | const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| { |
| 81 | 81 | return step.fail("unable to update file from '{s}' to '{s}': {s}", .{ |
| 82 | 82 | full_src_path, full_dest_path, @errorName(err), |
| ... | ... | @@ -95,7 +95,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 95 | 95 | self.artifact.target.isWindows() and |
| 96 | 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 | 99 | const full_implib_path = dest_builder.getInstallPath(self.dest_dir, self.artifact.out_lib_filename); |
| 100 | 100 | const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_implib_path, .{}) catch |err| { |
| 101 | 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 | 105 | all_cached = all_cached and p == .fresh; |
| 106 | 106 | } |
| 107 | 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 | 109 | const full_pdb_path = dest_builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename); |
| 110 | 110 | const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_pdb_path, .{}) catch |err| { |
| 111 | 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 | 115 | all_cached = all_cached and p == .fresh; |
| 116 | 116 | } |
| 117 | 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 | 119 | const full_h_path = dest_builder.getInstallPath(h_dir, self.artifact.out_h_filename); |
| 120 | 120 | const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_h_path, .{}) catch |err| { |
| 121 | 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 | 2 | const mem = std.mem; |
| 3 | 3 | const fs = std.fs; |
| 4 | 4 | const Step = std.Build.Step; |
| 5 | const FileSource = std.Build.FileSource; | |
| 5 | const LazyPath = std.Build.LazyPath; | |
| 6 | 6 | const InstallDir = std.Build.InstallDir; |
| 7 | 7 | const InstallDirStep = @This(); |
| 8 | 8 | |
| ... | ... | @@ -15,7 +15,7 @@ dest_builder: *std.Build, |
| 15 | 15 | pub const base_id = .install_dir; |
| 16 | 16 | |
| 17 | 17 | pub const Options = struct { |
| 18 | source_dir: FileSource, | |
| 18 | source_dir: LazyPath, | |
| 19 | 19 | install_dir: InstallDir, |
| 20 | 20 | install_subdir: []const u8, |
| 21 | 21 | /// 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 | 1 | const std = @import("std"); |
| 2 | 2 | const Step = std.Build.Step; |
| 3 | const FileSource = std.Build.FileSource; | |
| 3 | const LazyPath = std.Build.LazyPath; | |
| 4 | 4 | const InstallDir = std.Build.InstallDir; |
| 5 | 5 | const InstallFile = @This(); |
| 6 | 6 | const assert = std.debug.assert; |
| ... | ... | @@ -8,7 +8,7 @@ const assert = std.debug.assert; |
| 8 | 8 | pub const base_id = .install_file; |
| 9 | 9 | |
| 10 | 10 | step: Step, |
| 11 | source: FileSource, | |
| 11 | source: LazyPath, | |
| 12 | 12 | dir: InstallDir, |
| 13 | 13 | dest_rel_path: []const u8, |
| 14 | 14 | /// This is used by the build system when a file being installed comes from one |
| ... | ... | @@ -17,7 +17,7 @@ dest_builder: *std.Build, |
| 17 | 17 | |
| 18 | 18 | pub fn create( |
| 19 | 19 | owner: *std.Build, |
| 20 | source: FileSource, | |
| 20 | source: LazyPath, | |
| 21 | 21 | dir: InstallDir, |
| 22 | 22 | dest_rel_path: []const u8, |
| 23 | 23 | ) *InstallFile { |
lib/std/Build/Step/ObjCopy.zig+10-8| ... | ... | @@ -20,7 +20,7 @@ pub const RawFormat = enum { |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | 22 | step: Step, |
| 23 | file_source: std.Build.FileSource, | |
| 23 | input_file: std.Build.LazyPath, | |
| 24 | 24 | basename: []const u8, |
| 25 | 25 | output_file: std.Build.GeneratedFile, |
| 26 | 26 | |
| ... | ... | @@ -37,30 +37,32 @@ pub const Options = struct { |
| 37 | 37 | |
| 38 | 38 | pub fn create( |
| 39 | 39 | owner: *std.Build, |
| 40 | file_source: std.Build.FileSource, | |
| 40 | input_file: std.Build.LazyPath, | |
| 41 | 41 | options: Options, |
| 42 | 42 | ) *ObjCopy { |
| 43 | 43 | const self = owner.allocator.create(ObjCopy) catch @panic("OOM"); |
| 44 | 44 | self.* = ObjCopy{ |
| 45 | 45 | .step = Step.init(.{ |
| 46 | 46 | .id = base_id, |
| 47 | .name = owner.fmt("objcopy {s}", .{file_source.getDisplayName()}), | |
| 47 | .name = owner.fmt("objcopy {s}", .{input_file.getDisplayName()}), | |
| 48 | 48 | .owner = owner, |
| 49 | 49 | .makeFn = make, |
| 50 | 50 | }), |
| 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(), | |
| 53 | 53 | .output_file = std.Build.GeneratedFile{ .step = &self.step }, |
| 54 | 54 | |
| 55 | 55 | .format = options.format, |
| 56 | 56 | .only_section = options.only_section, |
| 57 | 57 | .pad_to = options.pad_to, |
| 58 | 58 | }; |
| 59 | file_source.addStepDependencies(&self.step); | |
| 59 | input_file.addStepDependencies(&self.step); | |
| 60 | 60 | return self; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | pub fn getOutputSource(self: *const ObjCopy) std.Build.FileSource { | |
| 63 | pub const getOutputSource = getOutput; // DEPRECATED, use getOutput | |
| 64 | ||
| 65 | pub fn getOutput(self: *const ObjCopy) std.Build.LazyPath { | |
| 64 | 66 | return .{ .generated = &self.output_file }; |
| 65 | 67 | } |
| 66 | 68 | |
| ... | ... | @@ -75,7 +77,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 75 | 77 | // bytes when ObjCopy implementation is modified incompatibly. |
| 76 | 78 | man.hash.add(@as(u32, 0xe18b7baf)); |
| 77 | 79 | |
| 78 | const full_src_path = self.file_source.getPath(b); | |
| 80 | const full_src_path = self.input_file.getPath(b); | |
| 79 | 81 | _ = try man.addFile(full_src_path, null); |
| 80 | 82 | man.hash.addOptionalBytes(self.only_section); |
| 81 | 83 | man.hash.addOptional(self.pad_to); |
lib/std/Build/Step/Options.zig+23-31| ... | ... | @@ -3,7 +3,7 @@ const builtin = @import("builtin"); |
| 3 | 3 | const fs = std.fs; |
| 4 | 4 | const Step = std.Build.Step; |
| 5 | 5 | const GeneratedFile = std.Build.GeneratedFile; |
| 6 | const FileSource = std.Build.FileSource; | |
| 6 | const LazyPath = std.Build.LazyPath; | |
| 7 | 7 | |
| 8 | 8 | const Options = @This(); |
| 9 | 9 | |
| ... | ... | @@ -13,8 +13,7 @@ step: Step, |
| 13 | 13 | generated_file: GeneratedFile, |
| 14 | 14 | |
| 15 | 15 | contents: std.ArrayList(u8), |
| 16 | artifact_args: std.ArrayList(OptionArtifactArg), | |
| 17 | file_source_args: std.ArrayList(OptionFileSourceArg), | |
| 16 | args: std.ArrayList(OptionLazyPathArg), | |
| 18 | 17 | |
| 19 | 18 | pub fn create(owner: *std.Build) *Options { |
| 20 | 19 | const self = owner.allocator.create(Options) catch @panic("OOM"); |
| ... | ... | @@ -27,8 +26,7 @@ pub fn create(owner: *std.Build) *Options { |
| 27 | 26 | }), |
| 28 | 27 | .generated_file = undefined, |
| 29 | 28 | .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), | |
| 32 | 30 | }; |
| 33 | 31 | self.generated_file = .{ .step = &self.step }; |
| 34 | 32 | |
| ... | ... | @@ -168,35 +166,42 @@ fn printLiteral(out: anytype, val: anytype, indent: u8) !void { |
| 168 | 166 | } |
| 169 | 167 | } |
| 170 | 168 | |
| 169 | pub const addOptionFileSource = addOptionPath; // DEPRECATED, use addPathOption | |
| 170 | ||
| 171 | 171 | /// The value is the path in the cache dir. |
| 172 | 172 | /// Adds a dependency automatically. |
| 173 | pub fn addOptionFileSource( | |
| 173 | pub fn addOptionPath( | |
| 174 | 174 | self: *Options, |
| 175 | 175 | name: []const u8, |
| 176 | source: FileSource, | |
| 176 | path: LazyPath, | |
| 177 | 177 | ) 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), | |
| 181 | 181 | }) catch @panic("OOM"); |
| 182 | source.addStepDependencies(&self.step); | |
| 182 | path.addStepDependencies(&self.step); | |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /// The value is the path in the cache dir. |
| 186 | 186 | /// Adds a dependency automatically. |
| 187 | 187 | pub 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 | 192 | self.step.dependOn(&artifact.step); |
| 190 | 193 | } |
| 191 | 194 | |
| 192 | 195 | pub fn createModule(self: *Options) *std.Build.Module { |
| 193 | 196 | return self.step.owner.createModule(.{ |
| 194 | .source_file = self.getSource(), | |
| 197 | .source_file = self.getOutput(), | |
| 195 | 198 | .dependencies = &.{}, |
| 196 | 199 | }); |
| 197 | 200 | } |
| 198 | 201 | |
| 199 | pub fn getSource(self: *Options) FileSource { | |
| 202 | pub const getSource = getOutput; // DEPRECATED, use getOutput | |
| 203 | ||
| 204 | pub fn getOutput(self: *Options) LazyPath { | |
| 200 | 205 | return .{ .generated = &self.generated_file }; |
| 201 | 206 | } |
| 202 | 207 | |
| ... | ... | @@ -207,19 +212,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 207 | 212 | const b = step.owner; |
| 208 | 213 | const self = @fieldParentPtr(Options, "step", step); |
| 209 | 214 | |
| 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| { | |
| 219 | 216 | self.addOption( |
| 220 | 217 | []const u8, |
| 221 | 218 | item.name, |
| 222 | item.source.getPath(b), | |
| 219 | item.path.getPath(b), | |
| 223 | 220 | ); |
| 224 | 221 | } |
| 225 | 222 | |
| ... | ... | @@ -294,14 +291,9 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 294 | 291 | } |
| 295 | 292 | } |
| 296 | 293 | |
| 297 | const OptionArtifactArg = struct { | |
| 298 | name: []const u8, | |
| 299 | artifact: *Step.Compile, | |
| 300 | }; | |
| 301 | ||
| 302 | const OptionFileSourceArg = struct { | |
| 294 | const OptionLazyPathArg = struct { | |
| 303 | 295 | name: []const u8, |
| 304 | source: FileSource, | |
| 296 | path: LazyPath, | |
| 305 | 297 | }; |
| 306 | 298 | |
| 307 | 299 | test Options { |
lib/std/Build/Step/Run.zig+28-20| ... | ... | @@ -82,7 +82,7 @@ has_side_effects: bool = false, |
| 82 | 82 | pub const StdIn = union(enum) { |
| 83 | 83 | none, |
| 84 | 84 | bytes: []const u8, |
| 85 | file_source: std.Build.FileSource, | |
| 85 | file_source: std.Build.LazyPath, | |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | 88 | pub const StdIo = union(enum) { |
| ... | ... | @@ -120,15 +120,15 @@ pub const StdIo = union(enum) { |
| 120 | 120 | |
| 121 | 121 | pub const Arg = union(enum) { |
| 122 | 122 | artifact: *Step.Compile, |
| 123 | file_source: PrefixedFileSource, | |
| 124 | directory_source: PrefixedFileSource, | |
| 123 | file_source: PrefixedLazyPath, | |
| 124 | directory_source: PrefixedLazyPath, | |
| 125 | 125 | bytes: []u8, |
| 126 | 126 | output: *Output, |
| 127 | 127 | }; |
| 128 | 128 | |
| 129 | pub const PrefixedFileSource = struct { | |
| 129 | pub const PrefixedLazyPath = struct { | |
| 130 | 130 | prefix: []const u8, |
| 131 | file_source: std.Build.FileSource, | |
| 131 | file_source: std.Build.LazyPath, | |
| 132 | 132 | }; |
| 133 | 133 | |
| 134 | 134 | pub const Output = struct { |
| ... | ... | @@ -169,9 +169,9 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void { |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /// 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 | |
| 173 | 173 | /// throughout the build system. |
| 174 | pub fn addOutputFileArg(self: *Run, basename: []const u8) std.Build.FileSource { | |
| 174 | pub fn addOutputFileArg(self: *Run, basename: []const u8) std.Build.LazyPath { | |
| 175 | 175 | return self.addPrefixedOutputFileArg("", basename); |
| 176 | 176 | } |
| 177 | 177 | |
| ... | ... | @@ -179,7 +179,7 @@ pub fn addPrefixedOutputFileArg( |
| 179 | 179 | self: *Run, |
| 180 | 180 | prefix: []const u8, |
| 181 | 181 | basename: []const u8, |
| 182 | ) std.Build.FileSource { | |
| 182 | ) std.Build.LazyPath { | |
| 183 | 183 | const b = self.step.owner; |
| 184 | 184 | |
| 185 | 185 | const output = b.allocator.create(Output) catch @panic("OOM"); |
| ... | ... | @@ -197,14 +197,18 @@ pub fn addPrefixedOutputFileArg( |
| 197 | 197 | return .{ .generated = &output.generated_file }; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | pub fn addFileSourceArg(self: *Run, file_source: std.Build.FileSource) void { | |
| 201 | self.addPrefixedFileSourceArg("", file_source); | |
| 200 | pub const addFileSourceArg = addFileArg; // DEPRECATED, use addFileArg | |
| 201 | ||
| 202 | pub fn addFileArg(self: *Run, file_source: std.Build.LazyPath) void { | |
| 203 | self.addPrefixedFileArg("", file_source); | |
| 202 | 204 | } |
| 203 | 205 | |
| 204 | pub fn addPrefixedFileSourceArg(self: *Run, prefix: []const u8, file_source: std.Build.FileSource) void { | |
| 206 | pub const addPrefixedFileSourceArg = addPrefixedFileArg; // DEPRECATED, use addPrefixedFileArg | |
| 207 | ||
| 208 | pub fn addPrefixedFileArg(self: *Run, prefix: []const u8, file_source: std.Build.LazyPath) void { | |
| 205 | 209 | const b = self.step.owner; |
| 206 | 210 | |
| 207 | const prefixed_file_source: PrefixedFileSource = .{ | |
| 211 | const prefixed_file_source: PrefixedLazyPath = .{ | |
| 208 | 212 | .prefix = b.dupe(prefix), |
| 209 | 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 | 216 | file_source.addStepDependencies(&self.step); |
| 213 | 217 | } |
| 214 | 218 | |
| 215 | pub fn addDirectorySourceArg(self: *Run, directory_source: std.Build.FileSource) void { | |
| 216 | self.addPrefixedDirectorySourceArg("", directory_source); | |
| 219 | pub const addDirectorySourceArg = addDirectoryArg; // DEPRECATED, use addDirectoryArg | |
| 220 | ||
| 221 | pub fn addDirectoryArg(self: *Run, directory_source: std.Build.LazyPath) void { | |
| 222 | self.addPrefixedDirectoryArg("", directory_source); | |
| 217 | 223 | } |
| 218 | 224 | |
| 219 | pub fn addPrefixedDirectorySourceArg(self: *Run, prefix: []const u8, directory_source: std.Build.FileSource) void { | |
| 225 | pub const addPrefixedDirectorySourceArg = addPrefixedDirectoryArg; // DEPRECATED, use addPrefixedDirectoryArg | |
| 226 | ||
| 227 | pub fn addPrefixedDirectoryArg(self: *Run, prefix: []const u8, directory_source: std.Build.LazyPath) void { | |
| 220 | 228 | const b = self.step.owner; |
| 221 | 229 | |
| 222 | const prefixed_directory_source: PrefixedFileSource = .{ | |
| 230 | const prefixed_directory_source: PrefixedLazyPath = .{ | |
| 223 | 231 | .prefix = b.dupe(prefix), |
| 224 | 232 | .file_source = directory_source.dupe(b), |
| 225 | 233 | }; |
| ... | ... | @@ -331,7 +339,7 @@ pub fn addCheck(self: *Run, new_check: StdIo.Check) void { |
| 331 | 339 | } |
| 332 | 340 | } |
| 333 | 341 | |
| 334 | pub fn captureStdErr(self: *Run) std.Build.FileSource { | |
| 342 | pub fn captureStdErr(self: *Run) std.Build.LazyPath { | |
| 335 | 343 | assert(self.stdio != .inherit); |
| 336 | 344 | |
| 337 | 345 | if (self.captured_stderr) |output| return .{ .generated = &output.generated_file }; |
| ... | ... | @@ -346,7 +354,7 @@ pub fn captureStdErr(self: *Run) std.Build.FileSource { |
| 346 | 354 | return .{ .generated = &output.generated_file }; |
| 347 | 355 | } |
| 348 | 356 | |
| 349 | pub fn captureStdOut(self: *Run) std.Build.FileSource { | |
| 357 | pub fn captureStdOut(self: *Run) std.Build.LazyPath { | |
| 350 | 358 | assert(self.stdio != .inherit); |
| 351 | 359 | |
| 352 | 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 | 457 | self.addPathForDynLibs(artifact); |
| 450 | 458 | } |
| 451 | 459 | const file_path = artifact.installed_path orelse |
| 452 | artifact.getOutputSource().getPath(b); | |
| 460 | artifact.getEmittedBin().getPath(b); | |
| 453 | 461 | |
| 454 | 462 | try argv_list.append(file_path); |
| 455 | 463 | |
| ... | ... | @@ -1241,7 +1249,7 @@ fn addPathForDynLibs(self: *Run, artifact: *Step.Compile) void { |
| 1241 | 1249 | switch (link_object) { |
| 1242 | 1250 | .other_step => |other| { |
| 1243 | 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 | 1253 | addPathForDynLibs(self, other); |
| 1246 | 1254 | } |
| 1247 | 1255 | }, |
lib/std/Build/Step/TranslateC.zig+10-6| ... | ... | @@ -9,7 +9,7 @@ const TranslateC = @This(); |
| 9 | 9 | pub const base_id = .translate_c; |
| 10 | 10 | |
| 11 | 11 | step: Step, |
| 12 | source: std.Build.FileSource, | |
| 12 | source: std.Build.LazyPath, | |
| 13 | 13 | include_dirs: std.ArrayList([]const u8), |
| 14 | 14 | c_macros: std.ArrayList([]const u8), |
| 15 | 15 | out_basename: []const u8, |
| ... | ... | @@ -18,7 +18,7 @@ optimize: std.builtin.OptimizeMode, |
| 18 | 18 | output_file: std.Build.GeneratedFile, |
| 19 | 19 | |
| 20 | 20 | pub const Options = struct { |
| 21 | source_file: std.Build.FileSource, | |
| 21 | source_file: std.Build.LazyPath, | |
| 22 | 22 | target: CrossTarget, |
| 23 | 23 | optimize: std.builtin.OptimizeMode, |
| 24 | 24 | }; |
| ... | ... | @@ -53,10 +53,14 @@ pub const AddExecutableOptions = struct { |
| 53 | 53 | linkage: ?Step.Compile.Linkage = null, |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | pub fn getOutput(self: *TranslateC) std.Build.LazyPath { | |
| 57 | return .{ .generated = &self.output_file }; | |
| 58 | } | |
| 59 | ||
| 56 | 60 | /// Creates a step to build an executable from the translated source. |
| 57 | 61 | pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Compile { |
| 58 | 62 | return self.step.owner.addExecutable(.{ |
| 59 | .root_source_file = .{ .generated = &self.output_file }, | |
| 63 | .root_source_file = self.getOutput(), | |
| 60 | 64 | .name = options.name orelse "translated_c", |
| 61 | 65 | .version = options.version, |
| 62 | 66 | .target = options.target orelse self.target, |
| ... | ... | @@ -70,7 +74,7 @@ pub fn addExecutable(self: *TranslateC, options: AddExecutableOptions) *Step.Com |
| 70 | 74 | /// `createModule` can be used instead to create a private module. |
| 71 | 75 | pub fn addModule(self: *TranslateC, name: []const u8) *std.Build.Module { |
| 72 | 76 | return self.step.owner.addModule(name, .{ |
| 73 | .source_file = .{ .generated = &self.output_file }, | |
| 77 | .source_file = self.getOutput(), | |
| 74 | 78 | }); |
| 75 | 79 | } |
| 76 | 80 | |
| ... | ... | @@ -83,7 +87,7 @@ pub fn createModule(self: *TranslateC) *std.Build.Module { |
| 83 | 87 | |
| 84 | 88 | module.* = .{ |
| 85 | 89 | .builder = b, |
| 86 | .source_file = .{ .generated = &self.output_file }, | |
| 90 | .source_file = self.getOutput(), | |
| 87 | 91 | .dependencies = std.StringArrayHashMap(*std.Build.Module).init(b.allocator), |
| 88 | 92 | }; |
| 89 | 93 | return module; |
| ... | ... | @@ -96,7 +100,7 @@ pub fn addIncludeDir(self: *TranslateC, include_dir: []const u8) void { |
| 96 | 100 | pub fn addCheckFile(self: *TranslateC, expected_matches: []const []const u8) *Step.CheckFile { |
| 97 | 101 | return Step.CheckFile.create( |
| 98 | 102 | self.step.owner, |
| 99 | .{ .generated = &self.output_file }, | |
| 103 | self.getOutput(), | |
| 100 | 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 | 28 | sub_path: []const u8, |
| 29 | 29 | contents: Contents, |
| 30 | 30 | |
| 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 | 34 | return .{ .generated = &self.generated_file }; |
| 33 | 35 | } |
| 34 | 36 | }; |
| ... | ... | @@ -40,7 +42,7 @@ pub const OutputSourceFile = struct { |
| 40 | 42 | |
| 41 | 43 | pub const Contents = union(enum) { |
| 42 | 44 | bytes: []const u8, |
| 43 | copy: std.Build.FileSource, | |
| 45 | copy: std.Build.LazyPath, | |
| 44 | 46 | }; |
| 45 | 47 | |
| 46 | 48 | pub fn create(owner: *std.Build) *WriteFile { |
| ... | ... | @@ -59,7 +61,7 @@ pub fn create(owner: *std.Build) *WriteFile { |
| 59 | 61 | return wf; |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.FileSource { | |
| 64 | pub fn add(wf: *WriteFile, sub_path: []const u8, bytes: []const u8) std.Build.LazyPath { | |
| 63 | 65 | const b = wf.step.owner; |
| 64 | 66 | const gpa = b.allocator; |
| 65 | 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 | 72 | }; |
| 71 | 73 | wf.files.append(gpa, file) catch @panic("OOM"); |
| 72 | 74 | wf.maybeUpdateName(); |
| 73 | return file.getFileSource(); | |
| 75 | return file.getPath(); | |
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 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 | 82 | /// include sub-directories, in which case this step will ensure the |
| 81 | 83 | /// required sub-path exists. |
| 82 | 84 | /// This is the option expected to be used most commonly with `addCopyFile`. |
| 83 | pub fn addCopyFile(wf: *WriteFile, source: std.Build.FileSource, sub_path: []const u8) std.Build.FileSource { | |
| 85 | pub fn addCopyFile(wf: *WriteFile, source: std.Build.LazyPath, sub_path: []const u8) std.Build.LazyPath { | |
| 84 | 86 | const b = wf.step.owner; |
| 85 | 87 | const gpa = b.allocator; |
| 86 | 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 | 95 | |
| 94 | 96 | wf.maybeUpdateName(); |
| 95 | 97 | source.addStepDependencies(&wf.step); |
| 96 | return file.getFileSource(); | |
| 98 | return file.getLazyPath(); | |
| 97 | 99 | } |
| 98 | 100 | |
| 99 | 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 | 103 | /// used as part of the normal build process, but as a utility occasionally |
| 102 | 104 | /// run by a developer with intent to modify source files and then commit |
| 103 | 105 | /// those changes to version control. |
| 104 | pub fn addCopyFileToSource(wf: *WriteFile, source: std.Build.FileSource, sub_path: []const u8) void { | |
| 106 | pub fn addCopyFileToSource(wf: *WriteFile, source: std.Build.LazyPath, sub_path: []const u8) void { | |
| 105 | 107 | const b = wf.step.owner; |
| 106 | 108 | wf.output_source_files.append(b.allocator, .{ |
| 107 | 109 | .contents = .{ .copy = source }, |
| ... | ... | @@ -123,11 +125,13 @@ pub fn addBytesToSource(wf: *WriteFile, bytes: []const u8, sub_path: []const u8) |
| 123 | 125 | }) catch @panic("OOM"); |
| 124 | 126 | } |
| 125 | 127 | |
| 126 | pub const getFileSource = @compileError("Deprecated; use the return value from add()/addCopyFile(), or use files[i].getFileSource()"); | |
| 128 | pub const getFileSource = @compileError("Deprecated; use the return value from add()/addCopyFile(), or use files[i].getPath()"); | |
| 129 | ||
| 130 | pub const getDirectorySource = getDirectory; | |
| 127 | 131 | |
| 128 | /// Returns a `FileSource` representing the base directory that contains all the | |
| 132 | /// Returns a `LazyPath` representing the base directory that contains all the | |
| 129 | 133 | /// files from this `WriteFile`. |
| 130 | pub fn getDirectorySource(wf: *WriteFile) std.Build.FileSource { | |
| 134 | pub fn getDirectory(wf: *WriteFile) std.Build.LazyPath { | |
| 131 | 135 | return .{ .generated = &wf.generated_directory }; |
| 132 | 136 | } |
| 133 | 137 |
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 | .optimize = optimize, |
| 17 | 17 | .target = .{}, |
| 18 | 18 | }); |
| 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 = "." }); | |
| 21 | 21 | |
| 22 | 22 | const lib_b = b.addStaticLibrary(.{ |
| 23 | 23 | .name = "b", |
| 24 | 24 | .optimize = optimize, |
| 25 | 25 | .target = .{}, |
| 26 | 26 | }); |
| 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 = "." }); | |
| 29 | 29 | |
| 30 | 30 | const test_exe = b.addTest(.{ |
| 31 | 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 | 33 | }); |
| 34 | 34 | test_exe.linkLibrary(lib_a); |
| 35 | 35 | test_exe.linkLibrary(lib_b); |
| 36 | test_exe.addIncludePath("."); | |
| 36 | test_exe.addIncludePath(.{ .path = "." }); | |
| 37 | 37 | |
| 38 | 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 | 23 | .name = "test", |
| 24 | 24 | .optimize = optimize, |
| 25 | 25 | }); |
| 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 = &.{ | |
| 29 | 29 | "-nostdlib++", |
| 30 | 30 | "-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" }) }); | |
| 33 | 33 | |
| 34 | 34 | const run_cmd = b.addRunArtifact(exe); |
| 35 | 35 | run_cmd.expectStdErrEqual("x: 5\n"); |
test/link/macho/dead_strip/build.zig+1-1| ... | ... | @@ -52,7 +52,7 @@ fn createScenario( |
| 52 | 52 | .optimize = optimize, |
| 53 | 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 | 56 | exe.linkLibC(); |
| 57 | 57 | return exe; |
| 58 | 58 | } |
test/link/macho/dead_strip_dylibs/build.zig+1-1| ... | ... | @@ -53,7 +53,7 @@ fn createScenario( |
| 53 | 53 | .name = name, |
| 54 | 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 | 57 | exe.linkLibC(); |
| 58 | 58 | exe.linkFramework("Cocoa"); |
| 59 | 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 | 21 | .optimize = optimize, |
| 22 | 22 | .target = target, |
| 23 | 23 | }); |
| 24 | dylib.addCSourceFile("a.c", &.{}); | |
| 24 | dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); | |
| 25 | 25 | dylib.linkLibC(); |
| 26 | 26 | |
| 27 | 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 | 39 | .optimize = optimize, |
| 40 | 40 | .target = target, |
| 41 | 41 | }); |
| 42 | exe.addCSourceFile("main.c", &.{}); | |
| 42 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 43 | 43 | exe.linkSystemLibrary("a"); |
| 44 | exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource()); | |
| 45 | exe.addRPathDirectorySource(dylib.getOutputDirectorySource()); | |
| 44 | exe.addLibraryPath(dylib.getEmitDirectory()); | |
| 45 | exe.addRPath(dylib.getEmitDirectory()); | |
| 46 | 46 | exe.linkLibC(); |
| 47 | 47 | |
| 48 | 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 | 55 | |
| 56 | 56 | check_exe.checkStart(); |
| 57 | 57 | check_exe.checkExact("cmd RPATH"); |
| 58 | check_exe.checkExactFileSource("path", dylib.getOutputDirectorySource()); | |
| 58 | check_exe.checkExactPath("path", dylib.getOutputDirectorySource()); | |
| 59 | 59 | test_step.dependOn(&check_exe.step); |
| 60 | 60 | |
| 61 | 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 | 20 | .optimize = optimize, |
| 21 | 21 | .target = target, |
| 22 | 22 | }); |
| 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{} }); | |
| 25 | 25 | exe.linkLibC(); |
| 26 | 26 | |
| 27 | 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 | 18 | .optimize = optimize, |
| 19 | 19 | .target = .{ .os_tag = .macos }, |
| 20 | 20 | }); |
| 21 | exe.addCSourceFile("main.c", &.{}); | |
| 21 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 22 | 22 | exe.linkLibC(); |
| 23 | 23 | exe.entry_symbol_name = "_non_main"; |
| 24 | 24 |
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 | 18 | .optimize = optimize, |
| 19 | 19 | .target = .{ .os_tag = .macos }, |
| 20 | 20 | }); |
| 21 | lib.addCSourceFile("main.c", &.{}); | |
| 21 | lib.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 22 | 22 | lib.linkLibC(); |
| 23 | 23 | |
| 24 | 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 | 18 | .optimize = optimize, |
| 19 | 19 | .target = .{ .os_tag = .macos }, |
| 20 | 20 | }); |
| 21 | lib.addCSourceFile("bootstrap.c", &.{}); | |
| 21 | lib.addCSourceFile(.{ .file = .{ .path = "bootstrap.c" }, .flags = &.{} }); | |
| 22 | 22 | lib.linkLibC(); |
| 23 | 23 | lib.linker_allow_shlib_undefined = true; |
| 24 | 24 | |
| ... | ... | @@ -27,7 +27,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize |
| 27 | 27 | .optimize = optimize, |
| 28 | 28 | .target = .{ .os_tag = .macos }, |
| 29 | 29 | }); |
| 30 | exe.addCSourceFile("main.c", &.{}); | |
| 30 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 31 | 31 | exe.linkLibrary(lib); |
| 32 | 32 | exe.linkLibC(); |
| 33 | 33 | exe.entry_symbol_name = "_bootstrap"; |
test/link/macho/headerpad/build.zig+1-1| ... | ... | @@ -113,7 +113,7 @@ fn simpleExe( |
| 113 | 113 | .name = name, |
| 114 | 114 | .optimize = optimize, |
| 115 | 115 | }); |
| 116 | exe.addCSourceFile("main.c", &.{}); | |
| 116 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 117 | 117 | exe.linkLibC(); |
| 118 | 118 | exe.linkFramework("CoreFoundation"); |
| 119 | 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 | 20 | .name = "test", |
| 21 | 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 | 24 | exe.linkLibC(); |
| 25 | 25 | exe.linkFrameworkNeeded("Cocoa"); |
| 26 | 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 | 21 | .optimize = optimize, |
| 22 | 22 | .target = target, |
| 23 | 23 | }); |
| 24 | dylib.addCSourceFile("a.c", &.{}); | |
| 24 | dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); | |
| 25 | 25 | dylib.linkLibC(); |
| 26 | 26 | |
| 27 | 27 | // -dead_strip_dylibs |
| ... | ... | @@ -31,11 +31,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize |
| 31 | 31 | .optimize = optimize, |
| 32 | 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 | 35 | exe.linkLibC(); |
| 36 | 36 | exe.linkSystemLibraryNeeded("a"); |
| 37 | exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource()); | |
| 38 | exe.addRPathDirectorySource(dylib.getOutputDirectorySource()); | |
| 37 | exe.addLibraryPath(dylib.getEmitDirectory()); | |
| 38 | exe.addRPath(dylib.getEmitDirectory()); | |
| 39 | 39 | exe.dead_strip_dylibs = true; |
| 40 | 40 | |
| 41 | 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 | 18 | .name = "test", |
| 19 | 19 | .optimize = optimize, |
| 20 | 20 | }); |
| 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{} }); | |
| 24 | 24 | exe.linkLibC(); |
| 25 | 25 | // TODO when we figure out how to ship framework stubs for cross-compilation, |
| 26 | 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 | 19 | .optimize = optimize, |
| 20 | 20 | }); |
| 21 | 21 | 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{} }); | |
| 25 | 25 | exe.linkLibCpp(); |
| 26 | 26 | // TODO when we figure out how to ship framework stubs for cross-compilation, |
| 27 | 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 | 15 | .optimize = optimize, |
| 16 | 16 | .target = target, |
| 17 | 17 | }); |
| 18 | exe.addCSourceFile("main.c", &.{}); | |
| 18 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 19 | 19 | exe.linkLibC(); |
| 20 | 20 | exe.pagezero_size = 0x4000; |
| 21 | 21 | |
| ... | ... | @@ -39,7 +39,7 @@ pub fn build(b: *std.Build) void { |
| 39 | 39 | .optimize = optimize, |
| 40 | 40 | .target = target, |
| 41 | 41 | }); |
| 42 | exe.addCSourceFile("main.c", &.{}); | |
| 42 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 43 | 43 | exe.linkLibC(); |
| 44 | 44 | exe.pagezero_size = 0; |
| 45 | 45 |
test/link/macho/search_strategy/build.zig+6-6| ... | ... | @@ -55,7 +55,7 @@ fn createScenario( |
| 55 | 55 | .optimize = optimize, |
| 56 | 56 | .target = target, |
| 57 | 57 | }); |
| 58 | static.addCSourceFile("a.c", &.{}); | |
| 58 | static.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); | |
| 59 | 59 | static.linkLibC(); |
| 60 | 60 | static.override_dest_dir = std.Build.InstallDir{ |
| 61 | 61 | .custom = "static", |
| ... | ... | @@ -67,7 +67,7 @@ fn createScenario( |
| 67 | 67 | .optimize = optimize, |
| 68 | 68 | .target = target, |
| 69 | 69 | }); |
| 70 | dylib.addCSourceFile("a.c", &.{}); | |
| 70 | dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); | |
| 71 | 71 | dylib.linkLibC(); |
| 72 | 72 | dylib.override_dest_dir = std.Build.InstallDir{ |
| 73 | 73 | .custom = "dynamic", |
| ... | ... | @@ -78,11 +78,11 @@ fn createScenario( |
| 78 | 78 | .optimize = optimize, |
| 79 | 79 | .target = target, |
| 80 | 80 | }); |
| 81 | exe.addCSourceFile("main.c", &.{}); | |
| 81 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 82 | 82 | exe.linkSystemLibraryName(name); |
| 83 | 83 | 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()); | |
| 87 | 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 | 20 | .optimize = optimize, |
| 21 | 21 | .target = target, |
| 22 | 22 | }); |
| 23 | exe.addCSourceFile("main.c", &.{}); | |
| 23 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); | |
| 24 | 24 | exe.linkLibC(); |
| 25 | 25 | exe.stack_size = 0x100000000; |
| 26 | 26 |
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 | 21 | .optimize = optimize, |
| 22 | 22 | .target = target, |
| 23 | 23 | }); |
| 24 | lib.addCSourceFile("a.c", &.{}); | |
| 24 | lib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); | |
| 25 | 25 | lib.linkLibC(); |
| 26 | 26 | |
| 27 | 27 | const test_exe = b.addTest(.{ |
test/link/macho/unwind_info/build.zig+1-1| ... | ... | @@ -75,7 +75,7 @@ fn createScenario( |
| 75 | 75 | .target = target, |
| 76 | 76 | }); |
| 77 | 77 | b.default_step.dependOn(&exe.step); |
| 78 | exe.addIncludePath("."); | |
| 78 | exe.addIncludePath(.{ .path = "." }); | |
| 79 | 79 | exe.addCSourceFiles(&[_][]const u8{ |
| 80 | 80 | "main.cpp", |
| 81 | 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 | 18 | .name = "test", |
| 19 | 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 | 22 | exe.linkLibC(); |
| 23 | 23 | exe.linkFrameworkWeak("Cocoa"); |
| 24 | 24 |
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 | 21 | .target = target, |
| 22 | 22 | .optimize = optimize, |
| 23 | 23 | }); |
| 24 | dylib.addCSourceFile("a.c", &.{}); | |
| 24 | dylib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); | |
| 25 | 25 | dylib.linkLibC(); |
| 26 | 26 | b.installArtifact(dylib); |
| 27 | 27 | |
| ... | ... | @@ -30,11 +30,11 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize |
| 30 | 30 | .target = target, |
| 31 | 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 | 34 | exe.linkLibC(); |
| 35 | 35 | exe.linkSystemLibraryWeak("a"); |
| 36 | exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource()); | |
| 37 | exe.addRPathDirectorySource(dylib.getOutputDirectorySource()); | |
| 36 | exe.addLibraryPath(dylib.getEmitDirectory()); | |
| 37 | exe.addRPath(dylib.getEmitDirectory()); | |
| 38 | 38 | |
| 39 | 39 | const check = exe.checkObject(); |
| 40 | 40 | check.checkStart(); |
test/link/static_libs_from_object_files/build.zig+6-6| ... | ... | @@ -2,7 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | |
| 4 | 4 | const Build = std.Build; |
| 5 | const FileSource = Build.FileSource; | |
| 5 | const LazyPath = Build.LazyPath; | |
| 6 | 6 | const Step = Build.Step; |
| 7 | 7 | const Run = Step.Run; |
| 8 | 8 | const WriteFile = Step.WriteFile; |
| ... | ... | @@ -14,7 +14,7 @@ pub fn build(b: *Build) void { |
| 14 | 14 | b.default_step = test_step; |
| 15 | 15 | |
| 16 | 16 | // 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 | 18 | defer b.allocator.free(files); |
| 19 | 19 | { |
| 20 | 20 | for (files[0 .. nb_files - 1], 1..nb_files) |*file, i| { |
| ... | ... | @@ -47,7 +47,7 @@ pub fn build(b: *Build) void { |
| 47 | 47 | add(b, test_step, files, .ReleaseFast); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimize: std.builtin.OptimizeMode) void { | |
| 50 | fn add(b: *Build, test_step: *Step, files: []const LazyPath, optimize: std.builtin.OptimizeMode) void { | |
| 51 | 51 | const flags = [_][]const u8{ |
| 52 | 52 | "-Wall", |
| 53 | 53 | "-std=c11", |
| ... | ... | @@ -63,7 +63,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | 65 | for (files) |file| { |
| 66 | exe.addCSourceFileSource(.{ .source = file, .args = &flags }); | |
| 66 | exe.addCSourceFile(.{ .file = file, .flags = &flags }); | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 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 | 88 | |
| 89 | 89 | for (files, 1..) |file, i| { |
| 90 | 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 | } |
| 93 | 93 | |
| 94 | 94 | const exe = b.addExecutable(.{ |
| ... | ... | @@ -125,7 +125,7 @@ fn add(b: *Build, test_step: *Step, files: []const std.Build.FileSource, optimiz |
| 125 | 125 | .target = .{}, |
| 126 | 126 | .optimize = optimize, |
| 127 | 127 | }); |
| 128 | obj.addCSourceFileSource(.{ .source = file, .args = &flags }); | |
| 128 | obj.addCSourceFile(.{ .file = file, .flags = &flags }); | |
| 129 | 129 | |
| 130 | 130 | const lib = if (i & 1 == 0) lib_a else lib_b; |
| 131 | 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 | 19 | .optimize = optimize, |
| 20 | 20 | .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi }, |
| 21 | 21 | }); |
| 22 | exe.addCSourceFile("foo.c", &.{}); | |
| 22 | exe.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} }); | |
| 23 | 23 | exe.use_llvm = false; |
| 24 | 24 | exe.use_lld = false; |
| 25 | 25 |
test/link/wasm/infer-features/build.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ pub fn build(b: *std.Build) void { |
| 13 | 13 | .os_tag = .freestanding, |
| 14 | 14 | }, |
| 15 | 15 | }); |
| 16 | c_obj.addCSourceFile("foo.c", &.{}); | |
| 16 | c_obj.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &.{} }); | |
| 17 | 17 | |
| 18 | 18 | // Wasm library that doesn't have any features specified. This will |
| 19 | 19 | // infer its featureset from other linked object files. |
test/src/Cases.zig+3-3| ... | ... | @@ -518,12 +518,12 @@ pub fn lowerToBuildSteps( |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 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 | 522 | defer file_sources.deinit(); |
| 523 | 523 | for (update.files.items) |file| { |
| 524 | 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(); | |
| 527 | 527 | |
| 528 | 528 | const artifact = if (case.is_test) b.addTest(.{ |
| 529 | 529 | .root_source_file = root_source_file, |
| ... | ... | @@ -577,7 +577,7 @@ pub fn lowerToBuildSteps( |
| 577 | 577 | parent_step.dependOn(&artifact.step); |
| 578 | 578 | }, |
| 579 | 579 | .CompareObjectFile => |expected_output| { |
| 580 | const check = b.addCheckFile(artifact.getOutputSource(), .{ | |
| 580 | const check = b.addCheckFile(artifact.getEmittedBin(), .{ | |
| 581 | 581 | .expected_exact = expected_output, |
| 582 | 582 | }); |
| 583 | 583 |
test/src/CompareOutput.zig+3-3| ... | ... | @@ -99,7 +99,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { |
| 99 | 99 | .target = .{}, |
| 100 | 100 | .optimize = .Debug, |
| 101 | 101 | }); |
| 102 | exe.addAssemblyFileSource(write_src.files.items[0].getFileSource()); | |
| 102 | exe.addAssemblyFile(write_src.files.items[0].getPath()); | |
| 103 | 103 | |
| 104 | 104 | const run = b.addRunArtifact(exe); |
| 105 | 105 | run.setName(annotated_case_name); |
| ... | ... | @@ -119,7 +119,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { |
| 119 | 119 | |
| 120 | 120 | const exe = b.addExecutable(.{ |
| 121 | 121 | .name = "test", |
| 122 | .root_source_file = write_src.files.items[0].getFileSource(), | |
| 122 | .root_source_file = write_src.files.items[0].getPath(), | |
| 123 | 123 | .optimize = optimize, |
| 124 | 124 | .target = .{}, |
| 125 | 125 | }); |
| ... | ... | @@ -145,7 +145,7 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { |
| 145 | 145 | |
| 146 | 146 | const exe = b.addExecutable(.{ |
| 147 | 147 | .name = "test", |
| 148 | .root_source_file = write_src.files.items[0].getFileSource(), | |
| 148 | .root_source_file = write_src.files.items[0].getPath(), | |
| 149 | 149 | .target = .{}, |
| 150 | 150 | .optimize = .Debug, |
| 151 | 151 | }); |
test/src/StackTrace.zig+2-2| ... | ... | @@ -75,7 +75,7 @@ fn addExpect( |
| 75 | 75 | const write_src = b.addWriteFile("source.zig", source); |
| 76 | 76 | const exe = b.addExecutable(.{ |
| 77 | 77 | .name = "test", |
| 78 | .root_source_file = write_src.files.items[0].getFileSource(), | |
| 78 | .root_source_file = write_src.files.items[0].getPath(), | |
| 79 | 79 | .optimize = optimize_mode, |
| 80 | 80 | .target = .{}, |
| 81 | 81 | }); |
| ... | ... | @@ -88,7 +88,7 @@ fn addExpect( |
| 88 | 88 | |
| 89 | 89 | const check_run = b.addRunArtifact(self.check_exe); |
| 90 | 90 | check_run.setName(annotated_case_name); |
| 91 | check_run.addFileSourceArg(run.captureStdErr()); | |
| 91 | check_run.addFileArg(run.captureStdErr()); | |
| 92 | 92 | check_run.addArgs(&.{ |
| 93 | 93 | @tagName(optimize_mode), |
| 94 | 94 | }); |
test/src/run_translated_c.zig+1-1| ... | ... | @@ -85,7 +85,7 @@ pub const RunTranslatedCContext = struct { |
| 85 | 85 | _ = write_src.add(src_file.filename, src_file.source); |
| 86 | 86 | } |
| 87 | 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 | 89 | .target = .{}, |
| 90 | 90 | .optimize = .Debug, |
| 91 | 91 | }); |
test/src/translate_c.zig+1-1| ... | ... | @@ -108,7 +108,7 @@ pub const TranslateCContext = struct { |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 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 | 112 | .target = case.target, |
| 113 | 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 | 19 | .optimize = optimize, |
| 20 | 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 | 23 | exe_c.linkLibC(); |
| 24 | 24 | |
| 25 | 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 | 28 | .target = target, |
| 29 | 29 | }); |
| 30 | 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 | 32 | exe_cpp.linkLibCpp(); |
| 33 | 33 | |
| 34 | 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 | 19 | .optimize = .Debug, |
| 20 | 20 | }); |
| 21 | 21 | exe.addAnonymousModule("bootloader.elf", .{ |
| 22 | .source_file = bootloader.getOutputSource(), | |
| 22 | .source_file = bootloader.getEmittedBin(), | |
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | 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 | const test_artifact = b.addTest(.{ |
| 8 | 8 | .root_source_file = .{ .path = "main.zig" }, |
| 9 | 9 | }); |
| 10 | test_artifact.addIncludePath("a_directory"); | |
| 10 | test_artifact.addIncludePath(.{ .path = "a_directory" }); | |
| 11 | 11 | |
| 12 | 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 | 19 | .optimize = optimize, |
| 20 | 20 | .target = target, |
| 21 | 21 | }); |
| 22 | kernel.addObjectFile("./boot.S"); | |
| 23 | kernel.setLinkerScriptPath(.{ .path = "./linker.ld" }); | |
| 22 | kernel.addObjectFile(.{ .path = "./boot.S" }); | |
| 23 | kernel.setLinkerScript(.{ .path = "./linker.ld" }); | |
| 24 | 24 | b.installArtifact(kernel); |
| 25 | 25 | |
| 26 | 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 | const test_exe = b.addTest(.{ |
| 8 | 8 | .root_source_file = .{ .path = "a/test.zig" }, |
| 9 | 9 | }); |
| 10 | test_exe.setMainPkgPath("."); | |
| 10 | test_exe.setMainPkgPath(.{.path="."}); | |
| 11 | 11 | |
| 12 | 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 | 21 | .root_source_file = .{ .path = "main.zig" }, |
| 22 | 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 | 25 | exe.linkLibC(); |
| 26 | 26 | |
| 27 | 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 | 19 | .optimize = optimize, |
| 20 | 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 | 26 | exe.addObject(obj); |
| 24 | 27 | exe.linkSystemLibrary("c"); |
| 25 | 28 |
test/standalone/shared_library/build.zig+4-1| ... | ... | @@ -19,7 +19,10 @@ pub fn build(b: *std.Build) void { |
| 19 | 19 | .target = target, |
| 20 | 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 | 26 | exe.linkLibrary(lib); |
| 24 | 27 | exe.linkSystemLibrary("c"); |
| 25 | 28 |
test/standalone/stack_iterator/build.zig+4-1| ... | ... | @@ -74,7 +74,10 @@ pub fn build(b: *std.Build) void { |
| 74 | 74 | if (target.isWindows()) c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)"); |
| 75 | 75 | |
| 76 | 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 | 81 | c_shared_lib.linkLibC(); |
| 79 | 82 | |
| 80 | 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 | 11 | .optimize = optimize, |
| 12 | 12 | .target = .{}, |
| 13 | 13 | }); |
| 14 | foo.addCSourceFile("foo.c", &[_][]const u8{}); | |
| 15 | foo.addIncludePath("."); | |
| 14 | foo.addCSourceFile(.{ .file = .{ .path = "foo.c" }, .flags = &[_][]const u8{} }); | |
| 15 | foo.addIncludePath(.{ .path = "." }); | |
| 16 | 16 | |
| 17 | 17 | const test_exe = b.addTest(.{ |
| 18 | 18 | .root_source_file = .{ .path = "foo.zig" }, |
| 19 | 19 | .optimize = optimize, |
| 20 | 20 | }); |
| 21 | 21 | test_exe.linkLibrary(foo); |
| 22 | test_exe.addIncludePath("."); | |
| 22 | test_exe.addIncludePath(.{ .path = "." }); | |
| 23 | 23 | |
| 24 | 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 | 10 | .root_source_file = .{ .path = "main.zig" }, |
| 11 | 11 | .optimize = optimize, |
| 12 | 12 | }); |
| 13 | main.addIncludePath("."); | |
| 13 | main.addIncludePath(.{.path="."}); | |
| 14 | 14 | |
| 15 | 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 | 759 | "-fno-emit-bin", "-fno-emit-h", |
| 760 | 760 | "-fstrip", "-OReleaseFast", |
| 761 | 761 | }); |
| 762 | run.addFileSourceArg(writefile.files.items[0].getFileSource()); | |
| 762 | run.addFileArg(writefile.files.items[0].getPath()); | |
| 763 | 763 | const example_s = run.addPrefixedOutputFileArg("-femit-asm=", "example.s"); |
| 764 | 764 | |
| 765 | 765 | const checkfile = b.addCheckFile(example_s, .{ |
| ... | ... | @@ -1017,8 +1017,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1017 | 1017 | else |
| 1018 | 1018 | ""; |
| 1019 | 1019 | |
| 1020 | these_tests.overrideZigLibDir("lib"); | |
| 1021 | these_tests.addIncludePath("test"); | |
| 1020 | these_tests.overrideZigLibDir(.{ .path = "lib" }); | |
| 1021 | these_tests.addIncludePath(.{ .path = "test" }); | |
| 1022 | 1022 | |
| 1023 | 1023 | const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{ |
| 1024 | 1024 | options.name, |
| ... | ... | @@ -1038,10 +1038,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1038 | 1038 | .link_libc = test_target.link_libc, |
| 1039 | 1039 | .target = altered_target, |
| 1040 | 1040 | }); |
| 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 = &.{ | |
| 1045 | 1045 | // TODO output -std=c89 compatible C code |
| 1046 | 1046 | "-std=c99", |
| 1047 | 1047 | "-pedantic", |
| ... | ... | @@ -1058,7 +1058,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1058 | 1058 | "-Wno-absolute-value", |
| 1059 | 1059 | }, |
| 1060 | 1060 | }); |
| 1061 | compile_c.addIncludePath("lib"); // for zig.h | |
| 1061 | compile_c.addIncludePath(.{ .path = "lib" }); // for zig.h | |
| 1062 | 1062 | if (test_target.target.getOsTag() == .windows) { |
| 1063 | 1063 | if (true) { |
| 1064 | 1064 | // 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 | 1131 | test_step.target_info.dynamic_linker.max_byte = null; |
| 1132 | 1132 | } |
| 1133 | 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 | }); | |
| 1135 | 1138 | |
| 1136 | 1139 | // This test is intentionally trying to check if the external ABI is |
| 1137 | 1140 | // done properly. LTO would be a hindrance to this. |