Asset Bundler GUI (#427)

The AssetBundler is a new ToolsApplication that allows users to work through the entire Asset Bundling process without ever touching a command line.

* Integrating github/AssetBundler through commit 1d65018

* Asset Bundler bug fixes: platform initialization and GUI styling (#5)

* fixed enabled platform initialization

* fixed the cached engine root. This fixed some of my Seeds tab data issues. The default Engine Seed List appeared, and was able to display the contents on screen.

* updated my notes of active bugs

* changed some casing in various include lines to hopefully fix my linux build

* another include fix for linux

* AssetBundler GUI is now compiling on Mac

* removed some things off of my todo list because the mac build fix actually fixed the visuals! everything's the right color again

* removed the word Lumberyard from the bundler

* Asset bundler bug fixes - Bundles, Gems, and Tests (#9)

* Fixed the Bundle loading and generation problem. Turned out to be a FileWatcher issue.

* turns out gem loading wasn't broken, there were just no existing SeedListFiles for any of the gems loaded by the AutomatedTesting project. I added a default SeedListFile for the PrimitiveAssets Gem.

* fixed some failing AssetBundler Gem tests

* Misunderstood the need to have default seed lists for asset-only gems. removing the previously created seed list file

* Asset bundler bug fixes: Seeds Tab display issues and _dependencies.xml loading (#10)

* Fixed the Project Source column in the Seeds tab

* The AssetBundler will no longer attempt to copy a template version of the ProjectName_dependencies.xml file into your active project. However, it will throw an error if you do not have one. A follow-up ticket has been cut to address this issue.

* updated the AssetBundler icon. This one matches the current style guides

* PR feedback: pass a const ref instead of a value

* PR feedback: safer conversion from a string_view to a QString

Co-authored-by: alexpete <alexpete@amazon.com>
This commit is contained in:
Zaladane
2021-04-30 15:42:10 -07:00
committed by GitHub
parent 4e3846e679
commit a5d4eb5d44
76 changed files with 10163 additions and 63 deletions
+41 -35
View File
@@ -31,6 +31,7 @@ AZ_PUSH_DISABLE_WARNING(4244 4251, "-Wunknown-warning-option")
#include <QDir>
#include <QString>
#include <QStringList>
#include <QJsonDocument>
AZ_POP_DISABLE_WARNING
namespace AssetBundler
@@ -108,6 +109,8 @@ namespace AssetBundler
const char* AssetCatalogFilename = "assetcatalog.xml";
AZ::IO::FixedMaxPath g_cachedEngineRoot;
const char EngineDirectoryName[] = "Engine";
const char RestrictedDirectoryName[] = "restricted";
@@ -128,7 +131,7 @@ namespace AssetBundler
AZStd::unordered_map<AZStd::string, AZStd::string>& defaultSeedLists,
AzFramework::PlatformFlags platformFlags)
{
AZ::IO::FixedMaxPath engineRoot(GetEngineRoot());
AZ::IO::FixedMaxPath engineRoot(GetCachedEngineRoot());
AZ::IO::FixedMaxPath engineRestrictedRoot = engineRoot / RestrictedDirectoryName;
AZ::IO::FixedMaxPath engineLocalPath = AZ::IO::PathView(engineDirectory.LexicallyRelative(engineRoot));
@@ -201,15 +204,10 @@ namespace AssetBundler
}
}
AZ::IO::FixedMaxPath GetEngineRoot()
AZ::IO::FixedMaxPath GetCachedEngineRoot()
{
AZ::IO::FixedMaxPath engineRootPath;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
return engineRootPath;
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)
@@ -276,11 +274,11 @@ namespace AssetBundler
return defaultSeedLists;
}
AZStd::vector<AZStd::string> GetDefaultSeeds(AZStd::string_view enginePath, AZStd::string_view projectPath, AZStd::string_view projectName)
AZStd::vector<AZStd::string> GetDefaultSeeds(AZStd::string_view projectPath, AZStd::string_view projectName)
{
AZStd::vector<AZStd::string> defaultSeeds;
defaultSeeds.emplace_back(GetProjectDependenciesAssetPath(enginePath, projectPath, projectName));
defaultSeeds.emplace_back(GetProjectDependenciesAssetPath(projectPath, projectName));
return defaultSeeds;
}
@@ -294,34 +292,12 @@ namespace AssetBundler
return projectDependenciesFilePath.LexicallyNormal();
}
AZ::IO::Path GetProjectDependenciesFileTemplate(AZStd::string_view engineRoot)
{
AZ::IO::Path projectDependenciesFileTemplate = engineRoot;
projectDependenciesFileTemplate /= DefaultProjectTemplatePath;
projectDependenciesFileTemplate /= AZStd::string::format("%s%s", ProjectName, DependenciesFileSuffix);
projectDependenciesFileTemplate.ReplaceExtension(DependenciesFileExtension);
return projectDependenciesFileTemplate.LexicallyNormal();
}
AZ::IO::Path GetProjectDependenciesAssetPath(AZStd::string_view enginePath, AZStd::string_view projectPath, AZStd::string_view projectName)
AZ::IO::Path GetProjectDependenciesAssetPath(AZStd::string_view projectPath, AZStd::string_view projectName)
{
AZ::IO::Path projectDependenciesFile = GetProjectDependenciesFile(projectPath, projectName);
if (!AZ::IO::FileIOBase::GetInstance()->Exists(projectDependenciesFile.c_str()))
{
AZ_TracePrintf(AssetBundler::AppWindowName, "Project dependencies file %s doesn't exist.\n", projectDependenciesFile.c_str());
AZ::IO::Path projectDependenciesFileTemplate = GetProjectDependenciesFileTemplate(enginePath);
if (AZ::IO::FileIOBase::GetInstance()->Copy(projectDependenciesFileTemplate.c_str(), projectDependenciesFile.c_str()))
{
AZ_TracePrintf(AssetBundler::AppWindowName, "Copied project dependencies file template %s to the current project.\n",
projectDependenciesFile.c_str());
}
else
{
AZ_Error(AppWindowName, false, "Failed to copy project dependencies file template %s from default project"
" template to the current project.\n", projectDependenciesFileTemplate.c_str());
return {};
}
AZ_Error(AssetBundler::AppWindowName, false, "Project dependencies file %s doesn't exist.\n", projectDependenciesFile.c_str());
}
// Turn the absolute path into a cache-relative path
@@ -538,6 +514,14 @@ namespace AssetBundler
return platformSpecificCacheFolderPath;
}
AZStd::string GenerateKeyFromAbsolutePath(const AZStd::string& absoluteFilePath)
{
AZStd::string key(absoluteFilePath);
AzFramework::StringFunc::Path::Normalize(key);
AzFramework::StringFunc::Path::StripDrive(key);
return key;
}
void ConvertToRelativePath(AZStd::string_view parentFolderPath, AZStd::string& absoluteFilePath)
{
absoluteFilePath = AZ::IO::PathView(absoluteFilePath).LexicallyRelative(parentFolderPath).String();
@@ -822,4 +806,26 @@ namespace AssetBundler
}
return false;
}
QJsonObject ReadJson(const AZStd::string& filePath)
{
QByteArray byteArray;
QFile jsonFile;
jsonFile.setFileName(filePath.c_str());
jsonFile.open(QIODevice::ReadOnly | QIODevice::Text);
byteArray = jsonFile.readAll();
jsonFile.close();
return QJsonDocument::fromJson(byteArray).object();
}
void SaveJson(const AZStd::string& filePath, const QJsonObject& jsonObject)
{
QFile jsonFile(filePath.c_str());
QJsonDocument JsonDocument;
JsonDocument.setObject(jsonObject);
jsonFile.open(QFile::WriteOnly | QFile::Text | QFile::Truncate);
jsonFile.write(JsonDocument.toJson());
jsonFile.close();
}
}