From 0c339d2e2d85aec0703a99bf640880c54dfdc93c Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Fri, 16 Jul 2021 21:55:26 -0500 Subject: [PATCH 1/2] Fixed the SettingsRegistryBuilder not merging the Registry directories within Gems Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- .../SettingsRegistryBuilder.cpp | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp index f574206637..f0651411c6 100644 --- a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp +++ b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp @@ -263,6 +263,12 @@ namespace AssetProcessor return; } + using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString; + // Placeholder Key used by the local Settings Registry for storing all Gems SourcePaths + // array entries. + constexpr auto PlaceholderGemKey = FixedValueString(AZ::SettingsRegistryMergeUtils::OrganizationRootKey) + + "/Gems/__SettingsRegistryBuilderPlaceholder"; + AZ::SettingsRegistryImpl registry; // Seed the local settings registry using the AssetProcessor settings registry @@ -279,18 +285,47 @@ namespace AssetProcessor for (const auto& settingsKey : settingsToCopy) { - AZ::SettingsRegistryInterface::FixedValueString settingsValue; + FixedValueString settingsValue; [[maybe_unused]] bool settingsCopied = settingsRegistry->Get(settingsValue, settingsKey) && registry.Set(settingsKey, settingsValue); AZ_Warning("Settings Registry Builder", settingsCopied, "Unable to copy setting %s from AssetProcessor settings registry" " to local settings registry", settingsKey.c_str()); } + + // Read the AssetProcessor loaded Gem Information from the global Registry + AZStd::vector gemInfos; + size_t pathIndex{}; + if (AzFramework::GetGemsInfo(gemInfos, *settingsRegistry)) + { + AZStd::vector sourcePaths; + for (const AzFramework::GemInfo& gemInfo : gemInfos) + { + for (const AZ::IO::Path& absoluteSourcePath : gemInfo.m_absoluteSourcePaths) + { + if (auto foundIt = AZStd::find(sourcePaths.begin(), sourcePaths.end(), absoluteSourcePath); + foundIt == sourcePaths.end()) + { + sourcePaths.emplace_back(absoluteSourcePath); + } + } + } + + for (const AZ::IO::Path& sourcePath : sourcePaths) + { + // Use JSON Pointer to append elements to the SourcePaths array + registry.Set(FixedValueString::format("%s/SourcePaths/%zu", PlaceholderGemKey.c_str(), pathIndex++), + sourcePath.Native()); + } + } } AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_EngineRegistry(registry, platform, specialization, &scratchBuffer); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_GemRegistries(registry, platform, specialization, &scratchBuffer); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectRegistry(registry, platform, specialization, &scratchBuffer); + // The Placeholder Key is removed now that the each gem "/Registry" directory has been merged + registry.Remove(PlaceholderGemKey); + // Merge the Project User and User home settings registry only in non-release builds constexpr bool executeRegDumpCommands = false; AZ::CommandLine* commandLine{}; From ce6514de6db04a63944bfaa47173dda0c1b815a4 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Mon, 19 Jul 2021 14:58:19 -0500 Subject: [PATCH 2/2] Added clarifying comments as to why the Gem's SourcePaths directory is temporarily copied over to the SettingsRegistryBuilder local Settings Registry instance Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- .../InternalBuilders/SettingsRegistryBuilder.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp index f0651411c6..f808850ad7 100644 --- a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp +++ b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp @@ -271,7 +271,7 @@ namespace AssetProcessor AZ::SettingsRegistryImpl registry; - // Seed the local settings registry using the AssetProcessor settings registry + // Seed the local settings registry using the AssetProcessor Settings Registry if (auto settingsRegistry = AZ::Interface::Get(); settingsRegistry != nullptr) { AZStd::array settingsToCopy{ @@ -292,7 +292,12 @@ namespace AssetProcessor " to local settings registry", settingsKey.c_str()); } - // Read the AssetProcessor loaded Gem Information from the global Registry + // The purpose of this section is to copy the Gem's SourcePaths from the Global Settings Registry + // the local SettingsRegistry. The reason this is needed is so that the call to + // `MergeSettingsToRegistry_GemRegistries` below is able to locate each gem's "/Registry" folder + // that will be merged into the bootstrap.game...setreg file + // This is used by the GameLauncher applications to read from a single merged .setreg file + // containing the settings needed to run a game/simulation without have access to the source code base registry AZStd::vector gemInfos; size_t pathIndex{}; if (AzFramework::GetGemsInfo(gemInfos, *settingsRegistry)) @@ -320,10 +325,13 @@ namespace AssetProcessor } AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_EngineRegistry(registry, platform, specialization, &scratchBuffer); + // This function iterates over each path for each the "/Amazon/Gems//SourcePaths" key and attempts + // to merge the "Registry" directory in each path. AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_GemRegistries(registry, platform, specialization, &scratchBuffer); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_ProjectRegistry(registry, platform, specialization, &scratchBuffer); - // The Placeholder Key is removed now that the each gem "/Registry" directory has been merged + // The Placeholder Key is removed now that each gem's "/Registry" directory have been merged to + // the local Settings Registry instance via `MergeSettingsToRegistry_GemRegistries` registry.Remove(PlaceholderGemKey); // Merge the Project User and User home settings registry only in non-release builds