Skip to content

Commit 314c668

Browse files
committed
windows build fix
1 parent fee6618 commit 314c668

1 file changed

Lines changed: 32 additions & 15 deletions

File tree

build.zig

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,33 @@ fn setupEmbeddedFFmpegBuild(b: *std.Build, exe: *std.Build.Step.Compile, target:
7878
std.fs.cwd().access(vendor_dir, .{}) catch {
7979
std.log.info("FFmpeg binaries not found, downloading...", .{});
8080

81-
// Make script executable first
82-
_ = std.process.Child.run(.{
83-
.allocator = b.allocator,
84-
.argv = &[_][]const u8{ "chmod", "+x", "./scripts/download-ffmpeg.sh" },
85-
}) catch {};
86-
87-
// Run download script
88-
const result = std.process.Child.run(.{
89-
.allocator = b.allocator,
90-
.argv = &[_][]const u8{"./scripts/download-ffmpeg.sh"},
91-
}) catch |err| {
92-
std.log.err("Failed to run download script: {}", .{err});
93-
std.log.err("Please run manually: chmod +x ./scripts/download-ffmpeg.sh && ./scripts/download-ffmpeg.sh", .{});
94-
std.process.exit(1);
81+
// Detect platform and run appropriate command
82+
const builtin = @import("builtin");
83+
const result = if (builtin.os.tag == .windows) blk: {
84+
// On Windows, run with bash (Git Bash is available in GitHub Actions)
85+
break :blk std.process.Child.run(.{
86+
.allocator = b.allocator,
87+
.argv = &[_][]const u8{ "bash", "./scripts/download-ffmpeg.sh" },
88+
}) catch |err| {
89+
std.log.err("Failed to run download script: {}", .{err});
90+
std.log.err("Please run manually: bash ./scripts/download-ffmpeg.sh", .{});
91+
std.process.exit(1);
92+
};
93+
} else blk: {
94+
// On Unix systems, make executable first then run
95+
_ = std.process.Child.run(.{
96+
.allocator = b.allocator,
97+
.argv = &[_][]const u8{ "chmod", "+x", "./scripts/download-ffmpeg.sh" },
98+
}) catch {};
99+
100+
break :blk std.process.Child.run(.{
101+
.allocator = b.allocator,
102+
.argv = &[_][]const u8{"./scripts/download-ffmpeg.sh"},
103+
}) catch |err| {
104+
std.log.err("Failed to run download script: {}", .{err});
105+
std.log.err("Please run manually: chmod +x ./scripts/download-ffmpeg.sh && ./scripts/download-ffmpeg.sh", .{});
106+
std.process.exit(1);
107+
};
95108
};
96109

97110
defer b.allocator.free(result.stdout);
@@ -102,7 +115,11 @@ fn setupEmbeddedFFmpegBuild(b: *std.Build, exe: *std.Build.Step.Compile, target:
102115
if (result.stderr.len > 0) {
103116
std.log.err("Script error output: {s}", .{result.stderr});
104117
}
105-
std.log.err("Please run manually: chmod +x ./scripts/download-ffmpeg.sh && ./scripts/download-ffmpeg.sh", .{});
118+
const manual_cmd = if (builtin.os.tag == .windows)
119+
"Please run manually: bash ./scripts/download-ffmpeg.sh"
120+
else
121+
"Please run manually: chmod +x ./scripts/download-ffmpeg.sh && ./scripts/download-ffmpeg.sh";
122+
std.log.err("{s}", .{manual_cmd});
106123
std.process.exit(1);
107124
}
108125

0 commit comments

Comments
 (0)