AssetBuilderInfo.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef UTILITIES_ASSETBUILDERINFO_H
  9. #define UTILITIES_ASSETBUILDERINFO_H
  10. #pragma once
  11. #include <functional>
  12. #include <QVector>
  13. #include <QLibrary>
  14. #include <AzCore/std/base.h>
  15. #include <AzCore/std/containers/set.h>
  16. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  17. #include <native/assetprocessor.h>
  18. #include <native/utilities/PlatformConfiguration.h>
  19. #include <native/resourcecompiler/RCBuilder.h>
  20. #include <AssetBuilder/AssetBuilderInfo.h>
  21. class QCoreApplication;
  22. namespace AssetProcessor
  23. {
  24. using AssetBuilder::AssetBuilderType;
  25. enum ASSET_BUILDER_TYPE
  26. {
  27. INVALID, VALID, NONE
  28. };
  29. // A string like "AssetBuilder.exe" which names the executable of the asset builder.
  30. extern const char* const s_assetBuilderRelativePath;
  31. //! Class to manage external module builders for the asset processor
  32. class ExternalModuleAssetBuilderInfo
  33. {
  34. public:
  35. ExternalModuleAssetBuilderInfo(const QString& modulePath);
  36. virtual ~ExternalModuleAssetBuilderInfo() = default;
  37. const QString& GetName() const;
  38. QString GetModuleFullPath() const;
  39. //! Perform a load of the external module, this is required before initialize.
  40. AssetBuilderType Load();
  41. //! Sanity check for the module's status
  42. bool IsLoaded() const;
  43. //! Perform the module initialization for the external builder
  44. void Initialize();
  45. //! Perform the necessary process of uninitializing an external builder
  46. void UnInitialize();
  47. //! Check to see if the builder has the required functions defined.
  48. AssetBuilderType GetAssetBuilderType();
  49. ASSET_BUILDER_TYPE IsAssetBuilder();
  50. //! Register a builder descriptor ID to track as part of this builders lifecycle management
  51. void RegisterBuilderDesc(const AZ::Uuid& builderDesc);
  52. //! Register a component descriptor to track as part of this builders lifecycle management
  53. void RegisterComponentDesc(AZ::ComponentDescriptor* descriptor);
  54. protected:
  55. AZStd::set<AZ::Uuid> m_registeredBuilderDescriptorIDs;
  56. typedef void(* InitializeModuleFunction)(AZ::EnvironmentInstance sharedEnvironment);
  57. typedef void(* ModuleRegisterDescriptorsFunction)(void);
  58. typedef void(* ModuleAddComponentsFunction)(AZ::Entity* entity);
  59. typedef void(* UninitializeModuleFunction)(void);
  60. template<typename T>
  61. T ResolveModuleFunction(const char* functionName, QStringList& missingFunctionsList);
  62. InitializeModuleFunction m_initializeModuleFunction;
  63. ModuleRegisterDescriptorsFunction m_moduleRegisterDescriptorsFunction;
  64. ModuleAddComponentsFunction m_moduleAddComponentsFunction;
  65. UninitializeModuleFunction m_uninitializeModuleFunction;
  66. AZStd::vector<AZ::ComponentDescriptor*> m_componentDescriptorList;
  67. AZ::Entity* m_entity = nullptr;
  68. QString m_builderName;
  69. QLibrary m_library;
  70. };
  71. //!This EBUS is used to send information from an internal builder to the AssetProcessor
  72. class AssetBuilderRegistrationBusTraits
  73. : public AZ::EBusTraits
  74. {
  75. public:
  76. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  77. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  78. typedef AZStd::recursive_mutex MutexType;
  79. virtual ~AssetBuilderRegistrationBusTraits() {}
  80. virtual void UnRegisterBuilderDescriptor(const AZ::Uuid& /*builderId*/) {}
  81. };
  82. typedef AZ::EBus<AssetBuilderRegistrationBusTraits> AssetBuilderRegistrationBus;
  83. } // AssetProcessor
  84. #endif //UTILITIES_ASSETBUILDERINFO_H