AssetValidationSystemComponent.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AssetValidationSystemComponent.h>
  9. #include <AzCore/Asset/AssetManager.h>
  10. #include <AzCore/Asset/AssetManagerBus.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. #include <AzCore/Serialization/EditContext.h>
  13. #include <AzCore/Serialization/EditContextConstants.inl>
  14. #include <AzCore/Serialization/Utils.h>
  15. #include <AzCore/Settings/SettingsRegistryMergeUtils.h>
  16. #include <AzCore/std/string/conversions.h>
  17. #include <AzFramework/API/ApplicationAPI.h>
  18. #include <AzFramework/FileTag/FileTag.h>
  19. #include <AzFramework/FileTag/FileTagBus.h>
  20. #include <AzFramework/StringFunc/StringFunc.h>
  21. #include <AssetSeedUtil.h>
  22. #include <ISystem.h>
  23. #include <IConsole.h>
  24. namespace AssetValidation
  25. {
  26. void AssetValidationSystemComponent::Reflect(AZ::ReflectContext* context)
  27. {
  28. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  29. {
  30. serialize->Class<AssetValidationSystemComponent, AZ::Component>()
  31. ->Version(0);
  32. if (AZ::EditContext* ec = serialize->GetEditContext())
  33. {
  34. ec->Class<AssetValidationSystemComponent>("AssetValidation", "[Description of functionality provided by this System Component]")
  35. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  36. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  37. ;
  38. }
  39. }
  40. }
  41. void AssetValidationSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  42. {
  43. provided.push_back(AZ_CRC_CE("AssetValidationService"));
  44. }
  45. void AssetValidationSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  46. {
  47. incompatible.push_back(AZ_CRC_CE("AssetValidationService"));
  48. }
  49. void AssetValidationSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  50. {
  51. AZ_UNUSED(required);
  52. }
  53. void AssetValidationSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  54. {
  55. AZ_UNUSED(dependent);
  56. }
  57. void AssetValidationSystemComponent::Init()
  58. {
  59. }
  60. void AssetValidationSystemComponent::Activate()
  61. {
  62. CrySystemEventBus::Handler::BusConnect();
  63. AssetValidationRequestBus::Handler::BusConnect();
  64. }
  65. void AssetValidationSystemComponent::Deactivate()
  66. {
  67. if (m_seedMode)
  68. {
  69. AZ::IO::ArchiveNotificationBus::Handler::BusDisconnect();
  70. }
  71. AssetValidationRequestBus::Handler::BusDisconnect();
  72. CrySystemEventBus::Handler::BusDisconnect();
  73. }
  74. void AssetValidationSystemComponent::ConsoleCommandSeedMode([[maybe_unused]] IConsoleCmdArgs* pCmdArgs)
  75. {
  76. AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::SeedMode);
  77. }
  78. void AssetValidationSystemComponent::ConsoleCommandTogglePrintExcluded([[maybe_unused]] IConsoleCmdArgs* pCmdArgs)
  79. {
  80. AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::TogglePrintExcluded);
  81. }
  82. void AssetValidationSystemComponent::TogglePrintExcluded()
  83. {
  84. m_printExcluded = !m_printExcluded;
  85. if (m_printExcluded)
  86. {
  87. AZ_TracePrintf("AssetValidation", "Asset Validation is now on");
  88. }
  89. else
  90. {
  91. AZ_TracePrintf("AssetValidation", "Asset Validation is now off");
  92. }
  93. }
  94. void AssetValidationSystemComponent::SeedMode()
  95. {
  96. m_seedMode = !m_seedMode;
  97. if (m_seedMode)
  98. {
  99. // adding excluded tags
  100. m_excludedFileTags.emplace_back(AzFramework::FileTag::FileTags[static_cast<unsigned int>(AzFramework::FileTag::FileTagsIndex::Ignore)]);
  101. m_excludedFileTags.emplace_back(AzFramework::FileTag::FileTags[static_cast<unsigned int>(AzFramework::FileTag::FileTagsIndex::ProductDependency)]);
  102. AZ::IO::ArchiveNotificationBus::Handler::BusConnect();
  103. BuildAssetList();
  104. AZ_TracePrintf("AssetValidation", "Asset Validation is now on");
  105. }
  106. else
  107. {
  108. AZ::IO::ArchiveNotificationBus::Handler::BusDisconnect();
  109. m_excludedFileTags.clear();
  110. AZ_TracePrintf("AssetValidation", "Asset Validation is now off");
  111. }
  112. AssetValidationNotificationBus::Broadcast(&AssetValidationNotificationBus::Events::SetSeedMode, m_seedMode);
  113. }
  114. void AssetValidationSystemComponent::OnCrySystemInitialized(ISystem& system, const SSystemInitParams& systemInitParams)
  115. {
  116. AZ_UNUSED(systemInitParams);
  117. system.GetIConsole()->AddCommand("seedmode", ConsoleCommandSeedMode);
  118. system.GetIConsole()->AddCommand("addseedpath", ConsoleCommandAddSeedPath);
  119. system.GetIConsole()->AddCommand("removeseedpath", ConsoleCommandRemoveSeedPath);
  120. system.GetIConsole()->AddCommand("listknownassets", ConsoleCommandKnownAssets);
  121. system.GetIConsole()->AddCommand("addseedlist", ConsoleCommandAddSeedList);
  122. system.GetIConsole()->AddCommand("removeseedlist", ConsoleCommandRemoveSeedList);
  123. system.GetIConsole()->AddCommand("printexcluded", ConsoleCommandTogglePrintExcluded);
  124. }
  125. bool AssetValidationSystemComponent::IsKnownAsset(const char* assetPath)
  126. {
  127. AZStd::string lowerAsset{ assetPath };
  128. AZStd::replace(lowerAsset.begin(), lowerAsset.end(), AZ_WRONG_DATABASE_SEPARATOR, AZ_CORRECT_DATABASE_SEPARATOR);
  129. const AZStd::vector<AZStd::string> prefixes = { "./", "@products@/" };
  130. for (const AZStd::string& prefix : prefixes)
  131. {
  132. if (lowerAsset.starts_with(prefix))
  133. {
  134. lowerAsset = lowerAsset.substr(prefix.length());
  135. break;
  136. }
  137. }
  138. AZStd::to_lower(lowerAsset.begin(), lowerAsset.end());
  139. return m_knownAssetPaths.count(lowerAsset) > 0;
  140. }
  141. bool AssetValidationSystemComponent::CheckKnownAsset(const char* assetPath)
  142. {
  143. if (!IsKnownAsset(assetPath))
  144. {
  145. using namespace AzFramework::FileTag;
  146. bool shouldIgnore = false;
  147. QueryFileTagsEventBus::EventResult(shouldIgnore, FileTagType::Exclude, &QueryFileTagsEventBus::Events::Match, assetPath, m_excludedFileTags);
  148. if (shouldIgnore)
  149. {
  150. if (m_printExcluded)
  151. {
  152. AZ_TracePrintf("AssetValidation", "Asset ( %s ) is excluded. \n", assetPath);
  153. }
  154. return true;
  155. }
  156. AZ_Warning("AssetValidation", false, "Asset not found in seed graph: %s", assetPath);
  157. AssetValidationNotificationBus::Broadcast(&AssetValidationNotificationBus::Events::UnknownAsset, assetPath);
  158. return false;
  159. }
  160. return true;
  161. }
  162. void AssetValidationSystemComponent::FileAccess(const char* assetPath)
  163. {
  164. CheckKnownAsset(assetPath);
  165. }
  166. void AssetValidationSystemComponent::AddKnownAssets(AZ::Data::AssetId assetId)
  167. {
  168. AZ::Data::AssetInfo baseAssetInfo;
  169. AZ::Data::AssetCatalogRequestBus::BroadcastResult(baseAssetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, assetId);
  170. m_knownAssetPaths.insert(baseAssetInfo.m_relativePath);
  171. AZ::Outcome<AZStd::vector<AZ::Data::ProductDependency>, AZStd::string> getDependenciesResult = AZ::Failure(AZStd::string());
  172. AZ::Data::AssetCatalogRequestBus::BroadcastResult(getDependenciesResult, &AZ::Data::AssetCatalogRequestBus::Events::GetAllProductDependencies, assetId);
  173. if (getDependenciesResult.IsSuccess())
  174. {
  175. AZStd::vector<AZ::Data::ProductDependency> entries = getDependenciesResult.TakeValue();
  176. for (const AZ::Data::ProductDependency& productDependency : entries)
  177. {
  178. if (m_knownAssetIds.insert(productDependency.m_assetId).second)
  179. {
  180. AZ::Data::AssetInfo thisAssetInfo;
  181. AZ::Data::AssetCatalogRequestBus::BroadcastResult(thisAssetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, productDependency.m_assetId);
  182. if (!thisAssetInfo.m_relativePath.empty())
  183. {
  184. m_knownAssetPaths.insert(thisAssetInfo.m_relativePath);
  185. }
  186. }
  187. }
  188. }
  189. }
  190. void AssetValidationSystemComponent::ListKnownAssets()
  191. {
  192. AZ_TracePrintf("AssetValidation", "Seed Asset ids:");
  193. for (const auto& thisIdPair : m_seedAssetIds)
  194. {
  195. AZ::Data::AssetInfo thisAssetInfo;
  196. AZ::Data::AssetCatalogRequestBus::BroadcastResult(thisAssetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, thisIdPair.first);
  197. AZ_TracePrintf("AssetValidation", "%s - (%s)", thisAssetInfo.m_relativePath.c_str(), thisIdPair.first.ToString<AZStd::string>().c_str());
  198. }
  199. AZ_TracePrintf("AssetValidation", "Known Paths:");
  200. for (const auto& thisPath : m_knownAssetPaths)
  201. {
  202. AZ::Data::AssetId thisAssetId;
  203. AZ::Data::AssetCatalogRequestBus::BroadcastResult(thisAssetId, &AZ::Data::AssetCatalogRequests::GetAssetIdByPath, thisPath.c_str(), AZ::Data::s_invalidAssetType, false);
  204. AZ_TracePrintf("AssetValidation", "%s - (%s)", thisPath.c_str(), thisAssetId.ToString<AZStd::string>().c_str());
  205. }
  206. }
  207. void AssetValidationSystemComponent::BuildAssetList()
  208. {
  209. m_knownAssetIds.clear();
  210. m_knownAssetPaths.clear();
  211. for (const auto& thisAsset : m_seedAssetIds)
  212. {
  213. AddKnownAssets(thisAsset.first);
  214. }
  215. for (const auto& thisPath : m_seedLists)
  216. {
  217. AzFramework::AssetSeedList seedList;
  218. if (!AZ::Utils::LoadObjectFromFileInPlace(thisPath, seedList))
  219. {
  220. AZ_Warning("AssetValidation", false, "Failed to load seed list %s", thisPath.c_str());
  221. continue;
  222. }
  223. AddSeedsFor(seedList, AZ_CRC(thisPath.c_str()));
  224. }
  225. }
  226. bool AssetValidationSystemComponent::AddSeedPath(const char* seedPath)
  227. {
  228. AZ::Data::AssetId assetId;
  229. const bool AutoRegister{ false };
  230. AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, seedPath, AZ::Data::s_invalidAssetType, AutoRegister);
  231. if (!assetId.IsValid())
  232. {
  233. AZ_Warning("AssetValidation", false, "Can't find an asset %s", seedPath);
  234. return false;
  235. }
  236. return AddSeedAssetId(assetId, 0);
  237. }
  238. bool AssetValidationSystemComponent::AddSeedAssetId(AZ::Data::AssetId assetId, AZ::u32 sourceId)
  239. {
  240. auto curEntry = m_seedAssetIds.find(assetId);
  241. if (curEntry != m_seedAssetIds.end() && curEntry->second.count(sourceId) > 0)
  242. {
  243. AZ_Warning("AssetValidation", false, "AssetID %s from source %d is already added", assetId.ToString< AZStd::string>().c_str(), sourceId);
  244. return false;
  245. }
  246. m_seedAssetIds[assetId].insert(sourceId);
  247. AddKnownAssets(assetId);
  248. AZ_TracePrintf("AssetValidation", "Added assedId %s from source %d", assetId.ToString< AZStd::string>().c_str(), sourceId);
  249. return true;
  250. }
  251. bool AssetValidationSystemComponent::RemoveSeedPath(const char* seedPath)
  252. {
  253. AZ::Data::AssetId assetId;
  254. const bool AutoRegister{ false };
  255. AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, seedPath, AZ::Data::s_invalidAssetType, AutoRegister);
  256. if (!assetId.IsValid())
  257. {
  258. AZ_Warning("AssetValidation", false, "Can't find an asset %s", seedPath);
  259. return false;
  260. }
  261. return RemoveSeedAssetId(assetId, 0);
  262. }
  263. bool AssetValidationSystemComponent::RemoveSeedAssetId(AZ::Data::AssetId assetId, AZ::u32 sourceId)
  264. {
  265. int removeResult = RemoveSeedAssetIdBySource(assetId, sourceId);
  266. if (removeResult == -1)
  267. {
  268. // invalid remove request
  269. return false;
  270. }
  271. else if(removeResult == 0)
  272. {
  273. // Success and it was the last entry of that assetId, we need to rebuild
  274. BuildAssetList();
  275. }
  276. return true;
  277. }
  278. bool AssetValidationSystemComponent::RemoveSeedAssetIdList(AssetSourceList assetList)
  279. {
  280. bool needRebuild{ false };
  281. for (auto& thisPair : assetList)
  282. {
  283. if (RemoveSeedAssetIdBySource(thisPair.first, thisPair.second) == 0)
  284. {
  285. needRebuild = true;
  286. }
  287. }
  288. if (needRebuild)
  289. {
  290. BuildAssetList();
  291. }
  292. return true;
  293. }
  294. int AssetValidationSystemComponent::RemoveSeedAssetIdBySource(const AZ::Data::AssetId& assetId, AZ::u32 sourceId)
  295. {
  296. auto curEntry = m_seedAssetIds.find(assetId);
  297. if (curEntry == m_seedAssetIds.end() || !curEntry->second.erase(sourceId))
  298. {
  299. AZ_Warning("AssetValidation", false, "AssetID %s from source %d is not in the seed assets list", assetId.ToString< AZStd::string>().c_str(), sourceId);
  300. return -1;
  301. }
  302. if (!curEntry->second.size())
  303. {
  304. m_seedAssetIds.erase(assetId);
  305. return 0;
  306. }
  307. return static_cast<int>(curEntry->second.size());
  308. }
  309. void AssetValidationSystemComponent::ConsoleCommandAddSeedPath(IConsoleCmdArgs* pCmdArgs)
  310. {
  311. if (pCmdArgs->GetArgCount() < 2)
  312. {
  313. AZ_TracePrintf("AssetValidation", "addseedpath assetpath");
  314. return;
  315. }
  316. AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::AddSeedPath, pCmdArgs->GetArg(1));
  317. }
  318. void AssetValidationSystemComponent::ConsoleCommandKnownAssets([[maybe_unused]] IConsoleCmdArgs* pCmdArgs)
  319. {
  320. AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::ListKnownAssets);
  321. }
  322. void AssetValidationSystemComponent::ConsoleCommandRemoveSeedPath(IConsoleCmdArgs* pCmdArgs)
  323. {
  324. if (pCmdArgs->GetArgCount() < 2)
  325. {
  326. AZ_TracePrintf("AssetValidation", "removeseedpath assetpath");
  327. return;
  328. }
  329. AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::RemoveSeedPath, pCmdArgs->GetArg(1));
  330. }
  331. void AssetValidationSystemComponent::ConsoleCommandAddSeedList(IConsoleCmdArgs* pCmdArgs)
  332. {
  333. if (pCmdArgs->GetArgCount() < 2)
  334. {
  335. AZ_TracePrintf("AssetValidation", "Command syntax is: addseedlist <path/to/seedfile> as a relative path under the /dev folder");
  336. return;
  337. }
  338. const char* seedfilepath = pCmdArgs->GetArg(1);
  339. AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::AddSeedList, seedfilepath);
  340. }
  341. bool AssetValidationSystemComponent::AddSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 seedId)
  342. {
  343. for (const AzFramework::SeedInfo& thisSeed : seedList)
  344. {
  345. AddSeedAssetId(thisSeed.m_assetId, seedId);
  346. }
  347. return true;
  348. }
  349. bool AssetValidationSystemComponent::RemoveSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 seedId)
  350. {
  351. AssetValidationRequests::AssetSourceList removeList;
  352. for (const AzFramework::SeedInfo& thisSeed : seedList)
  353. {
  354. removeList.push_back({ thisSeed.m_assetId, seedId });
  355. }
  356. RemoveSeedAssetIdList(removeList);
  357. return true;
  358. }
  359. bool AssetValidationSystemComponent::AddSeedListHelper(const char* seedPath)
  360. {
  361. AZStd::string absoluteSeedPath;
  362. AZ::Outcome<AzFramework::AssetSeedList, AZStd::string> loadSeedOutcome = LoadSeedList(seedPath, absoluteSeedPath);
  363. if (!loadSeedOutcome.IsSuccess())
  364. {
  365. AZ_Warning("AssetValidation", false, loadSeedOutcome.GetError().c_str());
  366. return false;
  367. }
  368. if (m_seedLists.count(absoluteSeedPath.c_str()))
  369. {
  370. AZ_Warning("AssetValidation", false, "Seed list %s (%s) already loaded", seedPath, absoluteSeedPath.c_str());
  371. return false;
  372. }
  373. AzFramework::AssetSeedList seedList = loadSeedOutcome.TakeValue();
  374. if (m_seedMode && !AddSeedsFor(seedList, AZ_CRC(absoluteSeedPath.c_str())))
  375. {
  376. return false;
  377. }
  378. m_seedLists.insert(absoluteSeedPath.c_str());
  379. AZ_TracePrintf("AssetValidation", "Added seed list %s (%s) with %u elements", seedPath, absoluteSeedPath.c_str(), seedList.size());
  380. return true;
  381. }
  382. bool GetDefaultSeedListFiles(AZStd::vector<AZStd::string>& defaultSeedListFiles)
  383. {
  384. auto settingsRegistry = AZ::SettingsRegistry::Get();
  385. AZ::SettingsRegistryInterface::FixedValueString gameFolder;
  386. auto projectKey = AZ::SettingsRegistryInterface::FixedValueString::format("%s/project_path", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey);
  387. settingsRegistry->Get(gameFolder, projectKey);
  388. if (gameFolder.empty())
  389. {
  390. AZ_Warning("AssetValidation", false, "Unable to locate game name in bootstrap.");
  391. return false;
  392. }
  393. AZStd::vector<AzFramework::GemInfo> gemInfoList;
  394. if (!AzFramework::GetGemsInfo(gemInfoList, *settingsRegistry))
  395. {
  396. AZ_Warning("AssetValidation", false, "Unable to get gem information.");
  397. return false;
  398. }
  399. defaultSeedListFiles = AssetSeed::GetDefaultSeedListFiles(gemInfoList, AzFramework::PlatformFlags::Platform_PC);
  400. return true;
  401. }
  402. bool AssetValidationSystemComponent::AddSeedList(const char* seedPath)
  403. {
  404. if (AZ::StringFunc::Equal(seedPath, "default"))
  405. {
  406. AZStd::vector<AZStd::string> defaultSeedListFiles;
  407. if(!GetDefaultSeedListFiles(defaultSeedListFiles))
  408. {
  409. return false;
  410. }
  411. for (const AZStd::string& seedListFile : defaultSeedListFiles)
  412. {
  413. if (!AddSeedListHelper(seedListFile.c_str()))
  414. {
  415. return false;
  416. }
  417. }
  418. return true;
  419. }
  420. return AddSeedListHelper(seedPath);
  421. }
  422. void AssetValidationSystemComponent::ConsoleCommandRemoveSeedList(IConsoleCmdArgs* pCmdArgs)
  423. {
  424. if (pCmdArgs->GetArgCount() < 2)
  425. {
  426. AZ_TracePrintf("AssetValidation", "removeseedlist seedlistpath");
  427. return;
  428. }
  429. const char* seedfilepath = pCmdArgs->GetArg(1);
  430. AssetValidationRequestBus::Broadcast(&AssetValidationRequestBus::Events::RemoveSeedList, seedfilepath);
  431. }
  432. AZ::Outcome<AzFramework::AssetSeedList, AZStd::string> AssetValidationSystemComponent::LoadSeedList(const char* seedPath, AZStd::string& seedListPath)
  433. {
  434. AZ::IO::Path absoluteSeedPath = seedPath;
  435. if (AZ::StringFunc::Path::IsRelative(seedPath))
  436. {
  437. AZ::IO::FixedMaxPath engineRoot = AZ::Utils::GetEnginePath();
  438. if (engineRoot.empty())
  439. {
  440. return AZ::Failure(AZStd::string("Couldn't get engine root"));
  441. }
  442. absoluteSeedPath = (engineRoot / seedPath).String();
  443. }
  444. AzFramework::AssetSeedList seedList;
  445. if (!AZ::Utils::LoadObjectFromFileInPlace(absoluteSeedPath.Native(), seedList))
  446. {
  447. return AZ::Failure(AZStd::string::format("Failed to load seed list %s", absoluteSeedPath.c_str()));
  448. }
  449. seedListPath = AZStd::move(absoluteSeedPath.Native());
  450. return AZ::Success(seedList);
  451. }
  452. bool AssetValidationSystemComponent::RemoveSeedListHelper(const char* seedPath)
  453. {
  454. AZStd::string absoluteSeedPath;
  455. AZ::Outcome<AzFramework::AssetSeedList, AZStd::string> loadSeedOutcome = LoadSeedList(seedPath, absoluteSeedPath);
  456. if (!loadSeedOutcome.IsSuccess())
  457. {
  458. AZ_Warning("AssetValidation", false, loadSeedOutcome.GetError().c_str());
  459. return false;
  460. }
  461. AzFramework::AssetSeedList seedList = loadSeedOutcome.TakeValue();
  462. if (!m_seedLists.count(absoluteSeedPath))
  463. {
  464. AZ_Warning("AssetValidation", false, "Seed path %s (%s) wasn't in seed lists", seedPath, absoluteSeedPath.c_str());
  465. return false;
  466. }
  467. m_seedLists.erase(absoluteSeedPath.c_str());
  468. // Don't check if we're currently in seed mode - that will be dealt with on the other side
  469. if (!RemoveSeedsFor(seedList, AZ_CRC(absoluteSeedPath.c_str())))
  470. {
  471. return false;
  472. }
  473. AZ_TracePrintf("AssetValidation", "Removed seed list %s with %u elements", absoluteSeedPath.c_str(), seedList.size());
  474. return true;
  475. }
  476. bool AssetValidationSystemComponent::RemoveSeedList(const char* seedPath)
  477. {
  478. if (AZ::StringFunc::Equal(seedPath, "default"))
  479. {
  480. AZStd::vector<AZStd::string> defaultSeedListFiles;
  481. if (!GetDefaultSeedListFiles(defaultSeedListFiles))
  482. {
  483. return false;
  484. }
  485. for (const AZStd::string& seedListFile : defaultSeedListFiles)
  486. {
  487. if (!RemoveSeedListHelper(seedListFile.c_str()))
  488. {
  489. return false;
  490. }
  491. }
  492. return true;
  493. }
  494. return RemoveSeedListHelper(seedPath);
  495. }
  496. }