From d4bf7cfaecb36a027d8330338d67746e191e82e0 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 21 Oct 2024 22:58:24 -0400 Subject: [PATCH] Made the codgen run on async --- .../Win64/UnrealEditor-GasaEditor.dll | 4 +- Project/Source/Gasa/GasaDevOptions.h | 3 + Project/Source/Gasa/GasaDevOptionsCache.cpp | 3 + Project/Source/Gasa/GasaDevOptionsCache.h | 2 + Project/Source/GasaEditor/GasaGen/GasaGen.cpp | 193 ++++++++++-------- .../GasaGen/GasaGen_DevOptionsCache.cpp | 3 - 6 files changed, 114 insertions(+), 94 deletions(-) diff --git a/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll b/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll index cd288f0..5170be4 100644 --- a/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll +++ b/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:91601ca4d02d2526c1f8617d2b10bdaa834c84ff91fbf11d68a08078fc171705 -size 50489856 +oid sha256:8e6d4de45e8d1f8b377c1608105ce1674d62304a7a0b1abde1afac5db1ba05bd +size 50490368 diff --git a/Project/Source/Gasa/GasaDevOptions.h b/Project/Source/Gasa/GasaDevOptions.h index 08eb3e4..ace3341 100644 --- a/Project/Source/Gasa/GasaDevOptions.h +++ b/Project/Source/Gasa/GasaDevOptions.h @@ -16,6 +16,9 @@ public: // NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp // They are used by GasaGen for the GasaDevOptionsCache + UPROPERTY(Config) + TSoftObjectPtr RandomBullshit; + UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="GAS") TArray< TSoftObjectPtr> AttributeSets; diff --git a/Project/Source/Gasa/GasaDevOptionsCache.cpp b/Project/Source/Gasa/GasaDevOptionsCache.cpp index 0fcbaff..0a11041 100644 --- a/Project/Source/Gasa/GasaDevOptionsCache.cpp +++ b/Project/Source/Gasa/GasaDevOptionsCache.cpp @@ -11,6 +11,9 @@ void FGasaDevOptionsCache::CachedDevOptions() { 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 ) { AttributeSets.Push( entry.LoadSynchronous() ); diff --git a/Project/Source/Gasa/GasaDevOptionsCache.h b/Project/Source/Gasa/GasaDevOptionsCache.h index 1cb942a..fbabc9a 100644 --- a/Project/Source/Gasa/GasaDevOptionsCache.h +++ b/Project/Source/Gasa/GasaDevOptionsCache.h @@ -8,6 +8,8 @@ struct GASA_API FGasaDevOptionsCache { GENERATED_BODY() + UPROPERTY() + UObject* RandomBullshit; UPROPERTY() TArray AttributeSets; UPROPERTY() diff --git a/Project/Source/GasaEditor/GasaGen/GasaGen.cpp b/Project/Source/GasaEditor/GasaGen/GasaGen.cpp index 5583cf7..39aacf7 100644 --- a/Project/Source/GasaEditor/GasaGen/GasaGen.cpp +++ b/Project/Source/GasaEditor/GasaGen/GasaGen.cpp @@ -5,6 +5,8 @@ // Editor Module #include "GasaEditorCommon.h" +#define LOCTEXT_NAMESPACE "GasaEditor" + global String Project_Path; global String Root_Path; @@ -16,99 +18,112 @@ global Code UModule_GASA_API; void Execute_GasaModule_Codegen() { - Gasa::LogEditor("Executing: Gasa Module code generation."); + FScopedSlowTask SlowTask(100.0f, LOCTEXT("RunningGasaGen", "Running GasaGen...")); + SlowTask.MakeDialog(); // Shows a progress dialog - gen::init(); - - FString ue_project_path = FPaths::ConvertRelativePathToFull( FPaths::ProjectDir() ); - FPaths::NormalizeDirectoryName(ue_project_path); - char const* ue_ansi_project_path = TCHAR_TO_ANSI( * ue_project_path); - - FString ue_root_path = FPaths::GetPath( ue_project_path ); - FPaths::NormalizeDirectoryName(ue_root_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() ); - 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 Project Directory: %s"), *ue_root_path); - - // Initialize Globals + AsyncTask(ENamedThreads::AnyBackgroundThreadNormalTask, [&SlowTask]() { - #pragma push_macro("UCLASS") - #pragma push_macro("UPROPERTY") - #pragma push_macro("USTRUCT") - #pragma push_macro("GENERATED_BODY") - #pragma push_macro("GASA_API") - #undef UCLASS - #undef UPROPERTY - #undef USTRUCT - #undef GENERATED_BODY - #undef GASA_API - UHT_UCLASS = code_str( UCLASS() ); - UHT_UPROPERTY = code_str( UPROPERTY() ); - UHT_USTRUCT = code_str( USTRUCT() ); - UHT_GENERATED_BODY = code_str( GENERATED_BODY()\n ); - UModule_GASA_API = code_str( GASA_API ); - #pragma pop_macro("UCLASS") - #pragma pop_macro("UPROPERTY") - #pragma pop_macro("USTRUCT") - #pragma pop_macro("GENERATED_BODY") - #pragma pop_macro("GASA_API") - } + Gasa::LogEditor("Executing: Gasa Module code generation."); - // Populate Defines - { - 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_ThreeParams)); - 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_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_NineParams)); - 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_TwoParams)); - 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_FUNCTION)); - 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_ThreeParams)); - 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_TwoParams)); - 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_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL)); - PreprocessorDefines.append( get_cached_string(str_ENUM_CLASS_FLAGS)); - PreprocessorDefines.append( get_cached_string(str_FORCEINLINE_DEBUGGABLE)); - // PreprocessorDefines.append( get_cached_string(str_FORCEINLINE)); - PreprocessorDefines.append( get_cached_string(str_GENERATED_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_PRAGMA_DISABLE_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_RESULT_DECL)); - PreprocessorDefines.append( get_cached_string(str_SLATE_BEGIN_ARGS)); - PreprocessorDefines.append( get_cached_string(str_SLATE_END_ARGS)); - PreprocessorDefines.append( get_cached_string(str_TEXT)); - PreprocessorDefines.append( get_cached_string(str_UCLASS)); - PreprocessorDefines.append( get_cached_string(str_UENUM)); - PreprocessorDefines.append( get_cached_string(str_UFUNCTION)); - PreprocessorDefines.append( get_cached_string(str_UMETA)); - PreprocessorDefines.append( get_cached_string(str_UPARAM)); - PreprocessorDefines.append( get_cached_string(str_UPROPERTY)); - PreprocessorDefines.append( get_cached_string(str_USTRUCT)); - PreprocessorDefines.append( get_cached_string(str_UE_REQUIRES)); - } + gen::init(); - //generate_AttributeSets(); - generate_DevOptionsCache(); - //generate_HostWidgetController(); + FString ue_project_path = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir()); + FPaths::NormalizeDirectoryName(ue_project_path); + char const* ue_ansi_project_path = TCHAR_TO_ANSI(*ue_project_path); - gen::deinit(); + FString ue_root_path = FPaths::GetPath(ue_project_path); + FPaths::NormalizeDirectoryName(ue_root_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()); + 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 Project Directory: %s"), *ue_root_path); + + // Initialize Globals + { + #pragma push_macro("UCLASS") + #pragma push_macro("UPROPERTY") + #pragma push_macro("USTRUCT") + #pragma push_macro("GENERATED_BODY") + #pragma push_macro("GASA_API") + #undef UCLASS + #undef UPROPERTY + #undef USTRUCT + #undef GENERATED_BODY + #undef GASA_API + UHT_UCLASS = code_str(UCLASS()); + UHT_UPROPERTY = code_str(UPROPERTY()); + UHT_USTRUCT = code_str(USTRUCT()); + UHT_GENERATED_BODY = code_str(GENERATED_BODY()\n); + UModule_GASA_API = code_str(GASA_API); + #pragma pop_macro("UCLASS") + #pragma pop_macro("UPROPERTY") + #pragma pop_macro("USTRUCT") + #pragma pop_macro("GENERATED_BODY") + #pragma pop_macro("GASA_API") + } + + // Populate Defines + { + 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_ThreeParams)); + 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_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_NineParams)); + 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_TwoParams)); + 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_FUNCTION)); + 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_ThreeParams)); + 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_TwoParams)); + 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_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL)); + PreprocessorDefines.append(get_cached_string(str_ENUM_CLASS_FLAGS)); + PreprocessorDefines.append(get_cached_string(str_FORCEINLINE_DEBUGGABLE)); + // PreprocessorDefines.append( get_cached_string(str_FORCEINLINE)); + PreprocessorDefines.append(get_cached_string(str_GENERATED_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_PRAGMA_DISABLE_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_RESULT_DECL)); + PreprocessorDefines.append(get_cached_string(str_SLATE_BEGIN_ARGS)); + PreprocessorDefines.append(get_cached_string(str_SLATE_END_ARGS)); + PreprocessorDefines.append(get_cached_string(str_TEXT)); + PreprocessorDefines.append(get_cached_string(str_UCLASS)); + PreprocessorDefines.append(get_cached_string(str_UENUM)); + PreprocessorDefines.append(get_cached_string(str_UFUNCTION)); + PreprocessorDefines.append(get_cached_string(str_UMETA)); + PreprocessorDefines.append(get_cached_string(str_UPARAM)); + PreprocessorDefines.append(get_cached_string(str_UPROPERTY)); + PreprocessorDefines.append(get_cached_string(str_USTRUCT)); + PreprocessorDefines.append(get_cached_string(str_UE_REQUIRES)); + } + + //generate_AttributeSets(); + generate_DevOptionsCache(); + //generate_HostWidgetController(); + + gen::deinit(); + + AsyncTask(ENamedThreads::GameThread, []() + { + // UI updates if needed + }); + }); } +#undef LOCTEXT_NAMESPACE + diff --git a/Project/Source/GasaEditor/GasaGen/GasaGen_DevOptionsCache.cpp b/Project/Source/GasaEditor/GasaGen/GasaGen_DevOptionsCache.cpp index 7057ff4..9f22504 100644 --- a/Project/Source/GasaEditor/GasaGen/GasaGen_DevOptionsCache.cpp +++ b/Project/Source/GasaEditor/GasaGen/GasaGen_DevOptionsCache.cpp @@ -6,8 +6,6 @@ #undef GASA_API #undef ensureMsgf - -PRAGMA_DISABLE_OPTIMIZATION void generate_DevOptionsCache() { Array GasaDevOptions_UPROPERTIES = Array::init(GlobalAllocator); @@ -162,7 +160,6 @@ void generate_DevOptionsCache() format_file( path_module_gasa "GasaDevOptionsCache.cpp" ); } } -PRAGMA_ENABLE_OPTIMIZATION #pragma pop_macro("ensureMsgf") #pragma pop_macro("GASA_API")