Swapped the order in which the engine.pak is searched (#4455)

* Swapped the order in which the engine.pak is searched

First the Project Cache Root folder is searched before falling back to
the Executable Directory

Removed the need for the engine.json and project.json in a project
release layout when a "Cache" directory exist at the root.
The project root uses the the first "Cache" directory it finds by scanning upwards as if fails to find a
project.json,
The engine root use the project root, if it fails to reconcile the
engine path using project.json "engine" key and the o3de_manifest.json
"engines_path" object.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Removed Generation of the engine.json and project.json in Release
Install builds.

The project and engine path can be determined based on the Cache
directory location.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added missing space for enginePakOpened

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding missing endif() and bracket argument terminator.


Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
lumberyard-employee-dm
2021-10-05 11:24:37 -05:00
committed by GitHub
parent 365dd61778
commit 14474dbac7
4 changed files with 26 additions and 34 deletions
@@ -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)
@@ -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());
}
}
@@ -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)
+1 -4
View File
@@ -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}")