From bcbe1bfef7017358114aed081ccb46b170a5b194 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Mon, 3 May 2021 20:09:37 -0500 Subject: [PATCH] LYN-2537 AssetBundler updates (#426) * LYN-2537 Updated the AssetBundler code to looks for the AssetSeedList files within the Assets/Engine directory Updated the MissingDependencyScanner GetXMLDependenciesFile functions to use the Assets/Engine directory as well Also fixed the MissingDependencyScanner to properly located dependency xml files within gem directories * Adding back input argument validation for the AssetBundler command options. Also added an application_options settings registry file that contains the list of valid command options for the ComponentApplication * Adding missing end of file newline for applications_options.setreg * Fixed the AssetBundler help output for the bundleSeed command --- .../AssetBundle/AssetBundleComponent.cpp | 29 ++----- .../source/ui/AssetBundlerTabWidget.cpp | 18 ++-- .../AssetBundler/source/ui/SeedTabWidget.cpp | 2 +- .../source/utils/applicationManager.cpp | 83 +++++++++++++++---- .../Tools/AssetBundler/source/utils/utils.cpp | 18 ++-- Code/Tools/AssetBundler/source/utils/utils.h | 15 ---- .../{ => Assets}/Engine/SeedAssetList.seed | 0 Code/Tools/AssetBundler/tests/tests_main.cpp | 15 ++-- .../utilities/MissingDependencyScanner.cpp | 12 +-- .../Code/Source/AssetSeedUtil.h | 2 +- .../Code/Tests/AssetValidationTest.cpp | 11 +-- Registry/application_options.setreg | 17 ++++ 12 files changed, 127 insertions(+), 95 deletions(-) rename Code/Tools/AssetBundler/tests/{ => Assets}/Engine/SeedAssetList.seed (100%) create mode 100644 Registry/application_options.setreg diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp index 61e144d338..95319d2e6b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -250,7 +250,7 @@ namespace AzToolsFramework AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); AZ_Assert(fileIO != nullptr, "AZ::IO::FileIOBase must be ready for use.\n"); - AZStd::string bundleFilePath = assetBundleSettings.m_bundleFilePath; + AZ::IO::Path bundleFilePath = AZ::IO::Path(AZStd::string_view{ AZ::Utils::GetEnginePath() }) / assetBundleSettings.m_bundleFilePath; AzFramework::PlatformId platformId = static_cast(AzFramework::PlatformHelper::GetPlatformIndexFromName(assetBundleSettings.m_platform.c_str())); @@ -259,22 +259,13 @@ namespace AzToolsFramework return false; } - const char* appRoot = nullptr; - AzFramework::ApplicationRequests::Bus::BroadcastResult(appRoot, &AzFramework::ApplicationRequests::GetAppRoot); - - if (AzFramework::StringFunc::Path::IsRelative(bundleFilePath.c_str())) - { - AzFramework::StringFunc::Path::ConstructFull(appRoot, bundleFilePath.c_str(), bundleFilePath, true); - } - AZ::u64 maxSizeInBytes = static_cast(assetBundleSettings.m_maxBundleSizeInMB * NumOfBytesInMB); AZ::u64 assetCatalogFileSizeBuffer = static_cast(AssetCatalogFileSizeBufferPercentage * assetBundleSettings.m_maxBundleSizeInMB * NumOfBytesInMB) / 100; AZ::u64 bundleSize = 0; AZ::u64 totalFileSize = 0; int bundleIndex = 0; - AZStd::string bundleFullPath = bundleFilePath; - AZStd::string tempBundleFilePath = bundleFullPath + "_temp"; + AZStd::string tempBundleFilePath = bundleFilePath.Native() + "_temp"; AZStd::vector dependentBundleNames; AZStd::vector levelDirs; @@ -301,7 +292,7 @@ namespace AzToolsFramework if (fileIO->Exists(bundleFilePath.c_str())) { // This will delete both the parent bundle as well as all the dependent bundles mentioned in the manifest file of the parent bundle. - if (!DeleteBundleFiles(bundleFilePath)) + if (!DeleteBundleFiles(bundleFilePath.Native())) { return false; } @@ -390,7 +381,7 @@ namespace AzToolsFramework // we need to find a bundle which does not exist on disk; bundleIndex++; numOfTries--; - dependentBundleFileName = CreateAssetBundleFileName(bundleFilePath, bundleIndex); + dependentBundleFileName = CreateAssetBundleFileName(bundleFilePath.Native(), bundleIndex); AzFramework::StringFunc::Path::ReplaceFullName(tempBundleFilePath, (dependentBundleFileName + tempBundleFileSuffix).c_str()); } while (numOfTries && fileIO->Exists(tempBundleFilePath.c_str())); @@ -463,15 +454,7 @@ namespace AzToolsFramework AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); - AZStd::string assetFileInfoListPath = assetBundleSettings.m_assetFileInfoListPath; - - const char* appRoot = nullptr; - AzFramework::ApplicationRequests::Bus::BroadcastResult(appRoot, &AzFramework::ApplicationRequests::GetAppRoot); - - if (AzFramework::StringFunc::Path::IsRelative(assetFileInfoListPath.c_str())) - { - AzFramework::StringFunc::Path::ConstructFull(appRoot, assetFileInfoListPath.c_str(), assetFileInfoListPath, true); - } + AZ::IO::Path assetFileInfoListPath = AZ::IO::Path{ AZStd::string_view{AZ::Utils::GetEnginePath()} } / assetBundleSettings.m_assetFileInfoListPath; if (!fileIO->Exists(assetFileInfoListPath.c_str())) { diff --git a/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp b/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp index 2719944af4..9dcfd34c35 100644 --- a/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/AssetBundlerTabWidget.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -232,8 +233,8 @@ namespace AssetBundler for (const QJsonValue scanPath : m_watchedFiles + m_watchedFolders) { - AZStd::string scanFilePathStr = scanPath.toString().toUtf8().data(); - AzFramework::StringFunc::Path::ConstructFull(GetCachedEngineRoot().c_str(), scanFilePathStr.c_str(), scanFilePathStr); + auto scanFilePathStr = (AZ::IO::Path(AZStd::string_view{ AZ::Utils::GetEnginePath() }) + / scanPath.toString().toUtf8().data()).LexicallyNormal(); // Check whether the file has already been watched // Get absolute file paths via QFileInfo to keep consistency in the letter case @@ -263,8 +264,8 @@ namespace AssetBundler for (auto itr = scanPaths.begin(); itr != scanPaths.end(); ++itr) { QJsonValueRef scanPathValueRef = *itr; - AZStd::string scanPath = scanPathValueRef.toString().toUtf8().data(); - AzFramework::StringFunc::Path::ConstructFull(GetCachedEngineRoot().c_str(), scanPath.c_str(), scanPath); + auto scanPath = (AZ::IO::Path(AZStd::string_view{ AZ::Utils::GetEnginePath() }) + / scanPathValueRef.toString().toUtf8().data()).LexicallyNormal(); // Check whether the file is being watched // Get absolute file paths via QFileInfo to keep consistency in the letter case @@ -316,13 +317,8 @@ namespace AssetBundler for (const QJsonValue scanPath : scanPaths[AssetBundlingFileTypes[fileType]].toArray()) { - AZStd::string absoluteScanPath = scanPath.toString().toUtf8().data(); - AZStd::replace(absoluteScanPath.begin(), absoluteScanPath.end(), AZ_WRONG_FILESYSTEM_SEPARATOR, AZ_CORRECT_FILESYSTEM_SEPARATOR); - - if (AzFramework::StringFunc::Path::IsRelative(absoluteScanPath.c_str())) - { - AzFramework::StringFunc::Path::ConstructFull(GetCachedEngineRoot().c_str(), absoluteScanPath.c_str(), absoluteScanPath); - } + auto absoluteScanPath = (AZ::IO::Path(AZStd::string_view{ AZ::Utils::GetEnginePath() }) + / scanPath.toString().toUtf8().data()).LexicallyNormal(); if (AZ::IO::FileIOBase::GetInstance()->IsDirectory(absoluteScanPath.c_str())) { diff --git a/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp b/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp index b05a2e0c90..60b4104c5a 100644 --- a/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp +++ b/Code/Tools/AssetBundler/source/ui/SeedTabWidget.cpp @@ -138,7 +138,7 @@ namespace AssetBundler m_watchedFolders.insert(m_guiApplicationManager->GetSeedListsFolder().c_str()); // Get the list of default Seed List files - m_filePathToGemNameMap = AssetBundler::GetDefaultSeedListFiles(GetCachedEngineRoot().c_str(), m_guiApplicationManager->GetCurrentProjectName(), + m_filePathToGemNameMap = AssetBundler::GetDefaultSeedListFiles(AZStd::string_view{ AZ::Utils::GetEnginePath() }, m_guiApplicationManager->GetCurrentProjectName(), m_guiApplicationManager->GetGemInfoList(), m_guiApplicationManager->GetEnabledPlatforms()); // Get the list of default Seeds that are not stored in a Seed List file on-disk diff --git a/Code/Tools/AssetBundler/source/utils/applicationManager.cpp b/Code/Tools/AssetBundler/source/utils/applicationManager.cpp index 7aae023e72..ccf5427771 100644 --- a/Code/Tools/AssetBundler/source/utils/applicationManager.cpp +++ b/Code/Tools/AssetBundler/source/utils/applicationManager.cpp @@ -45,13 +45,6 @@ namespace AssetBundler { const char compareVariablePrefix = '$'; - GemInfo::GemInfo(AZStd::string name, AZStd::string relativeFilePath, AZStd::string absoluteFilePath) - : m_gemName(name) - , m_relativeFilePath(relativeFilePath) - , m_absoluteFilePath(absoluteFilePath) - { - } - ApplicationManager::ApplicationManager(int* argc, char*** argv, QObject* parent) : QObject(parent) , AzToolsFramework::ToolsApplication(argc, argv) @@ -80,8 +73,6 @@ namespace AssetBundler m_assetSeedManager = AZStd::make_unique(); AZ_TracePrintf(AssetBundler::AppWindowName, "\n"); - g_cachedEngineRoot = AZ::IO::FixedMaxPath(GetEngineRoot()); - // There is no need to update the UserSettings file, so we can avoid a race condition by disabling save on shutdown AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); return true; @@ -383,6 +374,13 @@ namespace AssetBundler { using namespace AzToolsFramework; + auto validateArgsOutcome = ValidateInputArgs(parser, m_allSeedsArgs); + if (!validateArgsOutcome.IsSuccess()) + { + OutputHelpSeeds(); + return AZ::Failure(validateArgsOutcome.TakeError()); + } + SeedsParams params; params.m_ignoreFileCase = parser->HasSwitch(IgnoreFileCaseFlag); @@ -473,6 +471,13 @@ namespace AssetBundler AZ::Outcome ApplicationManager::ParseAssetListsCommandData(const AZ::CommandLine* parser) { + auto validateArgsOutcome = ValidateInputArgs(parser, m_allAssetListsArgs); + if (!validateArgsOutcome.IsSuccess()) + { + OutputHelpAssetLists(); + return AZ::Failure(validateArgsOutcome.TakeError()); + } + AssetListsParams params; // Read in Platform arg @@ -536,6 +541,13 @@ namespace AssetBundler AZ::Outcome ApplicationManager::ParseComparisonRulesCommandData(const AZ::CommandLine* parser) { + auto validateArgsOutcome = ValidateInputArgs(parser, m_allComparisonRulesArgs); + if (!validateArgsOutcome.IsSuccess()) + { + OutputHelpComparisonRules(); + return AZ::Failure(validateArgsOutcome.TakeError()); + } + ScopedTraceHandler traceHandler; ComparisonRulesParams params; @@ -918,6 +930,13 @@ namespace AssetBundler AZ::Outcome ApplicationManager::ParseCompareCommandData(const AZ::CommandLine* parser) { + auto validateArgsOutcome = ValidateInputArgs(parser, m_allCompareArgs); + if (!validateArgsOutcome.IsSuccess()) + { + OutputHelpCompare(); + return AZ::Failure(validateArgsOutcome.TakeError()); + } + ComparisonParams params; // Read in Platform arg @@ -1009,6 +1028,13 @@ namespace AssetBundler AZ::Outcome ApplicationManager::ParseBundleSettingsCommandData(const AZ::CommandLine* parser) { + auto validateArgsOutcome = ValidateInputArgs(parser, m_allBundleSettingsArgs); + if (!validateArgsOutcome.IsSuccess()) + { + OutputHelpBundleSettings(); + return AZ::Failure(validateArgsOutcome.TakeError()); + } + BundleSettingsParams params; // Read in Platform arg @@ -1213,6 +1239,13 @@ namespace AssetBundler AZ::Outcome ApplicationManager::ParseBundlesCommandData(const AZ::CommandLine* parser) { + auto validateArgsOutcome = ValidateInputArgs(parser, m_allBundlesArgs); + if (!validateArgsOutcome.IsSuccess()) + { + OutputHelpBundles(); + return AZ::Failure(validateArgsOutcome.TakeError()); + } + auto parseSettingsOutcome = ParseBundleSettingsAndOverrides(parser, BundlesCommand); if (!parseSettingsOutcome.IsSuccess()) { @@ -1224,6 +1257,14 @@ namespace AssetBundler AZ::Outcome ApplicationManager::ParseBundleSeedCommandData(const AZ::CommandLine* parser) { + + auto validateArgsOutcome = ValidateInputArgs(parser, m_allBundleSeedArgs); + if (!validateArgsOutcome.IsSuccess()) + { + OutputHelpBundleSeed(); + return AZ::Failure(validateArgsOutcome.TakeError()); + } + BundleSeedParams params; params.m_addSeedList = GetAddSeedArgList(parser); @@ -1241,6 +1282,12 @@ namespace AssetBundler AZ::Outcome ApplicationManager::ValidateInputArgs(const AZ::CommandLine* parser, const AZStd::vector& validArgList) { + constexpr AZStd::string_view ApplicationArgList = "/O3DE/AzCore/Application/ValidCommandOptions"; + AZStd::vector validApplicationArgs; + if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr) + { + settingsRegistry->GetObject(validApplicationArgs, ApplicationArgList); + } for (const auto& paramInfo : *parser) { // Skip positional arguments @@ -1258,10 +1305,18 @@ namespace AssetBundler break; } } + for (const auto& validArg : validApplicationArgs) + { + if (AZ::StringFunc::Equal(paramInfo.m_option, validArg)) + { + isValidArg = true; + break; + } + } if (!isValidArg) { - return AZ::Failure(AZStd::string::format("Unknown argument: \"--%s\" is not an unknown argument for this sub-command.", paramInfo.m_option.c_str())); + return AZ::Failure(AZStd::string::format(R"(Invalid argument: "--%s" is not a valid argument for this sub-command.)", paramInfo.m_option.c_str())); } } @@ -1346,10 +1401,10 @@ namespace AssetBundler } // If no platform was specified, defaulting to platforms specified in the asset processor config files - const char* appRoot = nullptr; - AzFramework::ApplicationRequests::Bus::BroadcastResult(appRoot, &AzFramework::ApplicationRequests::GetAppRoot); - - AzFramework::PlatformFlags platformFlags = GetEnabledPlatformFlags(GetEngineRoot(), appRoot, AZ::Utils::GetProjectPath().c_str()); + AzFramework::PlatformFlags platformFlags = GetEnabledPlatformFlags( + AZStd::string_view{ AZ::Utils::GetEnginePath() }, + AZStd::string_view{ AZ::Utils::GetEnginePath() }, + AZStd::string_view{ AZ::Utils::GetProjectPath() }); auto platformsString = AzFramework::PlatformHelper::GetCommaSeparatedPlatformList(platformFlags); AZ_TracePrintf(AppWindowName, "No platform specified, defaulting to platforms ( %s ).\n", platformsString.c_str()); diff --git a/Code/Tools/AssetBundler/source/utils/utils.cpp b/Code/Tools/AssetBundler/source/utils/utils.cpp index 6058728a76..39bc1a7e13 100644 --- a/Code/Tools/AssetBundler/source/utils/utils.cpp +++ b/Code/Tools/AssetBundler/source/utils/utils.cpp @@ -109,17 +109,15 @@ namespace AssetBundler const char* AssetCatalogFilename = "assetcatalog.xml"; - AZ::IO::FixedMaxPath g_cachedEngineRoot; - - const char EngineDirectoryName[] = "Engine"; + constexpr auto EngineDirectoryName = AZ::IO::FixedMaxPath("Assets") / "Engine"; const char RestrictedDirectoryName[] = "restricted"; const char PlatformsDirectoryName[] = "Platforms"; const char GemsDirectoryName[] = "Gems"; const char GemsAssetsDirectoryName[] = "Assets"; const char GemsSeedFileName[] = "seedList"; const char EngineSeedFileName[] = "SeedAssetList"; - + namespace Internal { @@ -131,7 +129,7 @@ namespace AssetBundler AZStd::unordered_map& defaultSeedLists, AzFramework::PlatformFlags platformFlags) { - AZ::IO::FixedMaxPath engineRoot(GetCachedEngineRoot()); + AZ::IO::FixedMaxPath engineRoot(AZ::Utils::GetEnginePath()); AZ::IO::FixedMaxPath engineRestrictedRoot = engineRoot / RestrictedDirectoryName; AZ::IO::FixedMaxPath engineLocalPath = AZ::IO::PathView(engineDirectory.LexicallyRelative(engineRoot)); @@ -204,12 +202,6 @@ namespace AssetBundler } } - AZ::IO::FixedMaxPath GetCachedEngineRoot() - { - AZ_Error(AppWindowName, !g_cachedEngineRoot.empty(), "Cached Engine Root has not been initialized by the Bundler."); - return g_cachedEngineRoot; - } - void AddPlatformIdentifier(AZStd::string& filePath, const AZStd::string& platformIdentifier) { AZStd::string fileName; @@ -257,11 +249,11 @@ namespace AssetBundler absoluteEngineSeedFilePath.ReplaceExtension(AzToolsFramework::AssetSeedManager::GetSeedFileExtension()); if (fileIO->Exists(absoluteEngineSeedFilePath.c_str())) { - defaultSeedLists[absoluteEngineSeedFilePath.Native()] = EngineDirectoryName; + defaultSeedLists[absoluteEngineSeedFilePath.Native()] = EngineDirectoryName.String(); } // Add Seed Lists from the Platforms directory - Internal::AddPlatformsDirectorySeeds(engineDirectory, EngineDirectoryName, defaultSeedLists, platformFlag); + Internal::AddPlatformsDirectorySeeds(engineDirectory, EngineDirectoryName.String(), defaultSeedLists, platformFlag); auto absoluteProjectDefaultSeedFilePath = AZ::IO::Path(projectPath) / EngineSeedFileName; absoluteProjectDefaultSeedFilePath.ReplaceExtension(AzToolsFramework::AssetSeedManager::GetSeedFileExtension()); diff --git a/Code/Tools/AssetBundler/source/utils/utils.h b/Code/Tools/AssetBundler/source/utils/utils.h index 629fd90a31..454a279878 100644 --- a/Code/Tools/AssetBundler/source/utils/utils.h +++ b/Code/Tools/AssetBundler/source/utils/utils.h @@ -122,20 +122,8 @@ namespace AssetBundler //////////////////////////////////////////////////////////////////////////////////////////// extern const char* AssetCatalogFilename; - extern AZ::IO::FixedMaxPath g_cachedEngineRoot; static const size_t MaxErrorMessageLength = 4096; - //! This struct stores gem related information - struct GemInfo - { - AZ_CLASS_ALLOCATOR(GemInfo, AZ::SystemAllocator, 0); - GemInfo(AZStd::string name, AZStd::string relativeFilePath, AZStd::string absoluteFilePath); - GemInfo() = default; - AZStd::string m_gemName; - AZStd::string m_relativeFilePath; - AZStd::string m_absoluteFilePath; - }; - // The Warning Absorber is used to absorb warnings // One case that this is being used is during loading of the asset catalog. @@ -151,9 +139,6 @@ namespace AssetBundler bool OnPreWarning(const char* window, const char* fileName, int line, const char* func, const char* message) override; }; - // Returns the cached engine root. Throws an error if the cached path has not been initialized by the Bundler Application. - AZ::IO::FixedMaxPath GetCachedEngineRoot(); - /** * Determines the name of the currently enabled game project * @return Current Project name on success, error message on failure diff --git a/Code/Tools/AssetBundler/tests/Engine/SeedAssetList.seed b/Code/Tools/AssetBundler/tests/Assets/Engine/SeedAssetList.seed similarity index 100% rename from Code/Tools/AssetBundler/tests/Engine/SeedAssetList.seed rename to Code/Tools/AssetBundler/tests/Assets/Engine/SeedAssetList.seed diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index 6d874a3320..9e12623b0d 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -88,7 +88,7 @@ namespace AssetBundler const char RelativeTestFolder[] = "Code/Tools/AssetBundler/tests"; const char GemsFolder[] = "Gems"; - const char EngineFolder[] = "Engine"; + constexpr auto EngineFolder = AZ::IO::FixedMaxPath("Assets") / "Engine"; const char PlatformsFolder[] = "Platforms"; const char DummyProjectFolder[] = "DummyProject"; @@ -113,13 +113,14 @@ namespace AssetBundler AZ::SettingsRegistry::Register(&m_registry); } - AssetBundler::g_cachedEngineRoot = m_data->m_application.get()->GetEngineRoot(); - if (AssetBundler::g_cachedEngineRoot.empty()) + AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath(); + if (engineRoot.empty()) { GTEST_FATAL_FAILURE_(AZStd::string::format("Unable to locate engine root.\n").c_str()); } - AzFramework::StringFunc::Path::Join(AssetBundler::g_cachedEngineRoot.c_str(), RelativeTestFolder, m_data->m_testEngineRoot); + + m_data->m_testEngineRoot = (engineRoot / RelativeTestFolder).LexicallyNormal().String(); m_data->m_localFileIO = aznew AZ::IO::LocalFileIO(); m_data->m_priorFileIO = AZ::IO::FileIOBase::GetInstance(); @@ -131,8 +132,8 @@ namespace AssetBundler AddGemData(m_data->m_testEngineRoot.c_str(), "GemA"); AddGemData(m_data->m_testEngineRoot.c_str(), "GemB"); - AZStd::string absoluteEngineSeedFilePath; - AzFramework::StringFunc::Path::ConstructFull(m_data->m_testEngineRoot.c_str(), EngineFolder, "SeedAssetList", AzToolsFramework::AssetSeedManager::GetSeedFileExtension(), absoluteEngineSeedFilePath, true); + auto absoluteEngineSeedFilePath = m_data->m_testEngineRoot / EngineFolder / "SeedAssetList"; + absoluteEngineSeedFilePath.ReplaceExtension(AzToolsFramework::AssetSeedManager::GetSeedFileExtension()); m_data->m_gemSeedFilePairList.emplace_back(AZStd::make_pair(absoluteEngineSeedFilePath, true)); AddGemData(m_data->m_testEngineRoot.c_str(), "GemC", false); @@ -212,7 +213,7 @@ namespace AssetBundler AZStd::unique_ptr m_application = {}; AZ::IO::FileIOBase* m_priorFileIO = nullptr; AZ::IO::FileIOBase* m_localFileIO = nullptr; - AZStd::string m_testEngineRoot; + AZ::IO::Path m_testEngineRoot; }; const int GemAIndex = 0; diff --git a/Code/Tools/AssetProcessor/native/utilities/MissingDependencyScanner.cpp b/Code/Tools/AssetProcessor/native/utilities/MissingDependencyScanner.cpp index 73125fd58a..9daf97cf79 100644 --- a/Code/Tools/AssetProcessor/native/utilities/MissingDependencyScanner.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/MissingDependencyScanner.cpp @@ -20,30 +20,32 @@ AZ_POP_DISABLE_WARNING #include "native/AssetDatabase/AssetDatabase.h" #include "native/assetprocessor.h" #include +#include #include #include #include #include +#include #include #include #include #include -#include namespace AssetProcessor { - const char* EngineFolder = "Engine"; + constexpr auto EngineFolder = AZ::IO::FixedMaxPath("Assets") / "Engine"; AZStd::string GetXMLDependenciesFile(const AZStd::string& fullPath, const AZStd::vector& gemInfoList, AZStd::string& tokenName) { AZ::IO::Path xmlDependenciesFileFullPath; - tokenName = EngineFolder; + tokenName = EngineFolder.String(); for (const AzFramework::GemInfo& gemElement : gemInfoList) { for (const AZ::IO::Path& absoluteSourcePath : gemElement.m_absoluteSourcePaths) { - if (AZ::StringFunc::StartsWith(fullPath, absoluteSourcePath.Native()) || AZ::StringFunc::Equal(absoluteSourcePath.Native(), fullPath)) + if (AZ::IO::PathView(fullPath).IsRelativeTo(absoluteSourcePath)) { + xmlDependenciesFileFullPath = absoluteSourcePath; xmlDependenciesFileFullPath /= AzFramework::GemInfo::GetGemAssetFolder(); xmlDependenciesFileFullPath /= AZStd::string::format("%s_Dependencies.xml", gemElement.m_gemName.c_str());; if (AZ::IO::FileIOBase::GetInstance()->Exists(xmlDependenciesFileFullPath.c_str())) @@ -57,7 +59,7 @@ namespace AssetProcessor // if we are here than either the %gemName%_Dependencies.xml file does not exists or the user inputted path is not inside a gems folder, // in both the cases we will return the engine dependencies file - xmlDependenciesFileFullPath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@devroot@"); + xmlDependenciesFileFullPath = AZ::Utils::GetEnginePath(); xmlDependenciesFileFullPath /= EngineFolder; xmlDependenciesFileFullPath /= "Engine_Dependencies.xml"; diff --git a/Gems/AssetValidation/Code/Source/AssetSeedUtil.h b/Gems/AssetValidation/Code/Source/AssetSeedUtil.h index 4a6ff1f1d8..60d94e8903 100644 --- a/Gems/AssetValidation/Code/Source/AssetSeedUtil.h +++ b/Gems/AssetValidation/Code/Source/AssetSeedUtil.h @@ -30,7 +30,7 @@ namespace AssetValidation::AssetSeed constexpr char GemsDirectoryName[] = "Gems"; constexpr char GemsSeedFileName[] = "seedList"; constexpr char EngineSeedFileName[] = "SeedAssetList"; - constexpr char EngineDirectoryName[] = "Engine"; + constexpr auto EngineDirectoryName = AZ::IO::FixedMaxPath("Assets") / "Engine"; void AddPlatformSeeds(const AZStd::string& rootFolder, AZStd::vector& defaultSeedLists, AzFramework::PlatformFlags platformFlags); diff --git a/Gems/AssetValidation/Code/Tests/AssetValidationTest.cpp b/Gems/AssetValidation/Code/Tests/AssetValidationTest.cpp index a5ff671fc3..5003c4484c 100644 --- a/Gems/AssetValidation/Code/Tests/AssetValidationTest.cpp +++ b/Gems/AssetValidation/Code/Tests/AssetValidationTest.cpp @@ -32,20 +32,21 @@ TEST_F(AssetValidationTest, DefaultSeedList_ReturnsExpectedSeedLists) { AZStd::vector gemInfo; - AZStd::string gemSeedList, engineSeedList, projectSeedList; + AZ::IO::Path gemSeedList, engineSeedList, projectSeedList; - ASSERT_TRUE(CreateDummyFile((AZ::IO::Path("mockGem") / AzFramework::GemInfo::GetGemAssetFolder()).c_str(), "seedList", "Mock Gem Seed List", gemSeedList)); - ASSERT_TRUE(CreateDummyFile("Engine", "SeedAssetList", "Engine Seed List", engineSeedList)); + ASSERT_TRUE(CreateDummyFile((AZ::IO::Path("mockGem") / AzFramework::GemInfo::GetGemAssetFolder()).c_str(), "seedList", "Mock Gem Seed List", gemSeedList.Native())); + ASSERT_TRUE(CreateDummyFile((AZ::IO::Path("Assets") / "Engine").c_str(), "SeedAssetList", "Engine Seed List", engineSeedList.Native())); AZ::SettingsRegistryInterface::FixedValueString projectName = AZ::Utils::GetProjectName(); ASSERT_FALSE(projectName.empty()); - ASSERT_TRUE(CreateDummyFile(projectName.c_str(), "SeedAssetList", "Project Seed List", projectSeedList)); + ASSERT_TRUE(CreateDummyFile(projectName.c_str(), "SeedAssetList", "Project Seed List", projectSeedList.Native())); AzFramework::GemInfo mockGem("MockGem"); mockGem.m_absoluteSourcePaths.push_back((m_tempDir / "mockGem").string().c_str()); gemInfo.push_back(mockGem); - AZStd::vector defaultSeedLists = AssetValidation::AssetSeed::GetDefaultSeedListFiles(gemInfo, AzFramework::PlatformFlags::Platform_PC); + AZStd::vector defaultSeedStringList = AssetValidation::AssetSeed::GetDefaultSeedListFiles(gemInfo, AzFramework::PlatformFlags::Platform_PC); + AZStd::vector defaultSeedLists{ AZStd::make_move_iterator(defaultSeedStringList.begin()), AZStd::make_move_iterator(defaultSeedStringList.end()) }; ASSERT_THAT(defaultSeedLists, ::testing::UnorderedElementsAre(gemSeedList, engineSeedList, projectSeedList)); } diff --git a/Registry/application_options.setreg b/Registry/application_options.setreg new file mode 100644 index 0000000000..06ccdc9b41 --- /dev/null +++ b/Registry/application_options.setreg @@ -0,0 +1,17 @@ +{ + "O3DE" : { + "AzCore": { + "Application": { + "ValidCommandOptions": [ + "project-path", + "engine-path", + "project-cache-path", + "regset", + "regremove", + "regdump", + "regdumpall" + ] + } + } + } +}