authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-11-15 11:07:00 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-11-16 09:13:24 -08:00
log400c9b2c4b6fa2630933d9ccbc1d15c7401efb1d
treee4b3281b3d4b7aef0759e0f3b62267fd56605efe
parentd80b093ef90b1f14c6cf8a2f0023649a4b391097

use absolute path for self/files packages


1 files changed, 2 insertions(+), 6 deletions(-)

src/common.zig+2-6
...@@ -305,11 +305,7 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name:...@@ -305,11 +305,7 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name:
305 }305 }
306 }306 }
307307
308 const cwdpath = try std.fs.cwd().realpathAlloc(alloc, ".");308 const fpath = try mdir.realpathAlloc(alloc, ".");
309 const mpath = try mdir.realpathAlloc(alloc, ".");
310 var fpath = extras.trimPrefix(mpath, cwdpath);
311 if (fpath.len == 0) fpath = std.fs.path.sep_str;
312
313 var cachedir = try std.fs.cwd().openDir(cachepath, .{});309 var cachedir = try std.fs.cwd().openDir(cachepath, .{});
314 defer cachedir.close();310 defer cachedir.close();
315 try cachedir.makePath("files");311 try cachedir.makePath("files");
...@@ -318,7 +314,7 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name:...@@ -318,7 +314,7 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name:
318 const rff = try destdir.createFile(fname, .{});314 const rff = try destdir.createFile(fname, .{});
319 defer rff.close();315 defer rff.close();
320 const w = rff.writer();316 const w = rff.writer();
321 try w.print("const srcpath = \"../../../{}\";\n\n", .{std.zig.fmtEscapes(fpath[1..])});317 try w.print("const srcpath = \"/{}\";\n\n", .{std.zig.fmtEscapes(fpath[1..])});
322 var iter = map.iterator();318 var iter = map.iterator();
323 while (iter.next()) |item| {319 while (iter.next()) |item| {
324 try w.print("pub const @\"/{}\" = @embedFile(srcpath ++ \"/{}\");\n", .{ std.zig.fmtEscapes(item.key_ptr.*), std.zig.fmtEscapes(item.value_ptr.*) });320 try w.print("pub const @\"/{}\" = @embedFile(srcpath ++ \"/{}\");\n", .{ std.zig.fmtEscapes(item.key_ptr.*), std.zig.fmtEscapes(item.value_ptr.*) });