1
- // Copyright Epic Games, Inc. All Rights Reserved.
2
-
3
- using UnrealBuildTool ;
4
- using System . Collections . Generic ;
5
- using System . IO ;
6
-
7
- public abstract class MobuLiveLinkPluginTargetBase : TargetRules
8
- {
9
- public MobuLiveLinkPluginTargetBase ( TargetInfo Target , string InMobuVersionString ) : base ( Target )
10
- {
11
- Type = TargetType . Program ;
12
-
13
- bShouldCompileAsDLL = true ;
14
- LinkType = TargetLinkType . Monolithic ;
15
- SolutionDirectory = "Programs/LiveLink" ;
16
-
17
- bool bIsNotForLicensees = false ;
18
- string NotForLicenseesFolder = bIsNotForLicensees ? "NotForLicensees" : "" ;
19
-
20
- ExeBinariesSubFolder = Path . Combine ( NotForLicenseesFolder , "MotionBuilder" , InMobuVersionString ) ;
21
- LaunchModuleName = "MobuLiveLinkPlugin" + InMobuVersionString ;
22
-
23
- // We only need minimal use of the engine for this plugin
24
- bBuildDeveloperTools = false ;
25
- bUseMallocProfiler = false ;
26
- bBuildWithEditorOnlyData = true ;
27
- bCompileAgainstEngine = false ;
28
- bCompileAgainstCoreUObject = true ;
29
- bCompileICU = false ;
30
- bHasExports = false ;
31
-
32
- string ResourcesFolder = Path . GetFullPath ( Path . Combine ( "Programs" , NotForLicenseesFolder , "MobuLiveLink/Resources" ) ) ;
33
- string BinariesDirectory = Path . GetFullPath ( Path . Combine ( "../Binaries" , "Win64" , NotForLicenseesFolder , "MotionBuilder" , InMobuVersionString ) ) ;
34
- PostBuildSteps . Add ( string . Format ( "echo Copying {0} to {1}..." , ResourcesFolder , BinariesDirectory ) ) ;
35
- PostBuildSteps . Add ( string . Format ( "copy /a /b /y /v \" {0}\\ *.*\" \" {1}\" 1>nul" , ResourcesFolder , BinariesDirectory ) ) ;
36
- }
37
- }
38
-
39
- public class MobuLiveLinkPlugin2017Target : MobuLiveLinkPluginTargetBase
40
- {
41
- public MobuLiveLinkPlugin2017Target ( TargetInfo Target ) : base ( Target , "2017" )
42
- { }
43
- }
1
+ // Copyright Epic Games, Inc. All Rights Reserved.
2
+
3
+ using UnrealBuildTool ;
4
+ using System ;
5
+ using System . IO ;
6
+ using Tools . DotNETCommon ;
7
+ using System . Runtime . CompilerServices ;
8
+
9
+ [ SupportedPlatforms ( UnrealPlatformClass . Desktop ) ]
10
+ public abstract class MobuLiveLinkPluginTargetBase : TargetRules
11
+ {
12
+ /// <summary>
13
+ /// Finds the innermost parent directory with the provided name. Search is case insensitive.
14
+ /// </summary>
15
+ string InnermostParentDirectoryPathWithName ( string ParentName , string CurrentPath )
16
+ {
17
+ DirectoryInfo ParentInfo = Directory . GetParent ( CurrentPath ) ;
18
+
19
+ if ( ParentInfo == null )
20
+ {
21
+ throw new DirectoryNotFoundException ( "Could not find parent folder '" + ParentName + "'" ) ;
22
+ }
23
+
24
+ // Case-insensitive check of the parent folder name.
25
+ if ( ParentInfo . Name . ToLower ( ) == ParentName . ToLower ( ) )
26
+ {
27
+ return ParentInfo . ToString ( ) ;
28
+ }
29
+
30
+ return InnermostParentDirectoryPathWithName ( ParentName , ParentInfo . ToString ( ) ) ;
31
+ }
32
+
33
+ /// <summary>
34
+ /// Returns the path to this .cs file.
35
+ /// </summary>
36
+ string GetCallerFilePath ( [ CallerFilePath ] string CallerFilePath = "" )
37
+ {
38
+ if ( CallerFilePath . Length == 0 )
39
+ {
40
+ throw new FileNotFoundException ( "Could not find the path of our .cs file" ) ;
41
+ }
42
+
43
+ return CallerFilePath ;
44
+ }
45
+
46
+ public MobuLiveLinkPluginTargetBase ( TargetInfo Target , string InMobuVersionString ) : base ( Target )
47
+ {
48
+ Type = TargetType . Program ;
49
+
50
+ bShouldCompileAsDLL = true ;
51
+ LinkType = TargetLinkType . Monolithic ;
52
+ SolutionDirectory = "Programs/LiveLink" ;
53
+ LaunchModuleName = "MobuLiveLinkPlugin" + InMobuVersionString ;
54
+
55
+ // We only need minimal use of the engine for this plugin
56
+ bBuildDeveloperTools = false ;
57
+ bUseMallocProfiler = false ;
58
+ bBuildWithEditorOnlyData = true ;
59
+ bCompileAgainstEngine = false ;
60
+ bCompileAgainstCoreUObject = true ;
61
+ bCompileICU = false ;
62
+ bHasExports = false ;
63
+
64
+ // This .cs file must be inside the source folder of this Program. We later use this to find other key directories.
65
+ string TargetFilePath = GetCallerFilePath ( ) ;
66
+
67
+ // We need to avoid failing to load DLL due to looking for EngineDir() in non-existent folders.
68
+ // By having it build in the same directory as the engine, it will assume the engine is in the same directory
69
+ // as the program, and because this folder always exists, it will not fail the check inside EngineDir().
70
+
71
+ // Because this is a Program, we assume that this target file resides under a "Programs" folder.
72
+ string ProgramsDir = InnermostParentDirectoryPathWithName ( "Programs" , TargetFilePath ) ;
73
+
74
+ // We assume this Program resides under a Source folder.
75
+ string SourceDir = InnermostParentDirectoryPathWithName ( "Source" , ProgramsDir ) ;
76
+
77
+ // The program is assumed to reside inside the "Engine" folder.
78
+ string EngineDir = InnermostParentDirectoryPathWithName ( "Engine" , SourceDir ) ;
79
+
80
+ // The default Binaries path is assumed to be a sibling of "Source" folder.
81
+ string DefaultBinDir = Path . GetFullPath ( Path . Combine ( SourceDir , ".." , "Binaries" , Platform . ToString ( ) ) ) ;
82
+
83
+ // We assume that the engine exe resides in Engine/Binaries/[Platform]
84
+ string EngineBinariesDir = Path . Combine ( EngineDir , "Binaries" , Platform . ToString ( ) ) ;
85
+
86
+ // Now we calculate the relative path between the default output directory and the engine binaries,
87
+ // in order to force the output of this program to be in the same folder as th engine.
88
+ ExeBinariesSubFolder = ( new DirectoryReference ( EngineBinariesDir ) ) . MakeRelativeTo ( new DirectoryReference ( DefaultBinDir ) ) ;
89
+
90
+ // Setting this is necessary since we are creating the binaries outside of Restricted.
91
+ bLegalToDistributeBinary = true ;
92
+
93
+ // We still need to copy the resources, so at this point we might as well copy the files where the default Binaries folder was meant to be.
94
+ // MobuLiveLinkPlugin.xml will be unaware of how the files got there.
95
+
96
+ string ResourcesDir = Path . Combine ( ProgramsDir , "MobuLiveLink" , "Resources" ) ;
97
+ string PostBuildBinDir = Path . Combine ( DefaultBinDir , "MotionBuilder" , InMobuVersionString ) ;
98
+
99
+ // Copy resources
100
+ PostBuildSteps . Add ( string . Format ( "echo Copying {0} to {1}..." , ResourcesDir , PostBuildBinDir ) ) ;
101
+ PostBuildSteps . Add ( string . Format ( "xcopy /y /i /v \" {0}\\ *.*\" \" {1}\" 1>nul" , ResourcesDir , PostBuildBinDir ) ) ;
102
+
103
+ // Copy binaries
104
+ PostBuildSteps . Add ( string . Format ( "echo Copying {0} to {1}..." , EngineBinariesDir , PostBuildBinDir ) ) ;
105
+ PostBuildSteps . Add ( string . Format ( "xcopy /y /i /v \" {0}\\ {1}.*\" \" {2}\" 1>nul" , EngineBinariesDir , LaunchModuleName , PostBuildBinDir ) ) ;
106
+ }
107
+ }
108
+
109
+ public class MobuLiveLinkPlugin2017Target : MobuLiveLinkPluginTargetBase
110
+ {
111
+ public MobuLiveLinkPlugin2017Target ( TargetInfo Target ) : base ( Target , "2017" )
112
+ {
113
+ //Mobu is not strict c++ compliant before Mobu 2019
114
+ WindowsPlatform . bStrictConformanceMode = false ;
115
+ }
116
+ }
0 commit comments