Skip to content

Commit e5b1e69

Browse files
committed
clean up
1 parent 4ecd243 commit e5b1e69

File tree

7 files changed

+15
-92
lines changed

7 files changed

+15
-92
lines changed

lib/std/Build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,7 @@ pub const LazyPath = union(enum) {
23732373
// basis for not traversing up too many directories.
23742374

23752375
var file_path: Cache.Path = .{
2376-
// TODO: generated should really get a Path
2376+
// TODO(robin): generated should really get a Path
23772377
.root_dir = Cache.Directory.cwd(),
23782378
.sub_path = gen.file.path orelse {
23792379
std.debug.lockStdErr();

lib/std/Build/Fuzz/WebServer.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ fn buildWasmBinary(
312312
const digest = body[@sizeOf(EbpHdr)..][0..Cache.bin_digest_len];
313313
result = Path{
314314
.root_dir = ws.global_cache_directory,
315-
.sub_path = try std.fmt.allocPrint(arena, "o" ++ std.fs.path.sep_str ++ "{}", .{std.fmt.fmtSliceHexLower(digest)}),
315+
.sub_path = try arena.dupe(u8, "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*)),
316316
};
317317
},
318318
else => {}, // ignore other messages

lib/std/Build/Step.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,10 @@ fn zigProcessUpdate(s: *Step, zp: *ZigProcess, watch: bool) !?Path {
538538
const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body));
539539
s.result_cached = ebp_hdr.flags.cache_hit;
540540
const digest = body[@sizeOf(EbpHdr)..][0..Cache.bin_digest_len];
541-
std.debug.print("got digest: {}\n", .{ std.fmt.fmtSliceHexLower(digest) });
542541
result = Path{
543542
.root_dir = b.cache_root,
544-
.sub_path = try std.fmt.allocPrint(arena, "o" ++ std.fs.path.sep_str ++ "{}", .{std.fmt.fmtSliceHexLower(digest)}),
543+
.sub_path = try arena.dupe(u8, "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*)),
545544
};
546-
std.debug.print("path: {}\n", .{ result.? });
547545
},
548546
.file_system_inputs => {
549547
s.clearWatchInputs();

lib/std/Build/Step/Compile.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,30 +1781,30 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
17811781

17821782
// Update generated files
17831783
if (maybe_output_dir) |output_dir| {
1784-
// std.debug.print("output dir: {}\n", .{output_dir});
17851784
if (compile.emit_directory) |lp| {
17861785
lp.path = b.fmt("{}", .{output_dir});
17871786
}
17881787

17891788
// -femit-bin[=path] (default) Output machine code
17901789
if (compile.generated_bin) |bin| {
17911790
bin.path = output_dir.joinString(b.allocator, compile.out_filename) catch @panic("OOM");
1792-
// std.debug.print("bin path: {s}\n", .{bin.path.?});
17931791
}
17941792

1793+
const sep = std.fs.path.sep_str;
1794+
17951795
// output PDB if someone requested it
17961796
if (compile.generated_pdb) |pdb| {
1797-
pdb.path = b.fmt("{}" ++ std.fs.path.sep_str ++ "{s}.pdb", .{ output_dir, compile.name });
1797+
pdb.path = b.fmt("{}" ++ sep ++ "{s}.pdb", .{ output_dir, compile.name });
17981798
}
17991799

18001800
// -femit-implib[=path] (default) Produce an import .lib when building a Windows DLL
18011801
if (compile.generated_implib) |implib| {
1802-
implib.path = b.fmt("{}" ++ std.fs.path.sep_str ++ "{s}.lib", .{ output_dir, compile.name });
1802+
implib.path = b.fmt("{}" ++ sep ++ "{s}.lib", .{ output_dir, compile.name });
18031803
}
18041804

18051805
// -femit-h[=path] Generate a C header file (.h)
18061806
if (compile.generated_h) |lp| {
1807-
lp.path = b.fmt("{}" ++ std.fs.path.sep_str ++ "{s}.h", .{ output_dir, compile.name });
1807+
lp.path = b.fmt("{}" ++ sep ++ "{s}.h", .{ output_dir, compile.name });
18081808
}
18091809

18101810
// -femit-docs[=path] Create a docs/ dir with html documentation
@@ -1814,17 +1814,17 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
18141814

18151815
// -femit-asm[=path] Output .s (assembly code)
18161816
if (compile.generated_asm) |lp| {
1817-
lp.path = b.fmt("{}" ++ std.fs.path.sep_str ++ "{s}.s", .{ output_dir, compile.name });
1817+
lp.path = b.fmt("{}" ++ sep ++ "{s}.s", .{ output_dir, compile.name });
18181818
}
18191819

18201820
// -femit-llvm-ir[=path] Produce a .ll file with optimized LLVM IR (requires LLVM extensions)
18211821
if (compile.generated_llvm_ir) |lp| {
1822-
lp.path = b.fmt("{}" ++ std.fs.path.sep_str ++ "{s}.ll", .{ output_dir, compile.name });
1822+
lp.path = b.fmt("{}" ++ sep ++ "{s}.ll", .{ output_dir, compile.name });
18231823
}
18241824

18251825
// -femit-llvm-bc[=path] Produce an optimized LLVM module as a .bc file (requires LLVM extensions)
18261826
if (compile.generated_llvm_bc) |lp| {
1827-
lp.path = b.fmt("{}" ++ std.fs.path.sep_str ++ "{s}.bc", .{ output_dir, compile.name });
1827+
lp.path = b.fmt("{}" ++ sep ++ "{s}.bc", .{ output_dir, compile.name });
18281828
}
18291829
}
18301830

src/Compilation.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4570,8 +4570,8 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module
45704570
}
45714571

45724572
const bin_digest = man.finalBin();
4573-
const hex_digest = Cache.binToHex(digest);
4574-
const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &hex_digest });
4573+
const hex_digest = Cache.binToHex(bin_digest);
4574+
const o_sub_path = "o" ++ std.fs.path.sep_str ++ hex_digest;
45754575
var o_dir = try comp.local_cache_directory.handle.makeOpenPath(o_sub_path, .{});
45764576
defer o_dir.close();
45774577

src/Sema.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6004,9 +6004,8 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
60046004
return sema.failWithOwnedErrorMsg(&child_block, msg);
60056005
}
60066006
const parent_mod = parent_block.ownerModule();
6007-
const c_import_zig_path = try std.fmt.allocPrint(comp.arena, "o" ++ std.fs.path.sep_str ++ "{}", .{
6008-
std.fmt.fmtSliceHexLower(&c_import_res.digest),
6009-
});
6007+
const digest = Cache.binToHex(c_import_res.digest);
6008+
const c_import_zig_path = try comp.arena.dupe(u8, "o" ++ std.fs.path.sep_str ++ digest);
60106009
const c_import_mod = Package.Module.create(comp.arena, .{
60116010
.global_cache_directory = comp.global_cache_directory,
60126011
.paths = .{

src/main.zig

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4229,85 +4229,11 @@ fn serveUpdateResults(s: *Server, comp: *Compilation) !void {
42294229
}
42304230

42314231
if (comp.digest) |digest| {
4232-
// var digest: [Cache.bin_digest_len]u8 = undefined;
4233-
// _ = std.fmt.hexToBytes(&digest, &hex_digest) catch unreachable;
4234-
// std.debug.print("sending digest: {*} {s} {}\n", .{ comp, &hex_digest, std.fmt.fmtSliceHexLower(&digest) });
42354232
try s.serveEmitDigest(&digest, .{
42364233
.flags = .{ .cache_hit = comp.last_update_was_cache_hit },
42374234
});
42384235
}
42394236

4240-
// This logic is counter-intuitive because the protocol accounts for each
4241-
// emitted artifact possibly being in a different location, which correctly
4242-
// matches the behavior of the compiler, however, the build system
4243-
// currently always passes flags that makes all build artifacts output to
4244-
// the same local cache directory, and relies on them all being in the same
4245-
// directory.
4246-
//
4247-
// So, until the build system and protocol are changed to reflect this,
4248-
// this logic must ensure that emit_bin_path is emitted for at least one
4249-
// thing, if there are any artifacts.
4250-
4251-
// std.debug.print("aaaaaaaaaaaaaaaaaa: {}\n", .{comp.cache_use});
4252-
// std.debug.print("aaaaaaaaaaaaaaaaaa comp.bin_file={s}\n", .{if (comp.bin_file) |bf| bf.emit.sub_path else "(null)"});
4253-
// std.debug.print("aaaaaaaaaaaaaaaaaa comp.emit_asm={s}\n", .{if (comp.emit_asm) |bf| bf.basename else "(null)"});
4254-
4255-
// switch (comp.cache_use) {
4256-
// .incremental => if (comp.bin_file) |lf| {
4257-
// const full_path = try lf.emit.directory.join(gpa, &.{lf.emit.sub_path});
4258-
// std.debug.print("aaaaaaaaaaaaaaaaax: full_path={s}\n", .{full_path});
4259-
// defer gpa.free(full_path);
4260-
// try s.serveEmitBinPath(full_path, .{
4261-
// .flags = .{ .cache_hit = comp.last_update_was_cache_hit },
4262-
// });
4263-
// return;
4264-
// },
4265-
// .whole => |whole| if (whole.bin_sub_path) |sub_path| {
4266-
// const full_path = try comp.local_cache_directory.join(gpa, &.{sub_path});
4267-
// std.debug.print("aaaaaaaaaaaaaaaaay: full_path={s}\n", .{full_path});
4268-
// defer gpa.free(full_path);
4269-
// try s.serveEmitBinPath(full_path, .{
4270-
// .flags = .{ .cache_hit = comp.last_update_was_cache_hit },
4271-
// });
4272-
// return;
4273-
// } else {
4274-
// std.debug.print("aaaaaaaaaaaaaaaaaz: ue {*}\n", .{whole});
4275-
// },
4276-
// }
4277-
4278-
// for ([_]?Compilation.Emit{
4279-
// comp.docs_emit,
4280-
// comp.implib_emit,
4281-
// }) |opt_emit| {
4282-
// const emit = opt_emit orelse continue;
4283-
// const full_path = try emit.directory.join(gpa, &.{emit.sub_path});
4284-
// std.debug.print("aaaaaaaaaaaaaaaaaz: full_path={s}\n", .{full_path});
4285-
// defer gpa.free(full_path);
4286-
// try s.serveEmitBinPath(full_path, .{
4287-
// .flags = .{ .cache_hit = comp.last_update_was_cache_hit },
4288-
// });
4289-
// return;
4290-
// }
4291-
4292-
// for ([_]?Compilation.EmitLoc{
4293-
// comp.emit_asm,
4294-
// comp.emit_llvm_ir,
4295-
// comp.emit_llvm_bc,
4296-
// }) |opt_emit_loc| {
4297-
// std.debug.print("aaaaa\n", .{});
4298-
// const emit_loc = opt_emit_loc orelse continue;
4299-
// std.debug.print("aaaaa emit_loc={}\n", .{emit_loc});
4300-
// const directory = emit_loc.directory orelse continue;
4301-
// std.debug.print("aaaaa directory={s}\n", .{directory.path.?});
4302-
// const full_path = try directory.join(gpa, &.{emit_loc.basename});
4303-
// std.debug.print("aaaaaaaaaaaaaaaaaw: full_path={s}\n", .{full_path});
4304-
// defer gpa.free(full_path);
4305-
// try s.serveEmitBinPath(full_path, .{
4306-
// .flags = .{ .cache_hit = comp.last_update_was_cache_hit },
4307-
// });
4308-
// return;
4309-
// }
4310-
43114237
// Serve empty error bundle to indicate the update is done.
43124238
try s.serveErrorBundle(std.zig.ErrorBundle.empty);
43134239
}

0 commit comments

Comments
 (0)