Skip to content

Commit

Permalink
Failed the build if cmake invocation fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Aug 8, 2024
1 parent 2b3898b commit 672dbb1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Editor/CompileCesiumForUnityNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,16 @@ private static void OnPostprocessAllAssets(

public int callbackOrder => 0;

/// <summary>
/// True if Unity should exit immediately after `OnPostBuildPlayerScriptDLLs` completes.
/// </summary>
public static bool ExitAfterCompile = false;

/// <summary>
/// The exit code of the last step of the build process, such as cmake or lipo.
/// </summary>
private static int LastRunExitCode = 0;

/// <summary>
/// Invoked after the managed script assemblies are compiled, including the CesiumForUnity
/// managed code. Building the CesiumForUnity assembly will generate C++ code via Reinterop,
Expand Down Expand Up @@ -227,7 +235,10 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report)
Process p = Process.Start("lipo", string.Join(' ', args));
p.WaitForExit();
if (p.ExitCode != 0)
throw new Exception("lipo failed");
{
UnityEngine.Debug.LogError($"Invocation of 'lipo' tool failed. The command-line was:{Environment.NewLine}lipo {string.Join(' ', args)}");
LastRunExitCode = p.ExitCode;
}

foreach (LibraryToBuild library in libraries)
{
Expand All @@ -237,7 +248,7 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report)

if (ExitAfterCompile)
{
EditorApplication.Exit(0);
EditorApplication.Exit(LastRunExitCode);
}
}

Expand Down Expand Up @@ -517,6 +528,7 @@ private static void RunAndLog(ProcessStartInfo startInfo, StreamWriter log, stri
if (configure.ExitCode != 0)
{
UnityEngine.Debug.LogError($"An error occurred while building CesiumForUnityNative. See {logFilename} for details. The command-line was:{Environment.NewLine}{startInfo.FileName} {startInfo.Arguments}");
LastRunExitCode = configure.ExitCode;
}
}
}
Expand Down

0 comments on commit 672dbb1

Please sign in to comment.