Skip to content

Commit d1b2fd3

Browse files
committed
feat: support embeded Ecsact SDK in ThirdParty folder
1 parent 806de5a commit d1b2fd3

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@ Source/**/*.ecsact.*
8383

8484
# Distribution files
8585
/Dist
86+
87+
# Third party files that get filled in with release script
88+
/ThirdParty

Source/Ecsact/Ecsact.Build.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ public Ecsact(ReadOnlyTargetRules Target) : base(Target) {
4040
PrivateDependencyModuleNames.Add("UnrealEd");
4141
}
4242

43-
var EcsactSdkVersion = GetEcsactSdkVersion();
44-
Environment.SetEnvironmentVariable(
45-
"EcsactPlugin_SdkVersion",
46-
EcsactSdkVersion
47-
);
43+
SetupEcsactSDK();
44+
}
4845

46+
private void SetupEcsactSDK() {
47+
var EcsactSdkVersion = GetEcsactSdkVersion();
4948
var EcsactSdkIncludeDir = GetEcsactSdkIncludeDir();
5049
PublicIncludePaths.Add(EcsactSdkIncludeDir);
5150

52-
// NOTE: For now these APIs are loaded on module startup
5351
PublicDefinitions.AddRange(new string[] {
52+
"WITH_ECSACT_SDK",
53+
// NOTE: For now these APIs are loaded on module startup
5454
"ECSACT_CORE_API_LOAD_AT_RUNTIME",
5555
"ECSACT_DYNAMIC_API_LOAD_AT_RUNTIME",
5656
"ECSACT_ASYNC_API_LOAD_AT_RUNTIME",
@@ -84,7 +84,7 @@ private string GetEcsactSdkVersion() {
8484

8585
try {
8686
var startInfo = new ProcessStartInfo();
87-
startInfo.FileName = "ecsact";
87+
startInfo.FileName = GetEcsactSdkBinary("ecsact");
8888
startInfo.Arguments = "--version";
8989
startInfo.RedirectStandardOutput = true;
9090
startInfo.UseShellExecute = false;
@@ -111,7 +111,7 @@ private string GetEcsactSdkIncludeDir() {
111111

112112
try {
113113
var startInfo = new ProcessStartInfo();
114-
startInfo.FileName = "ecsact";
114+
startInfo.FileName = GetEcsactSdkBinary("ecsact");
115115
startInfo.Arguments = "config include_dir";
116116
startInfo.RedirectStandardOutput = true;
117117
startInfo.UseShellExecute = false;
@@ -129,10 +129,21 @@ private string GetEcsactSdkIncludeDir() {
129129
return includePath;
130130
}
131131

132+
private string GetEcsactSdkBinary(string binaryName) {
133+
var thirdPartyEcsactSdk =
134+
Path.Combine(PluginDirectory, "ThirdParty/EcsactSDK");
135+
var exePath = Path.Combine(thirdPartyEcsactSdk, $"bin/{binaryName}.exe");
136+
if(File.Exists(exePath)) {
137+
return exePath;
138+
}
139+
140+
return binaryName;
141+
}
142+
132143
private void ExecEcsactCli(IList<string> Args) {
133144
try {
134145
var StartInfo = new ProcessStartInfo();
135-
StartInfo.FileName = "ecsact";
146+
StartInfo.FileName = GetEcsactSdkBinary("ecsact");
136147
foreach(var Arg in Args) {
137148
StartInfo.ArgumentList.Add(Arg);
138149
}

Source/EcsactUnrealCodegenPlugin/EcsactUnrealCodegenPlugin.Build.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,30 @@ public EcsactUnrealCodegenPlugin(ReadOnlyTargetRules Target) : base(Target) {
3030

3131
private string GetEcsactSdkIncludeDir() {
3232
var includePath = "";
33-
34-
try {
35-
var startInfo = new ProcessStartInfo();
36-
startInfo.FileName = "ecsact";
37-
startInfo.Arguments = "config include_dir";
38-
startInfo.RedirectStandardOutput = true;
39-
startInfo.UseShellExecute = false;
40-
startInfo.CreateNoWindow = true;
41-
42-
using(Process process = Process.Start(startInfo)) {
43-
using(StreamReader reader = process.StandardOutput) {
44-
includePath = reader.ReadToEnd().Trim();
45-
}
33+
var startInfo = new ProcessStartInfo();
34+
startInfo.FileName = GetEcsactSdkBinary("ecsact");
35+
startInfo.Arguments = "config include_dir";
36+
startInfo.RedirectStandardOutput = true;
37+
startInfo.UseShellExecute = false;
38+
startInfo.CreateNoWindow = true;
39+
40+
using(Process process = Process.Start(startInfo)) {
41+
using(StreamReader reader = process.StandardOutput) {
42+
includePath = reader.ReadToEnd().Trim();
4643
}
47-
} catch(Exception err) {
48-
throw new EcsactSdkNotFound(err);
4944
}
5045

5146
return includePath;
5247
}
48+
49+
private string GetEcsactSdkBinary(string binaryName) {
50+
var thirdPartyEcsactSdk =
51+
Path.Combine(PluginDirectory, "ThirdParty/EcsactSDK");
52+
var exePath = Path.Combine(thirdPartyEcsactSdk, $"bin/{binaryName}.exe");
53+
if(File.Exists(exePath)) {
54+
return exePath;
55+
}
56+
57+
return binaryName;
58+
}
5359
}

0 commit comments

Comments
 (0)