|
3 | 3 | using UnrealBuildTool; |
4 | 4 | using System.IO; |
5 | 5 | using System.Collections.Generic; |
| 6 | +//using Tools.DotNETCommon; |
6 | 7 |
|
7 | 8 | public class UnrealEnginePython : ModuleRules |
8 | 9 | { |
9 | 10 |
|
10 | 11 | // leave this string as empty for triggering auto-discovery of python installations... |
11 | 12 | private string PythonHome = ""; |
12 | 13 | bool UseThirdPartyPython = true; //embedded |
| 14 | + bool AutoAddProjectScriptsInPackaging = true; |
13 | 15 |
|
14 | | - //Or use the one included in third party folder |
15 | | - protected string ThirdPartyPythonHome |
| 16 | + //Or use the one included in third party folder |
| 17 | + protected string ThirdPartyPythonHome |
16 | 18 | { |
17 | 19 | get |
18 | 20 | { |
@@ -43,7 +45,50 @@ private string BinariesPath |
43 | 45 | get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../Binaries/")); } |
44 | 46 | } |
45 | 47 |
|
46 | | - private string[] windowsKnownPaths = |
| 48 | + private string ScriptsPath |
| 49 | + { |
| 50 | + get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../Content/Scripts/")); } |
| 51 | + } |
| 52 | + |
| 53 | + public void AddRuntimeDependenciesForCopying(ReadOnlyTargetRules Target) |
| 54 | + { |
| 55 | + if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32)) |
| 56 | + { |
| 57 | + RuntimeDependencies.Add(Path.Combine(ScriptsPath, "...")); |
| 58 | + |
| 59 | + if(AutoAddProjectScriptsInPackaging) |
| 60 | + { |
| 61 | + RuntimeDependencies.Add("$(ProjectDir)/Content/Scripts/..."); |
| 62 | + } |
| 63 | + //Copy binaries as dependencies |
| 64 | + if(UseThirdPartyPython) |
| 65 | + { |
| 66 | + string PlatformString = Target.Platform.ToString(); |
| 67 | + bool VerboseBuild = false; |
| 68 | + |
| 69 | + //Don't add android stuff so we use a manual method to enum a directory |
| 70 | + Tools.DotNETCommon.DirectoryReference BinDir = new Tools.DotNETCommon.DirectoryReference(Path.Combine(BinariesPath, PlatformString, "...")); |
| 71 | + |
| 72 | + if (Tools.DotNETCommon.DirectoryReference.Exists(BinDir)) |
| 73 | + { |
| 74 | + foreach (Tools.DotNETCommon.FileReference File in Tools.DotNETCommon.DirectoryReference.EnumerateFiles(BinDir, "*", SearchOption.AllDirectories)) |
| 75 | + { |
| 76 | + if (!File.ToString().Contains("android")) |
| 77 | + { |
| 78 | + RuntimeDependencies.Add(File.ToString()); |
| 79 | + } |
| 80 | + else if (VerboseBuild) |
| 81 | + { |
| 82 | + Log.TraceInformation("Not adding the following file as RuntimeDependency: "); |
| 83 | + Log.TraceInformation(File.ToString()); |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + private string[] windowsKnownPaths = |
47 | 92 | { |
48 | 93 | "C:/Program Files/Python37", |
49 | 94 | "C:/Program Files/Python36", |
@@ -247,6 +292,8 @@ public UnrealEnginePython(TargetInfo Target) |
247 | 292 |
|
248 | 293 | string dllPath = Path.Combine(BinariesPath, "Win64", string.Format("{0}.dll", PythonType.ToLower())); |
249 | 294 | RuntimeDependencies.Add(dllPath); |
| 295 | + |
| 296 | + AddRuntimeDependenciesForCopying(Target); |
250 | 297 | } |
251 | 298 | else if (PythonHome == "") |
252 | 299 | { |
|
0 commit comments