Skip to content

Commit ee9fda8

Browse files
[#99] Import ContentLayout.json into the analyze database (#101)
ContentLayout.json (written by BuildPipeline.BuildContentDirectory into the build report directory) contains important information for deciphering the output of a content directory build. Add new tables, views and indexes (created on demand) that would be populated from the JSON if a ContentLayout.json is encountered by analyze. A follow up PR is planned to implement further work described in issue #99.
1 parent ea63707 commit ee9fda8

31 files changed

Lines changed: 1191 additions & 0 deletions

Analyzer/AnalyzerTool.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class AnalyzerTool
1616

1717
public List<ISQLiteFileParser> parsers = new List<ISQLiteFileParser>()
1818
{
19+
new ContentLayoutParser(),
1920
new AddressablesBuildLayoutParser(),
2021
new SerializedFileParser(),
2122
};

Analyzer/Properties/Resources.Designer.cs

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Analyzer/Properties/Resources.resx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,42 @@
226226
<data name="AddrBuildSchemaDataPairs" type="System.Resources.ResXFileRef, System.Windows.Forms">
227227
<value>..\Resources\AddrBuildSchemaDataPairs.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
228228
</data>
229+
<data name="ContentLayout" type="System.Resources.ResXFileRef, System.Windows.Forms">
230+
<value>..\Resources\ContentLayout.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
231+
</data>
232+
<data name="ContentLayoutSerializedFiles" type="System.Resources.ResXFileRef, System.Windows.Forms">
233+
<value>..\Resources\ContentLayoutSerializedFiles.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
234+
</data>
235+
<data name="ContentLayoutSourceAssets" type="System.Resources.ResXFileRef, System.Windows.Forms">
236+
<value>..\Resources\ContentLayoutSourceAssets.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
237+
</data>
238+
<data name="ContentLayoutSerializedFileDependencies" type="System.Resources.ResXFileRef, System.Windows.Forms">
239+
<value>..\Resources\ContentLayoutSerializedFileDependencies.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
240+
</data>
241+
<data name="ContentLayoutLoadableDependencies" type="System.Resources.ResXFileRef, System.Windows.Forms">
242+
<value>..\Resources\ContentLayoutLoadableDependencies.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
243+
</data>
244+
<data name="ContentLayoutLoadableSceneDependencies" type="System.Resources.ResXFileRef, System.Windows.Forms">
245+
<value>..\Resources\ContentLayoutLoadableSceneDependencies.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
246+
</data>
247+
<data name="ContentLayoutLoadableObjects" type="System.Resources.ResXFileRef, System.Windows.Forms">
248+
<value>..\Resources\ContentLayoutLoadableObjects.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
249+
</data>
250+
<data name="ContentLayoutLoadableScenes" type="System.Resources.ResXFileRef, System.Windows.Forms">
251+
<value>..\Resources\ContentLayoutLoadableScenes.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
252+
</data>
253+
<data name="ContentLayoutBinaryArtifacts" type="System.Resources.ResXFileRef, System.Windows.Forms">
254+
<value>..\Resources\ContentLayoutBinaryArtifacts.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
255+
</data>
256+
<data name="ContentLayoutArtifactReferences" type="System.Resources.ResXFileRef, System.Windows.Forms">
257+
<value>..\Resources\ContentLayoutArtifactReferences.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
258+
</data>
259+
<data name="ContentLayoutViews" type="System.Resources.ResXFileRef, System.Windows.Forms">
260+
<value>..\Resources\ContentLayoutViews.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
261+
</data>
262+
<data name="ContentLayoutIndexes" type="System.Resources.ResXFileRef, System.Windows.Forms">
263+
<value>..\Resources\ContentLayoutIndexes.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
264+
</data>
229265
<data name="MonoScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
230266
<value>..\Resources\MonoScript.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
231267
</data>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Identity of the imported ContentLayout.json (see Documentation/contentlayout.md). The
2+
-- content_layout* tables are only created when a ContentLayout.json is part of the analyzed
3+
-- input. A single layout per database is supported.
4+
CREATE TABLE IF NOT EXISTS content_layout
5+
(
6+
id INTEGER, -- always 0 (single layout per database)
7+
name TEXT, -- path of the imported ContentLayout.json
8+
version INTEGER, -- schema version of the json file
9+
build_manifest_hash TEXT,
10+
PRIMARY KEY (id)
11+
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Direct references between binary artifacts (ArtifactReferences in the json), e.g. a
2+
-- serialized file referencing its .resS/.resource data files. References that go through a
3+
-- loadable are not included, and the graph is never cyclical. References to other serialized
4+
-- files are not recorded here either; those are in content_layout_serialized_file_dependencies.
5+
CREATE TABLE IF NOT EXISTS content_layout_artifact_references
6+
(
7+
artifact_index INTEGER, -- references content_layout_binary_artifacts.artifact_index
8+
referenced_artifact_index INTEGER,
9+
PRIMARY KEY (artifact_index, referenced_artifact_index)
10+
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- The artifacts that make up the build output (BinaryArtifacts in the json): the serialized
2+
-- files themselves plus the data files they use (.resS, .resource) and the manifest. This is the
3+
-- standard place to find artifact sizes. When stored as a file the filename is the content hash
4+
-- plus an extension derived from the category (content_layout_binary_artifacts_view adds it).
5+
CREATE TABLE IF NOT EXISTS content_layout_binary_artifacts
6+
(
7+
artifact_index INTEGER,
8+
content_hash TEXT,
9+
category TEXT, -- 'texture' | 'mesh' | 'audio' | 'video' | 'contentfile' | 'manifest'
10+
size INTEGER,
11+
PRIMARY KEY (artifact_index)
12+
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Created after the content_layout tables are populated, so inserts stay fast for very large
2+
-- layouts. The content_hash and asset_path indexes carry the views; the rest serve reverse
3+
-- lookups ("who depends on X", "which loadables live in file Y").
4+
CREATE INDEX content_layout_binary_artifacts_content_hash ON content_layout_binary_artifacts(content_hash);
5+
CREATE INDEX content_layout_source_assets_asset_path ON content_layout_source_assets(asset_path);
6+
CREATE INDEX content_layout_source_assets_file ON content_layout_source_assets(serialized_file_index);
7+
CREATE INDEX content_layout_serialized_file_dependencies_dep ON content_layout_serialized_file_dependencies(dependency_index);
8+
CREATE INDEX content_layout_artifact_references_ref ON content_layout_artifact_references(referenced_artifact_index);
9+
CREATE INDEX content_layout_loadable_objects_file ON content_layout_loadable_objects(serialized_file_index);
10+
CREATE INDEX content_layout_loadable_objects_guid ON content_layout_loadable_objects(guid);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Loadable objects referenced from each serialized file (LoadableDependencies in the json).
2+
CREATE TABLE IF NOT EXISTS content_layout_loadable_dependencies
3+
(
4+
serialized_file_index INTEGER, -- references content_layout_serialized_files.file_index
5+
object_id_hash TEXT -- references content_layout_loadable_objects.object_id_hash
6+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- The objects that can be loaded on demand (LoadableObjectIds in the json), identified
2+
-- independently of the serialized file that contains them. Also records where each one came from
3+
-- in the source project. The json's top-level RootAssets list is folded into the is_root_asset
4+
-- flag. serialized_file_index is NULL when the object was dropped from the build (json value -1,
5+
-- e.g. server build shader references).
6+
CREATE TABLE IF NOT EXISTS content_layout_loadable_objects
7+
(
8+
object_id_hash TEXT, -- hash of GUID, LFID and identifier_type
9+
guid TEXT, -- AssetDatabase GUID of the source asset
10+
asset_path TEXT,
11+
lfid INTEGER, -- local file id of the object in the source asset
12+
identifier_type INTEGER,
13+
serialized_file_index INTEGER, -- references content_layout_serialized_files.file_index, or NULL
14+
output_lfid INTEGER, -- local file id of the object in its output serialized file
15+
is_root_asset INTEGER,
16+
PRIMARY KEY (object_id_hash)
17+
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Scenes referenced from each serialized file (LoadableSceneDependencies in the json).
2+
CREATE TABLE IF NOT EXISTS content_layout_loadable_scene_dependencies
3+
(
4+
serialized_file_index INTEGER, -- references content_layout_serialized_files.file_index
5+
scene_path TEXT -- matches content_layout_loadable_scenes.path
6+
);

0 commit comments

Comments
 (0)