Made the codgen run on async

This commit is contained in:
Edward R. Gonzalez 2024-10-21 22:58:24 -04:00
parent a1a5f2f309
commit d4bf7cfaec
6 changed files with 114 additions and 94 deletions

Binary file not shown.

View File

@ -16,6 +16,9 @@ public:
// NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp // NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp
// They are used by GasaGen for the GasaDevOptionsCache // They are used by GasaGen for the GasaDevOptionsCache
UPROPERTY(Config)
TSoftObjectPtr<UDataTable> RandomBullshit;
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="GAS") UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="GAS")
TArray< TSoftObjectPtr<UDataTable>> AttributeSets; TArray< TSoftObjectPtr<UDataTable>> AttributeSets;

View File

@ -11,6 +11,9 @@ void FGasaDevOptionsCache::CachedDevOptions()
{ {
UGasaDevOptions* DevOpts = GetMutDevOptions(); UGasaDevOptions* DevOpts = GetMutDevOptions();
RandomBullshit = DevOpts->RandomBullshit.LoadSynchronous();
ensureMsgf( RandomBullshit != nullptr, TEXT( "RandomBullshit is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" ) );
for ( auto& entry : DevOpts->AttributeSets ) for ( auto& entry : DevOpts->AttributeSets )
{ {
AttributeSets.Push( entry.LoadSynchronous() ); AttributeSets.Push( entry.LoadSynchronous() );

View File

@ -8,6 +8,8 @@ struct GASA_API FGasaDevOptionsCache
{ {
GENERATED_BODY() GENERATED_BODY()
UPROPERTY()
UObject* RandomBullshit;
UPROPERTY() UPROPERTY()
TArray<UObject*> AttributeSets; TArray<UObject*> AttributeSets;
UPROPERTY() UPROPERTY()

View File

@ -5,6 +5,8 @@
// Editor Module // Editor Module
#include "GasaEditorCommon.h" #include "GasaEditorCommon.h"
#define LOCTEXT_NAMESPACE "GasaEditor"
global String Project_Path; global String Project_Path;
global String Root_Path; global String Root_Path;
@ -16,20 +18,25 @@ global Code UModule_GASA_API;
void Execute_GasaModule_Codegen() void Execute_GasaModule_Codegen()
{ {
FScopedSlowTask SlowTask(100.0f, LOCTEXT("RunningGasaGen", "Running GasaGen..."));
SlowTask.MakeDialog(); // Shows a progress dialog
AsyncTask(ENamedThreads::AnyBackgroundThreadNormalTask, [&SlowTask]()
{
Gasa::LogEditor("Executing: Gasa Module code generation."); Gasa::LogEditor("Executing: Gasa Module code generation.");
gen::init(); gen::init();
FString ue_project_path = FPaths::ConvertRelativePathToFull( FPaths::ProjectDir() ); FString ue_project_path = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
FPaths::NormalizeDirectoryName(ue_project_path); FPaths::NormalizeDirectoryName(ue_project_path);
char const* ue_ansi_project_path = TCHAR_TO_ANSI( * ue_project_path); char const* ue_ansi_project_path = TCHAR_TO_ANSI(*ue_project_path);
FString ue_root_path = FPaths::GetPath( ue_project_path ); FString ue_root_path = FPaths::GetPath(ue_project_path);
FPaths::NormalizeDirectoryName(ue_root_path); FPaths::NormalizeDirectoryName(ue_root_path);
char const* ue_ansi_rooot_path = TCHAR_TO_ANSI( * ue_project_path); char const* ue_ansi_rooot_path = TCHAR_TO_ANSI(*ue_project_path);
Project_Path = String::make_length(GlobalAllocator, ue_ansi_project_path, ue_project_path.Len() ); Project_Path = String::make_length(GlobalAllocator, ue_ansi_project_path, ue_project_path.Len());
Root_Path = String::make_length(GlobalAllocator, ue_ansi_rooot_path, ue_root_path.Len() ); Root_Path = String::make_length(GlobalAllocator, ue_ansi_rooot_path, ue_root_path.Len());
UE_LOG(LogTemp, Log, TEXT("Current ROOT Directory: %s"), *ue_project_path); UE_LOG(LogTemp, Log, TEXT("Current ROOT Directory: %s"), *ue_project_path);
UE_LOG(LogTemp, Log, TEXT("Current Project Directory: %s"), *ue_root_path); UE_LOG(LogTemp, Log, TEXT("Current Project Directory: %s"), *ue_root_path);
@ -45,11 +52,11 @@ void Execute_GasaModule_Codegen()
#undef USTRUCT #undef USTRUCT
#undef GENERATED_BODY #undef GENERATED_BODY
#undef GASA_API #undef GASA_API
UHT_UCLASS = code_str( UCLASS() ); UHT_UCLASS = code_str(UCLASS());
UHT_UPROPERTY = code_str( UPROPERTY() ); UHT_UPROPERTY = code_str(UPROPERTY());
UHT_USTRUCT = code_str( USTRUCT() ); UHT_USTRUCT = code_str(USTRUCT());
UHT_GENERATED_BODY = code_str( GENERATED_BODY()\n ); UHT_GENERATED_BODY = code_str(GENERATED_BODY()\n);
UModule_GASA_API = code_str( GASA_API ); UModule_GASA_API = code_str(GASA_API);
#pragma pop_macro("UCLASS") #pragma pop_macro("UCLASS")
#pragma pop_macro("UPROPERTY") #pragma pop_macro("UPROPERTY")
#pragma pop_macro("USTRUCT") #pragma pop_macro("USTRUCT")
@ -59,50 +66,50 @@ void Execute_GasaModule_Codegen()
// Populate Defines // Populate Defines
{ {
PreprocessorDefines.append( get_cached_string(str_DECLARE_CLASS)); PreprocessorDefines.append(get_cached_string(str_DECLARE_CLASS));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DELEGATE_RetVal_OneParam));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DELEGATE_RetVal_ThreeParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DELEGATE_SixParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DELEGATE_SixParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FiveParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_FourParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_NineParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SevenParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_ThreeParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_EVENT_ThreeParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_EVENT_TwoParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_EVENT_TwoParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_FUNCTION)); PreprocessorDefines.append(get_cached_string(str_DECLARE_FUNCTION));
PreprocessorDefines.append( get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN)); PreprocessorDefines.append(get_cached_string(str_DECLARE_LOG_CATEGORY_EXTERN));
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam)); PreprocessorDefines.append(get_cached_string(str_DECLARE_MULTICAST_DELEGATE_OneParam));
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_MULTICAST_DELEGATE_ThreeParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_MULTICAST_DELEGATE_TwoParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam)); PreprocessorDefines.append(get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_OneParam));
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_TwoParams));
PreprocessorDefines.append( get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams)); PreprocessorDefines.append(get_cached_string(str_DECLARE_TS_MULTICAST_DELEGATE_ThreeParams));
PreprocessorDefines.append( get_cached_string(str_DEFINE_ACTORDESC_TYPE)); PreprocessorDefines.append(get_cached_string(str_DEFINE_ACTORDESC_TYPE));
PreprocessorDefines.append( get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL)); PreprocessorDefines.append(get_cached_string(str_DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL));
PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS)); PreprocessorDefines.append(get_cached_string(str_ENUM_CLASS_FLAGS));
PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE)); PreprocessorDefines.append(get_cached_string(str_FORCEINLINE_DEBUGGABLE));
// PreprocessorDefines.append( get_cached_string(str_FORCEINLINE)); // PreprocessorDefines.append( get_cached_string(str_FORCEINLINE));
PreprocessorDefines.append( get_cached_string(str_GENERATED_BODY)); PreprocessorDefines.append(get_cached_string(str_GENERATED_BODY));
PreprocessorDefines.append( get_cached_string(str_GENERATED_UCLASS_BODY)); PreprocessorDefines.append(get_cached_string(str_GENERATED_UCLASS_BODY));
PreprocessorDefines.append( get_cached_string(str_GENERATED_USTRUCT_BODY)); PreprocessorDefines.append(get_cached_string(str_GENERATED_USTRUCT_BODY));
PreprocessorDefines.append( get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS)); PreprocessorDefines.append(get_cached_string(str_PRAGMA_DISABLE_DEPRECATION_WARNINGS));
PreprocessorDefines.append( get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS)); PreprocessorDefines.append(get_cached_string(str_PRAGMA_ENABLE_DEPRECATION_WARNINGS));
PreprocessorDefines.append( get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION)); PreprocessorDefines.append(get_cached_string(str_PROPERTY_BINDING_IMPLEMENTATION));
PreprocessorDefines.append( get_cached_string(str_RESULT_DECL)); PreprocessorDefines.append(get_cached_string(str_RESULT_DECL));
PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS)); PreprocessorDefines.append(get_cached_string(str_SLATE_BEGIN_ARGS));
PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS)); PreprocessorDefines.append(get_cached_string(str_SLATE_END_ARGS));
PreprocessorDefines.append( get_cached_string(str_TEXT)); PreprocessorDefines.append(get_cached_string(str_TEXT));
PreprocessorDefines.append( get_cached_string(str_UCLASS)); PreprocessorDefines.append(get_cached_string(str_UCLASS));
PreprocessorDefines.append( get_cached_string(str_UENUM)); PreprocessorDefines.append(get_cached_string(str_UENUM));
PreprocessorDefines.append( get_cached_string(str_UFUNCTION)); PreprocessorDefines.append(get_cached_string(str_UFUNCTION));
PreprocessorDefines.append( get_cached_string(str_UMETA)); PreprocessorDefines.append(get_cached_string(str_UMETA));
PreprocessorDefines.append( get_cached_string(str_UPARAM)); PreprocessorDefines.append(get_cached_string(str_UPARAM));
PreprocessorDefines.append( get_cached_string(str_UPROPERTY)); PreprocessorDefines.append(get_cached_string(str_UPROPERTY));
PreprocessorDefines.append( get_cached_string(str_USTRUCT)); PreprocessorDefines.append(get_cached_string(str_USTRUCT));
PreprocessorDefines.append( get_cached_string(str_UE_REQUIRES)); PreprocessorDefines.append(get_cached_string(str_UE_REQUIRES));
} }
//generate_AttributeSets(); //generate_AttributeSets();
@ -110,5 +117,13 @@ void Execute_GasaModule_Codegen()
//generate_HostWidgetController(); //generate_HostWidgetController();
gen::deinit(); gen::deinit();
AsyncTask(ENamedThreads::GameThread, []()
{
// UI updates if needed
});
});
} }
#undef LOCTEXT_NAMESPACE

View File

@ -6,8 +6,6 @@
#undef GASA_API #undef GASA_API
#undef ensureMsgf #undef ensureMsgf
PRAGMA_DISABLE_OPTIMIZATION
void generate_DevOptionsCache() void generate_DevOptionsCache()
{ {
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator); Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator);
@ -162,7 +160,6 @@ void generate_DevOptionsCache()
format_file( path_module_gasa "GasaDevOptionsCache.cpp" ); format_file( path_module_gasa "GasaDevOptionsCache.cpp" );
} }
} }
PRAGMA_ENABLE_OPTIMIZATION
#pragma pop_macro("ensureMsgf") #pragma pop_macro("ensureMsgf")
#pragma pop_macro("GASA_API") #pragma pop_macro("GASA_API")