@@ -36,7 +36,7 @@ pub fn build(b: *std.Build) !void {
3636
3737 const docgen_exe = b .addExecutable (.{
3838 .name = "docgen" ,
39- .root_source_file = .{ .path = "doc /docgen.zig" },
39+ .root_source_file = .{ .path = "tools /docgen.zig" },
4040 .target = .{},
4141 .optimize = .Debug ,
4242 });
@@ -45,9 +45,10 @@ pub fn build(b: *std.Build) !void {
4545 const docgen_cmd = b .addRunArtifact (docgen_exe );
4646 docgen_cmd .addArgs (&.{ "--zig" , b .zig_exe });
4747 if (b .zig_lib_dir ) | p | {
48- docgen_cmd .addArgs (&.{ "--zig-lib-dir" , p });
48+ docgen_cmd .addArg ("--zig-lib-dir" );
49+ docgen_cmd .addDirectoryArg (p );
4950 }
50- docgen_cmd .addFileSourceArg (.{ .path = "doc/langref.html.in" });
51+ docgen_cmd .addFileArg (.{ .path = "doc/langref.html.in" });
5152 const langref_file = docgen_cmd .addOutputFileArg ("langref.html" );
5253 const install_langref = b .addInstallFileWithDir (langref_file , .prefix , "doc/langref.html" );
5354 if (! skip_install_langref ) {
@@ -57,9 +58,8 @@ pub fn build(b: *std.Build) !void {
5758 const autodoc_test = b .addTest (.{
5859 .root_source_file = .{ .path = "lib/std/std.zig" },
5960 .target = target ,
61+ .zig_lib_dir = .{ .path = "lib" },
6062 });
61- autodoc_test .overrideZigLibDir ("lib" );
62- autodoc_test .emit_bin = .no_emit ; // https://github.com/ziglang/zig/issues/16351
6363 const install_std_docs = b .addInstallDirectory (.{
6464 .source_dir = autodoc_test .getEmittedDocs (),
6565 .install_dir = .prefix ,
@@ -88,8 +88,8 @@ pub fn build(b: *std.Build) !void {
8888 .name = "check-case" ,
8989 .root_source_file = .{ .path = "test/src/Cases.zig" },
9090 .optimize = optimize ,
91+ .main_pkg_path = .{ .path = "." },
9192 });
92- check_case_exe .main_pkg_path = "." ;
9393 check_case_exe .stack_size = stack_size ;
9494 check_case_exe .single_threaded = single_threaded ;
9595
@@ -196,10 +196,6 @@ pub fn build(b: *std.Build) !void {
196196 exe .pie = pie ;
197197 exe .sanitize_thread = sanitize_thread ;
198198 exe .entitlements = entitlements ;
199- // TODO -femit-bin/-fno-emit-bin should be inferred by the build system
200- // based on whether or not the exe is run or installed.
201- // https://github.com/ziglang/zig/issues/16351
202- if (no_bin ) exe .emit_bin = .no_emit ;
203199
204200 exe .build_id = b .option (
205201 std .Build .Step .Compile .BuildId ,
@@ -208,7 +204,7 @@ pub fn build(b: *std.Build) !void {
208204 );
209205
210206 if (! no_bin ) {
211- const install_exe = b .addInstallArtifact (exe );
207+ const install_exe = b .addInstallArtifact (exe , .{} );
212208 if (flat ) {
213209 install_exe .dest_dir = .prefix ;
214210 }
@@ -352,19 +348,18 @@ pub fn build(b: *std.Build) !void {
352348 exe_options .addOption (bool , "enable_tracy_allocation" , tracy_allocation );
353349 exe_options .addOption (bool , "value_tracing" , value_tracing );
354350 if (tracy ) | tracy_path | {
355- const client_cpp = fs .path .join (
356- b .allocator ,
351+ const client_cpp = b .pathJoin (
357352 &[_ ][]const u8 { tracy_path , "public" , "TracyClient.cpp" },
358- ) catch unreachable ;
353+ );
359354
360355 // On mingw, we need to opt into windows 7+ to get some features required by tracy.
361356 const tracy_c_flags : []const []const u8 = if (target .isWindows () and target .getAbi () == .gnu )
362357 &[_ ][]const u8 { "-DTRACY_ENABLE=1" , "-fno-sanitize=undefined" , "-D_WIN32_WINNT=0x601" }
363358 else
364359 &[_ ][]const u8 { "-DTRACY_ENABLE=1" , "-fno-sanitize=undefined" };
365360
366- exe .addIncludePath (tracy_path );
367- exe .addCSourceFile (client_cpp , tracy_c_flags );
361+ exe .addIncludePath (.{ . cwd_relative = tracy_path } );
362+ exe .addCSourceFile (.{ . file = .{ . cwd_relative = client_cpp }, . flags = tracy_c_flags } );
368363 if (! enable_llvm ) {
369364 exe .linkSystemLibraryName ("c++" );
370365 }
@@ -554,7 +549,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
554549 });
555550 run_opt .addArtifactArg (exe );
556551 run_opt .addArg ("-o" );
557- run_opt .addFileSourceArg (.{ .path = "stage1/zig1.wasm" });
552+ run_opt .addFileArg (.{ .path = "stage1/zig1.wasm" });
558553
559554 const copy_zig_h = b .addWriteFiles ();
560555 copy_zig_h .addCopyFileToSource (.{ .path = "lib/zig.h" }, "stage1/zig.h" );
@@ -603,19 +598,19 @@ fn addCmakeCfgOptionsToExe(
603598 // useful for package maintainers
604599 exe .headerpad_max_install_names = true ;
605600 }
606- exe .addObjectFile (fs . path . join ( b . allocator , &[_ ][]const u8 {
601+ exe .addObjectFile (.{ . cwd_relative = b . pathJoin ( &[_ ][]const u8 {
607602 cfg .cmake_binary_dir ,
608603 "zigcpp" ,
609604 b .fmt ("{s}{s}{s}" , .{
610605 cfg .cmake_static_library_prefix ,
611606 "zigcpp" ,
612607 cfg .cmake_static_library_suffix ,
613608 }),
614- }) catch unreachable );
609+ }) } );
615610 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 );
611+ exe .addIncludePath (.{ . cwd_relative = cfg .lld_include_dir } );
612+ exe .addIncludePath (.{ . cwd_relative = cfg .llvm_include_dir } );
613+ exe .addLibraryPath (.{ . cwd_relative = cfg .llvm_lib_dir } );
619614 addCMakeLibraryList (exe , cfg .clang_libraries );
620615 addCMakeLibraryList (exe , cfg .lld_libraries );
621616 addCMakeLibraryList (exe , cfg .llvm_libraries );
@@ -671,7 +666,7 @@ fn addCmakeCfgOptionsToExe(
671666 }
672667
673668 if (cfg .dia_guids_lib .len != 0 ) {
674- exe .addObjectFile (cfg .dia_guids_lib );
669+ exe .addObjectFile (.{ . cwd_relative = cfg .dia_guids_lib } );
675670 }
676671}
677672
@@ -732,7 +727,7 @@ fn addCxxKnownPath(
732727 }
733728 return error .RequiredLibraryNotFound ;
734729 }
735- exe .addObjectFile (path_unpadded );
730+ exe .addObjectFile (.{ . cwd_relative = path_unpadded } );
736731
737732 // TODO a way to integrate with system c++ include files here
738733 // c++ -E -Wp,-v -xc++ /dev/null
@@ -752,7 +747,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
752747 } else if (exe .target .isWindows () and mem .endsWith (u8 , lib , ".lib" ) and ! fs .path .isAbsolute (lib )) {
753748 exe .linkSystemLibrary (lib [0 .. lib .len - ".lib" .len ]);
754749 } else {
755- exe .addObjectFile (lib );
750+ exe .addObjectFile (.{ . cwd_relative = lib } );
756751 }
757752 }
758753}
0 commit comments