Integrating latest from github/staging

Integrating up through commit 5e1bdae
This commit is contained in:
alexpete
2021-03-26 14:31:50 -07:00
parent 9c54341af8
commit 36c4e827bd
764 changed files with 11453 additions and 20251 deletions
@@ -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
@@ -12,7 +12,7 @@
#pragma once
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/IO/Path/Path.h>
namespace AZ
@@ -20,10 +20,10 @@ namespace AZ
namespace SerializeContextTools
{
class Application final
: public AzToolsFramework::ToolsApplication
: public AZ::ComponentApplication
{
public:
Application(int* argc, char*** argv);
Application(int argc, char** argv);
~Application() override = default;
const char* GetConfigFilePath() const;
@@ -29,6 +29,4 @@ ly_add_target(
BUILD_DEPENDENCIES
PRIVATE
AZ::AzCore
AZ::AzFramework
AZ::AzToolsFramework
)
+14 -21
View File
@@ -14,13 +14,14 @@
#include <AzCore/Debug/Trace.h>
#include <AzCore/JSON/prettywriter.h>
#include <AzCore/Module/Module.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/Utils.h>
#include <AzCore/Serialization/Json/JsonSerialization.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/containers/unordered_set.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzCore/Utils/Utils.h>
#include <Application.h>
#include <Converter.h>
#include <Utilities.h>
@@ -33,7 +34,7 @@ namespace AZ
{
using namespace AZ::JsonSerializationResult;
const AzFramework::CommandLine* commandLine = application.GetCommandLine();
const AZ::CommandLine* commandLine = application.GetAzCommandLine();
if (!commandLine)
{
AZ_Error("SerializeContextTools", false, "Command line not available.");
@@ -123,7 +124,7 @@ namespace AZ
}
// If there's only one file, then use the original name instead of the extended name
AzFramework::StringFunc::Path::ReplaceExtension(filePath, extension.c_str());
AZ::StringFunc::Path::ReplaceExtension(filePath, extension.c_str());
if (documents.size() == 1)
{
AZ_Printf("Convert", " Exporting to '%s'\n", filePath.c_str());
@@ -142,7 +143,7 @@ namespace AZ
else
{
AZStd::string fileName;
AzFramework::StringFunc::Path::GetFileName(filePath.c_str(), fileName);
AZ::StringFunc::Path::GetFileName(filePath.c_str(), fileName);
for (PathDocumentPair& document : documents)
{
AZStd::string fileNameExtended = fileName;
@@ -150,7 +151,7 @@ namespace AZ
fileNameExtended += document.first;
Utilities::SanitizeFilePath(fileNameExtended);
AZStd::string finalFilePath = filePath;
AzFramework::StringFunc::Path::ReplaceFullName(finalFilePath, fileNameExtended.c_str(), extension.c_str());
AZ::StringFunc::Path::ReplaceFullName(finalFilePath, fileNameExtended.c_str(), extension.c_str());
AZ_Printf("Convert", " Exporting to '%s'\n", finalFilePath.c_str());
if (!isDryRun)
@@ -172,7 +173,7 @@ namespace AZ
bool Converter::ConvertApplicationDescriptor(Application& application)
{
const AzFramework::CommandLine* commandLine = application.GetCommandLine();
const AZ::CommandLine* commandLine = application.GetAzCommandLine();
if (!commandLine)
{
AZ_Error("SerializeContextTools", false, "Command line not available.");
@@ -212,7 +213,7 @@ namespace AZ
const AZStd::string& filePath = application.GetConfigFilePath();
AZ_Printf("Convert", "Reading '%s' for conversion.\n", filePath.c_str());
AZStd::string configurationName;
if (!AzFramework::StringFunc::Path::GetFileName(filePath.c_str(), configurationName) ||
if (!AZ::StringFunc::Path::GetFileName(filePath.c_str(), configurationName) ||
configurationName.empty())
{
AZ_Error("Convert", false, "Unable to extract configuration from '%s'.", filePath.c_str());
@@ -225,7 +226,7 @@ namespace AZ
AZ::IO::FixedMaxPath sourceGameFolder;
if (auto settingsRegistry = AZ::SettingsRegistry::Get();
!settingsRegistry
|| !settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_SourceGameFolder))
|| !settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath))
{
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.)");
@@ -314,7 +315,7 @@ namespace AZ
bool Converter::ConvertConfigFile(Application& application)
{
bool result = true;
const AzFramework::CommandLine* commandLine = application.GetCommandLine();
const AZ::CommandLine* commandLine = application.GetAzCommandLine();
if (!commandLine)
{
AZ_Error("SerializeContextTools", false, "Command line not available.");
@@ -334,13 +335,6 @@ namespace AZ
const bool isDryRun = commandLine->HasSwitch("dryrun");
// Use the Engine Root Folder from the Global Settings Registry
AZ::IO::FixedMaxPath engineRootPath;
if (auto globalSettingsRegistry = AZ::SettingsRegistry::Get(); globalSettingsRegistry != nullptr)
{
globalSettingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
// The AZ CommandLine internally splits switches on <comma> and semicolon
AZStd::vector<AZStd::string_view> fileList;
size_t filesToConvert = commandLine->GetNumSwitchValues("files");
@@ -353,10 +347,9 @@ namespace AZ
PathDocumentContainer documents;
for (AZStd::string_view configFileView : fileList)
{
// Appends the paths in "files" argument to the EngineRootPath
// If the "files" argument is absolute AZ::IO::Path follows the python os.join logic
// and replaces the paths before it with the absolute path
AZ::IO::FixedMaxPath configFilePath = engineRootPath / configFileView;
// Convert the supplied file list to an absolute path
AZStd::optional<AZ::IO::FixedMaxPathString> absFilePath = AZ::Utils::ConvertToAbsolutePath(configFileView);
AZ::IO::FixedMaxPath configFilePath = absFilePath ? *absFilePath : configFileView;
auto callback = [&documents, &outputExtension, &configFilePath](AZ::IO::PathView configFileView, bool isFile) -> bool
{
if (configFileView == "." || configFileView == "..")
@@ -866,7 +859,7 @@ namespace AZ
}
void Converter::SetupLogging(AZStd::string& scratchBuffer, JsonSerializationResult::JsonIssueCallback& callback,
const AzFramework::CommandLine& commandLine)
const AZ::CommandLine& commandLine)
{
if (commandLine.HasSwitch("verbose"))
{
+1 -1
View File
@@ -61,7 +61,7 @@ namespace AZ
rapidjson::StringBuffer& scratchBuffer);
static void SetupLogging(AZStd::string& scratchBuffer, JsonSerializationResult::JsonIssueCallback& callback,
const AzFramework::CommandLine& commandLine);
const AZ::CommandLine& commandLine);
static JsonSerializationResult::ResultCode VerboseLogging(AZStd::string& scratchBuffer, AZStd::string_view message,
JsonSerializationResult::ResultCode result, AZStd::string_view target);
static AZ::JsonSerializationResult::ResultCode SimpleLogging(AZStd::string& scratchBuffer, AZStd::string_view message,
+2 -1
View File
@@ -18,6 +18,7 @@
#include <AzCore/IO/SystemFile.h>
#include <AzCore/JSON/stringbuffer.h>
#include <AzCore/JSON/prettywriter.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/sort.h>
@@ -41,7 +42,7 @@ namespace AZ::SerializeContextTools
AZ::IO::Path sourceGameFolder;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_SourceGameFolder);
settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath);
}
bool result = true;
@@ -36,13 +36,13 @@ namespace AZ::SerializeContextTools
AZ::IO::Path sourceGameFolder;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_SourceGameFolder);
settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath);
}
AZ::IO::Path outputPath;
if (application.GetCommandLine()->HasSwitch("output"))
if (application.GetAzCommandLine()->HasSwitch("output"))
{
outputPath.Native() = application.GetCommandLine()->GetSwitchValue("output", 0);
outputPath.Native() = application.GetAzCommandLine()->GetSwitchValue("output", 0);
if (outputPath.IsRelative())
{
outputPath = sourceGameFolder / outputPath;
@@ -59,7 +59,7 @@ namespace AZ::SerializeContextTools
{
AZStd::vector<AZStd::string> result;
const AZ::CommandLine* commandLine = application.GetCommandLine();
const AZ::CommandLine* commandLine = application.GetAzCommandLine();
if (!commandLine)
{
AZ_Error("SerializeContextTools", false, "Command line not available.");
@@ -76,7 +76,7 @@ namespace AZ::SerializeContextTools
AZ::IO::Path sourceGameFolder;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_SourceGameFolder);
settingsRegistry->Get(sourceGameFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath);
}
AZStd::vector<AZStd::string_view> fileList;
+14 -14
View File
@@ -11,8 +11,8 @@
*/
#include <AzCore/Debug/Trace.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/CommandLine/CommandLine.h>
#include <AzCore/StringFunc/StringFunc.h>
#include <AzCore/Settings/CommandLine.h>
#include <Application.h>
#include <Converter.h>
#include <Dumper.h>
@@ -58,8 +58,8 @@ void PrintHelp()
AZ_Printf("Help", " [opt] -verbose: Report additional details during the conversion process.\n");
AZ_Printf("Help", " [opt] -regset <setreg_key>=<setreg_value>: Set setreg_value at key setreg_key within the settings registry.\n");
AZ_Printf("Help", " This can be used for example to override the Active Game Project in the settings registry.\n");
AZ_Printf("Help", " instead of using the sys_game_folder value from the bootstrap.cfg.\n");
AZ_Printf("Help", R"( Ex. -regset "/Amazon/AzCore/Bootstrap/sys_game_folder=AutomatedTesting"\n)");
AZ_Printf("Help", " instead of using the project_path value from the bootstrap.cfg.\n");
AZ_Printf("Help", R"( Ex. -regset "/Amazon/AzCore/Bootstrap/project_path=AutomatedTesting"\n)");
AZ_Printf("Help", " This sets the active game project as AutomatedTesting, overrideing the value in the bootstrap.cfg\n");
AZ_Printf("Help", " example: 'convertad -config=config/game.xml -dryrun\n");
AZ_Printf("Help", R"( 'convert-ini': Converts windows-style INI file to a json format file.)" "\n");
@@ -71,7 +71,7 @@ void PrintHelp()
AZ_Printf("Help", R"( [opt] -json-prefix=<prefix>: JSON pointer path prefix to anchor the JSON output underneath.)" "\n");
AZ_Printf("Help", R"( On Windows the <prefix> should be in quotes, as \"/\" is treated as command option prefix)" "\n");
AZ_Printf("Help", R"( [opt] -verbose: Report additional details during the conversion process.)" "\n");
AZ_Printf("Help", R"( example: 'convertconfig --files=AssetProcessorPlatformConfigIni;bootstrap.cfg --ext=setreg)" "\n");
AZ_Printf("Help", R"( example: 'convert-ini --files=AssetProcessorPlatformConfig.ini;bootstrap.cfg --ext=setreg)" "\n");
}
int main(int argc, char** argv)
@@ -79,15 +79,15 @@ int main(int argc, char** argv)
using namespace AZ::SerializeContextTools;
bool result = false;
Application application(&argc, &argv);
Application application(argc, argv);
AZ::ComponentApplication::StartupParameters startupParameters;
startupParameters.m_loadDynamicModules = false;
application.Start({}, startupParameters);
application.Create({}, startupParameters);
// Load the DynamicModules after the Application starts to prevent Gem System Components
// from activating
application.LoadDynamicModules();
const AZ::CommandLine* commandLine = application.GetCommandLine();
const AZ::CommandLine* commandLine = application.GetAzCommandLine();
if (commandLine->GetNumMiscValues() < 1)
{
PrintHelp();
@@ -96,23 +96,23 @@ int main(int argc, char** argv)
else
{
const AZStd::string& action = commandLine->GetMiscValue(0);
if (AzFramework::StringFunc::Equal("dumpfiles", action.c_str()))
if (AZ::StringFunc::Equal("dumpfiles", action.c_str()))
{
result = Dumper::DumpFiles(application);
}
else if (AzFramework::StringFunc::Equal("dumpsc", action.c_str()))
else if (AZ::StringFunc::Equal("dumpsc", action.c_str()))
{
result = Dumper::DumpSerializeContext(application);
}
else if (AzFramework::StringFunc::Equal("convert", action.c_str()))
else if (AZ::StringFunc::Equal("convert", action.c_str()))
{
result = Converter::ConvertObjectStreamFiles(application);
}
else if (AzFramework::StringFunc::Equal("convertad", action.c_str()))
else if (AZ::StringFunc::Equal("convertad", action.c_str()))
{
result = Converter::ConvertApplicationDescriptor(application);
}
else if (AzFramework::StringFunc::Equal("convert-ini", action.c_str()))
else if (AZ::StringFunc::Equal("convert-ini", action.c_str()))
{
result = Converter::ConvertConfigFile(application);
}
@@ -128,7 +128,7 @@ int main(int argc, char** argv)
AZ_Printf("SerializeContextTools", "Processing didn't complete fully as problems were encountered.\n");
}
application.Stop();
application.Destroy();
return result ? 0 : -1;
}