Merge branch 'development' into Prism/ShowRepoList

This commit is contained in:
nggieber
2021-10-11 09:20:06 -07:00
889 changed files with 22679 additions and 14037 deletions
@@ -27,7 +27,7 @@ namespace AWSNativeSDKInit
void CopyCaCertBundle()
{
AZStd::vector<char> contents;
AZStd::string certificatePath = "@assets@/certificates/aws/cacert.pem";
AZStd::string certificatePath = "@products@/certificates/aws/cacert.pem";
AZStd::string publicStoragePath = AZ::Android::Utils::GetAppPublicStoragePath();
publicStoragePath.append("/certificates/aws/cacert.pem");
@@ -36,6 +36,7 @@
#include <AssetBuilderComponent.h>
#include <AssetBuilderInfo.h>
#include <AzCore/Interface/Interface.h>
#include <Entity/EntityUtilityComponent.h>
namespace AssetBuilder
{
@@ -80,6 +81,7 @@ AZ::ComponentTypeList AssetBuilderApplication::GetRequiredSystemComponents() con
azrtti_typeid<AzToolsFramework::Components::EditorEntityModelComponent>(),
azrtti_typeid<AzToolsFramework::EditorEntityContextComponent>(),
azrtti_typeid<AzToolsFramework::Prefab::PrefabSystemComponent>(),
azrtti_typeid<AzToolsFramework::EntityUtilityComponent>(),
});
return components;
@@ -683,31 +683,26 @@ void AssetBuilderComponent::ProcessJob(const AssetBuilderSDK::ProcessJobFunction
AZ_Assert(settingsRegistry != nullptr, "SettingsRegistry must be ready for use in the AssetBuilder.");
// The root path is the cache plus the platform name.
AZ::IO::FixedMaxPath newRoot(m_gameCache);
AZ::IO::FixedMaxPath newProjectCache(m_gameCache);
// Check if the platform identifier is a valid "asset platform"
// If so, use it, other wise use the OS default platform as a fail safe
// This is to make sure the "debug platform" isn't added as a path segment
// the Cache Root folder
// the Cache ProjectCache folder
if (AzFramework::PlatformHelper::GetPlatformIdFromName(request.m_platformInfo.m_identifier) != AzFramework::PlatformId::Invalid)
{
newRoot /= request.m_platformInfo.m_identifier;
newProjectCache /= request.m_platformInfo.m_identifier;
}
else
{
newRoot /= AzFramework::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME);
newProjectCache /= AzFramework::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME);
}
// The asset path is root and the lower case game name.
AZ::IO::FixedMaxPath newAssets = newRoot;
// Now set the paths and run the job.
{
// Save out the prior paths.
ScopedAliasSetter assetAliasScope(*ioBase, "@assets@", newAssets.c_str());
ScopedAliasSetter rootAliasScope(*ioBase, "@root@", newRoot.c_str());
ScopedAliasSetter projectplatformCacheAliasScope(*ioBase, "@projectplatformcache@", newRoot.c_str());
ScopedAliasSetter projectPlatformCacheAliasScope(*ioBase, "@products@", newProjectCache.c_str());
ScopedSettingsRegistrySetter cacheRootFolderScope(*settingsRegistry,
AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder, newRoot.Native());
AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder, newProjectCache.Native());
// Invoke the Process Job function
job(request, outResponse);
@@ -27,7 +27,7 @@ namespace AssetProcessor
, m_registryBuiltOnce(false)
, m_registriesMutex(QMutex::Recursive)
{
for (const AssetBuilderSDK::PlatformInfo& info : m_platformConfig->GetEnabledPlatforms())
{
m_platforms.push_back(QString::fromUtf8(info.m_identifier.c_str()));
@@ -38,17 +38,9 @@ namespace AssetProcessor
// save 30mb for this. Really large projects do get this big (and bigger)
// if you don't do this, things get fragmented very fast.
m_saveBuffer.reserve(1024 * 1024 * 30);
m_absoluteDevFolderPath[0] = 0;
m_absoluteDevGameFolderPath[0] = 0;
m_saveBuffer.reserve(1024 * 1024 * 30);
AZStd::string engineRoot;
AzFramework::ApplicationRequests::Bus::BroadcastResult(engineRoot, &AzFramework::ApplicationRequests::GetEngineRoot);
azstrcpy(m_absoluteDevFolderPath, AZ_MAX_PATH_LEN, engineRoot.c_str());
AZStd::string gameFolderPath{AssetUtilities::ComputeProjectPath().toUtf8().constData()};
azstrcpy(m_absoluteDevGameFolderPath, AZ_MAX_PATH_LEN, gameFolderPath.c_str());
AssetUtilities::ComputeProjectPath();
AssetUtilities::ComputeProjectCacheRoot(m_cacheRootDir);
@@ -359,7 +351,7 @@ namespace AssetProcessor
[[maybe_unused]] bool makeDirResult = AZ::IO::SystemFile::CreateDir(absPath.toUtf8().constData());
AZ_Warning(AssetProcessor::ConsoleChannel, makeDirResult, "Failed create folder %s", platformCacheDir.toUtf8().constData());
}
// if we succeeded in doing this, then use "rename" to move the file over the previous copy.
bool moved = AssetUtilities::MoveFileWithTimeout(tempRegistryFile, actualRegistryFile, 3);
allCatalogsSaved = allCatalogsSaved && moved;
@@ -382,7 +374,7 @@ namespace AssetProcessor
}
}
}
{
// scoped to minimize the duration of this mutex lock
QMutexLocker locker(&m_savingRegistryMutex);
@@ -605,7 +597,7 @@ namespace AssetProcessor
AZStd::string nameForMap(relativeFilePath.toUtf8().constData());
AZStd::to_lower(nameForMap.begin(), nameForMap.end());
m_sourceNameToSourceUUIDMap.insert({ nameForMap, sourceUuid });
}
@@ -627,16 +619,6 @@ namespace AssetProcessor
//////////////////////////////////////////////////////////////////////////
const char* AssetCatalog::GetAbsoluteDevGameFolderPath()
{
return m_absoluteDevGameFolderPath;
}
const char* AssetCatalog::GetAbsoluteDevRootFolderPath()
{
return m_absoluteDevFolderPath;
}
bool AssetCatalog::GetRelativeProductPathFromFullSourceOrProductPath(const AZStd::string& fullSourceOrProductPath, AZStd::string& relativeProductPath)
{
ProcessGetRelativeProductPathFromFullSourceOrProductPathRequest(fullSourceOrProductPath, relativeProductPath);
@@ -976,7 +958,7 @@ namespace AssetProcessor
// regardless of which way we come into this function we must always use ConvertToRelativePath
// to convert from whatever the input format is to a database path (which may include output prefix)
QString databaseName;
QString databaseName;
QString scanFolder;
if (!AzFramework::StringFunc::Path::IsRelative(sourcePath))
{
@@ -1163,7 +1145,7 @@ namespace AssetProcessor
AZStd::string AssetCatalog::GetAssetPathById(const AZ::Data::AssetId& id)
{
return GetAssetInfoById(id).m_relativePath;
}
AZ::Data::AssetId AssetCatalog::GetAssetIdByPath(const char* path, const AZ::Data::AssetType& typeToRegister, bool autoRegisterIfNotFound)
@@ -1175,7 +1157,7 @@ namespace AssetProcessor
AZStd::string relProductPath;
GetRelativeProductPathFromFullSourceOrProductPath(path, relProductPath);
QString tempPlatformName = GetDefaultAssetPlatform();
AZ::Data::AssetId assetId;
{
QMutexLocker locker(&m_registriesMutex);
@@ -1344,7 +1326,7 @@ namespace AssetProcessor
//remove aliases if present
normalisedAssetPath = AssetUtilities::NormalizeAndRemoveAlias(normalisedAssetPath);
if (!normalisedAssetPath.isEmpty()) // this happens if it comes in as just for example "@assets@/"
if (!normalisedAssetPath.isEmpty()) // this happens if it comes in as just for example "@products@/"
{
AZStd::lock_guard<AZStd::mutex> lock(m_databaseMutex);
@@ -1439,7 +1421,7 @@ namespace AssetProcessor
relativePath = entry.m_sourceName;
watchFolder = scanEntry.m_scanFolder;
return true;
}
@@ -1489,7 +1471,7 @@ namespace AssetProcessor
{
return foundIter->second;
}
// we did not find it - try the backup mapping!
AssetId legacyMapping = registryToUse.GetAssetIdByLegacyAssetId(assetId);
if (legacyMapping.IsValid())
@@ -1533,7 +1515,7 @@ namespace AssetProcessor
return !assetInfo.m_relativePath.empty();
}
// Asset isn't in the DB or in the APM queue, we don't know what this asset ID is
return false;
}
@@ -1588,7 +1570,7 @@ namespace AssetProcessor
AZStd::string sourceFileFullPath;
AzFramework::StringFunc::Path::Join(watchFolder.c_str(), assetInfo.m_relativePath.c_str(), sourceFileFullPath);
assetInfo.m_sizeBytes = AZ::IO::SystemFile::Length(sourceFileFullPath.c_str());
assetInfo.m_assetType = AZ::Uuid::CreateNull(); // most source files don't have a type!
// Go through the list of source assets and see if this asset's file path matches any of the filters
@@ -88,8 +88,6 @@ namespace AssetProcessor
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::AssetSystem::AssetSystemRequestBus::Handler overrides
const char* GetAbsoluteDevGameFolderPath() override;
const char* GetAbsoluteDevRootFolderPath() override;
bool GetRelativeProductPathFromFullSourceOrProductPath(const AZStd::string& fullPath, AZStd::string& relativeProductPath) override;
//! Given a partial or full source file path, respond with its relative path and the watch folder it is relative to.
@@ -215,8 +213,6 @@ namespace AssetProcessor
AZStd::vector<char> m_saveBuffer; // so that we don't realloc all the time
char m_absoluteDevFolderPath[AZ_MAX_PATH_LEN];
char m_absoluteDevGameFolderPath[AZ_MAX_PATH_LEN];
QDir m_cacheRootDir;
};
}
@@ -56,15 +56,8 @@ namespace AssetProcessor
// cache this up front. Note that it can fail here, and will retry later.
InitializeCacheRoot();
m_absoluteDevFolderPath[0] = 0;
m_absoluteDevGameFolderPath[0] = 0;
QDir assetRoot;
if (AssetUtilities::ComputeAssetRoot(assetRoot))
{
azstrcpy(m_absoluteDevFolderPath, AZ_MAX_PATH_LEN, assetRoot.absolutePath().toUtf8().constData());
azstrcpy(m_absoluteDevGameFolderPath, AZ_MAX_PATH_LEN, AssetUtilities::ComputeProjectPath().toUtf8().constData());
}
AssetUtilities::ComputeAssetRoot(assetRoot);
using namespace AZStd::placeholders;
@@ -440,8 +440,6 @@ namespace AssetProcessor
AZStd::mutex m_sourceUUIDToSourceInfoMapMutex;
QString m_normalizedCacheRootPath;
char m_absoluteDevFolderPath[AZ_MAX_PATH_LEN];
char m_absoluteDevGameFolderPath[AZ_MAX_PATH_LEN];
QDir m_cacheRootDir;
bool m_isCurrentlyScanning = false;
bool m_quitRequested = false;
@@ -95,7 +95,7 @@ void FileServer::ConnectionAdded(unsigned int connId, Connection* connection)
Q_UNUSED(connection);
// Connection has not completed negotiation yet, register to be notified
// when we know what platform is connected and map the @assets@ alias then
// when we know what platform is connected and map the @products@ alias then
connect(connection, &Connection::AssetPlatformChanged, this, [this, connection]()
{
auto fileIO = m_fileIOs[connection->ConnectionId()];
@@ -114,8 +114,7 @@ void FileServer::ConnectionAdded(unsigned int connId, Connection* connection)
projectCacheRoot = QDir(projectCacheRoot.absoluteFilePath(assetPlatform));
}
const char* projectCachePath = projectCacheRoot.absolutePath().toUtf8().data();
fileIO->SetAlias("@assets@", projectCachePath);
fileIO->SetAlias("@root@", projectCachePath);
fileIO->SetAlias("@products@", projectCachePath);
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
@@ -955,10 +954,10 @@ void FileServer::ProcessFileTreeRequest(unsigned int connId, unsigned int, unsig
FileTreeResponse::FolderList folders;
AZStd::vector<AZ::OSString> untestedFolders;
if (fileIO->IsDirectory("@assets@"))
if (fileIO->IsDirectory("@products@"))
{
folders.push_back("@assets@");
untestedFolders.push_back("@assets@");
folders.push_back("@products@");
untestedFolders.push_back("@products@");
}
if (fileIO->IsDirectory("@usercache@"))
{
@@ -975,11 +974,6 @@ void FileServer::ProcessFileTreeRequest(unsigned int connId, unsigned int, unsig
folders.push_back("@log@");
untestedFolders.push_back("@log@");
}
if (fileIO->IsDirectory("@root@"))
{
folders.push_back("@root@");
untestedFolders.push_back("@root@");
}
AZ::IO::Result res = ResultCode::Success;
@@ -766,7 +766,7 @@ namespace AssetProcessor
TEST_F(AssetCatalogTest_GetFullSourcePath, AliasedCachePath_ReturnsAbsolutePathToSource)
{
//feed it a path with alias and asset id
QString fileToCheck = "@assets@/subfolder3/randomfileoutput.random1";
QString fileToCheck = "@products@/subfolder3/randomfileoutput.random1";
EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, m_data->m_temporarySourceDir, true, "subfolder3/somerandomfile.random"));
}
@@ -787,7 +787,7 @@ namespace AssetProcessor
TEST_F(AssetCatalogTest_GetFullSourcePath, InvalidSourcePathContainingCacheAlias_ReturnsAbsolutePathToSource)
{
//feed it a path with alias and input name
QString fileToCheck = "@assets@/somerandomfile.random";
QString fileToCheck = "@products@/somerandomfile.random";
EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, m_data->m_temporarySourceDir, true, "subfolder3/somerandomfile.random"));
}
@@ -62,7 +62,10 @@ namespace AssetProcessor
{
searchStr = searchStr.mid(0, subidPos);
}
AZ::Uuid filterAsUuid = AZ::Uuid::CreateStringPermissive(searchStr.toUtf8(), 0);
// Cap the string to some reasonable length, we don't want to try parsing an entire book
size_t cappedStringLength = searchStr.length() > 60 ? 60 : searchStr.length();
AZ::Uuid filterAsUuid = AZ::Uuid::CreateStringPermissive(searchStr.toUtf8(), cappedStringLength);
return DescendantMatchesFilter(*assetTreeItem, filter, filterAsUuid);
}
@@ -168,7 +168,9 @@ namespace AssetProcessor
if (childItem)
{
return createIndex(row, column, childItem);
QModelIndex index = createIndex(row, column, childItem);
Q_ASSERT(checkIndex(index));
return index;
}
return QModelIndex();
}
@@ -197,7 +199,9 @@ namespace AssetProcessor
{
return QModelIndex();
}
return createIndex(parentItem->GetRow(), 0, parentItem);
QModelIndex parentIndex = createIndex(parentItem->GetRow(), 0, parentItem);
Q_ASSERT(checkIndex(parentIndex));
return parentIndex;
}
bool AssetTreeModel::hasChildren(const QModelIndex &parent) const
@@ -92,6 +92,7 @@ namespace AssetProcessor
}
QModelIndex parentIndex = createIndex(parent->GetRow(), 0, parent);
Q_ASSERT(checkIndex(parentIndex));
beginRemoveRows(parentIndex, assetToRemove->GetRow(), assetToRemove->GetRow());
@@ -179,6 +180,8 @@ namespace AssetProcessor
QModelIndex existingIndexStart = createIndex(existingEntry->second->GetRow(), 0, existingEntry->second);
QModelIndex existingIndexEnd = createIndex(existingEntry->second->GetRow(), existingEntry->second->GetColumnCount() - 1, existingEntry->second);
Q_ASSERT(checkIndex(existingIndexStart));
Q_ASSERT(checkIndex(existingIndexEnd));
dataChanged(existingIndexStart, existingIndexEnd);
return;
}
@@ -205,7 +208,8 @@ namespace AssetProcessor
{
if (!modelIsResetting)
{
QModelIndex parentIndex = createIndex(parentItem->GetRow(), 0, parentItem);
QModelIndex parentIndex = parentItem == m_root.get() ? QModelIndex() : createIndex(parentItem->GetRow(), 0, parentItem);
Q_ASSERT(checkIndex(parentIndex));
beginInsertRows(parentIndex, parentItem->getChildCount(), parentItem->getChildCount());
}
nextParent = parentItem->CreateChild(ProductAssetTreeItemData::MakeShared(nullptr, currentFullFolderPath.Native(), currentPath.c_str(), true, AZ::Uuid::CreateNull()));
@@ -231,7 +235,8 @@ namespace AssetProcessor
if (!modelIsResetting)
{
QModelIndex parentIndex = createIndex(parentItem->GetRow(), 0, parentItem);
QModelIndex parentIndex = parentItem == m_root.get() ? QModelIndex() : createIndex(parentItem->GetRow(), 0, parentItem);
Q_ASSERT(checkIndex(parentIndex));
beginInsertRows(parentIndex, parentItem->getChildCount(), parentItem->getChildCount());
}
@@ -13,6 +13,7 @@
#include <AzCore/IO/Path/Path.h>
#include <native/utilities/assetUtils.h>
#include <AzCore/Console/IConsole.h>
#include <QDebug>
namespace AssetProcessor
{
@@ -102,7 +103,8 @@ namespace AssetProcessor
{
if (!modelIsResetting)
{
QModelIndex parentIndex = createIndex(parentItem->GetRow(), 0, parentItem);
QModelIndex parentIndex = parentItem == m_root.get() ? QModelIndex() : createIndex(parentItem->GetRow(), 0, parentItem);
Q_ASSERT(checkIndex(parentIndex));
beginInsertRows(parentIndex, parentItem->getChildCount(), parentItem->getChildCount());
}
nextParent = parentItem->CreateChild(SourceAssetTreeItemData::MakeShared(nullptr, nullptr, currentFullFolderPath.Native(), currentPath.c_str(), true));
@@ -118,7 +120,8 @@ namespace AssetProcessor
if (!modelIsResetting)
{
QModelIndex parentIndex = createIndex(parentItem->GetRow(), 0, parentItem);
QModelIndex parentIndex = parentItem == m_root.get() ? QModelIndex() : createIndex(parentItem->GetRow(), 0, parentItem);
Q_ASSERT(checkIndex(parentIndex));
beginInsertRows(parentIndex, parentItem->getChildCount(), parentItem->getChildCount());
}
@@ -173,7 +176,8 @@ namespace AssetProcessor
return;
}
QModelIndex parentIndex = createIndex(parent->GetRow(), 0, parent);
QModelIndex parentIndex = parent == m_root.get() ? QModelIndex() : createIndex(parent->GetRow(), 0, parent);
Q_ASSERT(checkIndex(parentIndex));
beginRemoveRows(parentIndex, assetToRemove->GetRow(), assetToRemove->GetRow());
@@ -47,7 +47,7 @@ void RCcontrollerUnitTests::Reset()
m_rcController.m_RCJobListModel.m_jobs.clear();
m_rcController.m_RCJobListModel.m_jobsInFlight.clear();
m_rcController.m_RCJobListModel.m_jobsInQueueLookup.clear();
m_rcController.m_pendingCriticalJobsPerPlatform.clear();
m_rcController.m_jobsCountPerPlatform.clear();
@@ -56,7 +56,7 @@ void RCcontrollerUnitTests::Reset()
m_rcController.m_RCQueueSortModel.AttachToModel(&m_rcController.m_RCJobListModel);
m_rcController.m_RCQueueSortModel.m_currentJobRunKeyToJobEntries.clear();
m_rcController.m_RCQueueSortModel.m_currentlyConnectedPlatforms.clear();
}
}
void RCcontrollerUnitTests::StartTest()
{
@@ -183,11 +183,11 @@ void RCcontrollerUnitTests::RunRCControllerTests()
QStringList tempJobNames;
// Note that while this is an OS-SPECIFIC path, this test does not actually invoke the file system
// or file operators, so is purely doing in-memory testing. So the path does not actually matter and the
// or file operators, so is purely doing in-memory testing. So the path does not actually matter and the
// test should function on other operating systems too.
// test - exact match
tempJobNames << "c:/somerandomfolder/dev/blah/test.dds";
tempJobNames << "c:/somerandomfolder/dev/blah/test.dds";
tempJobNames << "c:/somerandomfolder/dev/blah/test.cre"; // must not match
// test - NO MATCH
@@ -218,7 +218,7 @@ void RCcontrollerUnitTests::RunRCControllerTests()
QList<RCJob*> createdJobs;
for (QString name : tempJobNames)
{
@@ -270,7 +270,7 @@ void RCcontrollerUnitTests::RunRCControllerTests()
// EXACT MATCH TEST (with prefixes and such)
NetworkRequestID requestID(1, 1234);
m_rcController.OnRequestCompileGroup(requestID, "pc", "@assets@/blah/test.dds", AZ::Data::AssetId());
m_rcController.OnRequestCompileGroup(requestID, "pc", "@products@/blah/test.dds", AZ::Data::AssetId());
QCoreApplication::processEvents(QEventLoop::AllEvents);
// this should have matched exactly one item, and when we finish that item, it should terminate:
@@ -626,9 +626,9 @@ void RCcontrollerUnitTests::RunRCControllerTests()
jobdetailsB.m_jobEntry.m_watchFolderPath = scanFolderInfo.ScanPath();
jobdetailsB.m_jobEntry.m_jobKey = "TestJobB";
jobdetailsB.m_jobEntry.m_builderGuid = builderUuid;
jobdetailsB.m_critical = true; //make jobB critical so that it will be analyzed first even though we want JobA to run first
AssetBuilderSDK::SourceFileDependency sourceFileBDependency;
sourceFileBDependency.m_sourceFileDependencyPath = "fileB.txt";
@@ -694,10 +694,10 @@ void RCcontrollerUnitTests::RunRCControllerTests()
m_rcController.DispatchJobs();
UNIT_TEST_EXPECT_TRUE(UnitTestUtils::BlockUntil(allJobsCompleted, 5000));
UNIT_TEST_EXPECT_TRUE(jobFinishedB);
UNIT_TEST_EXPECT_TRUE(jobFinishedB);
// Now test the use case where we have a cyclic dependency,
// although the order in which these job will start is not defined but we can ensure that
// Now test the use case where we have a cyclic dependency,
// although the order in which these job will start is not defined but we can ensure that
// all the job finishes and RCController goes Idle
allJobsCompleted = false;
Reset();
@@ -728,8 +728,8 @@ void RCcontrollerUnitTests::RunRCControllerTests()
jobdetailsD.m_jobEntry.m_builderGuid = builderUuid;
AssetBuilderSDK::SourceFileDependency sourceFileDDependency;
sourceFileDDependency.m_sourceFileDependencyPath = "fileD.txt";
//creating cyclic job order dependencies i.e JobC and JobD have order job dependency on each other
//creating cyclic job order dependencies i.e JobC and JobD have order job dependency on each other
AssetBuilderSDK::JobDependency jobDependencyC("TestJobC", "pc", AssetBuilderSDK::JobDependencyType::Order, sourceFileCDependency);
AssetBuilderSDK::JobDependency jobDependencyD("TestJobD", "pc", AssetBuilderSDK::JobDependencyType::Order, sourceFileDDependency);
jobdetailsC.m_jobDependencyList.push_back({ jobDependencyD });
@@ -262,11 +262,10 @@ namespace UnitTestUtils
AZ::IO::FileIOBase::SetInstance(m_localFileIO);
m_localFileIO->SetAlias("@assets@", (newDir + QString("/ALIAS/assets")).toUtf8().constData());
m_localFileIO->SetAlias("@products@", (newDir + QString("/ALIAS/assets")).toUtf8().constData());
m_localFileIO->SetAlias("@log@", (newDir + QString("/ALIAS/logs")).toUtf8().constData());
m_localFileIO->SetAlias("@usercache@", (newDir + QString("/ALIAS/cache")).toUtf8().constData());
m_localFileIO->SetAlias("@user@", (newDir + QString("/ALIAS/user")).toUtf8().constData());
m_localFileIO->SetAlias("@root@", (newDir + QString("/ALIAS/root")).toUtf8().constData());
}
~ScopedDir()
@@ -104,17 +104,17 @@ ApplicationManager::BeforeRunStatus GUIApplicationManager::BeforeRun()
// The build process may leave behind some temporaries, try to delete them
RemoveTemporaries();
QDir devRoot;
AssetUtilities::ComputeAssetRoot(devRoot);
QDir projectAssetRoot;
AssetUtilities::ComputeAssetRoot(projectAssetRoot);
#if defined(EXTERNAL_CRASH_REPORTING)
CrashHandler::ToolsCrashHandler::InitCrashHandler("AssetProcessor", devRoot.absolutePath().toStdString());
CrashHandler::ToolsCrashHandler::InitCrashHandler("AssetProcessor", projectAssetRoot.absolutePath().toStdString());
#endif
AssetProcessor::MessageInfoBus::Handler::BusConnect();
// we have to monitor both the cache folder and the database file and restart AP if either of them gets deleted
// It is important to note that we are monitoring the parent folder and not the actual cache folder itself since
// we want to handle the use case on Mac OS if the user moves the cache folder to the trash.
m_qtFileWatcher.addPath(devRoot.absolutePath());
m_qtFileWatcher.addPath(projectAssetRoot.absolutePath());
QDir projectCacheRoot;
AssetUtilities::ComputeProjectCacheRoot(projectCacheRoot);
@@ -615,7 +615,6 @@ void GUIApplicationManager::DirectoryChanged([[maybe_unused]] QString path)
void GUIApplicationManager::FileChanged(QString path)
{
QDir devRoot = ApplicationManager::GetSystemRoot();
QDir projectCacheRoot;
AssetUtilities::ComputeProjectCacheRoot(projectCacheRoot);
QString assetDbPath = projectCacheRoot.filePath("assetdb.sqlite");
@@ -56,7 +56,7 @@ namespace CrashHandler
if (fileIO)
{
// If our devroot alias is available, use that
const char* devAlias = fileIO->GetAlias("@devroot@");
const char* devAlias = fileIO->GetAlias("@engroot@");
if (devAlias)
{
return devAlias;
@@ -11,5 +11,6 @@
namespace O3DE::ProjectManager
{
const QString ProjectBuildPathPostfix = ProjectBuildDirectoryName + "/linux";
const QString GetPythonScriptPath = "python/get_python.sh";
} // namespace O3DE::ProjectManager
@@ -86,5 +86,13 @@ namespace O3DE::ProjectManager
return AZ::Success();
}
AZ::Outcome<QString, QString> RunGetPythonScript(const QString& engineRoot)
{
return ExecuteCommandResultModalDialog(
QString("%1/python/get_python.sh").arg(engineRoot),
{},
QProcessEnvironment::systemEnvironment(),
QObject::tr("Running get_python script..."));
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
@@ -11,5 +11,6 @@
namespace O3DE::ProjectManager
{
const QString ProjectBuildPathPostfix = ProjectBuildDirectoryName + "/mac_xcode";
const QString GetPythonScriptPath = "python/get_python.sh";
} // namespace O3DE::ProjectManager
@@ -9,6 +9,7 @@
#include <QProcess>
#include <QStandardPaths>
#include <QDir>
namespace O3DE::ProjectManager
{
@@ -94,5 +95,14 @@ namespace O3DE::ProjectManager
return AZ::Success();
}
AZ::Outcome<QString, QString> RunGetPythonScript(const QString& engineRoot)
{
return ExecuteCommandResultModalDialog(
QString("%1/python/get_python.sh").arg(engineRoot),
{},
QProcessEnvironment::systemEnvironment(),
QObject::tr("Running get_python script..."));
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
@@ -10,5 +10,6 @@
namespace O3DE::ProjectManager
{
const QString ProjectBuildPathPostfix = ProjectBuildDirectoryName + "/windows_vs2019";
const QString GetPythonScriptPath = "python/get_python.bat";
} // namespace O3DE::ProjectManager
@@ -130,5 +130,14 @@ namespace O3DE::ProjectManager
return AZ::Success();
}
AZ::Outcome<QString, QString> RunGetPythonScript(const QString& engineRoot)
{
const QString batPath = QString("%1/python/get_python.bat").arg(engineRoot);
return ExecuteCommandResultModalDialog(
"cmd.exe",
QStringList{"/c", batPath},
QProcessEnvironment::systemEnvironment(),
QObject::tr("Running get_python script..."));
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
@@ -68,17 +68,46 @@ namespace O3DE::ProjectManager
}
m_pythonBindings = AZStd::make_unique<PythonBindings>(GetEngineRoot());
if (!m_pythonBindings || !m_pythonBindings->PythonStarted())
AZ_Assert(m_pythonBindings, "Failed to create PythonBindings");
if (!m_pythonBindings->PythonStarted())
{
if (interactive)
if (!interactive)
{
QMessageBox::critical(nullptr, QObject::tr("Failed to start Python"),
QObject::tr("This tool requires an O3DE engine with a Python runtime, "
"but either Python is missing or mis-configured. Please rename "
"your python/runtime folder to python/runtime_bak, then run "
"python/get_python.bat to restore the Python runtime folder."));
return false;
}
int result = QMessageBox::warning(nullptr, QObject::tr("Failed to start Python"),
QObject::tr("This tool requires an O3DE engine with a Python runtime, "
"but either Python is missing or mis-configured.<br><br>Press 'OK' to "
"run the %1 script automatically, or 'Cancel' "
" if you want to manually resolve the issue by renaming your "
" python/runtime folder and running %1 yourself.")
.arg(GetPythonScriptPath),
QMessageBox::Cancel, QMessageBox::Ok);
if (result == QMessageBox::Ok)
{
auto getPythonResult = ProjectUtils::RunGetPythonScript(GetEngineRoot());
if (!getPythonResult.IsSuccess())
{
QMessageBox::critical(
nullptr, QObject::tr("Failed to run %1 script").arg(GetPythonScriptPath),
QObject::tr("The %1 script failed, was canceled, or could not be run. "
"Please rename your python/runtime folder and then run "
"<pre>%1</pre>").arg(GetPythonScriptPath));
}
else if (!m_pythonBindings->StartPython())
{
QMessageBox::critical(
nullptr, QObject::tr("Failed to start Python"),
QObject::tr("Failed to start Python after running %1")
.arg(GetPythonScriptPath));
}
}
if (!m_pythonBindings->PythonStarted())
{
return false;
}
return false;
}
const AZ::CommandLine* commandLine = GetCommandLine();
@@ -18,6 +18,7 @@ namespace O3DE::ProjectManager
static const QString ProjectBuildDirectoryName = "build";
extern const QString ProjectBuildPathPostfix;
extern const QString GetPythonScriptPath;
static const QString ProjectBuildPathCmakeFiles = "CMakeFiles";
static const QString ProjectBuildErrorLogName = "CMakeProjectBuildError.log";
static const QString ProjectCacheDirectoryName = "Cache";
@@ -23,6 +23,11 @@
#include <QProgressDialog>
#include <QSpacerItem>
#include <QGridLayout>
#include <QTextEdit>
#include <QByteArray>
#include <QScrollBar>
#include <QProgressBar>
#include <QLabel>
#include <AzCore/std/chrono/chrono.h>
@@ -512,6 +517,97 @@ namespace O3DE::ProjectManager
return ProjectManagerScreen::Invalid;
}
AZ::Outcome<QString, QString> ExecuteCommandResultModalDialog(
const QString& cmd,
const QStringList& arguments,
const QProcessEnvironment& processEnv,
const QString& title)
{
QString resultOutput;
QProcess execProcess;
execProcess.setProcessEnvironment(processEnv);
execProcess.setProcessChannelMode(QProcess::MergedChannels);
QProgressDialog dialog(title, QObject::tr("Cancel"), /*minimum=*/0, /*maximum=*/0);
dialog.setMinimumWidth(500);
dialog.setAutoClose(false);
QProgressBar* bar = new QProgressBar(&dialog);
bar->setTextVisible(false);
bar->setMaximum(0); // infinite
dialog.setBar(bar);
QLabel* progressLabel = new QLabel(&dialog);
QVBoxLayout* layout = new QVBoxLayout();
// pre-fill the field with the title and command
const QString commandOutput = QString("%1<br>%2 %3<br>").arg(title).arg(cmd).arg(arguments.join(' '));
// replace the label with a scrollable text edit
QTextEdit* detailTextEdit = new QTextEdit(commandOutput, &dialog);
detailTextEdit->setReadOnly(true);
layout->addWidget(detailTextEdit);
layout->setMargin(0);
progressLabel->setLayout(layout);
progressLabel->setMinimumHeight(150);
dialog.setLabel(progressLabel);
auto readConnection = QObject::connect(&execProcess, &QProcess::readyReadStandardOutput,
[&]()
{
QScrollBar* scrollBar = detailTextEdit->verticalScrollBar();
bool autoScroll = scrollBar->value() == scrollBar->maximum();
QString output = execProcess.readAllStandardOutput();
detailTextEdit->append(output);
resultOutput.append(output);
if (autoScroll)
{
scrollBar->setValue(scrollBar->maximum());
}
});
auto exitConnection = QObject::connect(&execProcess,
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[&](int exitCode, [[maybe_unused]] QProcess::ExitStatus exitStatus)
{
QScrollBar* scrollBar = detailTextEdit->verticalScrollBar();
dialog.setMaximum(100);
dialog.setValue(dialog.maximum());
if (exitCode == 0 && scrollBar->value() == scrollBar->maximum())
{
dialog.close();
}
else
{
// keep the dialog open so the user can look at the output
dialog.setCancelButtonText(QObject::tr("Continue"));
}
});
execProcess.start(cmd, arguments);
dialog.exec();
QObject::disconnect(readConnection);
QObject::disconnect(exitConnection);
if (execProcess.state() == QProcess::Running)
{
execProcess.kill();
return AZ::Failure(QObject::tr("Process for command '%1' was canceled").arg(cmd));
}
int resultCode = execProcess.exitCode();
if (resultCode != 0)
{
return AZ::Failure(QObject::tr("Process for command '%1' failed (result code %2").arg(cmd).arg(resultCode));
}
return AZ::Success(resultOutput);
}
AZ::Outcome<QString, QString> ExecuteCommandResult(
const QString& cmd,
const QStringList& arguments,
@@ -35,15 +35,39 @@ namespace O3DE::ProjectManager
ProjectManagerScreen GetProjectManagerScreen(const QString& screen);
/**
* Execute a console command and return the result.
* @param cmd the command
* @param arguments the command argument list
* @param processEnv the environment
* @param commandTimeoutSeconds the amount of time in seconds to let the command run before terminating it
* @return AZ::Outcome with the command result on success
*/
AZ::Outcome<QString, QString> ExecuteCommandResult(
const QString& cmd,
const QStringList& arguments,
const QProcessEnvironment& processEnv,
int commandTimeoutSeconds = ProjectCommandLineTimeoutSeconds);
/**
* Execute a console command, display the progress in a modal dialog and return the result.
* @param cmd the command
* @param arguments the command argument list
* @param processEnv the environment
* @param commandTimeoutSeconds the amount of time in seconds to let the command run before terminating it
* @return AZ::Outcome with the command result on success
*/
AZ::Outcome<QString, QString> ExecuteCommandResultModalDialog(
const QString& cmd,
const QStringList& arguments,
const QProcessEnvironment& processEnv,
const QString& title);
AZ::Outcome<QProcessEnvironment, QString> GetCommandLineProcessEnvironment();
AZ::Outcome<QString, QString> GetProjectBuildPath(const QString& projectPath);
AZ::Outcome<void, QString> OpenCMakeGUI(const QString& projectPath);
AZ::Outcome<QString, QString> RunGetPythonScript(const QString& enginePath);
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
@@ -246,9 +246,11 @@ namespace O3DE::ProjectManager
if (Py_IsInitialized())
{
AZ_Warning("python", false, "Python is already active");
return false;
return m_pythonStarted;
}
m_pythonStarted = false;
// set PYTHON_HOME
AZStd::string pyBasePath = Platform::GetPythonHomePath(PY_PACKAGE, m_enginePath.c_str());
if (!AZ::IO::SystemFile::Exists(pyBasePath.c_str()))
@@ -304,7 +306,8 @@ namespace O3DE::ProjectManager
// make sure the engine is registered
RegisterThisEngine();
return !PyErr_Occurred();
m_pythonStarted = !PyErr_Occurred();
return m_pythonStarted;
}
catch ([[maybe_unused]] const std::exception& e)
{
@@ -31,6 +31,7 @@ namespace O3DE::ProjectManager
// PythonBindings overrides
bool PythonStarted() override;
bool StartPython() override;
// Engine
AZ::Outcome<EngineInfo> GetEngineInfo() override;
@@ -70,7 +71,6 @@ namespace O3DE::ProjectManager
ProjectInfo ProjectInfoFromPath(pybind11::handle path);
ProjectTemplateInfo ProjectTemplateInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath);
bool RegisterThisEngine();
bool StartPython();
bool StopPython();
@@ -38,6 +38,14 @@ namespace O3DE::ProjectManager
*/
virtual bool PythonStarted() = 0;
/**
* Attempt to start Python. Normally, Python is started when the bindings are created,
* but this method allows you to attempt to retry starting Python in case the configuration
* has changed.
* @return true if Python was started successfully, false on failure
*/
virtual bool StartPython() = 0;
// Engine
/**
@@ -87,7 +87,7 @@ namespace PythonBindingsExample
TEST_F(PythonBindingsExampleTest, Application_ImportAzLmbrPaths_Works)
{
ApplicationParameters params;
params.m_pythonStatement = "import azlmbr.paths; print (azlmbr.paths.engroot); print (azlmbr.paths.devroot)";
params.m_pythonStatement = "import azlmbr.paths; print (azlmbr.paths.engroot)";
EXPECT_TRUE(s_application->RunWithParameters(params));
}
@@ -194,8 +194,8 @@ namespace AZ
if (baseClass)
{
m_behaviorClass = behaviorClass;
return true;
}
return true;
}
return false;
}
@@ -47,6 +47,16 @@ namespace AZ
return m_sourceGuid;
}
void Scene::SetWatchFolder(const AZStd::string& watchFolder)
{
m_watchFolder = watchFolder;
}
const AZStd::string& Scene::GetWatchFolder() const
{
return m_watchFolder;
}
void Scene::SetManifestFilename(const AZStd::string& name)
{
m_manifestFilename = name;
@@ -111,6 +121,7 @@ namespace AZ
->Property("sourceGuid", BehaviorValueGetter(&Scene::m_sourceGuid), nullptr)
->Property("graph", BehaviorValueGetter(&Scene::m_graph), nullptr)
->Property("manifest", BehaviorValueGetter(&Scene::m_manifest), nullptr)
->Property("watchFolder", BehaviorValueGetter(&Scene::m_watchFolder), nullptr)
->Constant("SceneOrientation_YUp", BehaviorConstant(SceneOrientation::YUp))
->Constant("SceneOrientation_ZUp", BehaviorConstant(SceneOrientation::ZUp))
->Constant("SceneOrientation_XUp", BehaviorConstant(SceneOrientation::XUp))
@@ -34,6 +34,9 @@ namespace AZ
const AZStd::string& GetSourceFilename() const;
const Uuid& GetSourceGuid() const;
void SetWatchFolder(const AZStd::string& watchFolder);
const AZStd::string& GetWatchFolder() const;
void SetManifestFilename(const AZStd::string& name);
void SetManifestFilename(AZStd::string&& name);
const AZStd::string& GetManifestFilename() const;
@@ -59,6 +62,7 @@ namespace AZ
AZStd::string m_name;
AZStd::string m_manifestFilename;
AZStd::string m_sourceFilename;
AZStd::string m_watchFolder;
Uuid m_sourceGuid;
SceneGraph m_graph;
SceneManifest m_manifest;
@@ -97,7 +97,7 @@ namespace AZ
GraphObjectProxy* proxy = aznew GraphObjectProxy(graphObject);
return proxy;
}
return nullptr;
return aznew GraphObjectProxy(nullptr);
});
}
}
@@ -36,8 +36,7 @@ namespace AZ
{
namespace Containers
{
//! Protects from allocating too much memory. The choice of a 5MB threshold is arbitrary.
const size_t MaxSceneManifestFileSizeInBytes = 5 * 1024 * 1024;
const char ErrorWindowName[] = "SceneManifest";
@@ -41,6 +41,8 @@ namespace AZ
AZ_RTTI(SceneManifest, "{9274AD17-3212-4651-9F3B-7DCCB080E467}");
static constexpr size_t MaxSceneManifestFileSizeInBytes = AZStd::numeric_limits<size_t>::max();
virtual ~SceneManifest();
static AZStd::shared_ptr<const DataTypes::IManifestObject> SceneManifestConstDataConverter(
@@ -6,6 +6,7 @@
*
*/
#include <API/EditorAssetSystemAPI.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzFramework/StringFunc/StringFunc.h>
@@ -73,6 +74,10 @@ namespace AZ
{
}
void AssetImportRequest::GetGeneratedManifestExtension(AZStd::string& /*result*/)
{
}
void AssetImportRequest::GetSupportedFileExtensions(AZStd::unordered_set<AZStd::string>& /*extensions*/)
{
}
@@ -103,14 +108,34 @@ namespace AZ
AZ_UNUSED(value);
}
void AssetImportRequest::GetManifestDependencyPaths(AZStd::vector<AZStd::string>&)
{
}
AZStd::shared_ptr<Containers::Scene> AssetImportRequest::LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath, const Uuid& sourceGuid,
RequestingApplication requester, const Uuid& loadingComponentUuid)
RequestingApplication requester, const Uuid& loadingComponentUuid)
{
AZStd::string sceneName;
AzFramework::StringFunc::Path::GetFileName(assetFilePath.c_str(), sceneName);
AZStd::shared_ptr<Containers::Scene> scene = AZStd::make_shared<Containers::Scene>(AZStd::move(sceneName));
AZ_Assert(scene, "Unable to create new scene for asset importing.");
Data::AssetInfo assetInfo;
AZStd::string watchFolder;
bool result = false;
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(result, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourceUUID, sourceGuid, assetInfo, watchFolder);
if (result)
{
scene->SetWatchFolder(watchFolder);
}
else
{
AZ_Error(
"AssetImportRequest", false, "Failed to get watch folder for source %s",
sourceGuid.ToString<AZStd::string>().c_str());
}
// Unique pointer, will deactivate and clean up once going out of scope.
SceneCore::EntityConstructor::EntityPointer loaders =
SceneCore::EntityConstructor::BuildEntity("Scene Loading", loadingComponentUuid);
@@ -78,6 +78,8 @@ namespace AZ
virtual void GetSupportedFileExtensions(AZStd::unordered_set<AZStd::string>& extensions);
//! Gets the file extension for the manifest.
virtual void GetManifestExtension(AZStd::string& result);
//! Gets the file extension for the generated manifest.
virtual void GetGeneratedManifestExtension(AZStd::string& result);
//! Before asset loading starts this is called to allow for any required initialization.
virtual ProcessingResult PrepareForAssetLoading(Containers::Scene& scene, RequestingApplication requester);
@@ -97,6 +99,23 @@ namespace AZ
// Get scene processing project setting: UseCustomNormal
virtual void AreCustomNormalsUsed(bool & value);
/*!
Optional method for reporting source file dependencies that may exist in the scene manifest
Paths is a vector of JSON Path strings, relative to the IRule object
For example, the following path: /scriptFilename
Would match with this manifest:
{
"values": [
{
"$type": "Test",
"scriptFilename": "file.py"
}
]
}
*/
virtual void GetManifestDependencyPaths(AZStd::vector<AZStd::string>& paths);
//! Utility function to load an asset and manifest from file by using the EBus functions above.
//! @param assetFilePath The absolute path to the source file (not the manifest).
//! @param sourceGuid The guid assigned to the source file (not the manifest).
@@ -14,8 +14,10 @@
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/XML/rapidxml.h>
#include <AzCore/XML/rapidxml_print.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/IO/SystemFile.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/Casting/numeric_cast.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/API/ApplicationAPI.h>
@@ -170,11 +172,14 @@ namespace AZ
{
using AzToolsFramework::AssetSystemRequestBus;
const char* path = nullptr;
AssetSystemRequestBus::BroadcastResult(path, &AssetSystemRequestBus::Events::GetAbsoluteDevGameFolderPath);
if (path)
AZ::IO::Path projectPath;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
return path;
settingsRegistry->Get(projectPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath);
}
if (!projectPath.empty())
{
return projectPath.Native();
}
else
{
@@ -56,8 +56,14 @@ namespace AZ
result = s_extension;
}
void ManifestImportRequestHandler::GetGeneratedManifestExtension(AZStd::string& result)
{
result = s_extension;
result.append(s_generated);
}
Events::LoadingResult ManifestImportRequestHandler::LoadAsset(Containers::Scene& scene, const AZStd::string& path,
const Uuid& /*guid*/, RequestingApplication /*requester*/)
const Uuid& /*guid*/, RequestingApplication /*requester*/)
{
AZStd::string manifestPath = path + s_extension;
@@ -31,6 +31,7 @@ namespace AZ
static void Reflect(ReflectContext* context);
void GetManifestExtension(AZStd::string& result) override;
void GetGeneratedManifestExtension(AZStd::string& result) override;
Events::LoadingResult LoadAsset(Containers::Scene& scene, const AZStd::string& path, const Uuid& guid,
RequestingApplication requester) override;
@@ -19,6 +19,9 @@
#include <AzToolsFramework/API/EditorPythonConsoleBus.h>
#include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <Entity/EntityUtilityComponent.h>
#include <Prefab/PrefabSystemComponentInterface.h>
#include <Prefab/PrefabSystemScriptingBus.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/SceneManifest.h>
@@ -99,6 +102,7 @@ namespace AZ::SceneAPI::Behaviors
{
AZStd::string result;
CallResult(result, FN_OnUpdateManifest, scene);
ScriptBuildingNotificationBusHandler::BusDisconnect();
return result;
}
@@ -110,6 +114,7 @@ namespace AZ::SceneAPI::Behaviors
{
ExportProductList result;
CallResult(result, FN_OnPrepareForExport, scene, outputDirectory, platformIdentifier, productList);
ScriptBuildingNotificationBusHandler::BusDisconnect();
return result;
}
@@ -168,21 +173,9 @@ namespace AZ::SceneAPI::Behaviors
UnloadPython();
}
bool ScriptProcessorRuleBehavior::LoadPython(const AZ::SceneAPI::Containers::Scene& scene)
bool ScriptProcessorRuleBehavior::LoadPython(const AZ::SceneAPI::Containers::Scene& scene, AZStd::string& scriptPath)
{
if (m_editorPythonEventsInterface && !m_scriptFilename.empty())
{
return true;
}
// get project folder
auto settingsRegistry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath projectPath;
if (!settingsRegistry->Get(projectPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath))
{
return false;
}
int scriptDiscoveryAttempts = 0;
const AZ::SceneAPI::Containers::SceneManifest& manifest = scene.GetManifest();
auto view = Containers::MakeDerivedFilterView<DataTypes::IScriptProcessorRule>(manifest.GetValueStorage());
for (const auto& scriptItem : view)
@@ -194,9 +187,21 @@ namespace AZ::SceneAPI::Behaviors
continue;
}
++scriptDiscoveryAttempts;
// check for file exist via absolute path
if (!IO::FileIOBase::GetInstance()->Exists(scriptFilename.c_str()))
{
// get project folder
auto settingsRegistry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath projectPath;
if (!settingsRegistry->Get(projectPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath))
{
AZ_Error("scene", false, "With (%s) could not find Project Path during script discovery.",
scene.GetManifestFilename().c_str());
return false;
}
// check for script in the project folder
AZ::IO::FixedMaxPath projectScriptPath = projectPath / scriptFilename;
if (!IO::FileIOBase::GetInstance()->Exists(projectScriptPath.c_str()))
@@ -209,32 +214,47 @@ namespace AZ::SceneAPI::Behaviors
scriptFilename = AZStd::move(projectScriptPath);
}
// lazy load the Python interface
auto editorPythonEventsInterface = AZ::Interface<AzToolsFramework::EditorPythonEventsInterface>::Get();
if (editorPythonEventsInterface->IsPythonActive() == false)
{
const bool silenceWarnings = false;
if (editorPythonEventsInterface->StartPython(silenceWarnings) == false)
{
editorPythonEventsInterface = nullptr;
}
}
scriptPath = scriptFilename.c_str();
break;
}
// both Python and the script need to be ready
if (editorPythonEventsInterface == nullptr || scriptFilename.empty())
{
AZ_Warning("scene", false,"The scene manifest (%s) attempted to use script(%s) but Python is not enabled;"
"please add the EditorPythonBinding gem & PythonAssetBuilder gem to your project.",
scene.GetManifestFilename().c_str(), scriptFilename.c_str());
if (scriptPath.empty())
{
AZ_Warning("scene", scriptDiscoveryAttempts == 0,
"The scene manifest (%s) attempted to use script rule, but no script file path could be found.",
scene.GetManifestFilename().c_str());
return false;
}
return false;
}
m_editorPythonEventsInterface = editorPythonEventsInterface;
m_scriptFilename = scriptFilename.c_str();
// already prepared the Python VM?
if (m_editorPythonEventsInterface)
{
return true;
}
return false;
// lazy load the Python interface
auto editorPythonEventsInterface = AZ::Interface<AzToolsFramework::EditorPythonEventsInterface>::Get();
if (editorPythonEventsInterface->IsPythonActive() == false)
{
const bool silenceWarnings = false;
if (editorPythonEventsInterface->StartPython(silenceWarnings) == false)
{
editorPythonEventsInterface = nullptr;
}
}
// both Python and the script need to be ready
if (editorPythonEventsInterface == nullptr)
{
AZ_Warning("scene", false,
"The scene manifest (%s) attempted to prepare Python but Python can not start",
scene.GetManifestFilename().c_str());
return false;
}
m_editorPythonEventsInterface = editorPythonEventsInterface;
return true;
}
void ScriptProcessorRuleBehavior::UnloadPython()
@@ -251,11 +271,13 @@ namespace AZ::SceneAPI::Behaviors
{
using namespace AzToolsFramework;
auto executeCallback = [this, &context]()
AZStd::string scriptPath;
auto executeCallback = [&context, &scriptPath]()
{
// set up script's hook callback
EditorPythonRunnerRequestBus::Broadcast(&EditorPythonRunnerRequestBus::Events::ExecuteByFilename,
m_scriptFilename.c_str());
scriptPath.c_str());
// call script's callback to allow extra products
ExportProductList extraProducts;
@@ -279,7 +301,7 @@ namespace AZ::SceneAPI::Behaviors
}
};
if (LoadPython(context.GetScene()))
if (LoadPython(context.GetScene(), scriptPath))
{
EditorPythonConsoleNotificationHandler logger;
m_editorPythonEventsInterface->ExecuteWithLock(executeCallback);
@@ -306,23 +328,19 @@ namespace AZ::SceneAPI::Behaviors
{
using namespace AzToolsFramework;
// This behavior persists on the same AssetBuilder. Clear the script file name so that if
// this builder processes a scene file with a script file name, and then later processes
// a scene without a script file name, it won't run the old script on the new scene.
m_scriptFilename.clear();
if (action != ManifestAction::Update)
{
return Events::ProcessingResult::Ignored;
}
if (LoadPython(scene))
AZStd::string scriptPath;
if (LoadPython(scene, scriptPath))
{
AZStd::string manifestUpdate;
auto executeCallback = [this, &scene, &manifestUpdate]()
auto executeCallback = [&scene, &manifestUpdate, &scriptPath]()
{
EditorPythonRunnerRequestBus::Broadcast(&EditorPythonRunnerRequestBus::Events::ExecuteByFilename,
m_scriptFilename.c_str());
scriptPath.c_str());
ScriptBuildingNotificationBus::BroadcastResult(manifestUpdate, &ScriptBuildingNotificationBus::Events::OnUpdateManifest,
scene);
@@ -331,6 +349,9 @@ namespace AZ::SceneAPI::Behaviors
EditorPythonConsoleNotificationHandler logger;
m_editorPythonEventsInterface->ExecuteWithLock(executeCallback);
EntityUtilityBus::Broadcast(&EntityUtilityBus::Events::ResetEntityContext);
AZ::Interface<Prefab::PrefabSystemComponentInterface>::Get()->RemoveAllTemplates();
// attempt to load the manifest string back to a JSON-scene-manifest
auto sceneManifestLoader = AZStd::make_unique<AZ::SceneAPI::Containers::SceneManifest>();
auto loadOutcome = sceneManifestLoader->LoadFromString(manifestUpdate);
@@ -347,4 +368,8 @@ namespace AZ::SceneAPI::Behaviors
return Events::ProcessingResult::Ignored;
}
void ScriptProcessorRuleBehavior::GetManifestDependencyPaths(AZStd::vector<AZStd::string>& paths)
{
paths.emplace_back("/scriptFilename");
}
} // namespace AZ
@@ -37,6 +37,7 @@ namespace AZ::SceneAPI::Behaviors
, public Events::AssetImportRequestBus::Handler
{
public:
AZ_COMPONENT(ScriptProcessorRuleBehavior, "{24054E73-1B92-43B0-AC13-174B2F0E3F66}", SceneCore::BehaviorComponent);
~ScriptProcessorRuleBehavior() override = default;
@@ -44,22 +45,21 @@ namespace AZ::SceneAPI::Behaviors
SCENE_DATA_API void Activate() override;
SCENE_DATA_API void Deactivate() override;
static void Reflect(ReflectContext* context);
// AssetImportRequestBus::Handler
SCENE_DATA_API Events::ProcessingResult UpdateManifest(
Containers::Scene& scene,
ManifestAction action,
RequestingApplication requester) override;
SCENE_DATA_API void GetManifestDependencyPaths(AZStd::vector<AZStd::string>& paths) override;
protected:
bool LoadPython(const AZ::SceneAPI::Containers::Scene& scene);
bool LoadPython(const AZ::SceneAPI::Containers::Scene& scene, AZStd::string& scriptPath);
void UnloadPython();
bool DoPrepareForExport(Events::PreExportEventContext& context);
private:
AzToolsFramework::EditorPythonEventsInterface* m_editorPythonEventsInterface = nullptr;
AZStd::string m_scriptFilename;
struct ExportEventHandler;
AZStd::shared_ptr<ExportEventHandler> m_exportEventHandler;
@@ -38,7 +38,7 @@
// SliceConverter reads in a slice file (saved in an ObjectStream format), instantiates it, creates a prefab out of the data,
// and saves the prefab in a JSON format. This can be used for one-time migrations of slices or slice-based levels to prefabs.
//
//
// If the slice contains legacy data, it will print out warnings / errors about the data that couldn't be serialized.
// The prefab will be generated without that data.
@@ -56,7 +56,7 @@ namespace AZ
AZ_Error("SerializeContextTools", false, "Command line not available.");
return false;
}
JsonSerializerSettings convertSettings;
convertSettings.m_keepDefaults = commandLine->HasSwitch("keepdefaults");
convertSettings.m_registrationContext = application.GetJsonRegistrationContext();
@@ -82,7 +82,7 @@ namespace AZ
// Load the asset catalog so that we can find any nested assets successfully. We also need to tick the tick bus
// so that the OnCatalogLoaded event gets processed now, instead of during application shutdown.
AZ::Data::AssetCatalogRequestBus::Broadcast(
&AZ::Data::AssetCatalogRequestBus::Events::LoadCatalog, "@assets@/assetcatalog.xml");
&AZ::Data::AssetCatalogRequestBus::Events::LoadCatalog, "@products@/assetcatalog.xml");
application.Tick();
AZStd::string logggingScratchBuffer;
@@ -870,7 +870,7 @@ namespace AZ
// Wait for the disconnect to finish.
bool disconnected = false;
AzFramework::AssetSystemRequestBus::BroadcastResult(disconnected,
AzFramework::AssetSystemRequestBus::BroadcastResult(disconnected,
&AzFramework::AssetSystem::AssetSystemRequests::WaitUntilAssetProcessorDisconnected, AZStd::chrono::seconds(30));
AZ_Error("Convert-Slice", disconnected, "Asset Processor failed to disconnect successfully.");
+2
View File
@@ -38,3 +38,5 @@ ly_add_target(
PRIVATE
STANDALONETOOLS_ENABLE_LUA_IDE
)
ly_add_dependencies(Editor LuaIDE)
@@ -395,7 +395,7 @@ namespace LUAEditor
void LUAEditorMainWindow::OnLuaDocumentation()
{
QDesktopServices::openUrl(QUrl("http://docs.aws.amazon.com/lumberyard/latest/developerguide/lua-scripting-intro.html"));
QDesktopServices::openUrl(QUrl("https://o3de.org/docs/user-guide/scripting/lua/"));
}
void LUAEditorMainWindow::OnMenuCloseCurrentWindow()