Skip to content

Commit 8deceb4

Browse files
authored
feat: prepare for engine plugin packaging (#19)
1 parent e0e9f2c commit 8deceb4

File tree

9 files changed

+95
-41
lines changed

9 files changed

+95
-41
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ compile_commands.json
8080
# Generated Ecsact files
8181

8282
Source/**/*.ecsact.*
83+
84+
# Distribution files
85+
/Dist

Ecsact.uplugin

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"CanContainContent": true,
1414
"IsBetaVersion": true,
1515
"IsExperimentalVersion": false,
16-
"Installed": false,
16+
"Installed": true,
17+
"EngineVersion": "5.5.0",
18+
"EnabledByDefault": false,
1719
"Modules":
1820
[
1921
{

Source/Ecsact/Ecsact.Build.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ public Ecsact(ReadOnlyTargetRules Target) : base(Target) {
3232
"SlateCore",
3333
});
3434

35-
DynamicallyLoadedModuleNames.AddRange(new string[] {
36-
"EcsactUnrealCodegenPlugin",
37-
});
38-
//
39-
40-
var EcsactUnrealCodegenPluginPath = Path.Combine(
41-
ModuleDirectory,
42-
"..",
43-
"..",
44-
"Binaries",
45-
Target.Platform.ToString(),
46-
"UnrealEditor-EcsactUnrealCodegenPlugin.dll"
47-
);
48-
4935
if(Target.bBuildEditor) {
5036
PrivateDependencyModuleNames.Add("UnrealEd");
5137
}
@@ -78,31 +64,6 @@ public Ecsact(ReadOnlyTargetRules Target) : base(Target) {
7864
"ECSACT_STATIC_API_EXPORT",
7965
"ECSACT_SI_WASM_API_EXPORT",
8066
});
81-
82-
var EcsactSources = GetEcsactSources();
83-
84-
if(EcsactSources.Length > 0) {
85-
var CodegenArgs = new List<string>() {
86-
"codegen",
87-
"--format=json",
88-
"--plugin=cpp_header",
89-
// "--plugin=systems_header",
90-
// "--plugin=cpp_systems_header",
91-
// "--plugin=cpp_systems_source"
92-
};
93-
94-
if(!File.Exists(EcsactUnrealCodegenPluginPath)) {
95-
Console.WriteLine(
96-
"warning: EcsactUnrealCodegenPlugin was not built. It should have " +
97-
"been shipped with the Ecsact Unreal integration plugin."
98-
);
99-
} else {
100-
CodegenArgs.Add($"--plugin={EcsactUnrealCodegenPluginPath}");
101-
}
102-
103-
CodegenArgs.AddRange(EcsactSources);
104-
ExecEcsactCli(CodegenArgs);
105-
}
10667
}
10768

