LYN-2524: Launch AP from SDK when not found in the executable directory
This commit is contained in:
+23
-3
@@ -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<const char*>(nullptr), static_cast<const char*>(nullptr), static_cast<const char*>(nullptr)
|
||||
|
||||
+22
@@ -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,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())
|
||||
|
||||
+21
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user