| author | |
| committer | |
| log | d3a237a98c5a2ccf72a774b5f93425c02fea4bea |
| tree | b440fbaf013ed472c39a60381928c0224e694f5c |
| parent | 1728d92f60d4e9aa10d878e3235fc63764d3909b |
| parent | 3c3cee2cfabc5d03bb83cf6cc6a8ed80f13ee1df |
| signature |
remove --enable-cache option; std.Build.CompileStep: remove output_dir8 files changed, 89 insertions(+), 227 deletions(-)
doc/docgen.zig+21-40| ... | @@ -325,7 +325,6 @@ const Code = struct { | ... | @@ -325,7 +325,6 @@ const Code = struct { |
| 325 | link_objects: []const []const u8, | 325 | link_objects: []const []const u8, |
| 326 | target_str: ?[]const u8, | 326 | target_str: ?[]const u8, |
| 327 | link_libc: bool, | 327 | link_libc: bool, |
| 328 | backend_stage1: bool, | ||
| 329 | link_mode: ?std.builtin.LinkMode, | 328 | link_mode: ?std.builtin.LinkMode, |
| 330 | disable_cache: bool, | 329 | disable_cache: bool, |
| 331 | verbose_cimport: bool, | 330 | verbose_cimport: bool, |
| ... | @@ -596,7 +595,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -596,7 +595,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { |
| 596 | var link_mode: ?std.builtin.LinkMode = null; | 595 | var link_mode: ?std.builtin.LinkMode = null; |
| 597 | var disable_cache = false; | 596 | var disable_cache = false; |
| 598 | var verbose_cimport = false; | 597 | var verbose_cimport = false; |
| 599 | var backend_stage1 = false; | ||
| 600 | var additional_options = std.ArrayList([]const u8).init(allocator); | 598 | var additional_options = std.ArrayList([]const u8).init(allocator); |
| 601 | defer additional_options.deinit(); | 599 | defer additional_options.deinit(); |
| 602 | 600 | ||
| ... | @@ -631,8 +629,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -631,8 +629,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { |
| 631 | link_libc = true; | 629 | link_libc = true; |
| 632 | } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) { | 630 | } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) { |
| 633 | link_mode = .Dynamic; | 631 | link_mode = .Dynamic; |
| 634 | } else if (mem.eql(u8, end_tag_name, "backend_stage1")) { | ||
| 635 | backend_stage1 = true; | ||
| 636 | } else if (mem.eql(u8, end_tag_name, "additonal_option")) { | 632 | } else if (mem.eql(u8, end_tag_name, "additonal_option")) { |
| 637 | _ = try eatToken(tokenizer, Token.Id.Separator); | 633 | _ = try eatToken(tokenizer, Token.Id.Separator); |
| 638 | const option = try eatToken(tokenizer, Token.Id.TagContent); | 634 | const option = try eatToken(tokenizer, Token.Id.TagContent); |
| ... | @@ -660,7 +656,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -660,7 +656,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { |
| 660 | .link_objects = try link_objects.toOwnedSlice(), | 656 | .link_objects = try link_objects.toOwnedSlice(), |
| 661 | .target_str = target_str, | 657 | .target_str = target_str, |
| 662 | .link_libc = link_libc, | 658 | .link_libc = link_libc, |
| 663 | .backend_stage1 = backend_stage1, | ||
| 664 | .link_mode = link_mode, | 659 | .link_mode = link_mode, |
| 665 | .disable_cache = disable_cache, | 660 | .disable_cache = disable_cache, |
| 666 | .verbose_cimport = verbose_cimport, | 661 | .verbose_cimport = verbose_cimport, |
| ... | @@ -1380,10 +1375,10 @@ fn genHtml( | ... | @@ -1380,10 +1375,10 @@ fn genHtml( |
| 1380 | var build_args = std.ArrayList([]const u8).init(allocator); | 1375 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1381 | defer build_args.deinit(); | 1376 | defer build_args.deinit(); |
| 1382 | try build_args.appendSlice(&[_][]const u8{ | 1377 | try build_args.appendSlice(&[_][]const u8{ |
| 1383 | zig_exe, "build-exe", | 1378 | zig_exe, "build-exe", |
| 1384 | "--name", code.name, | 1379 | "--name", code.name, |
| 1385 | "--color", "on", | 1380 | "--color", "on", |
| 1386 | "--enable-cache", tmp_source_file_name, | 1381 | name_plus_ext, |
| 1387 | }); | 1382 | }); |
| 1388 | if (opt_zig_lib_dir) |zig_lib_dir| { | 1383 | if (opt_zig_lib_dir) |zig_lib_dir| { |
| 1389 | try build_args.appendSlice(&.{ "--zig-lib-dir", zig_lib_dir }); | 1384 | try build_args.appendSlice(&.{ "--zig-lib-dir", zig_lib_dir }); |
| ... | @@ -1400,21 +1395,13 @@ fn genHtml( | ... | @@ -1400,21 +1395,13 @@ fn genHtml( |
| 1400 | } | 1395 | } |
| 1401 | for (code.link_objects) |link_object| { | 1396 | for (code.link_objects) |link_object| { |
| 1402 | const name_with_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ link_object, obj_ext }); | 1397 | const name_with_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ link_object, obj_ext }); |
| 1403 | const full_path_object = try fs.path.join( | 1398 | try build_args.append(name_with_ext); |
| 1404 | allocator, | ||
| 1405 | &[_][]const u8{ tmp_dir_name, name_with_ext }, | ||
| 1406 | ); | ||
| 1407 | try build_args.append(full_path_object); | ||
| 1408 | try shell_out.print("{s} ", .{name_with_ext}); | 1399 | try shell_out.print("{s} ", .{name_with_ext}); |
| 1409 | } | 1400 | } |
| 1410 | if (code.link_libc) { | 1401 | if (code.link_libc) { |
| 1411 | try build_args.append("-lc"); | 1402 | try build_args.append("-lc"); |
| 1412 | try shell_out.print("-lc ", .{}); | 1403 | try shell_out.print("-lc ", .{}); |
| 1413 | } | 1404 | } |
| 1414 | if (code.backend_stage1) { | ||
| 1415 | try build_args.append("-fstage1"); | ||
| 1416 | try shell_out.print("-fstage1", .{}); | ||
| 1417 | } | ||
| 1418 | const target = try std.zig.CrossTarget.parse(.{ | 1405 | const target = try std.zig.CrossTarget.parse(.{ |
| 1419 | .arch_os_abi = code.target_str orelse "native", | 1406 | .arch_os_abi = code.target_str orelse "native", |
| 1420 | }); | 1407 | }); |
| ... | @@ -1461,7 +1448,7 @@ fn genHtml( | ... | @@ -1461,7 +1448,7 @@ fn genHtml( |
| 1461 | try shell_out.writeAll(colored_stderr); | 1448 | try shell_out.writeAll(colored_stderr); |
| 1462 | break :code_block; | 1449 | break :code_block; |
| 1463 | } | 1450 | } |
| 1464 | const exec_result = exec(allocator, &env_map, build_args.items) catch | 1451 | const exec_result = exec(allocator, &env_map, tmp_dir_name, build_args.items) catch |
| 1465 | return parseError(tokenizer, code.source_token, "example failed to compile", .{}); | 1452 | return parseError(tokenizer, code.source_token, "example failed to compile", .{}); |
| 1466 | 1453 | ||
| 1467 | if (code.verbose_cimport) { | 1454 | if (code.verbose_cimport) { |
| ... | @@ -1480,15 +1467,10 @@ fn genHtml( | ... | @@ -1480,15 +1467,10 @@ fn genHtml( |
| 1480 | } | 1467 | } |
| 1481 | } | 1468 | } |
| 1482 | 1469 | ||
| 1483 | const path_to_exe_dir = mem.trim(u8, exec_result.stdout, " \r\n"); | 1470 | const path_to_exe = try std.fmt.allocPrint(allocator, "./{s}{s}", .{ |
| 1484 | const path_to_exe_basename = try std.fmt.allocPrint(allocator, "{s}{s}", .{ | ||
| 1485 | code.name, | 1471 | code.name, |
| 1486 | target.exeFileExt(), | 1472 | target.exeFileExt(), |
| 1487 | }); | 1473 | }); |
| 1488 | const path_to_exe = try fs.path.join(allocator, &[_][]const u8{ | ||
| 1489 | path_to_exe_dir, | ||
| 1490 | path_to_exe_basename, | ||
| 1491 | }); | ||
| 1492 | const run_args = &[_][]const u8{path_to_exe}; | 1474 | const run_args = &[_][]const u8{path_to_exe}; |
| 1493 | 1475 | ||
| 1494 | var exited_with_signal = false; | 1476 | var exited_with_signal = false; |
| ... | @@ -1498,6 +1480,7 @@ fn genHtml( | ... | @@ -1498,6 +1480,7 @@ fn genHtml( |
| 1498 | .allocator = allocator, | 1480 | .allocator = allocator, |
| 1499 | .argv = run_args, | 1481 | .argv = run_args, |
| 1500 | .env_map = &env_map, | 1482 | .env_map = &env_map, |
| 1483 | .cwd = tmp_dir_name, | ||
| 1501 | .max_output_bytes = max_doc_file_size, | 1484 | .max_output_bytes = max_doc_file_size, |
| 1502 | }); | 1485 | }); |
| 1503 | switch (result.term) { | 1486 | switch (result.term) { |
| ... | @@ -1514,7 +1497,7 @@ fn genHtml( | ... | @@ -1514,7 +1497,7 @@ fn genHtml( |
| 1514 | } | 1497 | } |
| 1515 | break :blk result; | 1498 | break :blk result; |
| 1516 | } else blk: { | 1499 | } else blk: { |
| 1517 | break :blk exec(allocator, &env_map, run_args) catch return parseError(tokenizer, code.source_token, "example crashed", .{}); | 1500 | break :blk exec(allocator, &env_map, tmp_dir_name, run_args) catch return parseError(tokenizer, code.source_token, "example crashed", .{}); |
| 1518 | }; | 1501 | }; |
| 1519 | 1502 | ||
| 1520 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1503 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| ... | @@ -1555,10 +1538,6 @@ fn genHtml( | ... | @@ -1555,10 +1538,6 @@ fn genHtml( |
| 1555 | try test_args.append("-lc"); | 1538 | try test_args.append("-lc"); |
| 1556 | try shell_out.print("-lc ", .{}); | 1539 | try shell_out.print("-lc ", .{}); |
| 1557 | } | 1540 | } |
| 1558 | if (code.backend_stage1) { | ||
| 1559 | try test_args.append("-fstage1"); | ||
| 1560 | try shell_out.print("-fstage1", .{}); | ||
| 1561 | } | ||
| 1562 | if (code.target_str) |triple| { | 1541 | if (code.target_str) |triple| { |
| 1563 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); | 1542 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1564 | try shell_out.print("-target {s} ", .{triple}); | 1543 | try shell_out.print("-target {s} ", .{triple}); |
| ... | @@ -1579,7 +1558,7 @@ fn genHtml( | ... | @@ -1579,7 +1558,7 @@ fn genHtml( |
| 1579 | }, | 1558 | }, |
| 1580 | } | 1559 | } |
| 1581 | } | 1560 | } |
| 1582 | const result = exec(allocator, &env_map, test_args.items) catch | 1561 | const result = exec(allocator, &env_map, null, test_args.items) catch |
| 1583 | return parseError(tokenizer, code.source_token, "test failed", .{}); | 1562 | return parseError(tokenizer, code.source_token, "test failed", .{}); |
| 1584 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1563 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1585 | const escaped_stdout = try escapeHtml(allocator, result.stdout); | 1564 | const escaped_stdout = try escapeHtml(allocator, result.stdout); |
| ... | @@ -1610,10 +1589,6 @@ fn genHtml( | ... | @@ -1610,10 +1589,6 @@ fn genHtml( |
| 1610 | try test_args.append("-lc"); | 1589 | try test_args.append("-lc"); |
| 1611 | try shell_out.print("-lc ", .{}); | 1590 | try shell_out.print("-lc ", .{}); |
| 1612 | } | 1591 | } |
| 1613 | if (code.backend_stage1) { | ||
| 1614 | try test_args.append("-fstage1"); | ||
| 1615 | try shell_out.print("-fstage1", .{}); | ||
| 1616 | } | ||
| 1617 | const result = try ChildProcess.exec(.{ | 1592 | const result = try ChildProcess.exec(.{ |
| 1618 | .allocator = allocator, | 1593 | .allocator = allocator, |
| 1619 | .argv = test_args.items, | 1594 | .argv = test_args.items, |
| ... | @@ -1778,7 +1753,7 @@ fn genHtml( | ... | @@ -1778,7 +1753,7 @@ fn genHtml( |
| 1778 | const colored_stderr = try termColor(allocator, escaped_stderr); | 1753 | const colored_stderr = try termColor(allocator, escaped_stderr); |
| 1779 | try shell_out.print("\n{s} ", .{colored_stderr}); | 1754 | try shell_out.print("\n{s} ", .{colored_stderr}); |
| 1780 | } else { | 1755 | } else { |
| 1781 | _ = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); | 1756 | _ = exec(allocator, &env_map, null, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); |
| 1782 | } | 1757 | } |
| 1783 | try shell_out.writeAll("\n"); | 1758 | try shell_out.writeAll("\n"); |
| 1784 | }, | 1759 | }, |
| ... | @@ -1831,7 +1806,7 @@ fn genHtml( | ... | @@ -1831,7 +1806,7 @@ fn genHtml( |
| 1831 | try test_args.append(option); | 1806 | try test_args.append(option); |
| 1832 | try shell_out.print("{s} ", .{option}); | 1807 | try shell_out.print("{s} ", .{option}); |
| 1833 | } | 1808 | } |
| 1834 | const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); | 1809 | const result = exec(allocator, &env_map, null, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); |
| 1835 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1810 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1836 | const escaped_stdout = try escapeHtml(allocator, result.stdout); | 1811 | const escaped_stdout = try escapeHtml(allocator, result.stdout); |
| 1837 | try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout }); | 1812 | try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout }); |
| ... | @@ -1846,11 +1821,17 @@ fn genHtml( | ... | @@ -1846,11 +1821,17 @@ fn genHtml( |
| 1846 | } | 1821 | } |
| 1847 | } | 1822 | } |
| 1848 | 1823 | ||
| 1849 | fn exec(allocator: Allocator, env_map: *process.EnvMap, args: []const []const u8) !ChildProcess.ExecResult { | 1824 | fn exec( |
| 1825 | allocator: Allocator, | ||
| 1826 | env_map: *process.EnvMap, | ||
| 1827 | cwd: ?[]const u8, | ||
| 1828 | args: []const []const u8, | ||
| 1829 | ) !ChildProcess.ExecResult { | ||
| 1850 | const result = try ChildProcess.exec(.{ | 1830 | const result = try ChildProcess.exec(.{ |
| 1851 | .allocator = allocator, | 1831 | .allocator = allocator, |
| 1852 | .argv = args, | 1832 | .argv = args, |
| 1853 | .env_map = env_map, | 1833 | .env_map = env_map, |
| 1834 | .cwd = cwd, | ||
| 1854 | .max_output_bytes = max_doc_file_size, | 1835 | .max_output_bytes = max_doc_file_size, |
| 1855 | }); | 1836 | }); |
| 1856 | switch (result.term) { | 1837 | switch (result.term) { |
| ... | @@ -1877,12 +1858,12 @@ fn getBuiltinCode( | ... | @@ -1877,12 +1858,12 @@ fn getBuiltinCode( |
| 1877 | opt_zig_lib_dir: ?[]const u8, | 1858 | opt_zig_lib_dir: ?[]const u8, |
| 1878 | ) ![]const u8 { | 1859 | ) ![]const u8 { |
| 1879 | if (opt_zig_lib_dir) |zig_lib_dir| { | 1860 | if (opt_zig_lib_dir) |zig_lib_dir| { |
| 1880 | const result = try exec(allocator, env_map, &.{ | 1861 | const result = try exec(allocator, env_map, null, &.{ |
| 1881 | zig_exe, "build-obj", "--show-builtin", "--zig-lib-dir", zig_lib_dir, | 1862 | zig_exe, "build-obj", "--show-builtin", "--zig-lib-dir", zig_lib_dir, |
| 1882 | }); | 1863 | }); |
| 1883 | return result.stdout; | 1864 | return result.stdout; |
| 1884 | } else { | 1865 | } else { |
| 1885 | const result = try exec(allocator, env_map, &.{ | 1866 | const result = try exec(allocator, env_map, null, &.{ |
| 1886 | zig_exe, "build-obj", "--show-builtin", | 1867 | zig_exe, "build-obj", "--show-builtin", |
| 1887 | }); | 1868 | }); |
| 1888 | return result.stdout; | 1869 | return result.stdout; |
lib/std/Build.zig+4| ... | @@ -539,6 +539,8 @@ pub const TestOptions = struct { | ... | @@ -539,6 +539,8 @@ pub const TestOptions = struct { |
| 539 | optimize: std.builtin.Mode = .Debug, | 539 | optimize: std.builtin.Mode = .Debug, |
| 540 | version: ?std.builtin.Version = null, | 540 | version: ?std.builtin.Version = null, |
| 541 | max_rss: usize = 0, | 541 | max_rss: usize = 0, |
| 542 | filter: ?[]const u8 = null, | ||
| 543 | test_runner: ?[]const u8 = null, | ||
| 542 | }; | 544 | }; |
| 543 | 545 | ||
| 544 | pub fn addTest(b: *Build, options: TestOptions) *CompileStep { | 546 | pub fn addTest(b: *Build, options: TestOptions) *CompileStep { |
| ... | @@ -549,6 +551,8 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep { | ... | @@ -549,6 +551,8 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep { |
| 549 | .target = options.target, | 551 | .target = options.target, |
| 550 | .optimize = options.optimize, | 552 | .optimize = options.optimize, |
| 551 | .max_rss = options.max_rss, | 553 | .max_rss = options.max_rss, |
| 554 | .filter = options.filter, | ||
| 555 | .test_runner = options.test_runner, | ||
| 552 | }); | 556 | }); |
| 553 | } | 557 | } |
| 554 | 558 |
lib/std/Build/CompileStep.zig+48-105| ... | @@ -97,13 +97,10 @@ out_lib_filename: []const u8, | ... | @@ -97,13 +97,10 @@ out_lib_filename: []const u8, |
| 97 | out_pdb_filename: []const u8, | 97 | out_pdb_filename: []const u8, |
| 98 | modules: std.StringArrayHashMap(*Module), | 98 | modules: std.StringArrayHashMap(*Module), |
| 99 | 99 | ||
| 100 | object_src: []const u8, | ||
| 101 | |||
| 102 | link_objects: ArrayList(LinkObject), | 100 | link_objects: ArrayList(LinkObject), |
| 103 | include_dirs: ArrayList(IncludeDir), | 101 | include_dirs: ArrayList(IncludeDir), |
| 104 | c_macros: ArrayList([]const u8), | 102 | c_macros: ArrayList([]const u8), |
| 105 | installed_headers: ArrayList(*Step), | 103 | installed_headers: ArrayList(*Step), |
| 106 | output_dir: ?[]const u8, | ||
| 107 | is_linking_libc: bool = false, | 104 | is_linking_libc: bool = false, |
| 108 | is_linking_libcpp: bool = false, | 105 | is_linking_libcpp: bool = false, |
| 109 | vcpkg_bin_path: ?[]const u8 = null, | 106 | vcpkg_bin_path: ?[]const u8 = null, |
| ... | @@ -288,6 +285,8 @@ pub const Options = struct { | ... | @@ -288,6 +285,8 @@ pub const Options = struct { |
| 288 | linkage: ?Linkage = null, | 285 | linkage: ?Linkage = null, |
| 289 | version: ?std.builtin.Version = null, | 286 | version: ?std.builtin.Version = null, |
| 290 | max_rss: usize = 0, | 287 | max_rss: usize = 0, |
| 288 | filter: ?[]const u8 = null, | ||
| 289 | test_runner: ?[]const u8 = null, | ||
| 291 | }; | 290 | }; |
| 292 | 291 | ||
| 293 | pub const Kind = enum { | 292 | pub const Kind = enum { |
| ... | @@ -340,6 +339,23 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { | ... | @@ -340,6 +339,23 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { |
| 340 | options.target.zigTriple(owner.allocator) catch @panic("OOM"), | 339 | options.target.zigTriple(owner.allocator) catch @panic("OOM"), |
| 341 | }); | 340 | }); |
| 342 | 341 | ||
| 342 | const target_info = NativeTargetInfo.detect(options.target) catch @panic("unhandled error"); | ||
| 343 | |||
| 344 | const out_filename = std.zig.binNameAlloc(owner.allocator, .{ | ||
| 345 | .root_name = name, | ||
| 346 | .target = target_info.target, | ||
| 347 | .output_mode = switch (options.kind) { | ||
| 348 | .lib => .Lib, | ||
| 349 | .obj => .Obj, | ||
| 350 | .exe, .@"test" => .Exe, | ||
| 351 | }, | ||
| 352 | .link_mode = if (options.linkage) |some| @as(std.builtin.LinkMode, switch (some) { | ||
| 353 | .dynamic => .Dynamic, | ||
| 354 | .static => .Static, | ||
| 355 | }) else null, | ||
| 356 | .version = options.version, | ||
| 357 | }) catch @panic("OOM"); | ||
| 358 | |||
| 343 | const self = owner.allocator.create(CompileStep) catch @panic("OOM"); | 359 | const self = owner.allocator.create(CompileStep) catch @panic("OOM"); |
| 344 | self.* = CompileStep{ | 360 | self.* = CompileStep{ |
| 345 | .strip = null, | 361 | .strip = null, |
| ... | @@ -361,7 +377,7 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { | ... | @@ -361,7 +377,7 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { |
| 361 | .max_rss = options.max_rss, | 377 | .max_rss = options.max_rss, |
| 362 | }), | 378 | }), |
| 363 | .version = options.version, | 379 | .version = options.version, |
| 364 | .out_filename = undefined, | 380 | .out_filename = out_filename, |
| 365 | .out_h_filename = owner.fmt("{s}.h", .{name}), | 381 | .out_h_filename = owner.fmt("{s}.h", .{name}), |
| 366 | .out_lib_filename = undefined, | 382 | .out_lib_filename = undefined, |
| 367 | .out_pdb_filename = owner.fmt("{s}.pdb", .{name}), | 383 | .out_pdb_filename = owner.fmt("{s}.pdb", .{name}), |
| ... | @@ -375,18 +391,16 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { | ... | @@ -375,18 +391,16 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { |
| 375 | .rpaths = ArrayList(FileSource).init(owner.allocator), | 391 | .rpaths = ArrayList(FileSource).init(owner.allocator), |
| 376 | .framework_dirs = ArrayList(FileSource).init(owner.allocator), | 392 | .framework_dirs = ArrayList(FileSource).init(owner.allocator), |
| 377 | .installed_headers = ArrayList(*Step).init(owner.allocator), | 393 | .installed_headers = ArrayList(*Step).init(owner.allocator), |
| 378 | .object_src = undefined, | ||
| 379 | .c_std = std.Build.CStd.C99, | 394 | .c_std = std.Build.CStd.C99, |
| 380 | .zig_lib_dir = null, | 395 | .zig_lib_dir = null, |
| 381 | .main_pkg_path = null, | 396 | .main_pkg_path = null, |
| 382 | .exec_cmd_args = null, | 397 | .exec_cmd_args = null, |
| 383 | .filter = null, | 398 | .filter = options.filter, |
| 384 | .test_runner = null, | 399 | .test_runner = options.test_runner, |
| 385 | .disable_stack_probing = false, | 400 | .disable_stack_probing = false, |
| 386 | .disable_sanitize_c = false, | 401 | .disable_sanitize_c = false, |
| 387 | .sanitize_thread = false, | 402 | .sanitize_thread = false, |
| 388 | .rdynamic = false, | 403 | .rdynamic = false, |
| 389 | .output_dir = null, | ||
| 390 | .override_dest_dir = null, | 404 | .override_dest_dir = null, |
| 391 | .installed_path = null, | 405 | .installed_path = null, |
| 392 | .force_undefined_symbols = StringHashMap(void).init(owner.allocator), | 406 | .force_undefined_symbols = StringHashMap(void).init(owner.allocator), |
| ... | @@ -397,70 +411,41 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { | ... | @@ -397,70 +411,41 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { |
| 397 | .output_pdb_path_source = GeneratedFile{ .step = &self.step }, | 411 | .output_pdb_path_source = GeneratedFile{ .step = &self.step }, |
| 398 | .output_dirname_source = GeneratedFile{ .step = &self.step }, | 412 | .output_dirname_source = GeneratedFile{ .step = &self.step }, |
| 399 | 413 | ||
| 400 | .target_info = NativeTargetInfo.detect(self.target) catch @panic("unhandled error"), | 414 | .target_info = target_info, |
| 401 | }; | 415 | }; |
| 402 | self.computeOutFileNames(); | ||
| 403 | if (root_src) |rs| rs.addStepDependencies(&self.step); | ||
| 404 | return self; | ||
| 405 | } | ||
| 406 | |||
| 407 | fn computeOutFileNames(self: *CompileStep) void { | ||
| 408 | const b = self.step.owner; | ||
| 409 | const target = self.target_info.target; | ||
| 410 | |||
| 411 | self.out_filename = std.zig.binNameAlloc(b.allocator, .{ | ||
| 412 | .root_name = self.name, | ||
| 413 | .target = target, | ||
| 414 | .output_mode = switch (self.kind) { | ||
| 415 | .lib => .Lib, | ||
| 416 | .obj => .Obj, | ||
| 417 | .exe, .@"test" => .Exe, | ||
| 418 | }, | ||
| 419 | .link_mode = if (self.linkage) |some| @as(std.builtin.LinkMode, switch (some) { | ||
| 420 | .dynamic => .Dynamic, | ||
| 421 | .static => .Static, | ||
| 422 | }) else null, | ||
| 423 | .version = self.version, | ||
| 424 | }) catch @panic("OOM"); | ||
| 425 | 416 | ||
| 426 | if (self.kind == .lib) { | 417 | if (self.kind == .lib) { |
| 427 | if (self.linkage != null and self.linkage.? == .static) { | 418 | if (self.linkage != null and self.linkage.? == .static) { |
| 428 | self.out_lib_filename = self.out_filename; | 419 | self.out_lib_filename = self.out_filename; |
| 429 | } else if (self.version) |version| { | 420 | } else if (self.version) |version| { |
| 430 | if (target.isDarwin()) { | 421 | if (target_info.target.isDarwin()) { |
| 431 | self.major_only_filename = b.fmt("lib{s}.{d}.dylib", .{ | 422 | self.major_only_filename = owner.fmt("lib{s}.{d}.dylib", .{ |
| 432 | self.name, | 423 | self.name, |
| 433 | version.major, | 424 | version.major, |
| 434 | }); | 425 | }); |
| 435 | self.name_only_filename = b.fmt("lib{s}.dylib", .{self.name}); | 426 | self.name_only_filename = owner.fmt("lib{s}.dylib", .{self.name}); |
| 436 | self.out_lib_filename = self.out_filename; | 427 | self.out_lib_filename = self.out_filename; |
| 437 | } else if (target.os.tag == .windows) { | 428 | } else if (target_info.target.os.tag == .windows) { |
| 438 | self.out_lib_filename = b.fmt("{s}.lib", .{self.name}); | 429 | self.out_lib_filename = owner.fmt("{s}.lib", .{self.name}); |
| 439 | } else { | 430 | } else { |
| 440 | self.major_only_filename = b.fmt("lib{s}.so.{d}", .{ self.name, version.major }); | 431 | self.major_only_filename = owner.fmt("lib{s}.so.{d}", .{ self.name, version.major }); |
| 441 | self.name_only_filename = b.fmt("lib{s}.so", .{self.name}); | 432 | self.name_only_filename = owner.fmt("lib{s}.so", .{self.name}); |
| 442 | self.out_lib_filename = self.out_filename; | 433 | self.out_lib_filename = self.out_filename; |
| 443 | } | 434 | } |
| 444 | } else { | 435 | } else { |
| 445 | if (target.isDarwin()) { | 436 | if (target_info.target.isDarwin()) { |
| 446 | self.out_lib_filename = self.out_filename; | 437 | self.out_lib_filename = self.out_filename; |
| 447 | } else if (target.os.tag == .windows) { | 438 | } else if (target_info.target.os.tag == .windows) { |
| 448 | self.out_lib_filename = b.fmt("{s}.lib", .{self.name}); | 439 | self.out_lib_filename = owner.fmt("{s}.lib", .{self.name}); |
| 449 | } else { | 440 | } else { |
| 450 | self.out_lib_filename = self.out_filename; | 441 | self.out_lib_filename = self.out_filename; |
| 451 | } | 442 | } |
| 452 | } | 443 | } |
| 453 | if (self.output_dir != null) { | ||
| 454 | self.output_lib_path_source.path = b.pathJoin( | ||
| 455 | &.{ self.output_dir.?, self.out_lib_filename }, | ||
| 456 | ); | ||
| 457 | } | ||
| 458 | } | 444 | } |
| 459 | } | ||
| 460 | 445 | ||
| 461 | pub fn setOutputDir(self: *CompileStep, dir: []const u8) void { | 446 | if (root_src) |rs| rs.addStepDependencies(&self.step); |
| 462 | const b = self.step.owner; | 447 | |
| 463 | self.output_dir = b.dupePath(dir); | 448 | return self; |
| 464 | } | 449 | } |
| 465 | 450 | ||
| 466 | pub fn installHeader(cs: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void { | 451 | pub fn installHeader(cs: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void { |
| ... | @@ -853,24 +838,6 @@ fn linkSystemLibraryInner(self: *CompileStep, name: []const u8, opts: struct { | ... | @@ -853,24 +838,6 @@ fn linkSystemLibraryInner(self: *CompileStep, name: []const u8, opts: struct { |
| 853 | }) catch @panic("OOM"); | 838 | }) catch @panic("OOM"); |
| 854 | } | 839 | } |
| 855 | 840 | ||
| 856 | pub fn setName(self: *CompileStep, text: []const u8) void { | ||
| 857 | const b = self.step.owner; | ||
| 858 | assert(self.kind == .@"test"); | ||
| 859 | self.name = b.dupe(text); | ||
| 860 | } | ||
| 861 | |||
| 862 | pub fn setFilter(self: *CompileStep, text: ?[]const u8) void { | ||
| 863 | const b = self.step.owner; | ||
| 864 | assert(self.kind == .@"test"); | ||
| 865 | self.filter = if (text) |t| b.dupe(t) else null; | ||
| 866 | } | ||
| 867 | |||
| 868 | pub fn setTestRunner(self: *CompileStep, path: ?[]const u8) void { | ||
| 869 | const b = self.step.owner; | ||
| 870 | assert(self.kind == .@"test"); | ||
| 871 | self.test_runner = if (path) |p| b.dupePath(p) else null; | ||
| 872 | } | ||
| 873 | |||
| 874 | /// Handy when you have many C/C++ source files and want them all to have the same flags. | 841 | /// Handy when you have many C/C++ source files and want them all to have the same flags. |
| 875 | pub fn addCSourceFiles(self: *CompileStep, files: []const []const u8, flags: []const []const u8) void { | 842 | pub fn addCSourceFiles(self: *CompileStep, files: []const []const u8, flags: []const []const u8) void { |
| 876 | const b = self.step.owner; | 843 | const b = self.step.owner; |
| ... | @@ -1864,7 +1831,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -1864,7 +1831,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1864 | }); | 1831 | }); |
| 1865 | } | 1832 | } |
| 1866 | 1833 | ||
| 1867 | try zig_args.append("--enable-cache"); | ||
| 1868 | try zig_args.append("--listen=-"); | 1834 | try zig_args.append("--listen=-"); |
| 1869 | 1835 | ||
| 1870 | // Windows has an argument length limit of 32,766 characters, macOS 262,144 and Linux | 1836 | // Windows has an argument length limit of 32,766 characters, macOS 262,144 and Linux |
| ... | @@ -1932,54 +1898,31 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -1932,54 +1898,31 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1932 | }, | 1898 | }, |
| 1933 | else => |e| return e, | 1899 | else => |e| return e, |
| 1934 | }; | 1900 | }; |
| 1935 | const build_output_dir = fs.path.dirname(output_bin_path).?; | 1901 | const output_dir = fs.path.dirname(output_bin_path).?; |
| 1936 | |||
| 1937 | if (self.output_dir) |output_dir| { | ||
| 1938 | var src_dir = try fs.cwd().openIterableDir(build_output_dir, .{}); | ||
| 1939 | defer src_dir.close(); | ||
| 1940 | |||
| 1941 | // Create the output directory if it doesn't exist. | ||
| 1942 | try fs.cwd().makePath(output_dir); | ||
| 1943 | |||
| 1944 | var dest_dir = try fs.cwd().openDir(output_dir, .{}); | ||
| 1945 | defer dest_dir.close(); | ||
| 1946 | |||
| 1947 | var it = src_dir.iterate(); | ||
| 1948 | while (try it.next()) |entry| { | ||
| 1949 | // The compiler can put these files into the same directory, but we don't | ||
| 1950 | // want to copy them over. | ||
| 1951 | if (mem.eql(u8, entry.name, "llvm-ar.id") or | ||
| 1952 | mem.eql(u8, entry.name, "libs.txt") or | ||
| 1953 | mem.eql(u8, entry.name, "builtin.zig") or | ||
| 1954 | mem.eql(u8, entry.name, "zld.id") or | ||
| 1955 | mem.eql(u8, entry.name, "lld.id")) continue; | ||
| 1956 | |||
| 1957 | _ = try src_dir.dir.updateFile(entry.name, dest_dir, entry.name, .{}); | ||
| 1958 | } | ||
| 1959 | } else { | ||
| 1960 | self.output_dir = build_output_dir; | ||
| 1961 | } | ||
| 1962 | |||
| 1963 | // This will ensure all output filenames will now have the output_dir available! | ||
| 1964 | self.computeOutFileNames(); | ||
| 1965 | 1902 | ||
| 1966 | // Update generated files | 1903 | // Update generated files |
| 1967 | if (self.output_dir != null) { | 1904 | { |
| 1968 | self.output_dirname_source.path = self.output_dir.?; | 1905 | self.output_dirname_source.path = output_dir; |
| 1969 | 1906 | ||
| 1970 | self.output_path_source.path = b.pathJoin( | 1907 | self.output_path_source.path = b.pathJoin( |
| 1971 | &.{ self.output_dir.?, self.out_filename }, | 1908 | &.{ output_dir, self.out_filename }, |
| 1972 | ); | 1909 | ); |
| 1973 | 1910 | ||
| 1911 | if (self.kind == .lib) { | ||
| 1912 | self.output_lib_path_source.path = b.pathJoin( | ||
| 1913 | &.{ output_dir, self.out_lib_filename }, | ||
| 1914 | ); | ||
| 1915 | } | ||
| 1916 | |||
| 1974 | if (self.emit_h) { | 1917 | if (self.emit_h) { |
| 1975 | self.output_h_path_source.path = b.pathJoin( | 1918 | self.output_h_path_source.path = b.pathJoin( |
| 1976 | &.{ self.output_dir.?, self.out_h_filename }, | 1919 | &.{ output_dir, self.out_h_filename }, |
| 1977 | ); | 1920 | ); |
| 1978 | } | 1921 | } |
| 1979 | 1922 | ||
| 1980 | if (self.target.isWindows() or self.target.isUefi()) { | 1923 | if (self.target.isWindows() or self.target.isUefi()) { |
| 1981 | self.output_pdb_path_source.path = b.pathJoin( | 1924 | self.output_pdb_path_source.path = b.pathJoin( |
| 1982 | &.{ self.output_dir.?, self.out_pdb_filename }, | 1925 | &.{ output_dir, self.out_pdb_filename }, |
| 1983 | ); | 1926 | ); |
| 1984 | } | 1927 | } |
| 1985 | } | 1928 | } |
lib/std/Build/TranslateCStep.zig-1| ... | @@ -100,7 +100,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -100,7 +100,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 100 | try argv_list.append("translate-c"); | 100 | try argv_list.append("translate-c"); |
| 101 | try argv_list.append("-lc"); | 101 | try argv_list.append("-lc"); |
| 102 | 102 | ||
| 103 | try argv_list.append("--enable-cache"); | ||
| 104 | try argv_list.append("--listen=-"); | 103 | try argv_list.append("--listen=-"); |
| 105 | 104 | ||
| 106 | if (!self.target.isNative()) { | 105 | if (!self.target.isNative()) { |
src/main.zig+6-71| ... | @@ -386,7 +386,6 @@ const usage_build_generic = | ... | @@ -386,7 +386,6 @@ const usage_build_generic = |
| 386 | \\ --cache-dir [path] Override the local cache directory | 386 | \\ --cache-dir [path] Override the local cache directory |
| 387 | \\ --global-cache-dir [path] Override the global cache directory | 387 | \\ --global-cache-dir [path] Override the global cache directory |
| 388 | \\ --zig-lib-dir [path] Override path to Zig installation lib directory | 388 | \\ --zig-lib-dir [path] Override path to Zig installation lib directory |
| 389 | \\ --enable-cache Output to cache directory; print path to stdout | ||
| 390 | \\ | 389 | \\ |
| 391 | \\Compile Options: | 390 | \\Compile Options: |
| 392 | \\ -target [name] <arch><sub>-<os>-<abi> see the targets command | 391 | \\ -target [name] <arch><sub>-<os>-<abi> see the targets command |
| ... | @@ -756,7 +755,6 @@ fn buildOutputType( | ... | @@ -756,7 +755,6 @@ fn buildOutputType( |
| 756 | var link_libcpp = false; | 755 | var link_libcpp = false; |
| 757 | var link_libunwind = false; | 756 | var link_libunwind = false; |
| 758 | var want_native_include_dirs = false; | 757 | var want_native_include_dirs = false; |
| 759 | var enable_cache: ?bool = null; | ||
| 760 | var want_pic: ?bool = null; | 758 | var want_pic: ?bool = null; |
| 761 | var want_pie: ?bool = null; | 759 | var want_pie: ?bool = null; |
| 762 | var want_lto: ?bool = null; | 760 | var want_lto: ?bool = null; |
| ... | @@ -1203,8 +1201,6 @@ fn buildOutputType( | ... | @@ -1203,8 +1201,6 @@ fn buildOutputType( |
| 1203 | build_id = true; | 1201 | build_id = true; |
| 1204 | } else if (mem.eql(u8, arg, "-fno-build-id")) { | 1202 | } else if (mem.eql(u8, arg, "-fno-build-id")) { |
| 1205 | build_id = false; | 1203 | build_id = false; |
| 1206 | } else if (mem.eql(u8, arg, "--enable-cache")) { | ||
| 1207 | enable_cache = true; | ||
| 1208 | } else if (mem.eql(u8, arg, "--test-cmd-bin")) { | 1204 | } else if (mem.eql(u8, arg, "--test-cmd-bin")) { |
| 1209 | try test_exec_args.append(null); | 1205 | try test_exec_args.append(null); |
| 1210 | } else if (mem.eql(u8, arg, "--test-evented-io")) { | 1206 | } else if (mem.eql(u8, arg, "--test-evented-io")) { |
| ... | @@ -2641,7 +2637,7 @@ fn buildOutputType( | ... | @@ -2641,7 +2637,7 @@ fn buildOutputType( |
| 2641 | var cleanup_emit_bin_dir: ?fs.Dir = null; | 2637 | var cleanup_emit_bin_dir: ?fs.Dir = null; |
| 2642 | defer if (cleanup_emit_bin_dir) |*dir| dir.close(); | 2638 | defer if (cleanup_emit_bin_dir) |*dir| dir.close(); |
| 2643 | 2639 | ||
| 2644 | const have_enable_cache = enable_cache orelse false; | 2640 | const output_to_cache = listen != .none; |
| 2645 | const optional_version = if (have_version) version else null; | 2641 | const optional_version = if (have_version) version else null; |
| 2646 | 2642 | ||
| 2647 | const resolved_soname: ?[]const u8 = switch (soname) { | 2643 | const resolved_soname: ?[]const u8 = switch (soname) { |
| ... | @@ -2668,7 +2664,7 @@ fn buildOutputType( | ... | @@ -2668,7 +2664,7 @@ fn buildOutputType( |
| 2668 | switch (arg_mode) { | 2664 | switch (arg_mode) { |
| 2669 | .run, .zig_test => break :blk null, | 2665 | .run, .zig_test => break :blk null, |
| 2670 | else => { | 2666 | else => { |
| 2671 | if (have_enable_cache) { | 2667 | if (output_to_cache) { |
| 2672 | break :blk null; | 2668 | break :blk null; |
| 2673 | } else { | 2669 | } else { |
| 2674 | break :blk .{ .path = null, .handle = fs.cwd() }; | 2670 | break :blk .{ .path = null, .handle = fs.cwd() }; |
| ... | @@ -2686,12 +2682,6 @@ fn buildOutputType( | ... | @@ -2686,12 +2682,6 @@ fn buildOutputType( |
| 2686 | }, | 2682 | }, |
| 2687 | .yes => |full_path| b: { | 2683 | .yes => |full_path| b: { |
| 2688 | const basename = fs.path.basename(full_path); | 2684 | const basename = fs.path.basename(full_path); |
| 2689 | if (have_enable_cache) { | ||
| 2690 | break :b Compilation.EmitLoc{ | ||
| 2691 | .basename = basename, | ||
| 2692 | .directory = null, | ||
| 2693 | }; | ||
| 2694 | } | ||
| 2695 | if (fs.path.dirname(full_path)) |dirname| { | 2685 | if (fs.path.dirname(full_path)) |dirname| { |
| 2696 | const handle = fs.cwd().openDir(dirname, .{}) catch |err| { | 2686 | const handle = fs.cwd().openDir(dirname, .{}) catch |err| { |
| 2697 | fatal("unable to open output directory '{s}': {s}", .{ dirname, @errorName(err) }); | 2687 | fatal("unable to open output directory '{s}': {s}", .{ dirname, @errorName(err) }); |
| ... | @@ -3145,7 +3135,7 @@ fn buildOutputType( | ... | @@ -3145,7 +3135,7 @@ fn buildOutputType( |
| 3145 | .test_filter = test_filter, | 3135 | .test_filter = test_filter, |
| 3146 | .test_name_prefix = test_name_prefix, | 3136 | .test_name_prefix = test_name_prefix, |
| 3147 | .test_runner_path = test_runner_path, | 3137 | .test_runner_path = test_runner_path, |
| 3148 | .disable_lld_caching = !have_enable_cache, | 3138 | .disable_lld_caching = !output_to_cache, |
| 3149 | .subsystem = subsystem, | 3139 | .subsystem = subsystem, |
| 3150 | .wasi_exec_model = wasi_exec_model, | 3140 | .wasi_exec_model = wasi_exec_model, |
| 3151 | .debug_compile_errors = debug_compile_errors, | 3141 | .debug_compile_errors = debug_compile_errors, |
| ... | @@ -3240,19 +3230,7 @@ fn buildOutputType( | ... | @@ -3240,19 +3230,7 @@ fn buildOutputType( |
| 3240 | return cmdTranslateC(comp, arena, null); | 3230 | return cmdTranslateC(comp, arena, null); |
| 3241 | } | 3231 | } |
| 3242 | 3232 | ||
| 3243 | const hook: AfterUpdateHook = blk: { | 3233 | updateModule(comp) catch |err| switch (err) { |
| 3244 | if (!have_enable_cache) | ||
| 3245 | break :blk .none; | ||
| 3246 | |||
| 3247 | switch (emit_bin) { | ||
| 3248 | .no => break :blk .none, | ||
| 3249 | .yes_default_path => break :blk .print_emit_bin_dir_path, | ||
| 3250 | .yes => |full_path| break :blk .{ .update = full_path }, | ||
| 3251 | .yes_a_out => break :blk .{ .update = a_out_basename }, | ||
| 3252 | } | ||
| 3253 | }; | ||
| 3254 | |||
| 3255 | updateModule(gpa, comp, hook) catch |err| switch (err) { | ||
| 3256 | error.SemanticAnalyzeFail => if (listen == .none) process.exit(1), | 3234 | error.SemanticAnalyzeFail => if (listen == .none) process.exit(1), |
| 3257 | else => |e| return e, | 3235 | else => |e| return e, |
| 3258 | }; | 3236 | }; |
| ... | @@ -3800,13 +3778,7 @@ fn runOrTestHotSwap( | ... | @@ -3800,13 +3778,7 @@ fn runOrTestHotSwap( |
| 3800 | } | 3778 | } |
| 3801 | } | 3779 | } |
| 3802 | 3780 | ||
| 3803 | const AfterUpdateHook = union(enum) { | 3781 | fn updateModule(comp: *Compilation) !void { |
| 3804 | none, | ||
| 3805 | print_emit_bin_dir_path, | ||
| 3806 | update: []const u8, | ||
| 3807 | }; | ||
| 3808 | |||
| 3809 | fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void { | ||
| 3810 | { | 3782 | { |
| 3811 | // If the terminal is dumb, we dont want to show the user all the output. | 3783 | // If the terminal is dumb, we dont want to show the user all the output. |
| 3812 | var progress: std.Progress = .{ .dont_print_on_dumb = true }; | 3784 | var progress: std.Progress = .{ .dont_print_on_dumb = true }; |
| ... | @@ -3832,43 +3804,6 @@ fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void | ... | @@ -3832,43 +3804,6 @@ fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void |
| 3832 | if (errors.errorMessageCount() > 0) { | 3804 | if (errors.errorMessageCount() > 0) { |
| 3833 | errors.renderToStdErr(renderOptions(comp.color)); | 3805 | errors.renderToStdErr(renderOptions(comp.color)); |
| 3834 | return error.SemanticAnalyzeFail; | 3806 | return error.SemanticAnalyzeFail; |
| 3835 | } else switch (hook) { | ||
| 3836 | .none => {}, | ||
| 3837 | .print_emit_bin_dir_path => { | ||
| 3838 | const emit = comp.bin_file.options.emit.?; | ||
| 3839 | const full_path = try emit.directory.join(gpa, &.{emit.sub_path}); | ||
| 3840 | defer gpa.free(full_path); | ||
| 3841 | const dir_path = fs.path.dirname(full_path).?; | ||
| 3842 | try io.getStdOut().writer().print("{s}\n", .{dir_path}); | ||
| 3843 | }, | ||
| 3844 | .update => |full_path| { | ||
| 3845 | const bin_sub_path = comp.bin_file.options.emit.?.sub_path; | ||
| 3846 | const cwd = fs.cwd(); | ||
| 3847 | const cache_dir = comp.bin_file.options.emit.?.directory.handle; | ||
| 3848 | _ = try cache_dir.updateFile(bin_sub_path, cwd, full_path, .{}); | ||
| 3849 | |||
| 3850 | // If a .pdb file is part of the expected output, we must also copy | ||
| 3851 | // it into place here. | ||
| 3852 | const is_coff = comp.bin_file.options.target.ofmt == .coff; | ||
| 3853 | const have_pdb = is_coff and !comp.bin_file.options.strip; | ||
| 3854 | if (have_pdb) { | ||
| 3855 | // Replace `.out` or `.exe` with `.pdb` on both the source and destination | ||
| 3856 | const src_bin_ext = fs.path.extension(bin_sub_path); | ||
| 3857 | const dst_bin_ext = fs.path.extension(full_path); | ||
| 3858 | |||
| 3859 | const src_pdb_path = try std.fmt.allocPrint(gpa, "{s}.pdb", .{ | ||
| 3860 | bin_sub_path[0 .. bin_sub_path.len - src_bin_ext.len], | ||
| 3861 | }); | ||
| 3862 | defer gpa.free(src_pdb_path); | ||
| 3863 | |||
| 3864 | const dst_pdb_path = try std.fmt.allocPrint(gpa, "{s}.pdb", .{ | ||
| 3865 | full_path[0 .. full_path.len - dst_bin_ext.len], | ||
| 3866 | }); | ||
| 3867 | defer gpa.free(dst_pdb_path); | ||
| 3868 | |||
| 3869 | _ = try cache_dir.updateFile(src_pdb_path, cwd, dst_pdb_path, .{}); | ||
| 3870 | } | ||
| 3871 | }, | ||
| 3872 | } | 3807 | } |
| 3873 | } | 3808 | } |
| 3874 | 3809 | ||
| ... | @@ -4499,7 +4434,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi | ... | @@ -4499,7 +4434,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 4499 | }; | 4434 | }; |
| 4500 | defer comp.destroy(); | 4435 | defer comp.destroy(); |
| 4501 | 4436 | ||
| 4502 | updateModule(gpa, comp, .none) catch |err| switch (err) { | 4437 | updateModule(comp) catch |err| switch (err) { |
| 4503 | error.SemanticAnalyzeFail => process.exit(2), | 4438 | error.SemanticAnalyzeFail => process.exit(2), |
| 4504 | else => |e| return e, | 4439 | else => |e| return e, |
| 4505 | }; | 4440 | }; |
test/standalone/issue_13970/build.zig+3-3| ... | @@ -6,16 +6,16 @@ pub fn build(b: *std.Build) void { | ... | @@ -6,16 +6,16 @@ pub fn build(b: *std.Build) void { |
| 6 | 6 | ||
| 7 | const test1 = b.addTest(.{ | 7 | const test1 = b.addTest(.{ |
| 8 | .root_source_file = .{ .path = "test_root/empty.zig" }, | 8 | .root_source_file = .{ .path = "test_root/empty.zig" }, |
| 9 | .test_runner = "src/main.zig", | ||
| 9 | }); | 10 | }); |
| 10 | const test2 = b.addTest(.{ | 11 | const test2 = b.addTest(.{ |
| 11 | .root_source_file = .{ .path = "src/empty.zig" }, | 12 | .root_source_file = .{ .path = "src/empty.zig" }, |
| 13 | .test_runner = "src/main.zig", | ||
| 12 | }); | 14 | }); |
| 13 | const test3 = b.addTest(.{ | 15 | const test3 = b.addTest(.{ |
| 14 | .root_source_file = .{ .path = "empty.zig" }, | 16 | .root_source_file = .{ .path = "empty.zig" }, |
| 17 | .test_runner = "src/main.zig", | ||
| 15 | }); | 18 | }); |
| 16 | test1.setTestRunner("src/main.zig"); | ||
| 17 | test2.setTestRunner("src/main.zig"); | ||
| 18 | test3.setTestRunner("src/main.zig"); | ||
| 19 | 19 | ||
| 20 | test_step.dependOn(&b.addRunArtifact(test1).step); | 20 | test_step.dependOn(&b.addRunArtifact(test1).step); |
| 21 | test_step.dependOn(&b.addRunArtifact(test2).step); | 21 | test_step.dependOn(&b.addRunArtifact(test2).step); |
test/standalone/test_runner_module_imports/build.zig+1-1| ... | @@ -3,8 +3,8 @@ const std = @import("std"); | ... | @@ -3,8 +3,8 @@ const std = @import("std"); |
| 3 | pub fn build(b: *std.Build) void { | 3 | pub fn build(b: *std.Build) void { |
| 4 | const t = b.addTest(.{ | 4 | const t = b.addTest(.{ |
| 5 | .root_source_file = .{ .path = "src/main.zig" }, | 5 | .root_source_file = .{ .path = "src/main.zig" }, |
| 6 | .test_runner = "test_runner/main.zig", | ||
| 6 | }); | 7 | }); |
| 7 | t.setTestRunner("test_runner/main.zig"); | ||
| 8 | 8 | ||
| 9 | const module1 = b.createModule(.{ .source_file = .{ .path = "module1/main.zig" } }); | 9 | const module1 = b.createModule(.{ .source_file = .{ .path = "module1/main.zig" } }); |
| 10 | const module2 = b.createModule(.{ | 10 | const module2 = b.createModule(.{ |
test/tests.zig+6-6| ... | @@ -977,11 +977,11 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -977,11 +977,11 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 977 | .optimize = test_target.optimize_mode, | 977 | .optimize = test_target.optimize_mode, |
| 978 | .target = test_target.target, | 978 | .target = test_target.target, |
| 979 | .max_rss = max_rss, | 979 | .max_rss = max_rss, |
| 980 | .filter = options.test_filter, | ||
| 980 | }); | 981 | }); |
| 981 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; | 982 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; |
| 982 | const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default"; | 983 | const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default"; |
| 983 | these_tests.single_threaded = test_target.single_threaded; | 984 | these_tests.single_threaded = test_target.single_threaded; |
| 984 | these_tests.setFilter(options.test_filter); | ||
| 985 | if (test_target.link_libc) { | 985 | if (test_target.link_libc) { |
| 986 | these_tests.linkSystemLibrary("c"); | 986 | these_tests.linkSystemLibrary("c"); |
| 987 | } | 987 | } |
| ... | @@ -1037,10 +1037,15 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S | ... | @@ -1037,10 +1037,15 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S |
| 1037 | continue; | 1037 | continue; |
| 1038 | } | 1038 | } |
| 1039 | 1039 | ||
| 1040 | const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 1041 | |||
| 1040 | const test_step = b.addTest(.{ | 1042 | const test_step = b.addTest(.{ |
| 1041 | .root_source_file = .{ .path = "test/c_abi/main.zig" }, | 1043 | .root_source_file = .{ .path = "test/c_abi/main.zig" }, |
| 1042 | .optimize = optimize_mode, | 1044 | .optimize = optimize_mode, |
| 1043 | .target = c_abi_target, | 1045 | .target = c_abi_target, |
| 1046 | .name = b.fmt("test-c-abi-{s}-{s}", .{ | ||
| 1047 | triple_prefix, @tagName(optimize_mode), | ||
| 1048 | }), | ||
| 1044 | }); | 1049 | }); |
| 1045 | if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) { | 1050 | if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) { |
| 1046 | // TODO NativeTargetInfo insists on dynamically linking musl | 1051 | // TODO NativeTargetInfo insists on dynamically linking musl |
| ... | @@ -1057,11 +1062,6 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S | ... | @@ -1057,11 +1062,6 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S |
| 1057 | test_step.want_lto = false; | 1062 | test_step.want_lto = false; |
| 1058 | } | 1063 | } |
| 1059 | 1064 | ||
| 1060 | const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 1061 | test_step.setName(b.fmt("test-c-abi-{s}-{s} ", .{ | ||
| 1062 | triple_prefix, @tagName(optimize_mode), | ||
| 1063 | })); | ||
| 1064 | |||
| 1065 | const run = b.addRunArtifact(test_step); | 1065 | const run = b.addRunArtifact(test_step); |
| 1066 | run.skip_foreign_checks = true; | 1066 | run.skip_foreign_checks = true; |
| 1067 | step.dependOn(&run.step); | 1067 | step.dependOn(&run.step); |