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
@@ -18,6 +18,7 @@
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/Slice/SliceSystemComponent.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/Utils/Utils.h>
#include <AzFramework/Asset/AssetCatalogComponent.h>
#include <AzFramework/Asset/AssetSystemComponent.h>
@@ -97,21 +98,6 @@ AssetBuilderApplication::AssetBuilderApplication(int* argc, char*** argv)
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization(
*settingsRegistry, AssetBuilder::GetBuildTargetName());
// Override the /Amazon/AzCore/Bootstrap/sys_game_folder entry in the Settings Registry using the -gameName parameter
if (m_commandLine.GetNumSwitchValues("gameName") > 0)
{
const AZStd::string& gameFolderOverride = m_commandLine.GetSwitchValue("gameName", 0);
auto gameFolderCommandLineOverride = AZStd::string::format("--regset=%s/sys_game_folder=%s", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey,
gameFolderOverride.c_str());
AZ::CommandLine::ParamContainer commandLineArgs;
m_commandLine.Dump(commandLineArgs);
commandLineArgs.emplace_back(gameFolderCommandLineOverride);
m_commandLine.Parse(commandLineArgs);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*settingsRegistry, m_commandLine, false);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry);
}
AZ::Interface<IBuilderApplication>::Register(this);
}
@@ -123,7 +109,7 @@ AssetBuilderApplication::~AssetBuilderApplication()
void AssetBuilderApplication::RegisterCoreComponents()
{
AzToolsFramework::ToolsApplication::RegisterCoreComponents();
RegisterComponentDescriptor(AssetBuilderComponent::CreateDescriptor());
RegisterComponentDescriptor(AssetProcessor::ToolsAssetCatalogComponent::CreateDescriptor());
}
@@ -134,32 +120,8 @@ void AssetBuilderApplication::StartCommon(AZ::Entity* systemEntity)
// Merge in the SettingsRegistry for the game being processed. This does not
// necessarily correspond to the project name in the bootstrap.cfg since it
// the AssetBuilder supports overriding the gameName on the command line
// the AssetBuilder supports overriding the project-path on the command line
AZ::SettingsRegistryInterface& registry = *AZ::SettingsRegistry::Get();
AZ::SettingsRegistryInterface::FixedValueString gameName;
if (m_commandLine.GetNumSwitchValues("gameName") > 0)
{
gameName = AZStd::string_view(m_commandLine.GetSwitchValue("gameName", 0));
}
// Add the supplied gameName to the specialization key in the registry
if (!gameName.empty())
{
auto gameNameSpecialization = AZ::SettingsRegistryInterface::FixedValueString::format("%s/%.*s",
AZ::SettingsRegistryMergeUtils::SpecializationsRootKey, aznumeric_cast<int>(gameName.size()), gameName.data());
registry.Set(gameNameSpecialization, true);
}
else
{
// Add the project name as a registry specialization
auto projectKey = AZ::SettingsRegistryInterface::FixedValueString::format("%s/sys_game_folder", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey);
if (AZ::SettingsRegistryInterface::FixedValueString bootstrapGameName; registry.Get(bootstrapGameName, projectKey) && !bootstrapGameName.empty())
{
registry.Set(AZ::SettingsRegistryInterface::FixedValueString::format("%s/%s",
AZ::SettingsRegistryMergeUtils::SpecializationsRootKey, bootstrapGameName.c_str()),
true);
}
}
// Retrieve specializations from the Settings Registry and ComponentApplication derived classes
AZ::SettingsRegistryInterface::Specializations specializations;
@@ -177,41 +139,25 @@ void AssetBuilderApplication::StartCommon(AZ::Entity* systemEntity)
// the executable, we need to set the PATH environment variable.
AZStd::string exeFolder;
AZ::ComponentApplicationBus::BroadcastResult(exeFolder, &AZ::ComponentApplicationBus::Events::GetExecutableFolder);
setenv("PATH", exeFolder.c_str(), 1);
#endif // AZ_PLATFORM_MAC
AZStd::string gameRoot;
if (m_commandLine.GetNumSwitchValues("gameRoot") > 0)
{
gameRoot = m_commandLine.GetSwitchValue("gameRoot", 0);
}
if (gameRoot.empty())
// Make sure a project path was set to settings registry and error/warn if not.
auto projectPath = AZ::Utils::GetProjectPath();
if (projectPath.empty())
{
if (IsInDebugMode())
{
if (!AZ::SettingsRegistry::Get()->Get(gameRoot, AZ::SettingsRegistryMergeUtils::FilePathKey_SourceGameFolder))
{
AZ_Error("AssetBuilder", 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.)");
return;
}
AZ_Error("AssetBuilder", false, "Unable to determine the project path automatically. "
"Make sure a default project path has been set or provide a --project-path option on the command line. "
"(See -help for more info.)");
return;
}
else
{
AZ_Printf(AssetBuilderSDK::InfoWindow, "gameRoot not specified on the command line, assuming current directory.\n");
AZ_Printf(AssetBuilderSDK::InfoWindow, "gameRoot is best specified as the full path to the game's asset folder.");
}
}
if (!gameRoot.empty())
{
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
if (fileIO)
{
fileIO->SetAlias("@devassets@", gameRoot.c_str());
AZ_Printf(AssetBuilderSDK::InfoWindow, "project-path not specified on the command line, assuming current directory.\n");
AZ_Printf(AssetBuilderSDK::InfoWindow, "project-path is best specified as the full path to the project's folder.");
}
}
@@ -227,7 +173,7 @@ void AssetBuilderApplication::StartCommon(AZ::Entity* systemEntity)
// Disable parallel dependency loads since the builders can't count on all other assets and their info being ready.
// Specifically, asset builders can trigger asset loads during the building process. The ToolsAssetCatalog doesn't
// implement the dependency APIs, so the asset loads will fail to load any dependent assets.
//
//
// NOTE: The ToolsAssetCatalog could *potentially* implement the dependency APIs by querying the live Asset Processor instance,
// but this will return incomplete dependency information based on the subset of assets that have already processed.
// In theory, if the Asset Builder dependencies are set up correctly, the needed subset should always be processed first,
@@ -242,61 +188,6 @@ bool AssetBuilderApplication::IsInDebugMode() const
return AssetBuilderComponent::IsInDebugMode(m_commandLine);
}
bool AssetBuilderApplication::GetOptionalAppRootArg(char destinationRootArgBuffer[], size_t destinationRootArgBufferSize) const
{
// Only continue if the application received any arguments from the command line
if ((!this->m_argC) || (!this->m_argV))
{
return false;
}
int argc = this->m_argC;
char** argv = this->m_argV;
// Search for the app root argument (-approot=<PATH>) where <PATH> is the app root path to set for the application
const static char* appRootArgPrefix = "-approot=";
size_t appRootArgPrefixLen = strlen(appRootArgPrefix);
const char* appRootArg = nullptr;
for (int index = 0; index < argc; index++)
{
if (strncmp(appRootArgPrefix, argv[index], appRootArgPrefixLen) == 0)
{
appRootArg = &argv[index][appRootArgPrefixLen];
break;
}
}
if (appRootArg)
{
AZStd::string_view appRootArgView = appRootArg;
size_t afterStartQuotes = appRootArgView.find_first_not_of(R"(")");
if (afterStartQuotes != AZStd::string_view::npos)
{
appRootArgView.remove_prefix(afterStartQuotes);
}
size_t beforeEndQuotes = appRootArgView.find_last_not_of(R"(")");
if (beforeEndQuotes != AZStd::string_view::npos)
{
appRootArgView.remove_suffix(appRootArgView.size() - (beforeEndQuotes + 1));
}
appRootArgView.copy(destinationRootArgBuffer, destinationRootArgBufferSize);
destinationRootArgBuffer[appRootArgView.size()] = '\0';
const char lastChar = destinationRootArgBuffer[strlen(destinationRootArgBuffer) - 1];
bool needsTrailingPathDelim = (lastChar != AZ_CORRECT_FILESYSTEM_SEPARATOR) && (lastChar != AZ_WRONG_FILESYSTEM_SEPARATOR);
if (needsTrailingPathDelim)
{
azstrncat(destinationRootArgBuffer, destinationRootArgBufferSize, AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING, 1);
}
return true;
}
else
{
return false;
}
}
void AssetBuilderApplication::InitializeBuilderComponents()
{
CreateAndAddEntityFromComponentTags(AZStd::vector<AZ::Crc32>({ AssetBuilderSDK::ComponentTags::AssetBuilder }), "AssetBuilders Entity");