Skip to content

Commit 653d0c1

Browse files
arthurkehrwaldfreezy
authored andcommitted
Fix build postprocessing on macOS
1 parent cc0b04f commit 653d0c1

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

Editor/BuildPostprocessing.cs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public class BuildPostprocessing : IPostprocessBuildWithReport
2626

2727
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2828

29+
private const string _unsupportedPlaformMessage =
30+
"Visual Pinball Engine does not ship with an MPF executable for the build "
31+
+ "platform '{}}.' The build will not work unless MPF is installed "
32+
+ "on the end-user's device";
33+
2934
void IPostprocessBuildWithReport.OnPostprocessBuild(BuildReport report)
3035
{
3136
if (
@@ -34,16 +39,39 @@ void IPostprocessBuildWithReport.OnPostprocessBuild(BuildReport report)
3439
)
3540
return;
3641

37-
var streamingAssetsPath = FindStreamingAssets(report.summary.outputPath);
42+
var streamingAssetsPath = FindStreamingAssets(
43+
report.summary.platform,
44+
report.summary.outputPath
45+
);
3846
CleanMachineFolder(streamingAssetsPath);
3947
AddMpfBinaries(report.summary.platform, streamingAssetsPath);
4048
}
4149

42-
private static string FindStreamingAssets(string buildExePath)
50+
private static string FindStreamingAssets(BuildTarget platform, string buildExePath)
4351
{
44-
var dataDir = Directory
45-
.GetDirectories(Directory.GetParent(buildExePath).ToString(), "*_Data")
46-
.FirstOrDefault();
52+
string dataDir;
53+
54+
if (
55+
platform
56+
is BuildTarget.StandaloneWindows
57+
or BuildTarget.StandaloneWindows64
58+
or BuildTarget.StandaloneLinux64
59+
)
60+
{
61+
dataDir = Directory
62+
.GetDirectories(Directory.GetParent(buildExePath).ToString(), "*_Data")
63+
.FirstOrDefault();
64+
}
65+
else if (platform is BuildTarget.StandaloneOSX)
66+
{
67+
dataDir = Path.Combine(buildExePath, "Contents", "Resources", "Data");
68+
}
69+
else
70+
{
71+
throw new PlatformNotSupportedException(
72+
string.Format(_unsupportedPlaformMessage, platform)
73+
);
74+
}
4775

4876
return Path.Combine(dataDir, "StreamingAssets");
4977
}
@@ -63,9 +91,7 @@ private static void AddMpfBinaries(BuildTarget platform, string streamingAssetsP
6391
BuildTarget.StandaloneWindows => Constants.MpfBinaryDirWindows,
6492
BuildTarget.StandaloneWindows64 => Constants.MpfBinaryDirWindows,
6593
_ => throw new PlatformNotSupportedException(
66-
"Visual Pinball Engine does not ship with an MPF executable for the build "
67-
+ $"platform '{platform}.' The build will not work unless MPF is installed "
68-
+ $"on the end-user's device"
94+
string.Format(_unsupportedPlaformMessage, platform)
6995
),
7096
};
7197
var sourcePath = Path.Combine(

0 commit comments

Comments
 (0)