Skip to content

Commit a985b49

Browse files
authored
Linux Arm Support (#5)
* Linux Arm Support Lets try linux arm support * Update Build.csproj * Update BuildLinuxTask.cs * Create ffprobe.linux-arm64.config
1 parent 5c959d0 commit a985b49

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ${{ matrix.os }}
1010
strategy:
1111
matrix:
12-
os: [windows-latest, ubuntu-latest, macos-latest]
12+
os: [windows-latest, ubuntu-latest, macos-latest, ubuntu-22.04-arm]
1313
fail-fast: false
1414
steps:
1515
- name: Expose GitHub Runtime

build/Build.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<Using Include="Cake.Core.Diagnostics" />
2323
<Using Include="Cake.Core.IO" />
2424
<Using Include="Cake.FileHelpers" />
25+
<Using Include="System.Runtime.InteropServices" />
2526
</ItemGroup>
2627

2728
<ItemGroup>
@@ -34,4 +35,4 @@
3435
<ProjectReference Include="..\buildscripts\MonoGame.Tool.BuildScripts.csproj" />
3536
</ItemGroup>
3637

37-
</Project>
38+
</Project>

build/BuildLinuxTask.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ public sealed class BuildLinuxTask : FrostingTask<BuildContext>
1010
public override void Run(BuildContext context)
1111
{
1212
// Absolute path to the artifact directory is needed for flags since they don't allow relative path
13+
var arch = RuntimeInformation.OSArchitecture;
1314
var artifactDir = context.MakeAbsolute(new DirectoryPath(context.ArtifactsDir));
14-
var dependencyDir = context.MakeAbsolute(new DirectoryPath($"{context.ArtifactsDir}/../dependencies-linux-x64"));
15+
var dependencyDir = context.MakeAbsolute(new DirectoryPath($"{context.ArtifactsDir}/../dependencies-linux-{(arch == Architecture.Arm64 ? "arm64" : "x64")}"));
1516
var prefixFlag = $"--prefix=\"{dependencyDir}\"";
16-
var hostFlag = "--host=\"x86_64-linux-gnu\"";
17+
var hostFlag = arch == Architecture.Arm64 ? "--host=\"aarch64-linux-gnu\"" : "--host=\"x86_64-linux-gnu\"";
1718
var binDirFlag = $"--bindir=\"{artifactDir}\"";
1819

1920
var envVariables = new Dictionary<string, string>
@@ -85,7 +86,8 @@ private static string GetFFMpegConfigureFlags(BuildContext context)
8586
{
8687
var ignoreCommentsAndNewLines = (string line) => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#');
8788
var configureFlags = context.FileReadLines("ffprobe.config").Where(ignoreCommentsAndNewLines);
88-
var osConfigureFlags = context.FileReadLines($"ffprobe.linux-x64.config").Where(ignoreCommentsAndNewLines);
89+
var osConfigFile = RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "ffprobe.linux-arm64.config" : "ffprobe.linux-x64.config";
90+
var osConfigureFlags = context.FileReadLines(osConfigFile).Where(ignoreCommentsAndNewLines);
8991
return string.Join(' ', configureFlags) + " " + string.Join(' ', osConfigureFlags);
9092
}
9193
}

ffprobe.linux-arm64.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
########################################################################################################################
2+
### Toolchain Options
3+
########################################################################################################################
4+
--arch=aarch64
5+
--target-os=linux
6+
7+
########################################################################################################################
8+
### Optimization Options
9+
########################################################################################################################
10+
--enable-neon

0 commit comments

Comments
 (0)