Skip to content

Commit

Permalink
fix: EdgegapPlugin now builds properly on ARM machines instead of dep…
Browse files Browse the repository at this point in the history
…loyments failing silently
  • Loading branch information
mischa committed Nov 7, 2023
1 parent eab8609 commit 1b5f963
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
13 changes: 10 additions & 3 deletions Assets/Mirror/Hosting/Edgegap/Editor/EdgegapBuildUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,19 @@ public static async Task RunCommand_DockerBuild(string registry, string imageRep
{
string realErrorMessage = null;

// ARM -> x86 support:
// build commands use 'buildx' on ARM cpus for cross compilation.
// otherwise docker builds would not launch when deployed because
// Edgegap's infrastructure is on x86. instead the deployment logs
// would show an error in a linux .go file with 'not found'.
string buildCommand = IsArmCPU() ? "buildx build --platform linux/amd64" : "build";

#if UNITY_EDITOR_WIN
await RunCommand("docker.exe", $"build -t {registry}/{imageRepo}:{tag} .", onStatusUpdate,
await RunCommand("docker.exe", $"{buildCommand} -t {registry}/{imageRepo}:{tag} .", onStatusUpdate,
#elif UNITY_EDITOR_OSX
await RunCommand("/bin/bash", $"-c \"docker build -t {registry}/{imageRepo}:{tag} .\"", onStatusUpdate,
await RunCommand("/bin/bash", $"-c \"docker {buildCommand} -t {registry}/{imageRepo}:{tag} .\"", onStatusUpdate,
#elif UNITY_EDITOR_LINUX
await RunCommand("/bin/bash", $"-c \"docker build -t {registry}/{imageRepo}:{tag} .\"", onStatusUpdate,
await RunCommand("/bin/bash", $"-c \"docker {buildCommand} -t {registry}/{imageRepo}:{tag} .\"", onStatusUpdate,
#endif
(msg) =>
{
Expand Down
10 changes: 0 additions & 10 deletions Assets/Mirror/Hosting/Edgegap/Editor/EdgegapWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,6 @@ async void BuildAndPushServer()
}
// END MIRROR CHANGE

// MIRROR CHANGE
// Edgegap VMs are x86.
// ARM CPUs like Apple Silicon need special handling.
if (EdgegapBuildUtils.IsArmCPU())
{
onError($"Building from {RuntimeInformation.ProcessArchitecture} Processors is currently not supported because Edgegap infrastructure runs on x86.\n\nPlease find another machine to build from while we are working on ARM support.");
return;
}
// END MIRROR CHANGE

// create server build
BuildReport buildResult = EdgegapBuildUtils.BuildServer();
if (buildResult.summary.result != BuildResult.Succeeded)
Expand Down

0 comments on commit 1b5f963

Please sign in to comment.