Skip to content

Commit 9101c7c

Browse files
committed
bump buildscripts
1 parent e9528f8 commit 9101c7c

5 files changed

Lines changed: 151 additions & 14 deletions

File tree

.github/workflows/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ jobs:
2929
shell: bash
3030
run: |
3131
C:\\msys64\\usr\\bin\\bash.exe -c 'export PATH="/usr/bin:/mingw64/bin:$PATH"; pacman -S --needed --noconfirm mingw-w64-x86_64-toolchain mingw-w64-x86_64-mpg123 mingw-w64-x86_64-gtk2 mingw-w64-x86_64-libogg mingw-w64-x86_64-libvorbis mingw-w64-x86_64-lame mingw-w64-x86_64-pkg-config nasm yasm make base-devel autoconf automake libtool'
32+
33+
- name: Install llvm-mingw for ARM64 cross-compilation
34+
if: runner.os == 'Windows'
35+
shell: pwsh
36+
run: |
37+
$llvmMingwVersion = "20250114"
38+
$url = "https://github.com/mstorsjo/llvm-mingw/releases/download/$llvmMingwVersion/llvm-mingw-$llvmMingwVersion-ucrt-x86_64.zip"
39+
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\llvm-mingw.zip"
40+
Expand-Archive -Path "$env:TEMP\llvm-mingw.zip" -DestinationPath "C:\llvm-mingw-extract"
41+
if (Test-Path "C:\llvm-mingw") { Remove-Item -Path "C:\llvm-mingw" -Recurse -Force }
42+
Move-Item -Path "C:\llvm-mingw-extract\llvm-mingw-$llvmMingwVersion-ucrt-x86_64" -Destination "C:\llvm-mingw"
43+
Write-Host "llvm-mingw installed to C:\llvm-mingw"
44+
3245
- name: Clone repository
3346
uses: actions/checkout@v4
3447
with:
@@ -78,3 +91,6 @@ jobs:
7891
removeArtifacts: true
7992
artifacts: "artifacts/**/*.nupkg"
8093
token: ${{ secrets.GITHUB_TOKEN }}
94+
95+
96+

build/BuildWIndowsTask.cs

Lines changed: 120 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Cake.Common.Build.AppVeyor;
2+
13
namespace BuildScripts;
24

35
[TaskName("Build Windows")]
@@ -9,8 +11,14 @@ public sealed class BuildWindowsTask : FrostingTask<BuildContext>
911

