diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp index 113fdd433e..e1bd717e7b 100644 --- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryMergeUtils.cpp @@ -276,7 +276,9 @@ namespace AZ::SettingsRegistryMergeUtils return engineRoot; } - return {}; + // Fall back to using the project root as the engine root if the engine path could not be reconciled + // by checking the project.json "engine" string within o3de_manifest.json "engine_paths" object + return projectRoot; } AZ::IO::FixedMaxPath FindProjectRoot(SettingsRegistryInterface& settingsRegistry) @@ -309,7 +311,13 @@ namespace AZ::SettingsRegistryMergeUtils return projectRoot; } - return {}; + // Step 3 Check for a "Cache" directory by scanning upwards from the executable directory + if (auto candidateRoot = Internal::ScanUpRootLocator("Cache"); + !candidateRoot.empty() && AZ::IO::SystemFile::IsDirectory(candidateRoot.c_str())) + { + projectRoot = AZStd::move(candidateRoot); + } + return projectRoot; } AZStd::string_view ConfigParserSettings::DefaultCommentPrefixFilter(AZStd::string_view line) diff --git a/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp b/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp index 475a7d5504..424132b624 100644 --- a/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp +++ b/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp @@ -28,20 +28,22 @@ namespace AzGameFramework // can read from the FileIOBase instance if available m_settingsRegistry->SetUseFileIO(true); - // Attempt to mount the engine pak from the Executable Directory - // at the Assets alias, otherwise to attempting to mount the engine pak - // from the Cache folder - AZ::IO::FixedMaxPath enginePakPath = AZ::Utils::GetExecutableDirectory(); - enginePakPath /= "engine.pak"; - if (!m_archive->OpenPack("@assets@", enginePakPath.Native())) + // Attempt to mount the engine pak to the project product asset alias + // Search Order: + // - Project Cache Root Directory + // - Executable Directory + bool enginePakOpened{}; + AZ::IO::FixedMaxPath enginePakPath; + if (m_settingsRegistry->Get(enginePakPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder)) { - enginePakPath.clear(); - if (m_settingsRegistry->Get(enginePakPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder)) - { - // fall back to checking Project Cache Root. - enginePakPath /= "engine.pak"; - m_archive->OpenPack("@assets@", enginePakPath.Native()); - } + // fall back to checking Project Cache Root. + enginePakPath /= "engine.pak"; + enginePakOpened = m_archive->OpenPack("@projectproductassets@", enginePakPath.Native()); + } + if (!enginePakOpened) + { + enginePakPath = AZ::IO::FixedMaxPath(AZ::Utils::GetExecutableDirectory()) / "engine.pak"; + m_archive->OpenPack("@projectproductassets@", enginePakPath.Native()); } } diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 5fa7f21939..8fb2effe29 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -430,21 +430,6 @@ function(ly_setup_cmake_install) DESTINATION . COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) - string(CONFIGURE [=[ -if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$") - set(install_output_folder "${CMAKE_INSTALL_PREFIX}/@runtime_output_directory@") - file(WRITE ${install_output_folder}/engine.json -"{ - \"engine_name\": \"@LY_VERSION_ENGINE_NAME@\" -}") -endif() -]=] - install_engine_json_release - @ONLY - ) - install(CODE ${install_engine_json_release} - COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} # use the default for the time being - ) # Collect all Find files that were added with ly_add_external_target_path unset(additional_find_files) diff --git a/cmake/Projects.cmake b/cmake/Projects.cmake index 6109229e72..c09fe0fc6f 100644 --- a/cmake/Projects.cmake +++ b/cmake/Projects.cmake @@ -173,12 +173,9 @@ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$") message(STATUS "${install_output_folder}/engine.pak generated") endif() endif() - file(WRITE ${install_output_folder}/project.json -"{ - \"project_name\": \"@project_name@\" -}") endif() ]=]) + string(CONFIGURE "${install_engine_pak_template}" install_engine_pak_code @ONLY) ly_install_run_code("${install_engine_pak_code}")