Skip to content

Commit

Permalink
build: Fix cwd location
Browse files Browse the repository at this point in the history
  • Loading branch information
foxnne committed Jan 9, 2025
1 parent 9ef175b commit 62fdc74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub fn build(b: *std.Build) !void {
}
}

const run_cmd = b.addRunArtifact(exe);
const run_step = b.step("run", "Run the example");
run_step.dependOn(&b.addRunArtifact(exe).step);

exe.root_module.addImport("mach", mach_dep.module("mach"));
exe.root_module.addImport("zstbi", zstbi.module("root"));
Expand Down Expand Up @@ -88,7 +88,9 @@ pub fn build(b: *std.Build) !void {
});
exe.step.dependOn(&install_content_step.step);

b.installArtifact(exe);
const installArtifact = b.addInstallArtifact(exe, .{});
run_cmd.step.dependOn(&installArtifact.step);
run_step.dependOn(&run_cmd.step);
}

inline fn thisDir() []const u8 {
Expand Down
8 changes: 6 additions & 2 deletions src/Pixi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ pub fn init(_app: *App, _core: *Core, app_mod: mach.Mod(App), _editor: *Editor)

const allocator = gpa.allocator();

// Run from the directory where the executable is located so relative assets can be found.
var buffer: [1024]u8 = undefined;
const root_path = std.fs.selfExeDirPath(buffer[0..]) catch ".";
const path = std.fs.selfExeDirPath(buffer[0..]) catch ".";
std.posix.chdir(path) catch {};

std.log.debug("Root path: {s}", .{path});

const window = try core.windows.new(.{
.title = "Pixi",
Expand All @@ -152,7 +156,7 @@ pub fn init(_app: *App, _core: *Core, app_mod: mach.Mod(App), _editor: *Editor)
.allocator = allocator,
.timer = try mach.time.Timer.start(),
.window = window,
.root_path = try allocator.dupeZ(u8, root_path),
.root_path = try allocator.dupeZ(u8, path),
};
}

Expand Down

0 comments on commit 62fdc74

Please sign in to comment.