sideeffects / HoudiniEngineForUnreal

Houdini Engine Plugin for Unreal Engine.
http://www.sidefx.com/unreal
Other
1.36k stars 374 forks source link

Platform detection broken for macOS #85

Closed denschub closed 6 years ago

denschub commented 6 years ago

In HoudiniEngineEditor.Build.cs and HoudiniEngineRuntime.Build.cs, the platform detection for macOS fails. With the Mono version installed by the setup script in Unreals sources, Environment.OSVersion.Platform equals to PlatformID.Unix, not PlatformID.MacOSX as expected. Looking at reports like https://github.com/dotnet/corefx/issues/19694, this does not seem to be a new issue, so I wonder how you managed to even build this.

If I just run the supplied sources in the Houdini16.5-Unreal4.20 branch, the script complains it's unable to locate the Houdini Engine framework, because it is looking at the directory structure it would expect from Linux, but it's not there on macOS, obviously.

Looking at the Unreal engine source, I found a bit of trickery in their platform detection, which also got my build of the HoudiniEngineForUnreal to work:

diff --git a/Source/HoudiniEngineEditor/HoudiniEngineEditor.Build.cs b/Source/HoudiniEngineEditor/HoudiniEngineEditor.Build.cs
index f7d9e8b9..bc9878d4 100644
--- a/Source/HoudiniEngineEditor/HoudiniEngineEditor.Build.cs
+++ b/Source/HoudiniEngineEditor/HoudiniEngineEditor.Build.cs
@@ -134,7 +136,7 @@ public class HoudiniEngineEditor : ModuleRules
                 }
             }
         }
-        else if ( buildPlatformId == PlatformID.MacOSX )
+        else if ( buildPlatformId == PlatformID.Unix && Directory.Exists( "/Applications" ) && Directory.Exists( "/System" ) )
         {
             // Check for Houdini installation.
             string HPath = "/Applications/Houdini/Houdini" + HoudiniVersion + "/Frameworks/Houdini.framework/Versions/Current/Resources";
diff --git a/Source/HoudiniEngineRuntime/HoudiniEngineRuntime.Build.cs b/Source/HoudiniEngineRuntime/HoudiniEngineRuntime.Build.cs
index f814a657..d20149a6 100644
--- a/Source/HoudiniEngineRuntime/HoudiniEngineRuntime.Build.cs
+++ b/Source/HoudiniEngineRuntime/HoudiniEngineRuntime.Build.cs
@@ -158,7 +160,7 @@ public class HoudiniEngineRuntime : ModuleRules
                 }
             }
         }
-        else if ( buildPlatformId == PlatformID.MacOSX )
+        else if ( buildPlatformId == PlatformID.Unix && Directory.Exists( "/Applications" ) && Directory.Exists( "/System" ) )
         {
             // Check for Houdini installation.
             string HPath = "/Applications/Houdini/Houdini" + HoudiniVersion + "/Frameworks/Houdini.framework/Versions/Current/Resources";

I would submit a pull request, but the header of that file explicitly says

This file is generated. Do not modify directly.

so submitting a PR is probably a bad idea. I couldn't find the generator for that file, so I assume it's some magic not accessible to me. Casually pinging @dpernuit for more attention on this issue. :)

haowang1013 commented 6 years ago

We fixed it internally by passing ReadOnlyTargetRules to GetHFSPath and do platform switch like this:

if (Target.Platform == UnrealTargetPlatform.Win64)
{
...
}
else if (Target.Platform == UnrealTargetPlatform.Mac)
{
...
}

This is pretty much how all the plugins handle platform specific logic in UE4.

cgrebeld commented 6 years ago

Thanks for the report - we didn't run into this ourselves because our build process always has $HFS defined. Should be fixed with 8546c38e4bd10f2f3a221be26222066da6219276

denschub commented 6 years ago

Thanks for the fix! I'd totally give it a try, but it seems like there are no more macOS daily builds... :)

screen shot 2018-09-25 at 18 59 30