From 976501f947757dc72b19613cbc1e4f663fcae53d Mon Sep 17 00:00:00 2001 From: Tim Thomas Date: Thu, 29 May 2025 16:32:33 -0500 Subject: [PATCH 1/4] add in explict assets from build layout files --- Analyzer/Analyzer.csproj | 1 + Analyzer/AnalyzerTool.cs | 37 ++++++++++- Analyzer/Resources/Init.sql | 39 +++++++++++ Analyzer/SQLite/SQLiteWriter.cs | 114 +++++++++++++++++++++++++++++++- 4 files changed, 187 insertions(+), 4 deletions(-) diff --git a/Analyzer/Analyzer.csproj b/Analyzer/Analyzer.csproj index ac217d0..d6b4999 100644 --- a/Analyzer/Analyzer.csproj +++ b/Analyzer/Analyzer.csproj @@ -15,6 +15,7 @@ + diff --git a/Analyzer/AnalyzerTool.cs b/Analyzer/AnalyzerTool.cs index 943987a..46d75c2 100644 --- a/Analyzer/AnalyzerTool.cs +++ b/Analyzer/AnalyzerTool.cs @@ -1,7 +1,9 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using UnityDataTools.Analyzer.Build; using UnityDataTools.Analyzer.SQLite; using UnityDataTools.FileSystem; @@ -44,6 +46,12 @@ public int Analyze( int i = 1; foreach (var file in files) { + if (Path.GetExtension(file) == ".json") + { + ProcessBuildLayout(file, writer, i, files.Length); + ++i; + continue; + } if (ShouldIgnoreFile(file)) { var relativePath = Path.GetRelativePath(path, file); @@ -173,6 +181,33 @@ void ProcessFile(string file, string rootDirectory, SQLiteWriter writer, int fil } } + + + void ProcessBuildLayout(string file, SQLiteWriter writer, int fileIndex, int cntFiles) + { + try + { + Console.Error.WriteLine(file); + using (StreamReader reader = File.OpenText(file)) + { + JsonSerializer serializer = new JsonSerializer(); + BuildLayout buildLayout = (BuildLayout)serializer.Deserialize(reader, typeof(BuildLayout)); + writer.WriteBuildLayout(file, buildLayout); + ReportProgress(file, fileIndex, cntFiles); + } + } + catch (Exception e) + { + EraseProgressLine(); + Console.Error.WriteLine(); + Console.Error.WriteLine($"Error processing file: {file}"); + Console.WriteLine($"{e.GetType()}: {e.Message}"); + if (m_Verbose) + Console.WriteLine(e.StackTrace); + } + + } + int m_LastProgressMessageLength = 0; void ReportProgress(string relativePath, int fileIndex, int cntFiles) diff --git a/Analyzer/Resources/Init.sql b/Analyzer/Resources/Init.sql index a41a44a..5e79213 100644 --- a/Analyzer/Resources/Init.sql +++ b/Analyzer/Resources/Init.sql @@ -103,5 +103,44 @@ WHERE m.type = "Material"; INSERT INTO types (id, name) VALUES (-1, 'Scene'); +CREATE TABLE build_layouts +( + id INTEGER, + name TEXT, + build_target INTEGER, + start_time TEXT, + duration REAL, + error TEXT, + package_version TEXT, + player_version TEXT, + build_script TEXT, + result_hash TEXT, + type INTEGER, + unity_version TEXT, + PRIMARY KEY (id) +); + +create table build_layout_explicit_assets +( + id INTEGER, + build_id INTEGER, + bundle INTEGER, + file INTEGER, + asset_hash TEXT, + asset_path TEXT, + addressable_name TEXT, + externally_referenced_assets TEXT, + group_guid TEXT, + guid TEXT, + internal_id TEXT, + internal_referenced_explicit_assets TEXT, + internal_referenced_other_assets TEXT, + labels TEXT, + main_asset_type INTEGER, + serialized_size INTEGER, + streamed_size INTEGER, + PRIMARY KEY (id, build_id) +); + PRAGMA synchronous = OFF; PRAGMA journal_mode = MEMORY; diff --git a/Analyzer/SQLite/SQLiteWriter.cs b/Analyzer/SQLite/SQLiteWriter.cs index f468f49..d43be74 100644 --- a/Analyzer/SQLite/SQLiteWriter.cs +++ b/Analyzer/SQLite/SQLiteWriter.cs @@ -6,6 +6,10 @@ using UnityDataTools.Analyzer.SQLite.Handlers; using UnityDataTools.FileSystem; using UnityDataTools.FileSystem.TypeTreeReaders; +using UnityDataTools.Analyzer.Build; +using static System.Runtime.InteropServices.JavaScript.JSType; +using System.Xml.Linq; +using Newtonsoft.Json; namespace UnityDataTools.Analyzer.SQLite; @@ -45,6 +49,9 @@ public class SQLiteWriter : IWriter private SqliteCommand m_AddObjectCommand = new SqliteCommand(); private SqliteCommand m_AddTypeCommand = new SqliteCommand(); private SqliteCommand m_InsertDepCommand = new SqliteCommand(); + private SqliteCommand m_InsertBuild = new SqliteCommand(); + private SqliteCommand m_ExplicitAsset = new SqliteCommand(); + private SqliteCommand m_LastId = new SqliteCommand(); private SqliteTransaction m_CurrentTransaction = null; public SQLiteWriter(string databaseName, bool skipReferences) { @@ -125,7 +132,7 @@ private void CreateSQLiteCommands() m_AddReferenceCommand.Parameters.Add("@referenced_object", SqliteType.Integer); m_AddReferenceCommand.Parameters.Add("@property_path", SqliteType.Text); m_AddReferenceCommand.Parameters.Add("@property_type", SqliteType.Text); - + m_AddObjectCommand = m_Database.CreateCommand(); m_AddObjectCommand.CommandText = "INSERT INTO objects (id, object_id, serialized_file, type, name, game_object, size, crc32) VALUES (@id, @object_id, @serialized_file, @type, @name, @game_object, @size, @crc32)"; m_AddObjectCommand.Parameters.Add("@id", SqliteType.Integer); @@ -146,8 +153,45 @@ private void CreateSQLiteCommands() m_InsertDepCommand.CommandText = "INSERT INTO asset_dependencies(object, dependency) VALUES(@object, @dependency)"; m_InsertDepCommand.Parameters.Add("@object", SqliteType.Integer); m_InsertDepCommand.Parameters.Add("@dependency", SqliteType.Integer); - } + m_InsertBuild = m_Database.CreateCommand(); + m_InsertBuild.CommandText = "INSERT INTO build_layouts (name, build_target, start_time, duration, error, package_version, player_version, build_script, result_hash, type, unity_version) VALUES (@name, @build_target, @start_time, @duration, @error, @package_version, @player_version, @build_script, @result_hash, @type, @unity_version)"; + m_InsertBuild.Parameters.Add("@name", SqliteType.Text); + m_InsertBuild.Parameters.Add("@build_target", SqliteType.Integer); + m_InsertBuild.Parameters.Add("@start_time", SqliteType.Integer); + m_InsertBuild.Parameters.Add("@duration", SqliteType.Real); + m_InsertBuild.Parameters.Add("@error", SqliteType.Text); + m_InsertBuild.Parameters.Add("@package_version", SqliteType.Text); + m_InsertBuild.Parameters.Add("@player_version", SqliteType.Text); + m_InsertBuild.Parameters.Add("@build_script", SqliteType.Text); + m_InsertBuild.Parameters.Add("@result_hash", SqliteType.Text); + m_InsertBuild.Parameters.Add("@type", SqliteType.Integer); + m_InsertBuild.Parameters.Add("@unity_version", SqliteType.Text); + + m_ExplicitAsset = m_Database.CreateCommand(); + m_ExplicitAsset.CommandText = + "INSERT INTO build_layout_explicit_assets (id, build_id, bundle, file, asset_hash, asset_path, addressable_name, externally_referenced_assets, group_guid, guid, internal_id, internal_referenced_explicit_assets, internal_referenced_other_assets, labels, streamed_size, serialized_size, main_asset_type) VALUES (@id, @build_id, @bundle, @file, @asset_hash, @asset_path, @addressable_name, @externally_referenced_assets, @group_guid, @guid, @internal_id, @internal_referenced_explicit_assets, @internal_referenced_other_assets, @labels, @streamed_size, @serialized_size, @main_asset_type)"; + m_ExplicitAsset.Parameters.Add("@id", SqliteType.Integer); + m_ExplicitAsset.Parameters.Add("@build_id", SqliteType.Integer); + m_ExplicitAsset.Parameters.Add("@bundle", SqliteType.Integer); + m_ExplicitAsset.Parameters.Add("@file", SqliteType.Integer); + m_ExplicitAsset.Parameters.Add("@asset_hash", SqliteType.Text); + m_ExplicitAsset.Parameters.Add("@asset_path", SqliteType.Text); + m_ExplicitAsset.Parameters.Add("@addressable_name", SqliteType.Text); + m_ExplicitAsset.Parameters.Add("@externally_referenced_assets", SqliteType.Text); // JSONB type in SQLite uses TEXT + m_ExplicitAsset.Parameters.Add("@group_guid", SqliteType.Text); + m_ExplicitAsset.Parameters.Add("@guid", SqliteType.Text); + m_ExplicitAsset.Parameters.Add("@internal_id", SqliteType.Text); + m_ExplicitAsset.Parameters.Add("@internal_referenced_explicit_assets", SqliteType.Text); // JSONB type in SQLite uses TEXT + m_ExplicitAsset.Parameters.Add("@internal_referenced_other_assets", SqliteType.Text); // JSONB type in SQLite uses TEXT + m_ExplicitAsset.Parameters.Add("@labels", SqliteType.Text); // JSONB type in SQLite uses TEXT + m_ExplicitAsset.Parameters.Add("@streamed_size", SqliteType.Integer); + m_ExplicitAsset.Parameters.Add("@serialized_size", SqliteType.Integer); + m_ExplicitAsset.Parameters.Add("@main_asset_type", SqliteType.Integer); + + m_LastId = m_Database.CreateCommand(); + m_LastId.CommandText = "SELECT last_insert_rowid()"; + } public void BeginAssetBundle(string name, long size) { if (m_CurrentAssetBundleId != -1) @@ -171,7 +215,71 @@ public void EndAssetBundle() m_CurrentAssetBundleId = -1; } - + + public void WriteBuildLayout(string filename, BuildLayout buildLayout) + { + using var transaction = m_Database.BeginTransaction(); + m_CurrentTransaction = transaction; + + try + { + m_InsertBuild.Transaction = transaction; + m_InsertBuild.Parameters["@name"].Value = Path.GetFileName(filename); + m_InsertBuild.Parameters["@build_target"].Value = buildLayout.BuildTarget; + m_InsertBuild.Parameters["@start_time"].Value = buildLayout.BuildStartTime; + m_InsertBuild.Parameters["@duration"].Value = buildLayout.Duration; + m_InsertBuild.Parameters["@error"].Value = buildLayout.BuildError; + m_InsertBuild.Parameters["@package_version"].Value = buildLayout.PackageVersion; + m_InsertBuild.Parameters["@player_version"].Value = buildLayout.PlayerBuildVersion; + m_InsertBuild.Parameters["@build_script"].Value = buildLayout.BuildScript; + m_InsertBuild.Parameters["@result_hash"].Value = buildLayout.BuildResultHash; + m_InsertBuild.Parameters["@type"].Value = buildLayout.BuildType; + m_InsertBuild.Parameters["@unity_version"].Value = buildLayout.UnityVersion; + m_InsertBuild.ExecuteNonQuery(); + + m_LastId.Transaction = transaction; + long buildId = (long) m_LastId.ExecuteScalar(); + Console.WriteLine($"Build ID: {buildId}"); + + foreach (var reference in buildLayout.references.RefIds) + { + switch(reference.type.Class) + { + case "BuildLayout/ExplicitAsset": + m_ExplicitAsset.Transaction = transaction; + m_ExplicitAsset.Parameters["@id"].Value = reference.rid; + m_ExplicitAsset.Parameters["@build_id"].Value = buildId; + m_ExplicitAsset.Parameters["@bundle"].Value = reference.data.Bundle.rid; + m_ExplicitAsset.Parameters["@file"].Value = reference.data.File.rid; + m_ExplicitAsset.Parameters["@asset_hash"].Value = reference.data.AssetHash.Hash; + m_ExplicitAsset.Parameters["@asset_path"].Value = reference.data.AssetPath; + m_ExplicitAsset.Parameters["@addressable_name"].Value = reference.data.AddressableName; + m_ExplicitAsset.Parameters["@externally_referenced_assets"].Value = JsonConvert.SerializeObject(reference.data.ExternallyReferencedAssets) ?? "[]"; + m_ExplicitAsset.Parameters["@group_guid"].Value = reference.data.GroupGuid; + m_ExplicitAsset.Parameters["@guid"].Value = reference.data.Guid; + m_ExplicitAsset.Parameters["@internal_id"].Value = reference.data.InternalId; + m_ExplicitAsset.Parameters["@internal_referenced_explicit_assets"].Value = JsonConvert.SerializeObject(reference.data.InternalReferencedExplicitAssets) ?? "[]"; + m_ExplicitAsset.Parameters["@internal_referenced_other_assets"].Value = JsonConvert.SerializeObject(reference.data.InternalReferencedOtherAssets) ?? "[]"; + m_ExplicitAsset.Parameters["@labels"].Value = JsonConvert.SerializeObject(reference.data.Labels) ?? "[]"; + m_ExplicitAsset.Parameters["@main_asset_type"].Value = reference.data.MainAssetType; + m_ExplicitAsset.Parameters["@serialized_size"].Value = reference.data.SerializedSize; + m_ExplicitAsset.Parameters["@streamed_size"].Value = reference.data.StreamedSize; + m_ExplicitAsset.ExecuteNonQuery(); + break; + } + } + + // do the stuff + transaction.Commit(); + } + catch (Exception e) + { + transaction.Rollback(); + throw; + } + } + + public void WriteSerializedFile(string relativePath, string fullPath, string containingFolder) { using var sf = UnityFileSystem.OpenSerializedFile(fullPath); From 2db2e6f4ffbc9420f3f300b9abc41fea271ce172 Mon Sep 17 00:00:00 2001 From: Tim Thomas Date: Mon, 30 Jun 2025 11:44:38 -0500 Subject: [PATCH 2/4] added addressables build reports --- .gitignore | 3 + Analyzer/AnalyzerTool.cs | 6 +- Analyzer/Resources/Init.sql | 4 +- Analyzer/SQLite/Commands/AbstractCommand.cs | 54 +++++++++ Analyzer/SQLite/Commands/AddressablesBuild.cs | 35 ++++++ .../AddressablesBuildExplicitAsset.cs | 38 ++++++ Analyzer/SQLite/SQLiteWriter.cs | 109 +++++++----------- 7 files changed, 175 insertions(+), 74 deletions(-) create mode 100644 Analyzer/SQLite/Commands/AbstractCommand.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuild.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs diff --git a/.gitignore b/.gitignore index aa59e68..d4d2a12 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ UnityFileSystemTestData/**/*.sln UnityFileSystemTestData/ProjectSettings/ UnityFileSystemTestData/UserSettings/ UnityFileSystemTestData/Packages/ +*.db +*.txt +*.csv diff --git a/Analyzer/AnalyzerTool.cs b/Analyzer/AnalyzerTool.cs index 46d75c2..d144a50 100644 --- a/Analyzer/AnalyzerTool.cs +++ b/Analyzer/AnalyzerTool.cs @@ -48,7 +48,7 @@ public int Analyze( { if (Path.GetExtension(file) == ".json") { - ProcessBuildLayout(file, writer, i, files.Length); + ProcessAddressablesBuild(file, writer, i, files.Length); ++i; continue; } @@ -183,7 +183,7 @@ void ProcessFile(string file, string rootDirectory, SQLiteWriter writer, int fil - void ProcessBuildLayout(string file, SQLiteWriter writer, int fileIndex, int cntFiles) + void ProcessAddressablesBuild(string file, SQLiteWriter writer, int fileIndex, int cntFiles) { try { @@ -192,7 +192,7 @@ void ProcessBuildLayout(string file, SQLiteWriter writer, int fileIndex, int cnt { JsonSerializer serializer = new JsonSerializer(); BuildLayout buildLayout = (BuildLayout)serializer.Deserialize(reader, typeof(BuildLayout)); - writer.WriteBuildLayout(file, buildLayout); + writer.WriteAddressablesBuild(file, buildLayout); ReportProgress(file, fileIndex, cntFiles); } } diff --git a/Analyzer/Resources/Init.sql b/Analyzer/Resources/Init.sql index 5e79213..da0dc9c 100644 --- a/Analyzer/Resources/Init.sql +++ b/Analyzer/Resources/Init.sql @@ -103,7 +103,7 @@ WHERE m.type = "Material"; INSERT INTO types (id, name) VALUES (-1, 'Scene'); -CREATE TABLE build_layouts +CREATE TABLE addr_builds ( id INTEGER, name TEXT, @@ -120,7 +120,7 @@ CREATE TABLE build_layouts PRIMARY KEY (id) ); -create table build_layout_explicit_assets +create table addr_build_explicit_assets ( id INTEGER, build_id INTEGER, diff --git a/Analyzer/SQLite/Commands/AbstractCommand.cs b/Analyzer/SQLite/Commands/AbstractCommand.cs new file mode 100644 index 0000000..df06b2c --- /dev/null +++ b/Analyzer/SQLite/Commands/AbstractCommand.cs @@ -0,0 +1,54 @@ +using Microsoft.Data.Sqlite; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Analyzer.SQLite.Commands +{ + internal abstract class AbstractCommand + { + protected abstract string TableName { get; } + protected abstract Dictionary Fields { get; } + + private SqliteCommand m_Command = new SqliteCommand(); + + public void CreateCommand(SqliteConnection database) + { + m_Command = database.CreateCommand(); + var commandText = new StringBuilder($"INSERT INTO {TableName} ("); + commandText.Append(string.Join(", ", Fields.Keys)); + commandText.Append(") VALUES (@"); + commandText.Append(string.Join(", @", Fields.Keys)); + commandText.Append(")"); + m_Command.CommandText = commandText.ToString(); + + foreach (var entry in Fields) + { + m_Command.Parameters.Add("@" + entry.Key, entry.Value); + } + } + public void SetValue(string key, object value) + { + if (m_Command.Parameters.Contains(key)) + { + m_Command.Parameters[key].Value = value ?? DBNull.Value; + } + else + { + throw new ArgumentException($"Parameter '{key}' does not exist in the command."); + } + } + + public void SetTransaction(SqliteTransaction transaction) + { + m_Command.Transaction = transaction; + } + + public int ExecuteNonQuery() + { + return m_Command.ExecuteNonQuery(); + } + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuild.cs b/Analyzer/SQLite/Commands/AddressablesBuild.cs new file mode 100644 index 0000000..9ecc04e --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuild.cs @@ -0,0 +1,35 @@ +using Microsoft.Data.Sqlite; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Analyzer.SQLite.Commands +{ + internal class AddressablesBuild : AbstractCommand + { + protected override string TableName { get => "addr_builds"; } + protected override Dictionary Fields { get => new Dictionary + { + { "name", SqliteType.Text }, + { "build_target", SqliteType.Integer }, + { "start_time", SqliteType.Integer }, + { "duration", SqliteType.Real }, + { "error", SqliteType.Text }, + { "package_version", SqliteType.Text }, + { "player_version", SqliteType.Text }, + { "build_script", SqliteType.Text }, + { "result_hash", SqliteType.Text }, + { "type", SqliteType.Integer }, + { "unity_version", SqliteType.Text } + }; } + public AddressablesBuild() + { + + } + + + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs new file mode 100644 index 0000000..138807d --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs @@ -0,0 +1,38 @@ +using Microsoft.Data.Sqlite; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Analyzer.SQLite.Commands +{ + internal class AddressablesBuildExplicitAsset : AbstractCommand + { + protected override string TableName => "addr_build_explicit_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer}, + { "bundle", SqliteType.Integer}, + { "file", SqliteType.Integer }, + { "asset_hash", SqliteType.Text }, + { "asset_path", SqliteType.Text }, + { "addressable_name", SqliteType.Text }, + { "externally_referenced_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "group_guid", SqliteType.Text }, + { "guid", SqliteType.Text }, + { "internal_id", SqliteType.Text }, + { "internal_referenced_explicit_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "internal_referenced_other_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "labels", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "streamed_size", SqliteType.Integer }, + { "serialized_size", SqliteType.Integer }, + { "main_asset_type", SqliteType.Integer } + }; + public AddressablesBuildExplicitAsset() + { + } + } +} diff --git a/Analyzer/SQLite/SQLiteWriter.cs b/Analyzer/SQLite/SQLiteWriter.cs index d43be74..330cdbd 100644 --- a/Analyzer/SQLite/SQLiteWriter.cs +++ b/Analyzer/SQLite/SQLiteWriter.cs @@ -10,6 +10,7 @@ using static System.Runtime.InteropServices.JavaScript.JSType; using System.Xml.Linq; using Newtonsoft.Json; +using Analyzer.SQLite.Commands; namespace UnityDataTools.Analyzer.SQLite; @@ -49,8 +50,8 @@ public class SQLiteWriter : IWriter private SqliteCommand m_AddObjectCommand = new SqliteCommand(); private SqliteCommand m_AddTypeCommand = new SqliteCommand(); private SqliteCommand m_InsertDepCommand = new SqliteCommand(); - private SqliteCommand m_InsertBuild = new SqliteCommand(); - private SqliteCommand m_ExplicitAsset = new SqliteCommand(); + private AddressablesBuild m_AddressablesBuild = new AddressablesBuild(); + private AddressablesBuildExplicitAsset m_AddressablesExplicitAsset = new AddressablesBuildExplicitAsset(); private SqliteCommand m_LastId = new SqliteCommand(); private SqliteTransaction m_CurrentTransaction = null; public SQLiteWriter(string databaseName, bool skipReferences) @@ -154,40 +155,8 @@ private void CreateSQLiteCommands() m_InsertDepCommand.Parameters.Add("@object", SqliteType.Integer); m_InsertDepCommand.Parameters.Add("@dependency", SqliteType.Integer); - m_InsertBuild = m_Database.CreateCommand(); - m_InsertBuild.CommandText = "INSERT INTO build_layouts (name, build_target, start_time, duration, error, package_version, player_version, build_script, result_hash, type, unity_version) VALUES (@name, @build_target, @start_time, @duration, @error, @package_version, @player_version, @build_script, @result_hash, @type, @unity_version)"; - m_InsertBuild.Parameters.Add("@name", SqliteType.Text); - m_InsertBuild.Parameters.Add("@build_target", SqliteType.Integer); - m_InsertBuild.Parameters.Add("@start_time", SqliteType.Integer); - m_InsertBuild.Parameters.Add("@duration", SqliteType.Real); - m_InsertBuild.Parameters.Add("@error", SqliteType.Text); - m_InsertBuild.Parameters.Add("@package_version", SqliteType.Text); - m_InsertBuild.Parameters.Add("@player_version", SqliteType.Text); - m_InsertBuild.Parameters.Add("@build_script", SqliteType.Text); - m_InsertBuild.Parameters.Add("@result_hash", SqliteType.Text); - m_InsertBuild.Parameters.Add("@type", SqliteType.Integer); - m_InsertBuild.Parameters.Add("@unity_version", SqliteType.Text); - - m_ExplicitAsset = m_Database.CreateCommand(); - m_ExplicitAsset.CommandText = - "INSERT INTO build_layout_explicit_assets (id, build_id, bundle, file, asset_hash, asset_path, addressable_name, externally_referenced_assets, group_guid, guid, internal_id, internal_referenced_explicit_assets, internal_referenced_other_assets, labels, streamed_size, serialized_size, main_asset_type) VALUES (@id, @build_id, @bundle, @file, @asset_hash, @asset_path, @addressable_name, @externally_referenced_assets, @group_guid, @guid, @internal_id, @internal_referenced_explicit_assets, @internal_referenced_other_assets, @labels, @streamed_size, @serialized_size, @main_asset_type)"; - m_ExplicitAsset.Parameters.Add("@id", SqliteType.Integer); - m_ExplicitAsset.Parameters.Add("@build_id", SqliteType.Integer); - m_ExplicitAsset.Parameters.Add("@bundle", SqliteType.Integer); - m_ExplicitAsset.Parameters.Add("@file", SqliteType.Integer); - m_ExplicitAsset.Parameters.Add("@asset_hash", SqliteType.Text); - m_ExplicitAsset.Parameters.Add("@asset_path", SqliteType.Text); - m_ExplicitAsset.Parameters.Add("@addressable_name", SqliteType.Text); - m_ExplicitAsset.Parameters.Add("@externally_referenced_assets", SqliteType.Text); // JSONB type in SQLite uses TEXT - m_ExplicitAsset.Parameters.Add("@group_guid", SqliteType.Text); - m_ExplicitAsset.Parameters.Add("@guid", SqliteType.Text); - m_ExplicitAsset.Parameters.Add("@internal_id", SqliteType.Text); - m_ExplicitAsset.Parameters.Add("@internal_referenced_explicit_assets", SqliteType.Text); // JSONB type in SQLite uses TEXT - m_ExplicitAsset.Parameters.Add("@internal_referenced_other_assets", SqliteType.Text); // JSONB type in SQLite uses TEXT - m_ExplicitAsset.Parameters.Add("@labels", SqliteType.Text); // JSONB type in SQLite uses TEXT - m_ExplicitAsset.Parameters.Add("@streamed_size", SqliteType.Integer); - m_ExplicitAsset.Parameters.Add("@serialized_size", SqliteType.Integer); - m_ExplicitAsset.Parameters.Add("@main_asset_type", SqliteType.Integer); + m_AddressablesBuild.CreateCommand(m_Database); + m_AddressablesExplicitAsset.CreateCommand(m_Database); m_LastId = m_Database.CreateCommand(); m_LastId.CommandText = "SELECT last_insert_rowid()"; @@ -216,26 +185,26 @@ public void EndAssetBundle() m_CurrentAssetBundleId = -1; } - public void WriteBuildLayout(string filename, BuildLayout buildLayout) + public void WriteAddressablesBuild(string filename, BuildLayout buildLayout) { using var transaction = m_Database.BeginTransaction(); m_CurrentTransaction = transaction; try { - m_InsertBuild.Transaction = transaction; - m_InsertBuild.Parameters["@name"].Value = Path.GetFileName(filename); - m_InsertBuild.Parameters["@build_target"].Value = buildLayout.BuildTarget; - m_InsertBuild.Parameters["@start_time"].Value = buildLayout.BuildStartTime; - m_InsertBuild.Parameters["@duration"].Value = buildLayout.Duration; - m_InsertBuild.Parameters["@error"].Value = buildLayout.BuildError; - m_InsertBuild.Parameters["@package_version"].Value = buildLayout.PackageVersion; - m_InsertBuild.Parameters["@player_version"].Value = buildLayout.PlayerBuildVersion; - m_InsertBuild.Parameters["@build_script"].Value = buildLayout.BuildScript; - m_InsertBuild.Parameters["@result_hash"].Value = buildLayout.BuildResultHash; - m_InsertBuild.Parameters["@type"].Value = buildLayout.BuildType; - m_InsertBuild.Parameters["@unity_version"].Value = buildLayout.UnityVersion; - m_InsertBuild.ExecuteNonQuery(); + m_AddressablesBuild.SetTransaction(transaction); + m_AddressablesBuild.SetValue("name", Path.GetFileName(filename)); + m_AddressablesBuild.SetValue("build_target", buildLayout.BuildTarget); + m_AddressablesBuild.SetValue("start_time", buildLayout.BuildStartTime); + m_AddressablesBuild.SetValue("duration", buildLayout.Duration); + m_AddressablesBuild.SetValue("error", buildLayout.BuildError); + m_AddressablesBuild.SetValue("package_version", buildLayout.PackageVersion); + m_AddressablesBuild.SetValue("player_version", buildLayout.PlayerBuildVersion); + m_AddressablesBuild.SetValue("build_script", buildLayout.BuildScript); + m_AddressablesBuild.SetValue("result_hash", buildLayout.BuildResultHash); + m_AddressablesBuild.SetValue("type", buildLayout.BuildType); + m_AddressablesBuild.SetValue("unity_version", buildLayout.UnityVersion); + m_AddressablesBuild.ExecuteNonQuery(); m_LastId.Transaction = transaction; long buildId = (long) m_LastId.ExecuteScalar(); @@ -246,25 +215,27 @@ public void WriteBuildLayout(string filename, BuildLayout buildLayout) switch(reference.type.Class) { case "BuildLayout/ExplicitAsset": - m_ExplicitAsset.Transaction = transaction; - m_ExplicitAsset.Parameters["@id"].Value = reference.rid; - m_ExplicitAsset.Parameters["@build_id"].Value = buildId; - m_ExplicitAsset.Parameters["@bundle"].Value = reference.data.Bundle.rid; - m_ExplicitAsset.Parameters["@file"].Value = reference.data.File.rid; - m_ExplicitAsset.Parameters["@asset_hash"].Value = reference.data.AssetHash.Hash; - m_ExplicitAsset.Parameters["@asset_path"].Value = reference.data.AssetPath; - m_ExplicitAsset.Parameters["@addressable_name"].Value = reference.data.AddressableName; - m_ExplicitAsset.Parameters["@externally_referenced_assets"].Value = JsonConvert.SerializeObject(reference.data.ExternallyReferencedAssets) ?? "[]"; - m_ExplicitAsset.Parameters["@group_guid"].Value = reference.data.GroupGuid; - m_ExplicitAsset.Parameters["@guid"].Value = reference.data.Guid; - m_ExplicitAsset.Parameters["@internal_id"].Value = reference.data.InternalId; - m_ExplicitAsset.Parameters["@internal_referenced_explicit_assets"].Value = JsonConvert.SerializeObject(reference.data.InternalReferencedExplicitAssets) ?? "[]"; - m_ExplicitAsset.Parameters["@internal_referenced_other_assets"].Value = JsonConvert.SerializeObject(reference.data.InternalReferencedOtherAssets) ?? "[]"; - m_ExplicitAsset.Parameters["@labels"].Value = JsonConvert.SerializeObject(reference.data.Labels) ?? "[]"; - m_ExplicitAsset.Parameters["@main_asset_type"].Value = reference.data.MainAssetType; - m_ExplicitAsset.Parameters["@serialized_size"].Value = reference.data.SerializedSize; - m_ExplicitAsset.Parameters["@streamed_size"].Value = reference.data.StreamedSize; - m_ExplicitAsset.ExecuteNonQuery(); + m_AddressablesExplicitAsset.SetTransaction(transaction); + m_AddressablesExplicitAsset.SetValue("id", reference.rid); + m_AddressablesExplicitAsset.SetValue("build_id", buildId); + m_AddressablesExplicitAsset.SetValue("bundle", reference.data.Bundle.rid); + m_AddressablesExplicitAsset.SetValue("file", reference.data.File.rid); + m_AddressablesExplicitAsset.SetValue("asset_hash", reference.data.AssetHash.Hash); + m_AddressablesExplicitAsset.SetValue("asset_path", reference.data.AssetPath); + m_AddressablesExplicitAsset.SetValue("addressable_name", reference.data.AddressableName); + m_AddressablesExplicitAsset.SetValue("externally_referenced_assets", + JsonConvert.SerializeObject(reference.data.ExternallyReferencedAssets) ?? "[]"); + m_AddressablesExplicitAsset.SetValue("group_guid", reference.data.GroupGuid); + m_AddressablesExplicitAsset.SetValue("guid", reference.data.Guid); + m_AddressablesExplicitAsset.SetValue("internal_id", reference.data.InternalId); + m_AddressablesExplicitAsset.SetValue("internal_referenced_explicit_assets", + JsonConvert.SerializeObject(reference.data.InternalReferencedExplicitAssets) ?? "[]"); + m_AddressablesExplicitAsset.SetValue("internal_referenced_other_assets", + JsonConvert.SerializeObject(reference.data.InternalReferencedOtherAssets) ?? "[]"); + m_AddressablesExplicitAsset.SetValue("labels", + JsonConvert.SerializeObject(reference.data.Labels) ?? "[]"); + m_AddressablesExplicitAsset.SetValue("main_asset_type", reference.data.MainAssetType); + m_AddressablesExplicitAsset.ExecuteNonQuery(); break; } } From f11d2b626888a8f80ef7cdfef799217d29f0a83a Mon Sep 17 00:00:00 2001 From: Tim Thomas Date: Mon, 7 Jul 2025 13:21:15 -0500 Subject: [PATCH 3/4] initial import of several additional commands --- Analyzer/SQLite/Commands/AbstractCommand.cs | 5 +- .../Commands/AddressablesBuildBundle.cs | 66 +++++++++++ .../AddressablesBuildDataFromOtherAsset.cs | 46 ++++++++ .../SQLite/Commands/AddressablesBuildFile.cs | 50 ++++++++ .../SQLite/Commands/AddressablesBuildGroup.cs | 39 +++++++ .../Commands/AddressablesBuildSchema.cs | 35 ++++++ .../Commands/AddressablesBuildSubFile.cs | 34 ++++++ Analyzer/SQLite/SQLiteWriter.cs | 109 ++++++++++++++++++ 8 files changed, 382 insertions(+), 2 deletions(-) create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildBundle.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildFile.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildGroup.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildSchema.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildSubFile.cs diff --git a/Analyzer/SQLite/Commands/AbstractCommand.cs b/Analyzer/SQLite/Commands/AbstractCommand.cs index df06b2c..0d4b049 100644 --- a/Analyzer/SQLite/Commands/AbstractCommand.cs +++ b/Analyzer/SQLite/Commands/AbstractCommand.cs @@ -31,9 +31,10 @@ public void CreateCommand(SqliteConnection database) } public void SetValue(string key, object value) { - if (m_Command.Parameters.Contains(key)) + string prefixedKey = $"@{key}"; + if (m_Command.Parameters.Contains(prefixedKey)) { - m_Command.Parameters[key].Value = value ?? DBNull.Value; + m_Command.Parameters[prefixedKey].Value = value ?? DBNull.Value; } else { diff --git a/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs new file mode 100644 index 0000000..0b853bf --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs @@ -0,0 +1,66 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_bundles + ( + id INTEGER, + build_id INTEGER, + asset_count INTEGER, + build_status INTEGER, + bundle_dependencies TEXT, + crc INTEGER, + compression TEXT, + dependencies TEXT, + dependency_file_size INTEGER, + dependent_bundles TEXT, + expanded_dependencies TEXT, + expanded_dependency_file_size INTEGER, + file_size INTEGER, + files TEXT, + group_rid INTEGER, + hash TEXT, + internal_name TEXT, + load_path TEXT, + name TEXT, + provider TEXT, + result_type TEXT, + PRIMARY KEY (id, build_id) + ); + */ + internal class AddressablesBuildBundle : AbstractCommand + { + protected override string TableName => "addr_build_bundles"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "asset_count", SqliteType.Integer }, + { "build_status", SqliteType.Integer }, + { "bundle_dependencies", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "crc", SqliteType.Integer }, + { "compression", SqliteType.Text }, + { "dependencies", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "dependency_file_size", SqliteType.Integer }, + { "dependent_bundles", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "expanded_dependencies", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "expanded_dependency_file_size", SqliteType.Integer }, + { "file_size", SqliteType.Integer }, + { "files", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "group_rid", SqliteType.Integer }, + { "hash", SqliteType.Text }, // JSON object stored as TEXT + { "internal_name", SqliteType.Text }, + { "load_path", SqliteType.Text }, + { "name", SqliteType.Text }, + { "provider", SqliteType.Text }, + { "result_type", SqliteType.Text } + }; + + public AddressablesBuildBundle() + { + } + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs new file mode 100644 index 0000000..3d24fa1 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs @@ -0,0 +1,46 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_data_from_other_assets + ( + id INTEGER, + build_id INTEGER, + asset_guid TEXT, + asset_path TEXT, + file INTEGER, + main_asset_type INTEGER, + object_count INTEGER, + objects TEXT, + referencing_assets TEXT, + serialized_size INTEGER, + streamed_size INTEGER, + PRIMARY KEY (id, build_id) + ); + */ + internal class AddressablesBuildDataFromOtherAsset : AbstractCommand + { + protected override string TableName => "addr_build_data_from_other_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "asset_guid", SqliteType.Text }, + { "asset_path", SqliteType.Text }, + { "file", SqliteType.Integer }, + { "main_asset_type", SqliteType.Integer }, + { "object_count", SqliteType.Integer }, + { "objects", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "referencing_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "serialized_size", SqliteType.Integer }, + { "streamed_size", SqliteType.Integer } + }; + + public AddressablesBuildDataFromOtherAsset() + { + } + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuildFile.cs b/Analyzer/SQLite/Commands/AddressablesBuildFile.cs new file mode 100644 index 0000000..24f7606 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildFile.cs @@ -0,0 +1,50 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_files + ( + id INTEGER, + build_id INTEGER, + assets TEXT, + bundle INTEGER, + bundle_object_info_size INTEGER, + external_references TEXT, + mono_script_count INTEGER, + mono_script_size INTEGER, + name TEXT, + other_assets TEXT, + preload_info_size INTEGER, + sub_files TEXT, + write_result_filename TEXT, + PRIMARY KEY (id, build_id) + ); + */ + internal class AddressablesBuildFile : AbstractCommand + { + protected override string TableName => "addr_build_files"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "bundle", SqliteType.Integer }, + { "bundle_object_info_size", SqliteType.Integer }, + { "external_references", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "mono_script_count", SqliteType.Integer }, + { "mono_script_size", SqliteType.Integer }, + { "name", SqliteType.Text }, + { "other_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "preload_info_size", SqliteType.Integer }, + { "sub_files", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "write_result_filename", SqliteType.Text } + }; + + public AddressablesBuildFile() + { + } + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs b/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs new file mode 100644 index 0000000..74c1465 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs @@ -0,0 +1,39 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_groups + ( + id INTEGER, + build_id INTEGER, + bundles TEXT, + guid TEXT, + name TEXT, + packing_mode TEXT, + schemas TEXT, + PRIMARY KEY (id, build_id) + ); + */ + internal class AddressablesBuildGroup : AbstractCommand + { + protected override string TableName => "addr_build_groups"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "bundles", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "guid", SqliteType.Text }, + { "name", SqliteType.Text }, + { "packing_mode", SqliteType.Text }, + { "schemas", SqliteType.Text } // JSONB type in SQLite uses TEXT + }; + + public AddressablesBuildGroup() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs b/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs new file mode 100644 index 0000000..0f0667f --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs @@ -0,0 +1,35 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_schemas + ( + id INTEGER, + build_id INTEGER, + guid TEXT, + schema_data_pairs TEXT, + type TEXT, + PRIMARY KEY (id, build_id) + ); + */ + internal class AddressablesBuildSchema : AbstractCommand + { + protected override string TableName => "addr_build_schemas"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "guid", SqliteType.Text }, + { "schema_data_pairs", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "type", SqliteType.Text } + }; + + public AddressablesBuildSchema() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildSubFile.cs b/Analyzer/SQLite/Commands/AddressablesBuildSubFile.cs new file mode 100644 index 0000000..96df36a --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildSubFile.cs @@ -0,0 +1,34 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_sub_files + ( + id INTEGER, + build_id INTEGER, + is_serialized_file INTEGER, + name TEXT, + size INTEGER, + PRIMARY KEY (id, build_id) + ); + */ + internal class AddressablesBuildSubFile : AbstractCommand + { + protected override string TableName => "addr_build_sub_files"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "is_serialized_file", SqliteType.Integer }, + { "name", SqliteType.Text }, + { "size", SqliteType.Integer } + }; + + public AddressablesBuildSubFile() + { + } + } +} diff --git a/Analyzer/SQLite/SQLiteWriter.cs b/Analyzer/SQLite/SQLiteWriter.cs index 330cdbd..abf4a88 100644 --- a/Analyzer/SQLite/SQLiteWriter.cs +++ b/Analyzer/SQLite/SQLiteWriter.cs @@ -51,7 +51,13 @@ public class SQLiteWriter : IWriter private SqliteCommand m_AddTypeCommand = new SqliteCommand(); private SqliteCommand m_InsertDepCommand = new SqliteCommand(); private AddressablesBuild m_AddressablesBuild = new AddressablesBuild(); + private AddressablesBuildBundle m_AddressablesBuildBundle = new AddressablesBuildBundle(); + private AddressablesBuildDataFromOtherAsset m_AddressablesDataFromOtherAsset = new AddressablesBuildDataFromOtherAsset(); private AddressablesBuildExplicitAsset m_AddressablesExplicitAsset = new AddressablesBuildExplicitAsset(); + private AddressablesBuildFile m_AddressablesBuildFile = new AddressablesBuildFile(); + private AddressablesBuildGroup m_AddressablesBuildGroup = new AddressablesBuildGroup(); + private AddressablesBuildSchema m_AddressablesBuildSchema = new AddressablesBuildSchema(); + private AddressablesBuildSubFile m_AddressablesBuildSubFile = new AddressablesBuildSubFile(); private SqliteCommand m_LastId = new SqliteCommand(); private SqliteTransaction m_CurrentTransaction = null; public SQLiteWriter(string databaseName, bool skipReferences) @@ -156,7 +162,13 @@ private void CreateSQLiteCommands() m_InsertDepCommand.Parameters.Add("@dependency", SqliteType.Integer); m_AddressablesBuild.CreateCommand(m_Database); + m_AddressablesBuildBundle.CreateCommand(m_Database); + m_AddressablesDataFromOtherAsset.CreateCommand(m_Database); m_AddressablesExplicitAsset.CreateCommand(m_Database); + m_AddressablesBuildFile.CreateCommand(m_Database); + m_AddressablesBuildGroup.CreateCommand(m_Database); + m_AddressablesBuildSchema.CreateCommand(m_Database); + m_AddressablesBuildSubFile.CreateCommand(m_Database); m_LastId = m_Database.CreateCommand(); m_LastId.CommandText = "SELECT last_insert_rowid()"; @@ -214,6 +226,48 @@ public void WriteAddressablesBuild(string filename, BuildLayout buildLayout) { switch(reference.type.Class) { + case "BuildLayout/Bundle": + m_AddressablesBuildBundle.SetTransaction(transaction); + m_AddressablesBuildBundle.SetValue("id", reference.rid); + m_AddressablesBuildBundle.SetValue("build_id", buildId); + m_AddressablesBuildBundle.SetValue("asset_count", reference.data.AssetCount); + m_AddressablesBuildBundle.SetValue("build_status", reference.data.BuildStatus); + m_AddressablesBuildBundle.SetValue("bundle_dependencies", JsonConvert.SerializeObject(reference.data.BundleDependencies) ?? "[]"); + m_AddressablesBuildBundle.SetValue("crc", reference.data.CRC); + m_AddressablesBuildBundle.SetValue("compression", reference.data.Compression); + m_AddressablesBuildBundle.SetValue("dependencies", JsonConvert.SerializeObject(reference.data.Dependencies) ?? "[]"); + m_AddressablesBuildBundle.SetValue("dependency_file_size", reference.data.DependencyFileSize); + m_AddressablesBuildBundle.SetValue("dependent_bundles", JsonConvert.SerializeObject(reference.data.DependentBundles) ?? "[]"); + m_AddressablesBuildBundle.SetValue("expanded_dependencies", JsonConvert.SerializeObject(reference.data.ExpandedDependencies) ?? "[]"); + m_AddressablesBuildBundle.SetValue("expanded_dependency_file_size", reference.data.ExpandedDependencyFileSize); + m_AddressablesBuildBundle.SetValue("file_size", reference.data.FileSize); + m_AddressablesBuildBundle.SetValue("files", JsonConvert.SerializeObject(reference.data.Files) ?? "[]"); + m_AddressablesBuildBundle.SetValue("group_rid", reference.data.Group.rid); + m_AddressablesBuildBundle.SetValue("hash", JsonConvert.SerializeObject(reference.data.Hash)); + m_AddressablesBuildBundle.SetValue("internal_name", reference.data.InternalName); + m_AddressablesBuildBundle.SetValue("load_path", reference.data.LoadPath); + m_AddressablesBuildBundle.SetValue("name", reference.data.Name); + m_AddressablesBuildBundle.SetValue("provider", reference.data.Provider); + m_AddressablesBuildBundle.SetValue("result_type", reference.data.ResultType); + m_AddressablesBuildBundle.ExecuteNonQuery(); + break; + + case "BuildLayout/DataFromOtherAsset": + m_AddressablesDataFromOtherAsset.SetTransaction(transaction); + m_AddressablesDataFromOtherAsset.SetValue("id", reference.rid); + m_AddressablesDataFromOtherAsset.SetValue("build_id", buildId); + m_AddressablesDataFromOtherAsset.SetValue("asset_guid", reference.data.AssetGuid); + m_AddressablesDataFromOtherAsset.SetValue("asset_path", reference.data.AssetPath); + m_AddressablesDataFromOtherAsset.SetValue("file", reference.data.File.rid); + m_AddressablesDataFromOtherAsset.SetValue("main_asset_type", reference.data.MainAssetType); + m_AddressablesDataFromOtherAsset.SetValue("object_count", reference.data.ObjectCount); + m_AddressablesDataFromOtherAsset.SetValue("objects", JsonConvert.SerializeObject(reference.data.Objects) ?? "[]"); + m_AddressablesDataFromOtherAsset.SetValue("referencing_assets", JsonConvert.SerializeObject(reference.data.ReferencingAssets) ?? "[]"); + m_AddressablesDataFromOtherAsset.SetValue("serialized_size", reference.data.SerializedSize); + m_AddressablesDataFromOtherAsset.SetValue("streamed_size", reference.data.StreamedSize); + m_AddressablesDataFromOtherAsset.ExecuteNonQuery(); + break; + case "BuildLayout/ExplicitAsset": m_AddressablesExplicitAsset.SetTransaction(transaction); m_AddressablesExplicitAsset.SetValue("id", reference.rid); @@ -234,9 +288,63 @@ public void WriteAddressablesBuild(string filename, BuildLayout buildLayout) JsonConvert.SerializeObject(reference.data.InternalReferencedOtherAssets) ?? "[]"); m_AddressablesExplicitAsset.SetValue("labels", JsonConvert.SerializeObject(reference.data.Labels) ?? "[]"); + m_AddressablesExplicitAsset.SetValue("streamed_size", reference.data.StreamedSize); + m_AddressablesExplicitAsset.SetValue("serialized_size", reference.data.SerializedSize); m_AddressablesExplicitAsset.SetValue("main_asset_type", reference.data.MainAssetType); m_AddressablesExplicitAsset.ExecuteNonQuery(); break; + case "BuildLayout/File": + m_AddressablesBuildFile.SetTransaction(transaction); + m_AddressablesBuildFile.SetValue("id", reference.rid); + m_AddressablesBuildFile.SetValue("build_id", buildId); + m_AddressablesBuildFile.SetValue("assets", JsonConvert.SerializeObject(reference.data.Assets) ?? "[]"); + m_AddressablesBuildFile.SetValue("bundle", reference.data.Bundle.rid); + m_AddressablesBuildFile.SetValue("bundle_object_info_size", reference.data.BundleObjectInfo.Size); + m_AddressablesBuildFile.SetValue("external_references", JsonConvert.SerializeObject(reference.data.ExternalReferences) ?? "[]"); + m_AddressablesBuildFile.SetValue("mono_script_count", reference.data.MonoScriptCount); + m_AddressablesBuildFile.SetValue("mono_script_size", reference.data.MonoScriptSize); + m_AddressablesBuildFile.SetValue("name", reference.data.Name); + m_AddressablesBuildFile.SetValue("other_assets", JsonConvert.SerializeObject(reference.data.OtherAssets) ?? "[]"); + m_AddressablesBuildFile.SetValue("preload_info_size", reference.data.PreloadInfoSize); + m_AddressablesBuildFile.SetValue("sub_files", JsonConvert.SerializeObject(reference.data.SubFiles) ?? "[]"); + m_AddressablesBuildFile.SetValue("write_result_filename", reference.data.WriteResultFilename); + m_AddressablesBuildFile.ExecuteNonQuery(); + break; + + case "BuildLayout/Group": + m_AddressablesBuildGroup.SetTransaction(transaction); + m_AddressablesBuildGroup.SetValue("id", reference.rid); + m_AddressablesBuildGroup.SetValue("build_id", buildId); + m_AddressablesBuildGroup.SetValue("bundles", JsonConvert.SerializeObject(reference.data.Bundles) ?? "[]"); + m_AddressablesBuildGroup.SetValue("guid", reference.data.Guid); + m_AddressablesBuildGroup.SetValue("name", reference.data.Name); + m_AddressablesBuildGroup.SetValue("packing_mode", reference.data.PackingMode); + m_AddressablesBuildGroup.SetValue("schemas", JsonConvert.SerializeObject(reference.data.Schemas) ?? "[]"); + m_AddressablesBuildGroup.ExecuteNonQuery(); + break; + + case "BuildLayout/SchemaData": + m_AddressablesBuildSchema.SetTransaction(transaction); + m_AddressablesBuildSchema.SetValue("id", reference.rid); + m_AddressablesBuildSchema.SetValue("build_id", buildId); + m_AddressablesBuildSchema.SetValue("guid", reference.data.Guid); + m_AddressablesBuildSchema.SetValue("schema_data_pairs", JsonConvert.SerializeObject(reference.data.SchemaDataPairs) ?? "[]"); + m_AddressablesBuildSchema.SetValue("type", reference.data.Type); + m_AddressablesBuildSchema.ExecuteNonQuery(); + break; + + case "BuildLayout/SubFile": + m_AddressablesBuildSubFile.SetTransaction(transaction); + m_AddressablesBuildSubFile.SetValue("id", reference.rid); + m_AddressablesBuildSubFile.SetValue("build_id", buildId); + m_AddressablesBuildSubFile.SetValue("is_serialized_file", reference.data.IsSerializedFile ? 1 : 0); + m_AddressablesBuildSubFile.SetValue("name", reference.data.Name); + m_AddressablesBuildSubFile.SetValue("size", reference.data.Size); + m_AddressablesBuildSubFile.ExecuteNonQuery(); + break; + + + } } @@ -245,6 +353,7 @@ public void WriteAddressablesBuild(string filename, BuildLayout buildLayout) } catch (Exception e) { + Console.WriteLine(e.StackTrace.ToString()); transaction.Rollback(); throw; } From 1bfdd3e400c5ec1abba6722ac1c753311db3bf79 Mon Sep 17 00:00:00 2001 From: Tim Thomas Date: Tue, 8 Jul 2025 13:12:01 -0500 Subject: [PATCH 4/4] add all addressable tables --- Analyzer/Resources/Init.sql | 238 +++++++- .../Commands/AddressablesBuildBundle.cs | 10 - .../AddressablesBuildBundleDependency.cs | 31 + .../AddressablesBuildBundleDependentBundle.cs | 32 + ...dressablesBuildBundleExpandedDependency.cs | 31 + .../Commands/AddressablesBuildBundleFile.cs | 32 + ...ddressablesBuildBundleRegularDependency.cs | 32 + .../AddressablesBuildDataFromOtherAsset.cs | 4 - ...dressablesBuildDataFromOtherAssetObject.cs | 42 ++ ...sBuildDataFromOtherAssetObjectReference.cs | 35 ++ ...BuildDataFromOtherAssetReferencingAsset.cs | 32 + .../AddressablesBuildExplicitAsset.cs | 31 +- ...dExplicitAssetExternallyReferencedAsset.cs | 32 + ...citAssetInternalReferencedExplicitAsset.cs | 32 + ...plicitAssetInternalReferencedOtherAsset.cs | 32 + .../AddressablesBuildExplicitAssetLabel.cs | 32 + .../SQLite/Commands/AddressablesBuildFile.cs | 8 - .../Commands/AddressablesBuildFileAsset.cs | 33 ++ .../AddressablesBuildFileExternalReference.cs | 33 ++ .../AddressablesBuildFileOtherAsset.cs | 33 ++ .../Commands/AddressablesBuildFileSubFile.cs | 33 ++ .../SQLite/Commands/AddressablesBuildGroup.cs | 4 - .../Commands/AddressablesBuildGroupBundle.cs | 34 ++ .../Commands/AddressablesBuildGroupSchema.cs | 34 ++ .../Commands/AddressablesBuildSchema.cs | 2 - .../AddressablesBuildSchemaDataPair.cs | 37 ++ Analyzer/SQLite/SQLiteWriter.cs | 556 ++++++++++++++---- 27 files changed, 1326 insertions(+), 159 deletions(-) create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildBundleDependency.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildBundleDependentBundle.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildBundleExpandedDependency.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildBundleFile.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildBundleRegularDependency.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObject.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObjectReference.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetReferencingAsset.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetExternallyReferencedAsset.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedOtherAsset.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetLabel.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildFileAsset.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildFileExternalReference.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildFileOtherAsset.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildFileSubFile.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildGroupBundle.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildGroupSchema.cs create mode 100644 Analyzer/SQLite/Commands/AddressablesBuildSchemaDataPair.cs diff --git a/Analyzer/Resources/Init.sql b/Analyzer/Resources/Init.sql index da0dc9c..37e195a 100644 --- a/Analyzer/Resources/Init.sql +++ b/Analyzer/Resources/Init.sql @@ -120,6 +120,111 @@ CREATE TABLE addr_builds PRIMARY KEY (id) ); +create table addr_build_bundles +( + id INTEGER, + build_id INTEGER, + asset_count INTEGER, + build_status INTEGER, + crc INTEGER, + compression TEXT, + dependency_file_size INTEGER, + expanded_dependency_file_size INTEGER, + file_size INTEGER, + group_rid INTEGER, + hash TEXT, + internal_name TEXT, + load_path TEXT, + name TEXT, + provider TEXT, + result_type TEXT, + PRIMARY KEY (id, build_id) +); +create table addr_build_bundle_dependent_bundles +( + bundle_id INTEGER, + build_id INTEGER, + dependent_bundle_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependent_bundle_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) +); +create table addr_build_bundle_dependencies +( + bundle_id INTEGER, + build_id INTEGER, + dependency_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependency_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) +); +create table addr_build_bundle_expanded_dependencies +( + bundle_id INTEGER, + build_id INTEGER, + dependency_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependency_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) +); + +create table addr_build_bundle_files +( + bundle_id INTEGER, + build_id INTEGER, + file_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, file_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) +); + create table addr_build_bundle_regular_dependencies +( + bundle_id INTEGER, + build_id INTEGER, + dependency_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependency_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) +); + create table addr_build_data_from_other_assets +( + id INTEGER, + build_id INTEGER, + asset_guid TEXT, + asset_path TEXT, + file INTEGER, + main_asset_type INTEGER, + object_count INTEGER, + serialized_size INTEGER, + streamed_size INTEGER, + PRIMARY KEY (id, build_id) +); +create table addr_build_data_from_other_asset_objects +( + data_from_other_asset_id INTEGER, + build_id INTEGER, + asset_type INTEGER, + component_name TEXT, + local_identifier_in_file INTEGER, + object_name TEXT, + serialized_size INTEGER, + streamed_size INTEGER, + PRIMARY KEY (data_from_other_asset_id, build_id, local_identifier_in_file), + FOREIGN KEY (data_from_other_asset_id, build_id) REFERENCES addr_build_data_from_other_assets(id, build_id) +); +create table addr_build_data_from_other_asset_object_references +( + data_from_other_asset_id INTEGER, + build_id INTEGER, + local_identifier_in_file INTEGER, + asset_id INTEGER, + object_id INTEGER, + PRIMARY KEY (data_from_other_asset_id, build_id, local_identifier_in_file, asset_id, object_id), + FOREIGN KEY (data_from_other_asset_id, build_id, local_identifier_in_file) REFERENCES addr_build_data_from_other_asset_objects(data_from_other_asset_id, build_id, local_identifier_in_file) +); +create table addr_build_data_from_other_asset_referencing_assets +( + data_from_other_asset_id INTEGER, + build_id INTEGER, + referencing_asset_rid INTEGER, + PRIMARY KEY (data_from_other_asset_id, build_id, referencing_asset_rid), + FOREIGN KEY (data_from_other_asset_id, build_id) REFERENCES addr_build_data_from_other_assets(id, build_id) +); create table addr_build_explicit_assets ( id INTEGER, @@ -129,18 +234,141 @@ create table addr_build_explicit_assets asset_hash TEXT, asset_path TEXT, addressable_name TEXT, - externally_referenced_assets TEXT, group_guid TEXT, guid TEXT, internal_id TEXT, - internal_referenced_explicit_assets TEXT, - internal_referenced_other_assets TEXT, - labels TEXT, main_asset_type INTEGER, serialized_size INTEGER, streamed_size INTEGER, PRIMARY KEY (id, build_id) ); - +create table addr_build_explicit_asset_externally_referenced_assets +( + explicit_asset_id INTEGER, + build_id INTEGER, + externally_referenced_asset_rid INTEGER, + PRIMARY KEY (explicit_asset_id, build_id, externally_referenced_asset_rid), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) +); +create table addr_build_explicit_asset_internal_referenced_explicit_assets +( + explicit_asset_id INTEGER, + build_id INTEGER, + internal_referenced_explicit_asset_rid INTEGER, + PRIMARY KEY (explicit_asset_id, build_id, internal_referenced_explicit_asset_rid), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) +); +create table addr_build_explicit_asset_internal_referenced_other_assets +( + explicit_asset_id INTEGER, + build_id INTEGER, + internal_referenced_other_asset_rid INTEGER, + PRIMARY KEY (explicit_asset_id, build_id, internal_referenced_other_asset_rid), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) +); +create table addr_build_explicit_asset_labels +( + explicit_asset_id INTEGER, + build_id INTEGER, + label TEXT, + PRIMARY KEY (explicit_asset_id, build_id, label), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) +); +create table addr_build_files +( + id INTEGER, + build_id INTEGER, + bundle INTEGER, + bundle_object_info_size INTEGER, + mono_script_count INTEGER, + mono_script_size INTEGER, + name TEXT, + preload_info_size INTEGER, + write_result_filename TEXT, + PRIMARY KEY (id, build_id) +); +create table addr_build_file_assets +( + file_id INTEGER, + build_id INTEGER, + asset_rid INTEGER, + PRIMARY KEY (file_id, build_id, asset_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) +); +create table addr_build_file_other_assets +( + file_id INTEGER, + build_id INTEGER, + other_asset_rid INTEGER, + PRIMARY KEY (file_id, build_id, other_asset_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) +); +create table addr_build_file_sub_files +( + file_id INTEGER, + build_id INTEGER, + sub_file_rid INTEGER, + PRIMARY KEY (file_id, build_id, sub_file_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) +); +create table addr_build_file_external_references +( + file_id INTEGER, + build_id INTEGER, + external_reference_rid INTEGER, + PRIMARY KEY (file_id, build_id, external_reference_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) +); +create table addr_build_groups +( + id INTEGER, + build_id INTEGER, + guid TEXT, + name TEXT, + packing_mode TEXT, + PRIMARY KEY (id, build_id) +); +create table addr_build_group_bundles +( + group_id INTEGER, + build_id INTEGER, + bundle_rid INTEGER, + PRIMARY KEY (group_id, build_id, bundle_rid), + FOREIGN KEY (group_id, build_id) REFERENCES addr_build_groups(id, build_id) +); +create table addr_build_group_schemas +( + group_id INTEGER, + build_id INTEGER, + schema_rid INTEGER, + PRIMARY KEY (group_id, build_id, schema_rid), + FOREIGN KEY (group_id, build_id) REFERENCES addr_build_groups(id, build_id) +); +create table addr_build_schemas +( + id INTEGER, + build_id INTEGER, + guid TEXT, + type TEXT, + PRIMARY KEY (id, build_id) +); +create table addr_build_schema_data_pairs +( + schema_id INTEGER, + build_id INTEGER, + key TEXT, + value TEXT, + PRIMARY KEY (schema_id, build_id, key), + FOREIGN KEY (schema_id, build_id) REFERENCES addr_build_schemas(id, build_id) +); +create table addr_build_sub_files +( + id INTEGER, + build_id INTEGER, + is_serialized_file INTEGER, + name TEXT, + size INTEGER, + PRIMARY KEY (id, build_id) +); PRAGMA synchronous = OFF; PRAGMA journal_mode = MEMORY; diff --git a/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs index 0b853bf..a852244 100644 --- a/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs @@ -10,16 +10,11 @@ create table addr_build_bundles build_id INTEGER, asset_count INTEGER, build_status INTEGER, - bundle_dependencies TEXT, crc INTEGER, compression TEXT, - dependencies TEXT, dependency_file_size INTEGER, - dependent_bundles TEXT, - expanded_dependencies TEXT, expanded_dependency_file_size INTEGER, file_size INTEGER, - files TEXT, group_rid INTEGER, hash TEXT, internal_name TEXT, @@ -40,16 +35,11 @@ internal class AddressablesBuildBundle : AbstractCommand { "build_id", SqliteType.Integer }, { "asset_count", SqliteType.Integer }, { "build_status", SqliteType.Integer }, - { "bundle_dependencies", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "crc", SqliteType.Integer }, { "compression", SqliteType.Text }, - { "dependencies", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "dependency_file_size", SqliteType.Integer }, - { "dependent_bundles", SqliteType.Text }, // JSONB type in SQLite uses TEXT - { "expanded_dependencies", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "expanded_dependency_file_size", SqliteType.Integer }, { "file_size", SqliteType.Integer }, - { "files", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "group_rid", SqliteType.Integer }, { "hash", SqliteType.Text }, // JSON object stored as TEXT { "internal_name", SqliteType.Text }, diff --git a/Analyzer/SQLite/Commands/AddressablesBuildBundleDependency.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundleDependency.cs new file mode 100644 index 0000000..e62b148 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundleDependency.cs @@ -0,0 +1,31 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_bundle_dependencies + ( + bundle_id INTEGER, + build_id INTEGER, + dependency_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependency_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) + ); + */ + internal class AddressablesBuildBundleDependency : AbstractCommand + { + protected override string TableName => "addr_build_bundle_dependencies"; + + protected override Dictionary Fields => new Dictionary + { + { "bundle_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "dependency_rid", SqliteType.Integer } + }; + + public AddressablesBuildBundleDependency() + { + } + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuildBundleDependentBundle.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundleDependentBundle.cs new file mode 100644 index 0000000..658369c --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundleDependentBundle.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_bundle_dependent_bundles + ( + bundle_id INTEGER, + build_id INTEGER, + dependent_bundle_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependent_bundle_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) + ); + */ + internal class AddressablesBuildBundleDependentBundle : AbstractCommand + { + protected override string TableName => "addr_build_bundle_dependent_bundles"; + + protected override Dictionary Fields => new Dictionary + { + { "bundle_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "dependent_bundle_rid", SqliteType.Integer } + }; + + public AddressablesBuildBundleDependentBundle() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildBundleExpandedDependency.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundleExpandedDependency.cs new file mode 100644 index 0000000..64d64c8 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundleExpandedDependency.cs @@ -0,0 +1,31 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_bundle_expanded_dependencies + ( + bundle_id INTEGER, + build_id INTEGER, + dependency_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependency_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) + ); + */ + internal class AddressablesBuildBundleExpandedDependency : AbstractCommand + { + protected override string TableName => "addr_build_bundle_expanded_dependencies"; + + protected override Dictionary Fields => new Dictionary + { + { "bundle_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "dependency_rid", SqliteType.Integer } + }; + + public AddressablesBuildBundleExpandedDependency() + { + } + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuildBundleFile.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundleFile.cs new file mode 100644 index 0000000..a88846b --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundleFile.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_bundle_files + ( + bundle_id INTEGER, + build_id INTEGER, + file_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, file_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) + ); + */ + internal class AddressablesBuildBundleFile : AbstractCommand + { + protected override string TableName => "addr_build_bundle_files"; + + protected override Dictionary Fields => new Dictionary + { + { "bundle_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "file_rid", SqliteType.Integer } + }; + + public AddressablesBuildBundleFile() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildBundleRegularDependency.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundleRegularDependency.cs new file mode 100644 index 0000000..b57673e --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundleRegularDependency.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_bundle_regular_dependencies + ( + bundle_id INTEGER, + build_id INTEGER, + dependency_rid INTEGER, + PRIMARY KEY (bundle_id, build_id, dependency_rid), + FOREIGN KEY (bundle_id, build_id) REFERENCES addr_build_bundles(id, build_id) + ); + */ + internal class AddressablesBuildBundleRegularDependency : AbstractCommand + { + protected override string TableName => "addr_build_bundle_regular_dependencies"; + + protected override Dictionary Fields => new Dictionary + { + { "bundle_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "dependency_rid", SqliteType.Integer } + }; + + public AddressablesBuildBundleRegularDependency() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs index 3d24fa1..22d36f4 100644 --- a/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs +++ b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.cs @@ -13,8 +13,6 @@ create table addr_build_data_from_other_assets file INTEGER, main_asset_type INTEGER, object_count INTEGER, - objects TEXT, - referencing_assets TEXT, serialized_size INTEGER, streamed_size INTEGER, PRIMARY KEY (id, build_id) @@ -33,8 +31,6 @@ internal class AddressablesBuildDataFromOtherAsset : AbstractCommand { "file", SqliteType.Integer }, { "main_asset_type", SqliteType.Integer }, { "object_count", SqliteType.Integer }, - { "objects", SqliteType.Text }, // JSONB type in SQLite uses TEXT - { "referencing_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "serialized_size", SqliteType.Integer }, { "streamed_size", SqliteType.Integer } }; diff --git a/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObject.cs b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObject.cs new file mode 100644 index 0000000..6589f51 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObject.cs @@ -0,0 +1,42 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_data_from_other_asset_objects + ( + data_from_other_asset_id INTEGER, + build_id INTEGER, + asset_type INTEGER, + component_name TEXT, + local_identifier_in_file INTEGER, + object_name TEXT, + serialized_size INTEGER, + streamed_size INTEGER, + PRIMARY KEY (data_from_other_asset_id, build_id, local_identifier_in_file), + FOREIGN KEY (data_from_other_asset_id, build_id) REFERENCES addr_build_data_from_other_assets(id, build_id) + ); + */ + internal class AddressablesBuildDataFromOtherAssetObject : AbstractCommand + { + protected override string TableName => "addr_build_data_from_other_asset_objects"; + + protected override Dictionary Fields => new Dictionary + { + { "data_from_other_asset_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "asset_type", SqliteType.Integer }, + { "component_name", SqliteType.Text }, + { "local_identifier_in_file", SqliteType.Integer }, + { "object_name", SqliteType.Text }, + { "serialized_size", SqliteType.Integer }, + { "streamed_size", SqliteType.Integer } + }; + + public AddressablesBuildDataFromOtherAssetObject() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObjectReference.cs b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObjectReference.cs new file mode 100644 index 0000000..0bf0829 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetObjectReference.cs @@ -0,0 +1,35 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_data_from_other_asset_object_references + ( + data_from_other_asset_id INTEGER, + build_id INTEGER, + local_identifier_in_file INTEGER, + asset_id INTEGER, + object_id INTEGER, + PRIMARY KEY (data_from_other_asset_id, build_id, local_identifier_in_file, asset_id, object_id), + FOREIGN KEY (data_from_other_asset_id, build_id, local_identifier_in_file) REFERENCES addr_build_data_from_other_asset_objects(data_from_other_asset_id, build_id, local_identifier_in_file) + ); + */ + internal class AddressablesBuildDataFromOtherAssetObjectReference : AbstractCommand + { + protected override string TableName => "addr_build_data_from_other_asset_object_references"; + + protected override Dictionary Fields => new Dictionary + { + { "data_from_other_asset_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "local_identifier_in_file", SqliteType.Integer }, + { "asset_id", SqliteType.Integer }, + { "object_id", SqliteType.Integer } + }; + + public AddressablesBuildDataFromOtherAssetObjectReference() + { + } + } +} diff --git a/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetReferencingAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetReferencingAsset.cs new file mode 100644 index 0000000..2247250 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAssetReferencingAsset.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_data_from_other_asset_referencing_assets + ( + data_from_other_asset_id INTEGER, + build_id INTEGER, + referencing_asset_rid INTEGER, + PRIMARY KEY (data_from_other_asset_id, build_id, referencing_asset_rid), + FOREIGN KEY (data_from_other_asset_id, build_id) REFERENCES addr_build_data_from_other_assets(id, build_id) + ); + */ + internal class AddressablesBuildDataFromOtherAssetReferencingAsset : AbstractCommand + { + protected override string TableName => "addr_build_data_from_other_asset_referencing_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "data_from_other_asset_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "referencing_asset_rid", SqliteType.Integer } + }; + + public AddressablesBuildDataFromOtherAssetReferencingAsset() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs index 138807d..e653304 100644 --- a/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs +++ b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs @@ -1,12 +1,27 @@ using Microsoft.Data.Sqlite; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Analyzer.SQLite.Commands { + /* TABLE DEFINITION: + create table addr_build_explicit_assets + ( + id INTEGER, + build_id INTEGER, + bundle INTEGER, + file INTEGER, + asset_hash TEXT, + asset_path TEXT, + addressable_name TEXT, + group_guid TEXT, + guid TEXT, + internal_id TEXT, + main_asset_type INTEGER, + serialized_size INTEGER, + streamed_size INTEGER, + PRIMARY KEY (id, build_id) + ); + */ internal class AddressablesBuildExplicitAsset : AbstractCommand { protected override string TableName => "addr_build_explicit_assets"; @@ -20,16 +35,12 @@ internal class AddressablesBuildExplicitAsset : AbstractCommand { "asset_hash", SqliteType.Text }, { "asset_path", SqliteType.Text }, { "addressable_name", SqliteType.Text }, - { "externally_referenced_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "group_guid", SqliteType.Text }, { "guid", SqliteType.Text }, { "internal_id", SqliteType.Text }, - { "internal_referenced_explicit_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT - { "internal_referenced_other_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT - { "labels", SqliteType.Text }, // JSONB type in SQLite uses TEXT + { "main_asset_type", SqliteType.Integer }, { "streamed_size", SqliteType.Integer }, - { "serialized_size", SqliteType.Integer }, - { "main_asset_type", SqliteType.Integer } + { "serialized_size", SqliteType.Integer } }; public AddressablesBuildExplicitAsset() { diff --git a/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetExternallyReferencedAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetExternallyReferencedAsset.cs new file mode 100644 index 0000000..79ae7d0 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetExternallyReferencedAsset.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_explicit_asset_externally_referenced_assets + ( + explicit_asset_id INTEGER, + build_id INTEGER, + externally_referenced_asset_rid INTEGER, + PRIMARY KEY (explicit_asset_id, build_id, externally_referenced_asset_rid), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) + ); + */ + internal class AddressablesBuildExplicitAssetExternallyReferencedAsset : AbstractCommand + { + protected override string TableName => "addr_build_explicit_asset_externally_referenced_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "explicit_asset_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "externally_referenced_asset_rid", SqliteType.Integer } + }; + + public AddressablesBuildExplicitAssetExternallyReferencedAsset() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.cs new file mode 100644 index 0000000..07b3c20 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_explicit_asset_internal_referenced_explicit_assets + ( + explicit_asset_id INTEGER, + build_id INTEGER, + internal_referenced_explicit_asset_rid INTEGER, + PRIMARY KEY (explicit_asset_id, build_id, internal_referenced_explicit_asset_rid), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) + ); + */ + internal class AddressablesBuildExplicitAssetInternalReferencedExplicitAsset : AbstractCommand + { + protected override string TableName => "addr_build_explicit_asset_internal_referenced_explicit_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "explicit_asset_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "internal_referenced_explicit_asset_rid", SqliteType.Integer } + }; + + public AddressablesBuildExplicitAssetInternalReferencedExplicitAsset() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedOtherAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedOtherAsset.cs new file mode 100644 index 0000000..84e34f6 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetInternalReferencedOtherAsset.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_explicit_asset_internal_referenced_other_assets + ( + explicit_asset_id INTEGER, + build_id INTEGER, + internal_referenced_other_asset_rid INTEGER, + PRIMARY KEY (explicit_asset_id, build_id, internal_referenced_other_asset_rid), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) + ); + */ + internal class AddressablesBuildExplicitAssetInternalReferencedOtherAsset : AbstractCommand + { + protected override string TableName => "addr_build_explicit_asset_internal_referenced_other_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "explicit_asset_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "internal_referenced_other_asset_rid", SqliteType.Integer } + }; + + public AddressablesBuildExplicitAssetInternalReferencedOtherAsset() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetLabel.cs b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetLabel.cs new file mode 100644 index 0000000..c9699f8 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAssetLabel.cs @@ -0,0 +1,32 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_explicit_asset_labels + ( + explicit_asset_id INTEGER, + build_id INTEGER, + label TEXT, + PRIMARY KEY (explicit_asset_id, build_id, label), + FOREIGN KEY (explicit_asset_id, build_id) REFERENCES addr_build_explicit_assets(id, build_id) + ); + */ + internal class AddressablesBuildExplicitAssetLabel : AbstractCommand + { + protected override string TableName => "addr_build_explicit_asset_labels"; + + protected override Dictionary Fields => new Dictionary + { + { "explicit_asset_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "label", SqliteType.Text } + }; + + public AddressablesBuildExplicitAssetLabel() + { + } + } +} + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildFile.cs b/Analyzer/SQLite/Commands/AddressablesBuildFile.cs index 24f7606..be501b1 100644 --- a/Analyzer/SQLite/Commands/AddressablesBuildFile.cs +++ b/Analyzer/SQLite/Commands/AddressablesBuildFile.cs @@ -8,16 +8,12 @@ create table addr_build_files ( id INTEGER, build_id INTEGER, - assets TEXT, bundle INTEGER, bundle_object_info_size INTEGER, - external_references TEXT, mono_script_count INTEGER, mono_script_size INTEGER, name TEXT, - other_assets TEXT, preload_info_size INTEGER, - sub_files TEXT, write_result_filename TEXT, PRIMARY KEY (id, build_id) ); @@ -30,16 +26,12 @@ internal class AddressablesBuildFile : AbstractCommand { { "id", SqliteType.Integer }, { "build_id", SqliteType.Integer }, - { "assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "bundle", SqliteType.Integer }, { "bundle_object_info_size", SqliteType.Integer }, - { "external_references", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "mono_script_count", SqliteType.Integer }, { "mono_script_size", SqliteType.Integer }, { "name", SqliteType.Text }, - { "other_assets", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "preload_info_size", SqliteType.Integer }, - { "sub_files", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "write_result_filename", SqliteType.Text } }; diff --git a/Analyzer/SQLite/Commands/AddressablesBuildFileAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildFileAsset.cs new file mode 100644 index 0000000..c28dd8c --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildFileAsset.cs @@ -0,0 +1,33 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_file_assets + ( + file_id INTEGER, + build_id INTEGER, + asset_rid INTEGER, + PRIMARY KEY (file_id, build_id, asset_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) + ); + */ + internal class AddressablesBuildFileAsset : AbstractCommand + { + protected override string TableName => "addr_build_file_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "file_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "asset_rid", SqliteType.Integer } + }; + + public AddressablesBuildFileAsset() + { + } + } +} + + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildFileExternalReference.cs b/Analyzer/SQLite/Commands/AddressablesBuildFileExternalReference.cs new file mode 100644 index 0000000..e567c64 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildFileExternalReference.cs @@ -0,0 +1,33 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_file_external_references + ( + file_id INTEGER, + build_id INTEGER, + external_reference_rid INTEGER, + PRIMARY KEY (file_id, build_id, external_reference_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) + ); + */ + internal class AddressablesBuildFileExternalReference : AbstractCommand + { + protected override string TableName => "addr_build_file_external_references"; + + protected override Dictionary Fields => new Dictionary + { + { "file_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "external_reference_rid", SqliteType.Integer } + }; + + public AddressablesBuildFileExternalReference() + { + } + } +} + + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildFileOtherAsset.cs b/Analyzer/SQLite/Commands/AddressablesBuildFileOtherAsset.cs new file mode 100644 index 0000000..88cf503 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildFileOtherAsset.cs @@ -0,0 +1,33 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_file_other_assets + ( + file_id INTEGER, + build_id INTEGER, + other_asset_rid INTEGER, + PRIMARY KEY (file_id, build_id, other_asset_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) + ); + */ + internal class AddressablesBuildFileOtherAsset : AbstractCommand + { + protected override string TableName => "addr_build_file_other_assets"; + + protected override Dictionary Fields => new Dictionary + { + { "file_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "other_asset_rid", SqliteType.Integer } + }; + + public AddressablesBuildFileOtherAsset() + { + } + } +} + + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildFileSubFile.cs b/Analyzer/SQLite/Commands/AddressablesBuildFileSubFile.cs new file mode 100644 index 0000000..cea5590 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildFileSubFile.cs @@ -0,0 +1,33 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_file_sub_files + ( + file_id INTEGER, + build_id INTEGER, + sub_file_rid INTEGER, + PRIMARY KEY (file_id, build_id, sub_file_rid), + FOREIGN KEY (file_id, build_id) REFERENCES addr_build_files(id, build_id) + ); + */ + internal class AddressablesBuildFileSubFile : AbstractCommand + { + protected override string TableName => "addr_build_file_sub_files"; + + protected override Dictionary Fields => new Dictionary + { + { "file_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "sub_file_rid", SqliteType.Integer } + }; + + public AddressablesBuildFileSubFile() + { + } + } +} + + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs b/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs index 74c1465..01a515d 100644 --- a/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs +++ b/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs @@ -8,11 +8,9 @@ create table addr_build_groups ( id INTEGER, build_id INTEGER, - bundles TEXT, guid TEXT, name TEXT, packing_mode TEXT, - schemas TEXT, PRIMARY KEY (id, build_id) ); */ @@ -24,11 +22,9 @@ internal class AddressablesBuildGroup : AbstractCommand { { "id", SqliteType.Integer }, { "build_id", SqliteType.Integer }, - { "bundles", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "guid", SqliteType.Text }, { "name", SqliteType.Text }, { "packing_mode", SqliteType.Text }, - { "schemas", SqliteType.Text } // JSONB type in SQLite uses TEXT }; public AddressablesBuildGroup() diff --git a/Analyzer/SQLite/Commands/AddressablesBuildGroupBundle.cs b/Analyzer/SQLite/Commands/AddressablesBuildGroupBundle.cs new file mode 100644 index 0000000..5408224 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildGroupBundle.cs @@ -0,0 +1,34 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_group_bundles + ( + group_id INTEGER, + build_id INTEGER, + bundle_rid INTEGER, + PRIMARY KEY (group_id, build_id, bundle_rid), + FOREIGN KEY (group_id, build_id) REFERENCES addr_build_groups(id, build_id) + ); + */ + internal class AddressablesBuildGroupBundle : AbstractCommand + { + protected override string TableName => "addr_build_group_bundles"; + + protected override Dictionary Fields => new Dictionary + { + { "group_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "bundle_rid", SqliteType.Integer } + }; + + public AddressablesBuildGroupBundle() + { + } + } +} + + + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildGroupSchema.cs b/Analyzer/SQLite/Commands/AddressablesBuildGroupSchema.cs new file mode 100644 index 0000000..63e9f96 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildGroupSchema.cs @@ -0,0 +1,34 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_group_schemas + ( + group_id INTEGER, + build_id INTEGER, + schema_rid INTEGER, + PRIMARY KEY (group_id, build_id, schema_rid), + FOREIGN KEY (group_id, build_id) REFERENCES addr_build_groups(id, build_id) + ); + */ + internal class AddressablesBuildGroupSchema : AbstractCommand + { + protected override string TableName => "addr_build_group_schemas"; + + protected override Dictionary Fields => new Dictionary + { + { "group_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "schema_rid", SqliteType.Integer } + }; + + public AddressablesBuildGroupSchema() + { + } + } +} + + + diff --git a/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs b/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs index 0f0667f..6a65f32 100644 --- a/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs +++ b/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs @@ -9,7 +9,6 @@ create table addr_build_schemas id INTEGER, build_id INTEGER, guid TEXT, - schema_data_pairs TEXT, type TEXT, PRIMARY KEY (id, build_id) ); @@ -23,7 +22,6 @@ internal class AddressablesBuildSchema : AbstractCommand { "id", SqliteType.Integer }, { "build_id", SqliteType.Integer }, { "guid", SqliteType.Text }, - { "schema_data_pairs", SqliteType.Text }, // JSONB type in SQLite uses TEXT { "type", SqliteType.Text } }; diff --git a/Analyzer/SQLite/Commands/AddressablesBuildSchemaDataPair.cs b/Analyzer/SQLite/Commands/AddressablesBuildSchemaDataPair.cs new file mode 100644 index 0000000..60c45a0 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildSchemaDataPair.cs @@ -0,0 +1,37 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_schema_data_pairs + ( + schema_id INTEGER, + build_id INTEGER, + key TEXT, + value TEXT, + PRIMARY KEY (schema_id, build_id, key), + FOREIGN KEY (schema_id, build_id) REFERENCES addr_build_schemas(id, build_id) + ); + */ + internal class AddressablesBuildSchemaDataPair : AbstractCommand + { + protected override string TableName => "addr_build_schema_data_pairs"; + + protected override Dictionary Fields => new Dictionary + { + { "schema_id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "key", SqliteType.Text }, + { "value", SqliteType.Text } + }; + + public AddressablesBuildSchemaDataPair() + { + } + } +} + + + + diff --git a/Analyzer/SQLite/SQLiteWriter.cs b/Analyzer/SQLite/SQLiteWriter.cs index abf4a88..6d4747f 100644 --- a/Analyzer/SQLite/SQLiteWriter.cs +++ b/Analyzer/SQLite/SQLiteWriter.cs @@ -16,7 +16,7 @@ namespace UnityDataTools.Analyzer.SQLite; public class SQLiteWriter : IWriter { - private HashSet m_TypeSet = new (); + private HashSet m_TypeSet = new(); private int m_CurrentAssetBundleId = -1; private int m_NextAssetBundleId = 0; @@ -24,15 +24,15 @@ public class SQLiteWriter : IWriter private string m_DatabaseName; private bool m_SkipReferences; - private Util.IdProvider m_SerializedFileIdProvider = new (); - private Util.ObjectIdProvider m_ObjectIdProvider = new (); + private Util.IdProvider m_SerializedFileIdProvider = new(); + private Util.ObjectIdProvider m_ObjectIdProvider = new(); private Regex m_RegexSceneFile = new(@"BuildPlayer-([^\.]+)(?:\.sharedAssets)?"); - + // Used to map PPtr fileId to its corresponding serialized file id in the database. - Dictionary m_LocalToDbFileId = new (); + Dictionary m_LocalToDbFileId = new(); - private Dictionary m_Handlers = new () + private Dictionary m_Handlers = new() { { "Mesh", new MeshHandler() }, { "Texture2D", new Texture2DHandler() }, @@ -42,7 +42,7 @@ public class SQLiteWriter : IWriter { "AssetBundle", new AssetBundleHandler() }, { "PreloadData", new PreloadDataHandler() }, }; - + private SqliteConnection m_Database; private SqliteCommand m_AddReferenceCommand = new SqliteCommand(); private SqliteCommand m_AddAssetBundleCommand = new SqliteCommand(); @@ -51,12 +51,38 @@ public class SQLiteWriter : IWriter private SqliteCommand m_AddTypeCommand = new SqliteCommand(); private SqliteCommand m_InsertDepCommand = new SqliteCommand(); private AddressablesBuild m_AddressablesBuild = new AddressablesBuild(); + private AddressablesBuildBundle m_AddressablesBuildBundle = new AddressablesBuildBundle(); + private AddressablesBuildBundleDependency m_AddressablesBuildBundleDependency = new AddressablesBuildBundleDependency(); + private AddressablesBuildBundleExpandedDependency m_AddressablesBuildBundleExpandedDependency = new AddressablesBuildBundleExpandedDependency(); + private AddressablesBuildBundleRegularDependency m_AddressablesBuildBundleRegularDependency = new AddressablesBuildBundleRegularDependency(); + private AddressablesBuildBundleDependentBundle m_AddressablesBuildBundleDependentBundle = new AddressablesBuildBundleDependentBundle(); + private AddressablesBuildBundleFile m_AddressablesBuildBundleFile = new AddressablesBuildBundleFile(); + private AddressablesBuildDataFromOtherAsset m_AddressablesDataFromOtherAsset = new AddressablesBuildDataFromOtherAsset(); + private AddressablesBuildDataFromOtherAssetObject m_AddressablesBuildDataFromOtherAssetObject = new AddressablesBuildDataFromOtherAssetObject(); + private AddressablesBuildDataFromOtherAssetObjectReference m_AddressablesBuildDataFromOtherAssetObjectReference = new AddressablesBuildDataFromOtherAssetObjectReference(); + private AddressablesBuildDataFromOtherAssetReferencingAsset m_AddressablesBuildDataFromOtherAssetReferencingAsset = new AddressablesBuildDataFromOtherAssetReferencingAsset(); + private AddressablesBuildExplicitAsset m_AddressablesExplicitAsset = new AddressablesBuildExplicitAsset(); + private AddressablesBuildExplicitAssetExternallyReferencedAsset m_AddressablesBuildExplicitAssetExternallyReferencedAsset = new AddressablesBuildExplicitAssetExternallyReferencedAsset(); + private AddressablesBuildExplicitAssetInternalReferencedExplicitAsset m_AddressablesBuildExplicitAssetInternalReferencedExplicitAsset = new AddressablesBuildExplicitAssetInternalReferencedExplicitAsset(); + private AddressablesBuildExplicitAssetInternalReferencedOtherAsset m_AddressablesBuildExplicitAssetInternalReferencedOtherAsset = new AddressablesBuildExplicitAssetInternalReferencedOtherAsset(); + private AddressablesBuildExplicitAssetLabel m_AddressablesBuildExplicitAssetLabel = new AddressablesBuildExplicitAssetLabel(); + private AddressablesBuildFile m_AddressablesBuildFile = new AddressablesBuildFile(); + private AddressablesBuildFileAsset m_AddressablesBuildFileAsset = new AddressablesBuildFileAsset(); + private AddressablesBuildFileExternalReference m_AddressablesBuildFileExternalReference = new AddressablesBuildFileExternalReference(); + private AddressablesBuildFileOtherAsset m_AddressablesBuildFileOtherAsset = new AddressablesBuildFileOtherAsset(); + private AddressablesBuildFileSubFile m_AddressablesBuildFileSubFile = new AddressablesBuildFileSubFile(); + private AddressablesBuildGroup m_AddressablesBuildGroup = new AddressablesBuildGroup(); + private AddressablesBuildGroupBundle m_AddressablesBuildGroupBundle = new AddressablesBuildGroupBundle(); + private AddressablesBuildGroupSchema m_AddressablesBuildGroupSchema = new AddressablesBuildGroupSchema(); + private AddressablesBuildSchema m_AddressablesBuildSchema = new AddressablesBuildSchema(); + private AddressablesBuildSchemaDataPair m_AddressablesBuildSchemaDataPair = new AddressablesBuildSchemaDataPair(); + private AddressablesBuildSubFile m_AddressablesBuildSubFile = new AddressablesBuildSubFile(); private SqliteCommand m_LastId = new SqliteCommand(); private SqliteTransaction m_CurrentTransaction = null; @@ -96,9 +122,9 @@ public void Begin() // Console.WriteLine($"Connection state before init: {m_Database.State}"); handler.Init(m_Database); // Console.WriteLine($"Connection state after init: {m_Database.State}"); - + } - + CreateSQLiteCommands(); } @@ -108,7 +134,7 @@ public void End() { throw new InvalidOperationException("SQLiteWriter.End called before SQLiteWriter.Begin"); } - + foreach (var handler in m_Handlers.Values) { handler.Finalize(m_Database); @@ -162,12 +188,45 @@ private void CreateSQLiteCommands() m_InsertDepCommand.Parameters.Add("@dependency", SqliteType.Integer); m_AddressablesBuild.CreateCommand(m_Database); + // Build Bundle Tables m_AddressablesBuildBundle.CreateCommand(m_Database); + m_AddressablesBuildBundleDependency.CreateCommand(m_Database); + m_AddressablesBuildBundleExpandedDependency.CreateCommand(m_Database); + m_AddressablesBuildBundleRegularDependency.CreateCommand(m_Database); + m_AddressablesBuildBundleDependentBundle.CreateCommand(m_Database); + m_AddressablesBuildBundleFile.CreateCommand(m_Database); + + // Data From Other Asset Tables + // Data From Other Asset Tables m_AddressablesDataFromOtherAsset.CreateCommand(m_Database); + m_AddressablesBuildDataFromOtherAssetObject.CreateCommand(m_Database); + m_AddressablesBuildDataFromOtherAssetObjectReference.CreateCommand(m_Database); + m_AddressablesBuildDataFromOtherAssetReferencingAsset.CreateCommand(m_Database); + + // Explicit Asset Tables m_AddressablesExplicitAsset.CreateCommand(m_Database); + m_AddressablesBuildExplicitAssetExternallyReferencedAsset.CreateCommand(m_Database); + m_AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.CreateCommand(m_Database); + m_AddressablesBuildExplicitAssetInternalReferencedOtherAsset.CreateCommand(m_Database); + m_AddressablesBuildExplicitAssetLabel.CreateCommand(m_Database); + + // File Tables m_AddressablesBuildFile.CreateCommand(m_Database); + m_AddressablesBuildFileAsset.CreateCommand(m_Database); + m_AddressablesBuildFileExternalReference.CreateCommand(m_Database); + m_AddressablesBuildFileOtherAsset.CreateCommand(m_Database); + m_AddressablesBuildFileSubFile.CreateCommand(m_Database); + + // Group Tables m_AddressablesBuildGroup.CreateCommand(m_Database); + m_AddressablesBuildGroupBundle.CreateCommand(m_Database); + m_AddressablesBuildGroupSchema.CreateCommand(m_Database); + + // Schema Tables m_AddressablesBuildSchema.CreateCommand(m_Database); + m_AddressablesBuildSchemaDataPair.CreateCommand(m_Database); + + // SubFile Tables m_AddressablesBuildSubFile.CreateCommand(m_Database); m_LastId = m_Database.CreateCommand(); @@ -179,7 +238,7 @@ public void BeginAssetBundle(string name, long size) { throw new InvalidOperationException("SQLWriter.BeginAssetBundle called twice"); } - + m_CurrentAssetBundleId = m_NextAssetBundleId++; m_AddAssetBundleCommand.Parameters["@id"].Value = m_CurrentAssetBundleId; m_AddAssetBundleCommand.Parameters["@name"].Value = name; @@ -219,132 +278,40 @@ public void WriteAddressablesBuild(string filename, BuildLayout buildLayout) m_AddressablesBuild.ExecuteNonQuery(); m_LastId.Transaction = transaction; - long buildId = (long) m_LastId.ExecuteScalar(); + long buildId = (long)m_LastId.ExecuteScalar(); Console.WriteLine($"Build ID: {buildId}"); foreach (var reference in buildLayout.references.RefIds) { - switch(reference.type.Class) + switch (reference.type.Class) { case "BuildLayout/Bundle": - m_AddressablesBuildBundle.SetTransaction(transaction); - m_AddressablesBuildBundle.SetValue("id", reference.rid); - m_AddressablesBuildBundle.SetValue("build_id", buildId); - m_AddressablesBuildBundle.SetValue("asset_count", reference.data.AssetCount); - m_AddressablesBuildBundle.SetValue("build_status", reference.data.BuildStatus); - m_AddressablesBuildBundle.SetValue("bundle_dependencies", JsonConvert.SerializeObject(reference.data.BundleDependencies) ?? "[]"); - m_AddressablesBuildBundle.SetValue("crc", reference.data.CRC); - m_AddressablesBuildBundle.SetValue("compression", reference.data.Compression); - m_AddressablesBuildBundle.SetValue("dependencies", JsonConvert.SerializeObject(reference.data.Dependencies) ?? "[]"); - m_AddressablesBuildBundle.SetValue("dependency_file_size", reference.data.DependencyFileSize); - m_AddressablesBuildBundle.SetValue("dependent_bundles", JsonConvert.SerializeObject(reference.data.DependentBundles) ?? "[]"); - m_AddressablesBuildBundle.SetValue("expanded_dependencies", JsonConvert.SerializeObject(reference.data.ExpandedDependencies) ?? "[]"); - m_AddressablesBuildBundle.SetValue("expanded_dependency_file_size", reference.data.ExpandedDependencyFileSize); - m_AddressablesBuildBundle.SetValue("file_size", reference.data.FileSize); - m_AddressablesBuildBundle.SetValue("files", JsonConvert.SerializeObject(reference.data.Files) ?? "[]"); - m_AddressablesBuildBundle.SetValue("group_rid", reference.data.Group.rid); - m_AddressablesBuildBundle.SetValue("hash", JsonConvert.SerializeObject(reference.data.Hash)); - m_AddressablesBuildBundle.SetValue("internal_name", reference.data.InternalName); - m_AddressablesBuildBundle.SetValue("load_path", reference.data.LoadPath); - m_AddressablesBuildBundle.SetValue("name", reference.data.Name); - m_AddressablesBuildBundle.SetValue("provider", reference.data.Provider); - m_AddressablesBuildBundle.SetValue("result_type", reference.data.ResultType); - m_AddressablesBuildBundle.ExecuteNonQuery(); + WriteBuildLayoutBundle(reference, buildId, transaction); break; case "BuildLayout/DataFromOtherAsset": - m_AddressablesDataFromOtherAsset.SetTransaction(transaction); - m_AddressablesDataFromOtherAsset.SetValue("id", reference.rid); - m_AddressablesDataFromOtherAsset.SetValue("build_id", buildId); - m_AddressablesDataFromOtherAsset.SetValue("asset_guid", reference.data.AssetGuid); - m_AddressablesDataFromOtherAsset.SetValue("asset_path", reference.data.AssetPath); - m_AddressablesDataFromOtherAsset.SetValue("file", reference.data.File.rid); - m_AddressablesDataFromOtherAsset.SetValue("main_asset_type", reference.data.MainAssetType); - m_AddressablesDataFromOtherAsset.SetValue("object_count", reference.data.ObjectCount); - m_AddressablesDataFromOtherAsset.SetValue("objects", JsonConvert.SerializeObject(reference.data.Objects) ?? "[]"); - m_AddressablesDataFromOtherAsset.SetValue("referencing_assets", JsonConvert.SerializeObject(reference.data.ReferencingAssets) ?? "[]"); - m_AddressablesDataFromOtherAsset.SetValue("serialized_size", reference.data.SerializedSize); - m_AddressablesDataFromOtherAsset.SetValue("streamed_size", reference.data.StreamedSize); - m_AddressablesDataFromOtherAsset.ExecuteNonQuery(); + WriteBuildLayoutDataFromOtherAsset(reference, buildId, transaction); break; case "BuildLayout/ExplicitAsset": - m_AddressablesExplicitAsset.SetTransaction(transaction); - m_AddressablesExplicitAsset.SetValue("id", reference.rid); - m_AddressablesExplicitAsset.SetValue("build_id", buildId); - m_AddressablesExplicitAsset.SetValue("bundle", reference.data.Bundle.rid); - m_AddressablesExplicitAsset.SetValue("file", reference.data.File.rid); - m_AddressablesExplicitAsset.SetValue("asset_hash", reference.data.AssetHash.Hash); - m_AddressablesExplicitAsset.SetValue("asset_path", reference.data.AssetPath); - m_AddressablesExplicitAsset.SetValue("addressable_name", reference.data.AddressableName); - m_AddressablesExplicitAsset.SetValue("externally_referenced_assets", - JsonConvert.SerializeObject(reference.data.ExternallyReferencedAssets) ?? "[]"); - m_AddressablesExplicitAsset.SetValue("group_guid", reference.data.GroupGuid); - m_AddressablesExplicitAsset.SetValue("guid", reference.data.Guid); - m_AddressablesExplicitAsset.SetValue("internal_id", reference.data.InternalId); - m_AddressablesExplicitAsset.SetValue("internal_referenced_explicit_assets", - JsonConvert.SerializeObject(reference.data.InternalReferencedExplicitAssets) ?? "[]"); - m_AddressablesExplicitAsset.SetValue("internal_referenced_other_assets", - JsonConvert.SerializeObject(reference.data.InternalReferencedOtherAssets) ?? "[]"); - m_AddressablesExplicitAsset.SetValue("labels", - JsonConvert.SerializeObject(reference.data.Labels) ?? "[]"); - m_AddressablesExplicitAsset.SetValue("streamed_size", reference.data.StreamedSize); - m_AddressablesExplicitAsset.SetValue("serialized_size", reference.data.SerializedSize); - m_AddressablesExplicitAsset.SetValue("main_asset_type", reference.data.MainAssetType); - m_AddressablesExplicitAsset.ExecuteNonQuery(); + WriteBuildLayoutExplicitAsset(reference, buildId, transaction); break; + case "BuildLayout/File": - m_AddressablesBuildFile.SetTransaction(transaction); - m_AddressablesBuildFile.SetValue("id", reference.rid); - m_AddressablesBuildFile.SetValue("build_id", buildId); - m_AddressablesBuildFile.SetValue("assets", JsonConvert.SerializeObject(reference.data.Assets) ?? "[]"); - m_AddressablesBuildFile.SetValue("bundle", reference.data.Bundle.rid); - m_AddressablesBuildFile.SetValue("bundle_object_info_size", reference.data.BundleObjectInfo.Size); - m_AddressablesBuildFile.SetValue("external_references", JsonConvert.SerializeObject(reference.data.ExternalReferences) ?? "[]"); - m_AddressablesBuildFile.SetValue("mono_script_count", reference.data.MonoScriptCount); - m_AddressablesBuildFile.SetValue("mono_script_size", reference.data.MonoScriptSize); - m_AddressablesBuildFile.SetValue("name", reference.data.Name); - m_AddressablesBuildFile.SetValue("other_assets", JsonConvert.SerializeObject(reference.data.OtherAssets) ?? "[]"); - m_AddressablesBuildFile.SetValue("preload_info_size", reference.data.PreloadInfoSize); - m_AddressablesBuildFile.SetValue("sub_files", JsonConvert.SerializeObject(reference.data.SubFiles) ?? "[]"); - m_AddressablesBuildFile.SetValue("write_result_filename", reference.data.WriteResultFilename); - m_AddressablesBuildFile.ExecuteNonQuery(); + WriteBuildLayoutFile(reference, buildId, transaction); break; case "BuildLayout/Group": - m_AddressablesBuildGroup.SetTransaction(transaction); - m_AddressablesBuildGroup.SetValue("id", reference.rid); - m_AddressablesBuildGroup.SetValue("build_id", buildId); - m_AddressablesBuildGroup.SetValue("bundles", JsonConvert.SerializeObject(reference.data.Bundles) ?? "[]"); - m_AddressablesBuildGroup.SetValue("guid", reference.data.Guid); - m_AddressablesBuildGroup.SetValue("name", reference.data.Name); - m_AddressablesBuildGroup.SetValue("packing_mode", reference.data.PackingMode); - m_AddressablesBuildGroup.SetValue("schemas", JsonConvert.SerializeObject(reference.data.Schemas) ?? "[]"); - m_AddressablesBuildGroup.ExecuteNonQuery(); + WriteBuildLayoutGroup(reference, buildId, transaction); break; case "BuildLayout/SchemaData": - m_AddressablesBuildSchema.SetTransaction(transaction); - m_AddressablesBuildSchema.SetValue("id", reference.rid); - m_AddressablesBuildSchema.SetValue("build_id", buildId); - m_AddressablesBuildSchema.SetValue("guid", reference.data.Guid); - m_AddressablesBuildSchema.SetValue("schema_data_pairs", JsonConvert.SerializeObject(reference.data.SchemaDataPairs) ?? "[]"); - m_AddressablesBuildSchema.SetValue("type", reference.data.Type); - m_AddressablesBuildSchema.ExecuteNonQuery(); + WriteBuildLayoutSchemaData(reference, buildId, transaction); break; case "BuildLayout/SubFile": - m_AddressablesBuildSubFile.SetTransaction(transaction); - m_AddressablesBuildSubFile.SetValue("id", reference.rid); - m_AddressablesBuildSubFile.SetValue("build_id", buildId); - m_AddressablesBuildSubFile.SetValue("is_serialized_file", reference.data.IsSerializedFile ? 1 : 0); - m_AddressablesBuildSubFile.SetValue("name", reference.data.Name); - m_AddressablesBuildSubFile.SetValue("size", reference.data.Size); - m_AddressablesBuildSubFile.ExecuteNonQuery(); + WriteBuildLayoutSubFile(reference, buildId, transaction); break; - - - } } @@ -359,6 +326,363 @@ public void WriteAddressablesBuild(string filename, BuildLayout buildLayout) } } + private void WriteBuildLayoutBundle(Reference reference, long buildId, SqliteTransaction transaction) + { + m_AddressablesBuildBundle.SetTransaction(transaction); + m_AddressablesBuildBundle.SetValue("id", reference.rid); + m_AddressablesBuildBundle.SetValue("build_id", buildId); + m_AddressablesBuildBundle.SetValue("asset_count", reference.data.AssetCount); + m_AddressablesBuildBundle.SetValue("build_status", reference.data.BuildStatus); + m_AddressablesBuildBundle.SetValue("crc", reference.data.CRC); + m_AddressablesBuildBundle.SetValue("compression", reference.data.Compression); + m_AddressablesBuildBundle.SetValue("dependency_file_size", reference.data.DependencyFileSize); + m_AddressablesBuildBundle.SetValue("expanded_dependency_file_size", reference.data.ExpandedDependencyFileSize); + m_AddressablesBuildBundle.SetValue("file_size", reference.data.FileSize); + m_AddressablesBuildBundle.SetValue("group_rid", reference.data.Group.rid); + m_AddressablesBuildBundle.SetValue("hash", JsonConvert.SerializeObject(reference.data.Hash)); + m_AddressablesBuildBundle.SetValue("internal_name", reference.data.InternalName); + m_AddressablesBuildBundle.SetValue("load_path", reference.data.LoadPath); + m_AddressablesBuildBundle.SetValue("name", reference.data.Name); + m_AddressablesBuildBundle.SetValue("provider", reference.data.Provider); + m_AddressablesBuildBundle.SetValue("result_type", reference.data.ResultType); + m_AddressablesBuildBundle.ExecuteNonQuery(); + + // Insert bundle dependencies + if (reference.data.BundleDependencies != null) + { + foreach (var dep in reference.data.BundleDependencies) + { + m_AddressablesBuildBundleDependency.SetTransaction(transaction); + m_AddressablesBuildBundleDependency.SetValue("bundle_id", reference.rid); + m_AddressablesBuildBundleDependency.SetValue("build_id", buildId); + m_AddressablesBuildBundleDependency.SetValue("dependency_rid", dep.rid); + m_AddressablesBuildBundleDependency.ExecuteNonQuery(); + } + } + + // Insert regular dependencies + if (reference.data.Dependencies != null) + { + foreach (var dep in reference.data.Dependencies) + { + m_AddressablesBuildBundleRegularDependency.SetTransaction(transaction); + m_AddressablesBuildBundleRegularDependency.SetValue("bundle_id", reference.rid); + m_AddressablesBuildBundleRegularDependency.SetValue("build_id", buildId); + m_AddressablesBuildBundleRegularDependency.SetValue("dependency_rid", dep.rid); + m_AddressablesBuildBundleRegularDependency.ExecuteNonQuery(); + } + } + + // Insert dependent bundles + if (reference.data.DependentBundles != null) + { + foreach (var depBundle in reference.data.DependentBundles) + { + m_AddressablesBuildBundleDependentBundle.SetTransaction(transaction); + m_AddressablesBuildBundleDependentBundle.SetValue("bundle_id", reference.rid); + m_AddressablesBuildBundleDependentBundle.SetValue("build_id", buildId); + m_AddressablesBuildBundleDependentBundle.SetValue("dependent_bundle_rid", depBundle.rid); + m_AddressablesBuildBundleDependentBundle.ExecuteNonQuery(); + } + } + + // Insert expanded dependencies + if (reference.data.ExpandedDependencies != null) + { + foreach (var dep in reference.data.ExpandedDependencies) + { + m_AddressablesBuildBundleExpandedDependency.SetTransaction(transaction); + m_AddressablesBuildBundleExpandedDependency.SetValue("bundle_id", reference.rid); + m_AddressablesBuildBundleExpandedDependency.SetValue("build_id", buildId); + m_AddressablesBuildBundleExpandedDependency.SetValue("dependency_rid", dep.rid); + m_AddressablesBuildBundleExpandedDependency.ExecuteNonQuery(); + } + } + + // Insert files + if (reference.data.Files != null) + { + foreach (var file in reference.data.Files) + { + m_AddressablesBuildBundleFile.SetTransaction(transaction); + m_AddressablesBuildBundleFile.SetValue("bundle_id", reference.rid); + m_AddressablesBuildBundleFile.SetValue("build_id", buildId); + m_AddressablesBuildBundleFile.SetValue("file_rid", file.rid); + m_AddressablesBuildBundleFile.ExecuteNonQuery(); + } + } + } + + private void WriteBuildLayoutDataFromOtherAsset(Reference reference, long buildId, SqliteTransaction transaction) + { + m_AddressablesDataFromOtherAsset.SetTransaction(transaction); + m_AddressablesDataFromOtherAsset.SetValue("id", reference.rid); + m_AddressablesDataFromOtherAsset.SetValue("build_id", buildId); + m_AddressablesDataFromOtherAsset.SetValue("asset_guid", reference.data.AssetGuid); + m_AddressablesDataFromOtherAsset.SetValue("asset_path", reference.data.AssetPath); + m_AddressablesDataFromOtherAsset.SetValue("file", reference.data.File.rid); + m_AddressablesDataFromOtherAsset.SetValue("main_asset_type", reference.data.MainAssetType); + m_AddressablesDataFromOtherAsset.SetValue("object_count", reference.data.ObjectCount); + m_AddressablesDataFromOtherAsset.SetValue("serialized_size", reference.data.SerializedSize); + m_AddressablesDataFromOtherAsset.SetValue("streamed_size", reference.data.StreamedSize); + m_AddressablesDataFromOtherAsset.ExecuteNonQuery(); + + // Insert objects + if (reference.data.Objects != null) + { + foreach (var obj in reference.data.Objects) + { + m_AddressablesBuildDataFromOtherAssetObject.SetTransaction(transaction); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("data_from_other_asset_id", reference.rid); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("build_id", buildId); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("asset_type", obj.AssetType); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("component_name", obj.ComponentName ?? ""); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("local_identifier_in_file", obj.LocalIdentifierInFile); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("object_name", obj.ObjectName ?? ""); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("serialized_size", obj.SerializedSize); + m_AddressablesBuildDataFromOtherAssetObject.SetValue("streamed_size", obj.StreamedSize); + m_AddressablesBuildDataFromOtherAssetObject.ExecuteNonQuery(); + + // Insert object references + if (obj.References != null) + { + foreach (var objRef in obj.References) + { + m_AddressablesBuildDataFromOtherAssetObjectReference.SetTransaction(transaction); + m_AddressablesBuildDataFromOtherAssetObjectReference.SetValue("data_from_other_asset_id", reference.rid); + m_AddressablesBuildDataFromOtherAssetObjectReference.SetValue("build_id", buildId); + m_AddressablesBuildDataFromOtherAssetObjectReference.SetValue("local_identifier_in_file", obj.LocalIdentifierInFile); + m_AddressablesBuildDataFromOtherAssetObjectReference.SetValue("asset_id", objRef.AssetId); + m_AddressablesBuildDataFromOtherAssetObjectReference.SetValue("object_id", objRef.ObjectId); + m_AddressablesBuildDataFromOtherAssetObjectReference.ExecuteNonQuery(); + } + } + } + } + + // Insert referencing assets + if (reference.data.ReferencingAssets != null) + { + foreach (var refAsset in reference.data.ReferencingAssets) + { + m_AddressablesBuildDataFromOtherAssetReferencingAsset.SetTransaction(transaction); + m_AddressablesBuildDataFromOtherAssetReferencingAsset.SetValue("data_from_other_asset_id", reference.rid); + m_AddressablesBuildDataFromOtherAssetReferencingAsset.SetValue("build_id", buildId); + m_AddressablesBuildDataFromOtherAssetReferencingAsset.SetValue("referencing_asset_rid", refAsset.rid); + m_AddressablesBuildDataFromOtherAssetReferencingAsset.ExecuteNonQuery(); + } + } + } + + private void WriteBuildLayoutExplicitAsset(Reference reference, long buildId, SqliteTransaction transaction) + { + m_AddressablesExplicitAsset.SetTransaction(transaction); + m_AddressablesExplicitAsset.SetValue("id", reference.rid); + m_AddressablesExplicitAsset.SetValue("build_id", buildId); + m_AddressablesExplicitAsset.SetValue("bundle", reference.data.Bundle.rid); + m_AddressablesExplicitAsset.SetValue("file", reference.data.File.rid); + m_AddressablesExplicitAsset.SetValue("asset_hash", reference.data.AssetHash.Hash); + m_AddressablesExplicitAsset.SetValue("asset_path", reference.data.AssetPath); + m_AddressablesExplicitAsset.SetValue("addressable_name", reference.data.AddressableName); + m_AddressablesExplicitAsset.SetValue("group_guid", reference.data.GroupGuid); + m_AddressablesExplicitAsset.SetValue("guid", reference.data.Guid); + m_AddressablesExplicitAsset.SetValue("internal_id", reference.data.InternalId); + m_AddressablesExplicitAsset.SetValue("streamed_size", reference.data.StreamedSize); + m_AddressablesExplicitAsset.SetValue("serialized_size", reference.data.SerializedSize); + m_AddressablesExplicitAsset.SetValue("main_asset_type", reference.data.MainAssetType); + m_AddressablesExplicitAsset.ExecuteNonQuery(); + + // Insert externally referenced assets + if (reference.data.ExternallyReferencedAssets != null) + { + foreach (var extRefAsset in reference.data.ExternallyReferencedAssets) + { + m_AddressablesBuildExplicitAssetExternallyReferencedAsset.SetTransaction(transaction); + m_AddressablesBuildExplicitAssetExternallyReferencedAsset.SetValue("explicit_asset_id", reference.rid); + m_AddressablesBuildExplicitAssetExternallyReferencedAsset.SetValue("build_id", buildId); + m_AddressablesBuildExplicitAssetExternallyReferencedAsset.SetValue("externally_referenced_asset_rid", extRefAsset.rid); + m_AddressablesBuildExplicitAssetExternallyReferencedAsset.ExecuteNonQuery(); + } + } + + // Insert internal referenced explicit assets + if (reference.data.InternalReferencedExplicitAssets != null) + { + foreach (var intRefExplicitAsset in reference.data.InternalReferencedExplicitAssets) + { + m_AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.SetTransaction(transaction); + m_AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.SetValue("explicit_asset_id", reference.rid); + m_AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.SetValue("build_id", buildId); + m_AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.SetValue("internal_referenced_explicit_asset_rid", intRefExplicitAsset.rid); + m_AddressablesBuildExplicitAssetInternalReferencedExplicitAsset.ExecuteNonQuery(); + } + } + + // Insert internal referenced other assets + if (reference.data.InternalReferencedOtherAssets != null) + { + foreach (var intRefOtherAsset in reference.data.InternalReferencedOtherAssets) + { + m_AddressablesBuildExplicitAssetInternalReferencedOtherAsset.SetTransaction(transaction); + m_AddressablesBuildExplicitAssetInternalReferencedOtherAsset.SetValue("explicit_asset_id", reference.rid); + m_AddressablesBuildExplicitAssetInternalReferencedOtherAsset.SetValue("build_id", buildId); + m_AddressablesBuildExplicitAssetInternalReferencedOtherAsset.SetValue("internal_referenced_other_asset_rid", intRefOtherAsset.rid); + m_AddressablesBuildExplicitAssetInternalReferencedOtherAsset.ExecuteNonQuery(); + } + } + + // Insert labels + if (reference.data.Labels != null) + { + foreach (var label in reference.data.Labels) + { + m_AddressablesBuildExplicitAssetLabel.SetTransaction(transaction); + m_AddressablesBuildExplicitAssetLabel.SetValue("explicit_asset_id", reference.rid); + m_AddressablesBuildExplicitAssetLabel.SetValue("build_id", buildId); + m_AddressablesBuildExplicitAssetLabel.SetValue("label", label); + m_AddressablesBuildExplicitAssetLabel.ExecuteNonQuery(); + } + } + } + + private void WriteBuildLayoutFile(Reference reference, long buildId, SqliteTransaction transaction) + { + m_AddressablesBuildFile.SetTransaction(transaction); + m_AddressablesBuildFile.SetValue("id", reference.rid); + m_AddressablesBuildFile.SetValue("build_id", buildId); + m_AddressablesBuildFile.SetValue("bundle", reference.data.Bundle.rid); + m_AddressablesBuildFile.SetValue("bundle_object_info_size", reference.data.BundleObjectInfo.Size); + m_AddressablesBuildFile.SetValue("mono_script_count", reference.data.MonoScriptCount); + m_AddressablesBuildFile.SetValue("mono_script_size", reference.data.MonoScriptSize); + m_AddressablesBuildFile.SetValue("name", reference.data.Name); + m_AddressablesBuildFile.SetValue("preload_info_size", reference.data.PreloadInfoSize); + m_AddressablesBuildFile.SetValue("write_result_filename", reference.data.WriteResultFilename); + m_AddressablesBuildFile.ExecuteNonQuery(); + + // Insert assets + if (reference.data.Assets != null) + { + foreach (var asset in reference.data.Assets) + { + m_AddressablesBuildFileAsset.SetTransaction(transaction); + m_AddressablesBuildFileAsset.SetValue("file_id", reference.rid); + m_AddressablesBuildFileAsset.SetValue("build_id", buildId); + m_AddressablesBuildFileAsset.SetValue("asset_rid", asset.rid); + m_AddressablesBuildFileAsset.ExecuteNonQuery(); + } + } + + // Insert external references + if (reference.data.ExternalReferences != null) + { + foreach (var extRef in reference.data.ExternalReferences) + { + m_AddressablesBuildFileExternalReference.SetTransaction(transaction); + m_AddressablesBuildFileExternalReference.SetValue("file_id", reference.rid); + m_AddressablesBuildFileExternalReference.SetValue("build_id", buildId); + m_AddressablesBuildFileExternalReference.SetValue("external_reference_rid", extRef.rid); + m_AddressablesBuildFileExternalReference.ExecuteNonQuery(); + } + } + + // Insert other assets + if (reference.data.OtherAssets != null) + { + foreach (var otherAsset in reference.data.OtherAssets) + { + m_AddressablesBuildFileOtherAsset.SetTransaction(transaction); + m_AddressablesBuildFileOtherAsset.SetValue("file_id", reference.rid); + m_AddressablesBuildFileOtherAsset.SetValue("build_id", buildId); + m_AddressablesBuildFileOtherAsset.SetValue("other_asset_rid", otherAsset.rid); + m_AddressablesBuildFileOtherAsset.ExecuteNonQuery(); + } + } + + // Insert sub files + if (reference.data.SubFiles != null) + { + foreach (var subFile in reference.data.SubFiles) + { + m_AddressablesBuildFileSubFile.SetTransaction(transaction); + m_AddressablesBuildFileSubFile.SetValue("file_id", reference.rid); + m_AddressablesBuildFileSubFile.SetValue("build_id", buildId); + m_AddressablesBuildFileSubFile.SetValue("sub_file_rid", subFile.rid); + m_AddressablesBuildFileSubFile.ExecuteNonQuery(); + } + } + } + + private void WriteBuildLayoutGroup(Reference reference, long buildId, SqliteTransaction transaction) + { + m_AddressablesBuildGroup.SetTransaction(transaction); + m_AddressablesBuildGroup.SetValue("id", reference.rid); + m_AddressablesBuildGroup.SetValue("build_id", buildId); + m_AddressablesBuildGroup.SetValue("guid", reference.data.Guid); + m_AddressablesBuildGroup.SetValue("name", reference.data.Name); + m_AddressablesBuildGroup.SetValue("packing_mode", reference.data.PackingMode); + m_AddressablesBuildGroup.ExecuteNonQuery(); + + // Insert bundles + if (reference.data.Bundles != null) + { + foreach (var bundle in reference.data.Bundles) + { + m_AddressablesBuildGroupBundle.SetTransaction(transaction); + m_AddressablesBuildGroupBundle.SetValue("group_id", reference.rid); + m_AddressablesBuildGroupBundle.SetValue("build_id", buildId); + m_AddressablesBuildGroupBundle.SetValue("bundle_rid", bundle.rid); + m_AddressablesBuildGroupBundle.ExecuteNonQuery(); + } + } + + // Insert schemas + if (reference.data.Schemas != null) + { + foreach (var schema in reference.data.Schemas) + { + m_AddressablesBuildGroupSchema.SetTransaction(transaction); + m_AddressablesBuildGroupSchema.SetValue("group_id", reference.rid); + m_AddressablesBuildGroupSchema.SetValue("build_id", buildId); + m_AddressablesBuildGroupSchema.SetValue("schema_rid", schema.rid); + m_AddressablesBuildGroupSchema.ExecuteNonQuery(); + } + } + } + + private void WriteBuildLayoutSchemaData(Reference reference, long buildId, SqliteTransaction transaction) + { + m_AddressablesBuildSchema.SetTransaction(transaction); + m_AddressablesBuildSchema.SetValue("id", reference.rid); + m_AddressablesBuildSchema.SetValue("build_id", buildId); + m_AddressablesBuildSchema.SetValue("guid", reference.data.Guid); + m_AddressablesBuildSchema.SetValue("type", reference.data.Type); + m_AddressablesBuildSchema.ExecuteNonQuery(); + + // Insert schema data pairs + if (reference.data.SchemaDataPairs != null) + { + foreach (var dataPair in reference.data.SchemaDataPairs) + { + m_AddressablesBuildSchemaDataPair.SetTransaction(transaction); + m_AddressablesBuildSchemaDataPair.SetValue("schema_id", reference.rid); + m_AddressablesBuildSchemaDataPair.SetValue("build_id", buildId); + m_AddressablesBuildSchemaDataPair.SetValue("key", dataPair.Key); + m_AddressablesBuildSchemaDataPair.SetValue("value", dataPair.Value); + m_AddressablesBuildSchemaDataPair.ExecuteNonQuery(); + } + } + } + + private void WriteBuildLayoutSubFile(Reference reference, long buildId, SqliteTransaction transaction) + { + m_AddressablesBuildSubFile.SetTransaction(transaction); + m_AddressablesBuildSubFile.SetValue("id", reference.rid); + m_AddressablesBuildSubFile.SetValue("build_id", buildId); + m_AddressablesBuildSubFile.SetValue("is_serialized_file", reference.data.IsSerializedFile ? 1 : 0); + m_AddressablesBuildSubFile.SetValue("name", reference.data.Name); + m_AddressablesBuildSubFile.SetValue("size", reference.data.Size); + m_AddressablesBuildSubFile.ExecuteNonQuery(); + } public void WriteSerializedFile(string relativePath, string fullPath, string containingFolder) { @@ -376,7 +700,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con if (match.Success) { var sceneName = match.Groups[1].Value; - + // There is no Scene object in Unity (a Scene is the full content of a // SerializedFile). We generate an object id using the name of the Scene // as SerializedFile name, and the object id 0. @@ -400,7 +724,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con m_AddObjectCommand.ExecuteNonQuery(); } } - + m_LocalToDbFileId.Clear(); Context ctx = new() @@ -463,7 +787,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con { name = randomAccessReader["m_Name"].GetValue(); } - + if (randomAccessReader.HasChild("m_GameObject")) { var pptr = randomAccessReader["m_GameObject"];