1012
public override void Run(BuildContext context)
1113
{
14+
Buildx64(context);
15+
Buildarm64(context);
16+
}
17+
18+
private void Buildx64(BuildContext context)
19+
{
1220
// Absolute path to the artifact directory is needed for flags since they don't allow relative path
13-
var artifactDir = context.MakeAbsolute(new DirectoryPath(context.ArtifactsDir));
21+
var artifactDir = context.MakeAbsolute(new DirectoryPath(System.IO.Path.Combine(context.ArtifactsDir, "windows-x64")));
1422

1523
// The directory that all dependencies that are built manually are output too. Originally this was output to the
1624
// artifacts directory but that started causing issues on the github runners, so it was moved back to the
@@ -21,22 +29,23 @@ public override void Run(BuildContext context)
2129
// since they would be set for the Windows side of things and not the mingw environment that everything is
2230
// running in. Instead, we'll build an export statement that can be used at the start of every process call to
2331
// ensure the correct environment variables are set for each command executed.
24-
var cFlagsExport = "export CFLAGS=\"-w\";";
25-
var ccFlagsExport = "export CCFLAGS=\"x86_64-w64-mingw32-gcc\";";
26-
var ldFlagsExport = "export LDFLAGS=\"--static\";";
27-
var pathExport = "export PATH=\"/usr/bin:/mingw64/bin:$PATH\";";
28-
var pkgConfigExport = $"export PKG_CONFIG_PATH=\"/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH\";";
29-
var exports = $"{pathExport}{cFlagsExport}{ccFlagsExport}{ldFlagsExport}{pkgConfigExport}";
32+
var cFlagsExport = "export CFLAGS='-w -Wno-error=incompatible-pointer-types';";
33+
var ccFlagsExport = "export CC='x86_64-w64-mingw32-gcc';";
34+
var cxxFlagsExport = "export CXX='x86_64-w64-mingw32-g++';";
35+
var ldFlagsExport = "export LDFLAGS='--static';";
36+
var pathExport = "export PATH='/usr/bin:/mingw64/bin:$PATH';";
37+
var pkgConfigExport = $"export PKG_CONFIG_PATH='/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH';";
38+
var exports = $"{pathExport}{cFlagsExport}{ccFlagsExport}{cxxFlagsExport}{ldFlagsExport}{pkgConfigExport}";
3039

3140
// The --prefix flag used for all ./configure commands to ensure that build dependencies are output to the
3241
// dependency directory specified
33-
var prefixFlag = $"--prefix=\"{dependencyDir}\"";
42+
var prefixFlag = $"--prefix='{dependencyDir}'";
3443

3544
// The --bindir flag used in the final ffprobe build so that the binary is output to the artifacts directory.
36-
var binDirFlag = $"--bindir=\"{artifactDir}\"";
45+
var binDirFlag = $"--bindir='{artifactDir}'";
3746

3847
// Get the FFprobe ./configure flags specific for this windows build
39-
var configureFlags = GetFFProbConfigureFlags(context);
48+
var configureFlags = GetFFProbConfigureFlags(context, "windows-x64");
4049

4150
// The command to execute in order to run the shell environment (mingw) needed for this build.
4251
var shellCommandPath = @"C:\msys64\usr\bin\bash.exe";
@@ -45,7 +54,9 @@ public override void Run(BuildContext context)
4554
// arguments of this instance for each command.
4655
var processSettings = new ProcessSettings();
4756

57+
4858
// Build libogg
59+
context.Information("Building libogg...");
4960
processSettings.WorkingDirectory = "./ogg";
5061
processSettings.Arguments = $"-c \"{exports} make distclean\"";
5162
context.StartProcess(shellCommandPath, processSettings);
@@ -59,6 +70,7 @@ public override void Run(BuildContext context)
5970
context.StartProcess(shellCommandPath, processSettings);
6071

6172
// build libvorbis
73+
context.Information("Building libvorbis...");
6274
processSettings.WorkingDirectory = "./vorbis";
6375
processSettings.Arguments = $"-c \"{exports} make distclean\"";
6476
context.StartProcess(shellCommandPath, processSettings);
@@ -72,6 +84,7 @@ public override void Run(BuildContext context)
7284
context.StartProcess(shellCommandPath, processSettings);
7385

7486
// build lame
87+
context.Information("Building lame...");
7588
processSettings.WorkingDirectory = "./lame";
7689
processSettings.Arguments = $"-c \"{exports} make distclean\"";
7790
context.StartProcess(shellCommandPath, processSettings);
@@ -83,6 +96,7 @@ public override void Run(BuildContext context)
8396
context.StartProcess(shellCommandPath, processSettings);
8497

8598
// Build ffprobe
99+
context.Information("Building ffprobe...");
86100
processSettings.WorkingDirectory = "./ffmpeg";
87101
processSettings.Arguments = $"-c \"{exports} make distclean\"";
88102
context.StartProcess(shellCommandPath, processSettings);
@@ -94,11 +108,105 @@ public override void Run(BuildContext context)
94108
context.StartProcess(shellCommandPath, processSettings);
95109
}
96110