10869
private string[] GetEcsactSources() {

Source/Ecsact/Public/EcsactUnreal/EcsactAsyncRunnerEvents.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "CoreMinimal.h"
4+
#include "UObject/Interface.h"
45
#include "ecsact/runtime/common.h"
56
#include "ecsact/runtime/async.h"
67
#include "EcsactAsyncRunnerEvents.generated.h"

Source/Ecsact/Public/EcsactUnreal/EcsactBlueprintLibrary.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include "Kismet/BlueprintFunctionLibrary.h"
34
#include "EcsactBlueprintLibrary.generated.h"
45

56
UCLASS()

Source/Ecsact/Public/EcsactUnreal/EcsactRunner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ECSACT_API UEcsactRunner : public UObject, public FTickableGameObject {
8888

8989
virtual auto OnWorldChanged(UWorld* OldWorld, UWorld* NewWorld) -> void;
9090

91-
UFUNCTION(BlueprintPure)
91+
UFUNCTION(BlueprintPure, Category = "Ecsact Runner")
9292
bool HasAsyncEvents() const;
9393

9494
auto Tick(float DeltaTime) -> void override;

Source/EcsactUnrealCodegenPlugin/EcsactUnrealCodegenPlugin.Build.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public EcsactUnrealCodegenPlugin(ReadOnlyTargetRules Target) : base(Target) {
1818
// Codegen plugins utilise the ecsact 'meta' module
1919
PrivateDefinitions.AddRange(new string[] {
2020
"ECSACT_META_API_LOAD_AT_RUNTIME",
21+
"ECSACT_META_API_EXPORT",
2122
});
2223
}
2324

Tools/DevInstall.nu

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use Package.nu package-plugin
2+
3+
def main [--ue-install-dir: string] {
4+
let info = package-plugin --ue-install-dir $ue_install_dir;
5+
let engine_plugins_dir = [$info.ue_install, "Engine", "Plugins", "Marketplace"] | path join;
6+
let plugin_extract_dir = [$engine_plugins_dir, $info.plugin_name] | path join;
7+
8+
print $"Extracting ($info.plugin_name) to ($plugin_extract_dir)";
9+
mkdir $plugin_extract_dir;
10+
tar -xf $info.plugin_archive -C $plugin_extract_dir;
11+
print $"(ansi green)Unreal ($info.plugin_name) successfully installed to ($engine_plugins_dir)(ansi reset)";
12+
}

Tools/Package.nu

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
def get-ue-install-dirs [] {
2+
if (sys host | get name) != "Windows" {
3+
print "Automatic unreal detection only supported on Windows"
4+
print "Please specify the --ue-install-dir option"
5+
exit 1
6+
}
7+
8+
let eng_reg_version_keys = ^reg.exe query 'HKLM\SOFTWARE\EpicGames\Unreal Engine' | str trim | lines;
9+
$eng_reg_version_keys | each {|key|
10+
^reg.exe query $key /v 'InstalledDirectory' | str trim | lines | get 1 | str trim | split column ' ' key type value | get value
11+
} | flatten
12+
}
13+
14+
def get-ue-os [] {
15+
match (sys host | get name) {
16+
"Windows" => "Win64",
17+
"Ubuntu" => "Linux",
18+
_ => {
19+
print $"unhandled host (sys host)"
20+
exit 1
21+
}
22+
}
23+
}
24+
25+
def ue-tool-extension [] {
26+
match (sys host | get name) {
27+
"Windows" => "bat",
28+
_ => "sh",
29+
}
30+
}
31+
32+
export def package-plugin [--ue-install-dir: string] {
33+
let install_dirs = if $ue_install_dir != null { [$ue_install_dir] } else { get-ue-install-dirs };
34+
let plugin_dir = $env.FILE_PWD | path join '..' | path expand;
35+
let dist_dir = [$plugin_dir, 'Dist'] | path join;
36+
mkdir $dist_dir;
37+
cd $plugin_dir;
38+
let plugin_descriptor_filename = (ls *.uplugin).0.name;
39+
let plugin_name = $plugin_descriptor_filename | split row ".uplugin" | get 0;
40+
let dist_archive = [$plugin_dir, 'Dist', $"($plugin_name)Unreal-(get-ue-os).zip"] | path join;
41+
let plugin_descriptor = [$plugin_dir, $plugin_descriptor_filename] | path join;
42+
let temp_package_dir = mktemp -d --suffix $"($plugin_name)UnrealPluginPackage";
43+
44+
if ($install_dirs | length) == 0 {
45+
print "Could not find Unreal Engine installation on your system";
46+
exit 1;
47+
}
48+
49+
let install_dir = if ($install_dirs | length) > 1 {
50+
$install_dirs | input list
51+
} else {
52+
$install_dirs | get 0
53+
};
54+
55+
print $"using ($install_dir)";
56+
57+
let engine_dir = [$install_dir, 'Engine'] | path join;
58+
let uat = [$engine_dir, 'Build', 'BatchFiles', $"RunUAT.(ue-tool-extension)"] | path join;
59+
^$uat BuildPlugin $"-Plugin=($plugin_descriptor)" $"-Package=($temp_package_dir)";
60+
61+
tar -a -cf $dist_archive -C $temp_package_dir '*';
62+
rm -rf $temp_package_dir;
63+
64+
return {
65+
ue_install: $install_dir,
66+
plugin_name: $plugin_name,
67+
plugin_archive: $dist_archive,
68+
};
69+
}
70+
71+
def main [--ue-install-dir: string] {
72+
package-plugin --ue-install-dir $ue_install_dir
73+
}

0 commit comments

Comments
 (0)