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/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..d144a50 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") + { + ProcessAddressablesBuild(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 ProcessAddressablesBuild(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.WriteAddressablesBuild(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..37e195a 100644 --- a/Analyzer/Resources/Init.sql +++ b/Analyzer/Resources/Init.sql @@ -103,5 +103,272 @@ WHERE m.type = "Material"; INSERT INTO types (id, name) VALUES (-1, 'Scene'); +CREATE TABLE addr_builds +( + 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 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, + 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) +); +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/AbstractCommand.cs b/Analyzer/SQLite/Commands/AbstractCommand.cs new file mode 100644 index 0000000..0d4b049 --- /dev/null +++ b/Analyzer/SQLite/Commands/AbstractCommand.cs @@ -0,0 +1,55 @@ +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) + { + string prefixedKey = $"@{key}"; + if (m_Command.Parameters.Contains(prefixedKey)) + { + m_Command.Parameters[prefixedKey].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/AddressablesBuildBundle.cs b/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs new file mode 100644 index 0000000..a852244 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildBundle.cs @@ -0,0 +1,56 @@ +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, + 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) + ); + */ + 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 }, + { "crc", SqliteType.Integer }, + { "compression", SqliteType.Text }, + { "dependency_file_size", SqliteType.Integer }, + { "expanded_dependency_file_size", SqliteType.Integer }, + { "file_size", SqliteType.Integer }, + { "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/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 new file mode 100644 index 0000000..22d36f4 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildDataFromOtherAsset.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_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) + ); + */ + 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 }, + { "serialized_size", SqliteType.Integer }, + { "streamed_size", SqliteType.Integer } + }; + + public AddressablesBuildDataFromOtherAsset() + { + } + } +} 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 new file mode 100644 index 0000000..e653304 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildExplicitAsset.cs @@ -0,0 +1,49 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +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"; + + 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 }, + { "group_guid", SqliteType.Text }, + { "guid", SqliteType.Text }, + { "internal_id", SqliteType.Text }, + { "main_asset_type", SqliteType.Integer }, + { "streamed_size", 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 new file mode 100644 index 0000000..be501b1 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildFile.cs @@ -0,0 +1,42 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + 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) + ); + */ + internal class AddressablesBuildFile : AbstractCommand + { + protected override string TableName => "addr_build_files"; + + protected override Dictionary Fields => new Dictionary + { + { "id", SqliteType.Integer }, + { "build_id", SqliteType.Integer }, + { "bundle", SqliteType.Integer }, + { "bundle_object_info_size", SqliteType.Integer }, + { "mono_script_count", SqliteType.Integer }, + { "mono_script_size", SqliteType.Integer }, + { "name", SqliteType.Text }, + { "preload_info_size", SqliteType.Integer }, + { "write_result_filename", SqliteType.Text } + }; + + public AddressablesBuildFile() + { + } + } +} 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 new file mode 100644 index 0000000..01a515d --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildGroup.cs @@ -0,0 +1,35 @@ +using Microsoft.Data.Sqlite; +using System.Collections.Generic; + +namespace Analyzer.SQLite.Commands +{ + /* TABLE DEFINITION: + create table addr_build_groups + ( + id INTEGER, + build_id INTEGER, + guid TEXT, + name TEXT, + packing_mode 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 }, + { "guid", SqliteType.Text }, + { "name", SqliteType.Text }, + { "packing_mode", SqliteType.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 new file mode 100644 index 0000000..6a65f32 --- /dev/null +++ b/Analyzer/SQLite/Commands/AddressablesBuildSchema.cs @@ -0,0 +1,33 @@ +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, + 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 }, + { "type", SqliteType.Text } + }; + + public AddressablesBuildSchema() + { + } + } +} + 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/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 f468f49..6d4747f 100644 --- a/Analyzer/SQLite/SQLiteWriter.cs +++ b/Analyzer/SQLite/SQLiteWriter.cs @@ -6,12 +6,17 @@ 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; +using Analyzer.SQLite.Commands; 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; @@ -19,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() }, @@ -37,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(); @@ -45,6 +50,41 @@ public class SQLiteWriter : IWriter private SqliteCommand m_AddObjectCommand = new SqliteCommand(); 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; public SQLiteWriter(string databaseName, bool skipReferences) { @@ -82,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(); } @@ -94,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); @@ -125,7 +165,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,15 +186,59 @@ 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_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(); + m_LastId.CommandText = "SELECT last_insert_rowid()"; + } public void BeginAssetBundle(string name, long size) { if (m_CurrentAssetBundleId != -1) { throw new InvalidOperationException("SQLWriter.BeginAssetBundle called twice"); } - + m_CurrentAssetBundleId = m_NextAssetBundleId++; m_AddAssetBundleCommand.Parameters["@id"].Value = m_CurrentAssetBundleId; m_AddAssetBundleCommand.Parameters["@name"].Value = name; @@ -171,7 +255,435 @@ public void EndAssetBundle() m_CurrentAssetBundleId = -1; } - + + public void WriteAddressablesBuild(string filename, BuildLayout buildLayout) + { + using var transaction = m_Database.BeginTransaction(); + m_CurrentTransaction = transaction; + + try + { + 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(); + Console.WriteLine($"Build ID: {buildId}"); + + foreach (var reference in buildLayout.references.RefIds) + { + switch (reference.type.Class) + { + case "BuildLayout/Bundle": + WriteBuildLayoutBundle(reference, buildId, transaction); + break; + + case "BuildLayout/DataFromOtherAsset": + WriteBuildLayoutDataFromOtherAsset(reference, buildId, transaction); + break; + + case "BuildLayout/ExplicitAsset": + WriteBuildLayoutExplicitAsset(reference, buildId, transaction); + break; + + case "BuildLayout/File": + WriteBuildLayoutFile(reference, buildId, transaction); + break; + + case "BuildLayout/Group": + WriteBuildLayoutGroup(reference, buildId, transaction); + break; + + case "BuildLayout/SchemaData": + WriteBuildLayoutSchemaData(reference, buildId, transaction); + break; + + case "BuildLayout/SubFile": + WriteBuildLayoutSubFile(reference, buildId, transaction); + break; + } + } + + // do the stuff + transaction.Commit(); + } + catch (Exception e) + { + Console.WriteLine(e.StackTrace.ToString()); + transaction.Rollback(); + throw; + } + } + + 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) { using var sf = UnityFileSystem.OpenSerializedFile(fullPath); @@ -188,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. @@ -212,7 +724,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con m_AddObjectCommand.ExecuteNonQuery(); } } - + m_LocalToDbFileId.Clear(); Context ctx = new() @@ -275,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"];