97-
private static string GetFFProbConfigureFlags(BuildContext context)
111+
private void Buildarm64(BuildContext context)
112+
{
113+
// Absolute path to the artifact directory is needed for flags since they don't allow relative path
114+
var artifactDir = context.MakeAbsolute(new DirectoryPath(System.IO.Path.Combine(context.ArtifactsDir, "windows-arm64")));
115+
context.CreateDirectory(artifactDir);
116+
117+
// The directory that all dependencies that are built manually are output too. Originally this was output to the
118+
// artifacts directory but that started causing issues on the github runners, so it was moved back to the
119+
// project root directory.
120+
var dependencyDir = context.MakeAbsolute(new DirectoryPath($"{context.ArtifactsDir}/../dependencies-windows-arm64"));
121+
122+
// For Windows build, since we're using mingw environment, we can't set environment variables as normal
123+
// since they would be set for the Windows side of things and not the mingw environment that everything is
124+
// running in. Instead, we'll build an export statement that can be used at the start of every process call to
125+
// ensure the correct environment variables are set for each command executed.
126+
var depPathUnix = dependencyDir.FullPath.Replace("\\", "/").Replace("C:", "/c");
127+
var cFlagsExport = $"export CFLAGS='-w -I{depPathUnix}/include';";
128+
var ccFlagsExport = "export CC='aarch64-w64-mingw32-clang';";
129+
var cxxFlagsExport = "export CXX='aarch64-w64-mingw32-clang++';";
130+
var ldFlagsExport = $"export LDFLAGS='-static -L{depPathUnix}/lib';";
131+
var pathExport = "export PATH='/c/llvm-mingw/bin:/usr/bin:/mingw64/bin:$PATH';";
132+
// Convert Windows dependency path to MSYS2 Unix path for pkg-config
133+
134+
var pkgConfigExport = $"export PKG_CONFIG_PATH='{depPathUnix}/lib/pkgconfig';";
135+
var exports = $"{pathExport}{cFlagsExport}{ccFlagsExport}{cxxFlagsExport}{ldFlagsExport}{pkgConfigExport}";
136+
137+
var artifactPathUnix = artifactDir.FullPath.Replace("\\", "/").Replace("C:", "/c");
138+
// The --prefix flag used for all ./configure commands to ensure that build dependencies are output to the
139+
// dependency directory specified
140+
var prefixFlag = $"--prefix='{depPathUnix}'";
141+
142+
// The --bindir flag used in the final ffprobe build so that the binary is output to the artifacts directory.
143+
var binDirFlag = $"--bindir='{artifactPathUnix}'";
144+
145+
// Get the FFprobe ./configure flags specific for this windows build
146+
var configureFlags = GetFFProbConfigureFlags(context, "windows-arm64");
147+
148+
// The command to execute in order to run the shell environment (mingw) needed for this build.
149+
var shellCommandPath = @"C:\msys64\usr\bin\bash.exe";
150+
151+
// Reusuable process settings instance. As each dependency is built, we'll adjust the working directory and
152+
// arguments of this instance for each command.
153+
var processSettings = new ProcessSettings();
154+
155+
// Build libogg
156+
processSettings.WorkingDirectory = "./ogg";
157+
processSettings.Arguments = $"-c \"{exports} make distclean\"";
158+
context.StartProcess(shellCommandPath, processSettings);
159+
processSettings.Arguments = $"-c \"{exports} ./autogen.sh\"";
160+
context.StartProcess(shellCommandPath, processSettings);
161+
processSettings.Arguments = $"-c \"{exports} ./configure --host=aarch64-w64-mingw32 --disable-shared {prefixFlag}\"";
162+
context.StartProcess(shellCommandPath, processSettings);
163+
processSettings.Arguments = $"-c \"{exports} make -j{Environment.ProcessorCount}\"";
164+
context.StartProcess(shellCommandPath, processSettings);
165+
processSettings.Arguments = $"-c \"{exports} make install\"";
166+
context.StartProcess(shellCommandPath, processSettings);
167+
168+
// build libvorbis
169+
processSettings.WorkingDirectory = "./vorbis";
170+
processSettings.Arguments = $"-c \"{exports} make distclean\"";
171+
context.StartProcess(shellCommandPath, processSettings);
172+
processSettings.Arguments = $"-c \"{exports} ./autogen.sh\"";
173+
context.StartProcess(shellCommandPath, processSettings);
174+
processSettings.Arguments = $"-c \"{exports} ./configure --host=aarch64-w64-mingw32 --disable-examples --disable-docs --disable-shared {prefixFlag}\"";
175+
context.StartProcess(shellCommandPath, processSettings);
176+
processSettings.Arguments = $"-c \"{exports} make -j{Environment.ProcessorCount}\"";
177+
context.StartProcess(shellCommandPath, processSettings);
178+
processSettings.Arguments = $"-c \"{exports} make install\"";
179+
context.StartProcess(shellCommandPath, processSettings);
180+
181+
// build lame
182+
processSettings.WorkingDirectory = "./lame";
183+
processSettings.Arguments = $"-c \"{exports} make distclean\"";
184+
context.StartProcess(shellCommandPath, processSettings);
185+
processSettings.Arguments = $"-c \"{exports} ./configure --host=aarch64-w64-mingw32 --disable-frontend --disable-decoder --disable-shared {prefixFlag}\"";
186+
context.StartProcess(shellCommandPath, processSettings);
187+
processSettings.Arguments = $"-c \"{exports} make -j{Environment.ProcessorCount}\"";
188+
context.StartProcess(shellCommandPath, processSettings);
189+
processSettings.Arguments = $"-c \"{exports} make install\"";
190+
context.StartProcess(shellCommandPath, processSettings);
191+
192+
// Build ffprobe
193+
processSettings.WorkingDirectory = "./ffmpeg";
194+
processSettings.Arguments = $"-c \"{exports} make distclean\"";
195+
context.StartProcess(shellCommandPath, processSettings);
196+
processSettings.Arguments = $"-c \"{exports} ./configure --cc=aarch64-w64-mingw32-clang --cxx=aarch64-w64-mingw32-clang++ --cross-prefix=aarch64-w64-mingw32- --pkg-config=pkg-config {binDirFlag} {configureFlags}\"";
197+
context.StartProcess(shellCommandPath, processSettings);
198+
processSettings.Arguments = $"-c \"{exports} make -j{Environment.ProcessorCount}\"";
199+
context.StartProcess(shellCommandPath, processSettings);
200+
processSettings.Arguments = $"-c \"{exports} make install\"";
201+
context.StartProcess(shellCommandPath, processSettings);
202+
}
203+
204+
private static string GetFFProbConfigureFlags(BuildContext context, string rid = "windows-x64")
98205
{
99206
var ignoreCommentsAndNewLines = (string line) => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#');
100207
var configureFlags = context.FileReadLines("ffprobe.config").Where(ignoreCommentsAndNewLines);
101-
var osConfigureFlags = context.FileReadLines($"ffprobe.windows-x64.config").Where(ignoreCommentsAndNewLines);
208+
var osConfigureFlags = context.FileReadLines($"ffprobe.{rid}.config").Where(ignoreCommentsAndNewLines);
102209
return string.Join(' ', configureFlags) + " " + string.Join(' ', osConfigureFlags);
103210
}
104211
}
212+

ffprobe.windows-arm64.config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
########################################################################################################################
2+
### Toolchain Options
3+
########################################################################################################################
4+
--arch=aarch64
5+
--extra-cflags='-DHAVE_UNISTD_H=0'
6+
--target-os=mingw32
7+
8+
########################################################################################################################
9+
### Optimization Options
10+
########################################################################################################################
11+
--enable-asm
12+
--disable-x86asm
13+
--enable-neon

ffprobe.windows-x64.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
### Toolchain Options
33
########################################################################################################################
44
--arch=x86_64
5-
--extra-cflags="-DHAVE_UNISTD_H=0"
5+
--extra-cflags='-DHAVE_UNISTD_H=0'
66
--target-os=mingw32
77

88
########################################################################################################################

0 commit comments

Comments
 (0)