|
@@ -15,7 +15,7 @@
|
|
|
#include <AzToolsFramework/Thumbnails/ThumbnailerNullComponent.h>
|
|
|
#include <SliceConverterEditorEntityContextComponent.h>
|
|
|
|
|
|
-namespace AZ
|
|
|
+namespace AZ::SerializeContextTools
|
|
|
{
|
|
|
// SerializeContextTools is a full ToolsApplication that will load a project's Gem DLLs and initialize the system components.
|
|
|
// This level of initialization is required to get all the serialization contexts and asset handlers registered, so that when
|
|
@@ -26,113 +26,120 @@ namespace AZ
|
|
|
// can still be started up, but the thumbnail service itself won't do anything. The real ThumbnailerComponent uses Qt, which is why
|
|
|
// it isn't used.
|
|
|
|
|
|
- namespace SerializeContextTools
|
|
|
+ Application::Application(int argc, char** argv, AZ::IO::FileDescriptorCapturer* stdoutCapturer)
|
|
|
+ : AzToolsFramework::ToolsApplication(&argc, &argv)
|
|
|
+ , m_stdoutCapturer(stdoutCapturer)
|
|
|
{
|
|
|
- Application::Application(int argc, char** argv)
|
|
|
- : AzToolsFramework::ToolsApplication(&argc, &argv)
|
|
|
+ // We need a specialized variant of EditorEntityContextComponent for the SliceConverter, so we register the descriptor here.
|
|
|
+ RegisterComponentDescriptor(AzToolsFramework::SliceConverterEditorEntityContextComponent::CreateDescriptor());
|
|
|
+
|
|
|
+ AZ::IO::FixedMaxPath projectPath = AZ::Utils::GetProjectPath();
|
|
|
+ if (projectPath.empty())
|
|
|
{
|
|
|
- // We need a specialized variant of EditorEntityContextComponent for the SliceConverter, so we register the descriptor here.
|
|
|
- RegisterComponentDescriptor(AzToolsFramework::SliceConverterEditorEntityContextComponent::CreateDescriptor());
|
|
|
+ AZ_TracePrintf("Serialize Context Tools", "Unable to determine the project path . "
|
|
|
+ "Make sure project has been set or provide via the -project-path option on the command line. (See -help for more info.)");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- AZ::IO::FixedMaxPath projectPath = AZ::Utils::GetProjectPath();
|
|
|
- if (projectPath.empty())
|
|
|
+ size_t configSwitchCount = m_commandLine.GetNumSwitchValues("config");
|
|
|
+ if (configSwitchCount > 0)
|
|
|
+ {
|
|
|
+ AZ::IO::FixedMaxPath absConfigFilePath = projectPath / m_commandLine.GetSwitchValue("config", configSwitchCount - 1);
|
|
|
+ if (AZ::IO::SystemFile::Exists(absConfigFilePath.c_str()))
|
|
|
{
|
|
|
- AZ_TracePrintf("Serialize Context Tools", "Unable to determine the project path . "
|
|
|
- "Make sure project has been set or provide via the -project-path option on the command line. (See -help for more info.)");
|
|
|
- return;
|
|
|
+ m_configFilePath = AZStd::move(absConfigFilePath);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ // Merge the build system generated setting registry file by using either "Editor" or
|
|
|
+ // and "${ProjectName}_GameLauncher" as a specialization
|
|
|
+ auto projectName = AZ::Utils::GetProjectName();
|
|
|
+ if (projectName.empty())
|
|
|
+ {
|
|
|
+ AZ_Error("Serialize Context Tools", false, "Unable to query the project name from settings registry");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AZ::SettingsRegistryInterface::Specializations projectSpecializations{ projectName };
|
|
|
|
|
|
- size_t configSwitchCount = m_commandLine.GetNumSwitchValues("config");
|
|
|
- if (configSwitchCount > 0)
|
|
|
+ // If a project specialization has been passed in via the command line, use it.
|
|
|
+ if (size_t specializationCount = m_commandLine.GetNumSwitchValues("specializations"); specializationCount > 0)
|
|
|
{
|
|
|
- AZ::IO::FixedMaxPath absConfigFilePath = projectPath / m_commandLine.GetSwitchValue("config", configSwitchCount - 1);
|
|
|
- if (AZ::IO::SystemFile::Exists(absConfigFilePath.c_str()))
|
|
|
+ for (size_t specializationIndex = 0; specializationIndex < specializationCount; ++specializationIndex)
|
|
|
{
|
|
|
- m_configFilePath = AZStd::move(absConfigFilePath);
|
|
|
+ projectSpecializations.Append(m_commandLine.GetSwitchValue("specializations", specializationIndex));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // Merge the build system generated setting registry file by using either "Editor" or
|
|
|
- // and "${ProjectName}_GameLauncher" as a specialization
|
|
|
- auto projectName = AZ::Utils::GetProjectName();
|
|
|
- if (projectName.empty())
|
|
|
- {
|
|
|
- AZ_Error("Serialize Context Tools", false, "Unable to query the project name from settings registry");
|
|
|
- }
|
|
|
else
|
|
|
{
|
|
|
- AZ::SettingsRegistryInterface::Specializations projectSpecializations{ projectName };
|
|
|
-
|
|
|
- // If a project specialization has been passed in via the command line, use it.
|
|
|
- if (size_t specializationCount = m_commandLine.GetNumSwitchValues("specializations"); specializationCount > 0)
|
|
|
+ // Otherwise, if a config file was passed in, auto-set the specialization based on the config file name.
|
|
|
+ AZ::IO::PathView configFilenameStem = m_configFilePath.Stem();
|
|
|
+ if (AZ::StringFunc::Equal(configFilenameStem.Native(), "Editor"))
|
|
|
{
|
|
|
- for (size_t specializationIndex = 0; specializationIndex < specializationCount; ++specializationIndex)
|
|
|
- {
|
|
|
- projectSpecializations.Append(m_commandLine.GetSwitchValue("specializations", specializationIndex));
|
|
|
- }
|
|
|
+ projectSpecializations.Append("editor");
|
|
|
}
|
|
|
- else
|
|
|
+ else if (AZ::StringFunc::Equal(configFilenameStem.Native(), "Game"))
|
|
|
{
|
|
|
- // Otherwise, if a config file was passed in, auto-set the specialization based on the config file name.
|
|
|
- AZ::IO::PathView configFilenameStem = m_configFilePath.Stem();
|
|
|
- if (AZ::StringFunc::Equal(configFilenameStem.Native(), "Editor"))
|
|
|
- {
|
|
|
- projectSpecializations.Append("editor");
|
|
|
- }
|
|
|
- else if (AZ::StringFunc::Equal(configFilenameStem.Native(), "Game"))
|
|
|
- {
|
|
|
- projectSpecializations.Append(projectName + "_GameLauncher");
|
|
|
- }
|
|
|
-
|
|
|
- // If the "dumptypes" or "createtype" supplied attempt to load the editor gem dependencies
|
|
|
- if (m_commandLine.GetNumMiscValues() > 0 &&
|
|
|
- (m_commandLine.GetMiscValue(0) == "dumptypes" || m_commandLine.GetMiscValue(0) == "createtype"))
|
|
|
- {
|
|
|
- projectSpecializations.Append("editor");
|
|
|
- }
|
|
|
+ projectSpecializations.Append(projectName + "_GameLauncher");
|
|
|
}
|
|
|
|
|
|
- // Used the project specializations to merge the gem modules dependencies *.setreg files
|
|
|
- auto registry = AZ::SettingsRegistry::Get();
|
|
|
- AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_TargetBuildDependencyRegistry(*registry,
|
|
|
- AZ_TRAIT_OS_PLATFORM_CODENAME, projectSpecializations);
|
|
|
+ // If the "dumptypes" or "createtype" supplied attempt to load the editor gem dependencies
|
|
|
+ if (m_commandLine.GetNumMiscValues() > 0 &&
|
|
|
+ (m_commandLine.GetMiscValue(0) == "dumptypes" || m_commandLine.GetMiscValue(0) == "createtype"))
|
|
|
+ {
|
|
|
+ projectSpecializations.Append("editor");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- const char* Application::GetConfigFilePath() const
|
|
|
- {
|
|
|
- return m_configFilePath.c_str();
|
|
|
+ // Used the project specializations to merge the gem modules dependencies *.setreg files
|
|
|
+ auto registry = AZ::SettingsRegistry::Get();
|
|
|
+ AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_TargetBuildDependencyRegistry(*registry,
|
|
|
+ AZ_TRAIT_OS_PLATFORM_CODENAME, projectSpecializations);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- void Application::QueryApplicationType(AZ::ApplicationTypeQuery& appType) const
|
|
|
- {
|
|
|
- appType.m_maskValue = AZ::ApplicationTypeQuery::Masks::Tool;
|
|
|
- }
|
|
|
+ const char* Application::GetConfigFilePath() const
|
|
|
+ {
|
|
|
+ return m_configFilePath.c_str();
|
|
|
+ }
|
|
|
|
|
|
- void Application::SetSettingsRegistrySpecializations(AZ::SettingsRegistryInterface::Specializations& specializations)
|
|
|
- {
|
|
|
- AZ::ComponentApplication::SetSettingsRegistrySpecializations(specializations);
|
|
|
- specializations.Append("serializecontexttools");
|
|
|
- }
|
|
|
+ void Application::QueryApplicationType(AZ::ApplicationTypeQuery& appType) const
|
|
|
+ {
|
|
|
+ appType.m_maskValue = AZ::ApplicationTypeQuery::Masks::Tool;
|
|
|
+ }
|
|
|
|
|
|
- AZ::ComponentTypeList Application::GetRequiredSystemComponents() const
|
|
|
- {
|
|
|
- // By default, we use all of the standard system components.
|
|
|
- AZ::ComponentTypeList components = AzToolsFramework::ToolsApplication::GetRequiredSystemComponents();
|
|
|
-
|
|
|
- // Also add in the ThumbnailerNullComponent so that components requiring a ThumbnailService can still be started up.
|
|
|
- components.emplace_back(azrtti_typeid<AzToolsFramework::Thumbnailer::ThumbnailerNullComponent>());
|
|
|
-
|
|
|
- // The Slice Converter requires a specialized variant of the EditorEntityContextComponent that exposes the ability
|
|
|
- // to disable the behavior of activating entities on creation. During conversion, the creation flow will be triggered,
|
|
|
- // but entity activation requires a significant amount of subsystem initialization that's unneeded for conversion.
|
|
|
- // So, to get around this, we swap out EditorEntityContextComponent with SliceConverterEditorEntityContextComponent.
|
|
|
- components.erase(
|
|
|
- AZStd::remove(
|
|
|
- components.begin(), components.end(), azrtti_typeid<AzToolsFramework::EditorEntityContextComponent>()),
|
|
|
- components.end());
|
|
|
- components.emplace_back(azrtti_typeid<AzToolsFramework::SliceConverterEditorEntityContextComponent>());
|
|
|
- return components;
|
|
|
- }
|
|
|
- } // namespace SerializeContextTools
|
|
|
-} // namespace AZ
|
|
|
+ void Application::SetSettingsRegistrySpecializations(AZ::SettingsRegistryInterface::Specializations& specializations)
|
|
|
+ {
|
|
|
+ AZ::ComponentApplication::SetSettingsRegistrySpecializations(specializations);
|
|
|
+ specializations.Append("serializecontexttools");
|
|
|
+ }
|
|
|
+
|
|
|
+ AZ::ComponentTypeList Application::GetRequiredSystemComponents() const
|
|
|
+ {
|
|
|
+ // By default, we use all of the standard system components.
|
|
|
+ AZ::ComponentTypeList components = AzToolsFramework::ToolsApplication::GetRequiredSystemComponents();
|
|
|
+
|
|
|
+ // Also add in the ThumbnailerNullComponent so that components requiring a ThumbnailService can still be started up.
|
|
|
+ components.emplace_back(azrtti_typeid<AzToolsFramework::Thumbnailer::ThumbnailerNullComponent>());
|
|
|
+
|
|
|
+ // The Slice Converter requires a specialized variant of the EditorEntityContextComponent that exposes the ability
|
|
|
+ // to disable the behavior of activating entities on creation. During conversion, the creation flow will be triggered,
|
|
|
+ // but entity activation requires a significant amount of subsystem initialization that's unneeded for conversion.
|
|
|
+ // So, to get around this, we swap out EditorEntityContextComponent with SliceConverterEditorEntityContextComponent.
|
|
|
+ components.erase(
|
|
|
+ AZStd::remove(
|
|
|
+ components.begin(), components.end(), azrtti_typeid<AzToolsFramework::EditorEntityContextComponent>()),
|
|
|
+ components.end());
|
|
|
+ components.emplace_back(azrtti_typeid<AzToolsFramework::SliceConverterEditorEntityContextComponent>());
|
|
|
+ return components;
|
|
|
+ }
|
|
|
+
|
|
|
+ void Application::SetStdoutCapturer(AZ::IO::FileDescriptorCapturer* stdoutCapturer)
|
|
|
+ {
|
|
|
+ m_stdoutCapturer = stdoutCapturer;
|
|
|
+ }
|
|
|
+ AZ::IO::FileDescriptorCapturer* Application::GetStdoutCapturer() const
|
|
|
+ {
|
|
|
+ return m_stdoutCapturer;
|
|
|
+ }
|
|
|
+} // namespace AZ::SerializeContextTools
|