| ... | ... | @@ -1644,10 +1644,20 @@ pub const BuildExeSubprocessError = error{ |
| 1644 | 1644 | FailedButCacheIntact, |
| 1645 | 1645 | } || Io.Cancelable || Allocator.Error; |
| 1646 | 1646 | |
| 1647 | pub const BuildExeSubprocessResult = struct { |
| 1648 | received_fs_inputs: bool, |
| 1649 | cache_hit: bool, |
| 1650 | path: Cache.Path, |
| 1651 | }; |
| 1652 | |
| 1647 | 1653 | /// Assumes `argv` has `--listen=-` in it and the child process is `zig build-exe`. |
| 1648 | 1654 | /// |
| 1649 | 1655 | /// Result path is allocated via gpa. |
| 1650 | | pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOptions) BuildExeSubprocessError!Cache.Path { |
| 1656 | pub fn buildExeSubprocess( |
| 1657 | gpa: Allocator, |
| 1658 | io: Io, |
| 1659 | options: BuildExeSubprocessOptions, |
| 1660 | ) BuildExeSubprocessError!BuildExeSubprocessResult { |
| 1651 | 1661 | const cmd: SubprocessCommand = .{ .argv = options.argv }; |
| 1652 | 1662 | |
| 1653 | 1663 | var child = std.process.spawn(io, .{ |
| ... | ... | @@ -1699,6 +1709,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt |
| 1699 | 1709 | defer body_buffer.deinit(gpa); |
| 1700 | 1710 | |
| 1701 | 1711 | var received_fs_inputs = false; |
| 1712 | var cache_hit = false; |
| 1702 | 1713 | |
| 1703 | 1714 | while (true) { |
| 1704 | 1715 | const header = stdout.takeStruct(Header, .little) catch |err| switch (err) { |
| ... | ... | @@ -1739,9 +1750,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt |
| 1739 | 1750 | .emit_digest => { |
| 1740 | 1751 | const EmitDigest = Server.Message.EmitDigest; |
| 1741 | 1752 | const ebp_hdr: *align(1) const EmitDigest = @ptrCast(body); |
| 1742 | | if (!ebp_hdr.flags.cache_hit) { |
| 1743 | | log.info("source changes detected; rebuilt {s}", .{options.root_name}); |
| 1744 | | } |
| 1753 | cache_hit = ebp_hdr.flags.cache_hit; |
| 1745 | 1754 | const digest = body[@sizeOf(EmitDigest)..][0..Cache.bin_digest_len]; |
| 1746 | 1755 | if (result) |r| gpa.free(r.sub_path); |
| 1747 | 1756 | result = .{ |
| ... | ... | @@ -1831,7 +1840,11 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt |
| 1831 | 1840 | .output_mode = .Exe, |
| 1832 | 1841 | }); |
| 1833 | 1842 | defer gpa.free(bin_name); |
| 1834 | | return base_path.join(gpa, bin_name); |
| 1843 | return .{ |
| 1844 | .received_fs_inputs = received_fs_inputs, |
| 1845 | .cache_hit = cache_hit, |
| 1846 | .path = try base_path.join(gpa, bin_name), |
| 1847 | }; |
| 1835 | 1848 | } |
| 1836 | 1849 | |
| 1837 | 1850 | fn readStreamAlloc(gpa: Allocator, io: Io, file: Io.File, limit: Io.Limit) ![]u8 { |