From 38210d3e9183a77dfe10e0d0f4a79d2999ce3cf7 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Sun, 4 Sep 2022 21:44:07 +0200 Subject: [PATCH] embedFile build_runner.zig in executable --- build.zig | 2 -- src/Config.zig | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 71aa15b..d796185 100644 --- a/build.zig +++ b/build.zig @@ -111,8 +111,6 @@ pub fn build(b: *std.build.Builder) !void { exe.setBuildMode(mode); exe.install(); - b.installFile("src/special/build_runner.zig", "bin/build_runner.zig"); - const test_step = b.step("test", "Run all the tests"); test_step.dependOn(b.getInstallStep()); diff --git a/src/Config.zig b/src/Config.zig index 01558a1..5211ec1 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -206,6 +206,11 @@ pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_crea var exe_dir_bytes: [std.fs.MAX_PATH_BYTES]u8 = undefined; const exe_dir_path = try std.fs.selfExeDirPath(&exe_dir_bytes); config.build_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ exe_dir_path, "build_runner.zig" }); + + const file = try std.fs.createFileAbsolute(config.build_runner_path.?, .{}); + defer file.close(); + + try file.writeAll(@embedFile("special/build_runner.zig")); } if (null == config.global_cache_path) {