From 70b4938cffed004679b0bf6c0de9280cddab02a7 Mon Sep 17 00:00:00 2001 From: phistere Date: Wed, 21 Apr 2021 11:55:01 -0500 Subject: [PATCH 1/3] LYN-2524: Launch AP from SDK when not found in the executable directory --- .../AssetSystemComponentHelper_Linux.cpp | 26 ++++++++++++++++--- .../Asset/AssetSystemComponentHelper_Mac.cpp | 22 ++++++++++++++++ .../AssetSystemComponentHelper_Windows.cpp | 21 +++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp index 1f71b97a57..4f9aeaf6c3 100644 --- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp +++ b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp @@ -29,6 +29,29 @@ 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.Assign(engineRoot); + assetProcessorPath /= "bin"; +#if defined(AZ_DEBUG_BUILD) + assetProcessorPath /= "debug"; +#elif defined(AZ_PROFILE_BUILD) + assetProcessorPath /= "profile"; +#else + assetProcessorPath /= "release"; +#endif + assetProcessorPath /= "AssetProcessor"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + return false; + } + } + pid_t firstChildPid = fork(); if (firstChildPid == 0) { @@ -47,9 +70,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(nullptr), static_cast(nullptr), static_cast(nullptr) diff --git a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp index 43f7599676..cc31cc9a0c 100644 --- a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp +++ b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -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,26 @@ 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.Assign(engineRoot); + assetProcessorPath /= "bin"; + #if defined(AZ_DEBUG_BUILD) + assetProcessorPath /= "debug"; +#elif defined(AZ_PROFILE_BUILD) + assetProcessorPath /= "profile"; +#else + assetProcessorPath /= "release"; +#endif + assetProcessorPath /= "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()) diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index 3f4dbef22a..155a69a691 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -67,6 +68,26 @@ 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.Assign(engineRoot); + assetProcessorPath /= "bin"; +#if defined(AZ_DEBUG_BUILD) + assetProcessorPath /= "debug"; +#elif defined(AZ_PROFILE_BUILD) + assetProcessorPath /= "profile"; +#else + assetProcessorPath /= "release"; +#endif + assetProcessorPath /= "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 From f36bfd9db5ae5d9ef474a49b527aaf7c35762191 Mon Sep 17 00:00:00 2001 From: phistere Date: Wed, 21 Apr 2021 19:53:07 -0500 Subject: [PATCH 2/3] LYN-2524: Adding more files to CMake install to help AP run from SDK. Fixes an issue configuring an external project. --- cmake/PAL.cmake | 10 +++--- cmake/Platform/Common/Install_common.cmake | 40 +++++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/cmake/PAL.cmake b/cmake/PAL.cmake index 5131005c72..c7adb660f0 100644 --- a/cmake/PAL.cmake +++ b/cmake/PAL.cmake @@ -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() diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 286f449acd..023b7369a7 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -184,7 +184,7 @@ function(ly_setup_cmake_install) install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . - REGEX "Findo3de.cmake" EXCLUDE + REGEX "Findo3de.cmake" EXCLUDE REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE ) install( @@ -265,6 +265,44 @@ function(ly_setup_others) REGEX "runtime" EXCLUDE ) + # Registry + install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/bin/$/Registry + DESTINATION ./bin/$ + ) + 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/$/${qt_dir} + DESTINATION ./bin/$ + ) + 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() From 93ba2ea25175164b20a2458d258887edaf12b5ea Mon Sep 17 00:00:00 2001 From: phistere Date: Thu, 22 Apr 2021 11:42:58 -0500 Subject: [PATCH 3/3] LYN-2524: Updates for PR feedback. Simplify path building, fix whitespace. --- .../Asset/AssetSystemComponentHelper_Linux.cpp | 11 +---------- .../Asset/AssetSystemComponentHelper_Mac.cpp | 11 +---------- .../Asset/AssetSystemComponentHelper_Windows.cpp | 11 +---------- cmake/Platform/Common/Install_common.cmake | 2 +- 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp index 4f9aeaf6c3..1ae3945bd6 100644 --- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp +++ b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp @@ -35,16 +35,7 @@ namespace AzFramework::AssetSystem::Platform 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.Assign(engineRoot); - assetProcessorPath /= "bin"; -#if defined(AZ_DEBUG_BUILD) - assetProcessorPath /= "debug"; -#elif defined(AZ_PROFILE_BUILD) - assetProcessorPath /= "profile"; -#else - assetProcessorPath /= "release"; -#endif - assetProcessorPath /= "AssetProcessor"; + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor"; if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { diff --git a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp index cc31cc9a0c..6f1f860932 100644 --- a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp +++ b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp @@ -34,16 +34,7 @@ namespace AzFramework::AssetSystem::Platform 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.Assign(engineRoot); - assetProcessorPath /= "bin"; - #if defined(AZ_DEBUG_BUILD) - assetProcessorPath /= "debug"; -#elif defined(AZ_PROFILE_BUILD) - assetProcessorPath /= "profile"; -#else - assetProcessorPath /= "release"; -#endif - assetProcessorPath /= "AssetProcessor.app"; + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app"; if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index 155a69a691..b716778cf4 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -71,16 +71,7 @@ namespace AzFramework::AssetSystem::Platform 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.Assign(engineRoot); - assetProcessorPath /= "bin"; -#if defined(AZ_DEBUG_BUILD) - assetProcessorPath /= "debug"; -#elif defined(AZ_PROFILE_BUILD) - assetProcessorPath /= "profile"; -#else - assetProcessorPath /= "release"; -#endif - assetProcessorPath /= "AssetProcessor.exe"; + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe"; if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 023b7369a7..105b208338 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -184,7 +184,7 @@ function(ly_setup_cmake_install) install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . - REGEX "Findo3de.cmake" EXCLUDE + REGEX "Findo3de.cmake" EXCLUDE REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE ) install(