Integrating latest from github/staging
Integrating up through commit 5e1bdae
This commit is contained in:
@@ -13,73 +13,57 @@
|
||||
#include <Application.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace SerializeContextTools
|
||||
{
|
||||
Application::Application(int* argc, char*** argv)
|
||||
: AzToolsFramework::ToolsApplication(argc, argv)
|
||||
Application::Application(int argc, char** argv)
|
||||
: AZ::ComponentApplication(argc, argv)
|
||||
{
|
||||
AZ::IO::FixedMaxPath sourceGameFolder;
|
||||
if (!m_settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_SourceGameFolder))
|
||||
AZ::IO::FixedMaxPath projectPath = AZ::Utils::GetProjectPath();
|
||||
if (projectPath.empty())
|
||||
{
|
||||
AZ_Error("Serialize Context Tools", false, "Unable to determine the game root automatically. "
|
||||
"Make sure a default project has been set or provide a default option on the command line. (See -help for more info.)");
|
||||
AZ_Error("Serialize Context Tools", false, "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;
|
||||
}
|
||||
|
||||
AZStd::string configFilePath = "Config/Editor.xml";
|
||||
if (m_commandLine.HasSwitch("config"))
|
||||
size_t configSwitchCount = m_commandLine.GetNumSwitchValues("config");
|
||||
if (configSwitchCount > 0)
|
||||
{
|
||||
configFilePath = m_commandLine.GetSwitchValue("config", 0);
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPath absConfigFilePath = sourceGameFolder / configFilePath;
|
||||
if (AZ::IO::SystemFile::Exists(absConfigFilePath.c_str()))
|
||||
{
|
||||
m_configFilePath = AZStd::move(absConfigFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error("Serialize Context Tools", false, "Unable to resolve path to config file.");
|
||||
AZ::IO::FixedMaxPath absConfigFilePath = projectPath / m_commandLine.GetSwitchValue("config", configSwitchCount - 1);
|
||||
if (AZ::IO::SystemFile::Exists(absConfigFilePath.c_str()))
|
||||
{
|
||||
m_configFilePath = AZStd::move(absConfigFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge the build system generated setting registry file by using either "Editor" or
|
||||
// and "${ProjectName}_GameLauncher" as a specialization
|
||||
bool projectNameFound{};
|
||||
AZ::SettingsRegistryInterface::FixedValueString projectName;
|
||||
AZ::SettingsRegistryInterface& registry = *AZ::SettingsRegistry::Get();
|
||||
constexpr auto sysGameFolderKey = AZ::SettingsRegistryInterface::FixedValueString(
|
||||
AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/sys_game_folder";
|
||||
if (projectNameFound = registry.Get(projectName, sysGameFolderKey); !projectNameFound)
|
||||
auto projectName = AZ::Utils::GetProjectName();
|
||||
if (projectName.empty())
|
||||
{
|
||||
AZ_Error("Serialize Context Tools", false, "Unable to query the %s key from the SettingsRegistry",
|
||||
sysGameFolderKey.c_str());
|
||||
AZ_Error("Serialize Context Tools", false, "Unable to query the project name from settings registry");
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::IO::PathView configFilenameStem = m_configFilePath.Stem();
|
||||
AZ::SettingsRegistryInterface::Specializations projectSpecializations{ projectName };
|
||||
size_t configFilenameStemSize = configFilenameStem.Native().size();
|
||||
if (configFilenameStemSize > 0 && azstrnicmp(configFilenameStem.Native().data(), "Editor", configFilenameStemSize) == 0)
|
||||
AZ::IO::PathView configFilenameStem = m_configFilePath.Stem();
|
||||
if (AZ::StringFunc::Equal(configFilenameStem.Native(), "Editor"))
|
||||
{
|
||||
projectSpecializations.Append("editor");
|
||||
}
|
||||
else if (configFilenameStemSize > 0 && azstrnicmp(configFilenameStem.Native().data(), "Game", configFilenameStemSize) == 0)
|
||||
else if (AZ::StringFunc::Equal(configFilenameStem.Native(), "Game"))
|
||||
{
|
||||
projectSpecializations.Append(projectName + "_GameLauncher");
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_TracePrintf("Serialize Context Tools", "No Editor.xml or Game.xml supplied."
|
||||
R"( Build dependency specialization will not use a specialization of "%s" nor "editor" for locating *.setreg files)",
|
||||
(projectName + "_GameLauncher").c_str());
|
||||
}
|
||||
|
||||
// Used the project specializations to merge the build dependencies *.setreg files
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_TargetBuildDependencyRegistry(registry,
|
||||
auto registry = AZ::SettingsRegistry::Get();
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_TargetBuildDependencyRegistry(*registry,
|
||||
AZ_TRAIT_OS_PLATFORM_CODENAME, projectSpecializations);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +75,7 @@ namespace AZ
|
||||
|
||||
void Application::SetSettingsRegistrySpecializations(AZ::SettingsRegistryInterface::Specializations& specializations)
|
||||
{
|
||||
AzToolsFramework::ToolsApplication::SetSettingsRegistrySpecializations(specializations);
|
||||
AZ::ComponentApplication::SetSettingsRegistrySpecializations(specializations);
|
||||
specializations.Append("serializecontexttools");
|
||||
}
|
||||
} // namespace SerializeContextTools
|
||||
|
||||
Reference in New Issue
Block a user