Merge pull request #239 from aws-lumberyard-dev/ly-sdk/phistere/LaunchApFromSDK

Launch AssetProcessor from prebuilt SDK
- Look for AssetProcessor in a known SDK layout location if one in executable directory is not found.
- Adds more files to the CMake install to help fix some errors launching AP from SDK.
This commit is contained in:
Eric Phister
2021-04-22 14:32:14 -05:00
committed by GitHub
5 changed files with 83 additions and 7 deletions
@@ -29,6 +29,20 @@ namespace AzFramework::AssetSystem::Platform
bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot,
AZStd::string_view projectPath)
{
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
assetProcessorPath /= "AssetProcessor";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
return false;
}
}
pid_t firstChildPid = fork();
if (firstChildPid == 0)
{
@@ -47,9 +61,6 @@ namespace AzFramework::AssetSystem::Platform
pid_t secondChildPid = fork();
if (secondChildPid == 0)
{
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
assetProcessorPath /= "AssetProcessor";
AZStd::array args {
assetProcessorPath.c_str(), assetProcessorPath.c_str(), "--start-hidden",
static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), static_cast<const char*>(nullptr)
@@ -11,6 +11,7 @@
*/
#include <AzCore/IO/Path/Path.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <sys/types.h>
@@ -20,6 +21,7 @@ namespace AzFramework::AssetSystem::Platform
{
void AllowAssetProcessorToForeground()
{}
bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot,
AZStd::string_view projectPath)
{
@@ -29,6 +31,17 @@ namespace AzFramework::AssetSystem::Platform
assetProcessorPath /= "../../../AssetProcessor.app";
assetProcessorPath = assetProcessorPath.LexicallyNormal();
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
return false;
}
}
auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"(open -g "%s" --args --start-hidden)", assetProcessorPath.c_str());
// Add the engine path to the launch command if not empty
if (!engineRoot.empty())
@@ -12,6 +12,7 @@
#include <AzCore/PlatformIncl.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <Psapi.h>
@@ -67,6 +68,17 @@ namespace AzFramework::AssetSystem::Platform
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
assetProcessorPath /= "AssetProcessor.exe";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe";
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
{
return false;
}
}
auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"("%s" --start-hidden)", assetProcessorPath.c_str());
// Add the engine path to the launch command if not empty
+6 -4
View File
@@ -63,10 +63,12 @@ function(ly_get_absolute_pal_filename out_name in_name)
set(full_name ${in_name})
if (NOT EXISTS ${full_name})
string(REGEX MATCH "${repo_dir}/(.*)/Platform/([^/]*)/?(.*)$" match ${full_name})
if(${CMAKE_MATCH_2} IN_LIST PAL_RESTRICTED_PLATFORMS)
set(full_name ${repo_dir}/restricted/${CMAKE_MATCH_2}/${CMAKE_MATCH_1})
if(NOT "${CMAKE_MATCH_3}" STREQUAL "")
string(APPEND full_name "/" ${CMAKE_MATCH_3})
if(PAL_RESTRICTED_PLATFORMS)
if("${CMAKE_MATCH_2}" IN_LIST PAL_RESTRICTED_PLATFORMS)
set(full_name ${repo_dir}/restricted/${CMAKE_MATCH_2}/${CMAKE_MATCH_1})
if(NOT "${CMAKE_MATCH_3}" STREQUAL "")
string(APPEND full_name "/" ${CMAKE_MATCH_3})
endif()
endif()
endif()
endif()
@@ -265,6 +265,44 @@ function(ly_setup_others)
REGEX "runtime" EXCLUDE
)
# Registry
install(DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/bin/$<CONFIG>/Registry
DESTINATION ./bin/$<CONFIG>
)
install(DIRECTORY
# This one will change soon, Engine/Registry files will be relocated to Registry
${CMAKE_SOURCE_DIR}/Engine/Registry
DESTINATION ./Engine
)
install(FILES
${CMAKE_SOURCE_DIR}/AssetProcessorPlatformConfig.setreg
DESTINATION ./Registry
)
# Qt Binaries
set(QT_BIN_DIRS bearer iconengines imageformats platforms styles translations)
foreach(qt_dir ${QT_BIN_DIRS})
install(DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/bin/$<CONFIG>/${qt_dir}
DESTINATION ./bin/$<CONFIG>
)
endforeach()
# Templates
install(DIRECTORY
${CMAKE_SOURCE_DIR}/Templates
DESTINATION .
)
# Misc
install(FILES
${CMAKE_SOURCE_DIR}/ctest_pytest.ini
${CMAKE_SOURCE_DIR}/LICENSE.txt
${CMAKE_SOURCE_DIR}/README.md
DESTINATION .
)
endfunction()