Skip to content

Commit c643ac8

Browse files
Analyze - Support BuildReport files (#45)
Adds comprehensive support for analyzing Unity BuildReport files, enabling detailed inspection of build contents and source asset tracking.
1 parent a0c80e0 commit c643ac8

21 files changed

+6154
-10
lines changed

AGENTS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ dotnet test --filter "FullyQualifiedName~SerializedFile"
4747

4848
Test projects: UnityFileSystem.Tests, Analyzer.Tests, UnityDataTool.Tests, TestCommon (helper library)
4949

50+
### Code Style
51+
52+
#### Comments
53+
54+
* Write comments that explain "why". A few high level comments explaining the purpose of classes or methods is very helpful. Comments explaining tricky code are also helpful.
55+
* Avoid comments that are redundant with the code. Do not comment before each line of code explaining what it does unless there is something that is not obvious going on.
56+
* Do not use formal C# XML format when commenting methods, unless it is in an important interface class like UnityFileSystem.
57+
58+
#### Formatting
59+
60+
To repair white space or style issues, run:
61+
62+
```
63+
dotnet format whitespace . --folder
64+
dotnet format style
65+
```
66+
5067
### Running the Tool
5168
```bash
5269
# Show all commands

Analyzer/Properties/Resources.Designer.cs

Lines changed: 124 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Analyzer/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@
127127
<data name="AudioClip" type="System.Resources.ResXFileRef, System.Windows.Forms">
128128
<value>..\Resources\AudioClip.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
129129
</data>
130+
<data name="BuildReport" type="System.Resources.ResXFileRef, System.Windows.Forms">
131+
<value>..\Resources\BuildReport.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
132+
</data>
130133
<data name="Finalize" type="System.Resources.ResXFileRef, System.Windows.Forms">
131134
<value>..\Resources\Finalize.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
132135
</data>
@@ -226,4 +229,7 @@
226229
<data name="MonoScript" type="System.Resources.ResXFileRef, System.Windows.Forms">
227230
<value>..\Resources\MonoScript.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
228231
</data>
232+
<data name="PackedAssets" type="System.Resources.ResXFileRef, System.Windows.Forms">
233+
<value>..\Resources\PackedAssets.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
234+
</data>
229235
</root>

Analyzer/Resources/BuildReport.sql

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
CREATE TABLE IF NOT EXISTS build_reports(
2+
id INTEGER,
3+
build_type TEXT,
4+
build_result TEXT,
5+
platform_name TEXT,
6+
subtarget INTEGER,
7+
start_time TEXT,
8+
end_time TEXT,
9+
total_time_seconds INTEGER,
10+
total_size INTEGER,
11+
build_guid TEXT,
12+
total_errors INTEGER,
13+
total_warnings INTEGER,
14+
options INTEGER,
15+
asset_bundle_options INTEGER,
16+
output_path TEXT,
17+
crc INTEGER,
18+
PRIMARY KEY (id)
19+
);
20+
21+
CREATE TABLE IF NOT EXISTS build_report_files(
22+
build_report_id INTEGER NOT NULL,
23+
file_index INTEGER NOT NULL,
24+
path TEXT NOT NULL,
25+
role TEXT NOT NULL,
26+
size INTEGER NOT NULL,
27+
PRIMARY KEY (build_report_id, file_index),
28+
FOREIGN KEY (build_report_id) REFERENCES build_reports(id)
29+
);
30+
31+
CREATE TABLE IF NOT EXISTS build_report_archive_contents(
32+
build_report_id INTEGER NOT NULL,
33+
assetbundle TEXT NOT NULL,
34+
assetbundle_content TEXT NOT NULL,
35+
PRIMARY KEY (build_report_id, assetbundle_content),
36+
FOREIGN KEY (build_report_id) REFERENCES build_reports(id)
37+
);
38+
39+
CREATE VIEW build_report_files_view AS
40+
SELECT
41+
o.serialized_file,
42+
br.id AS build_report_id,
43+
br.build_type,
44+
br.platform_name,
45+
brf.file_index,
46+
brf.path,
47+
brf.role,
48+
brf.size
49+
FROM build_report_files brf
50+
INNER JOIN build_reports br ON brf.build_report_id = br.id
51+
INNER JOIN object_view o ON br.id = o.id;
52+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
CREATE TABLE IF NOT EXISTS build_report_packed_assets(
2+
id INTEGER,
3+
path TEXT,
4+
file_header_size INTEGER,
5+
PRIMARY KEY (id)
6+
);
7+
8+
CREATE TABLE IF NOT EXISTS build_report_source_assets(
9+
id INTEGER PRIMARY KEY AUTOINCREMENT,
10+
source_asset_guid TEXT NOT NULL,
11+
build_time_asset_path TEXT NOT NULL,
12+
UNIQUE(source_asset_guid, build_time_asset_path)
13+
);
14+
15+
CREATE TABLE IF NOT EXISTS build_report_packed_asset_info(
16+
packed_assets_id INTEGER,
17+
object_id INTEGER,
18+
type INTEGER,
19+
size INTEGER,
20+
offset INTEGER,
21+
source_asset_id INTEGER NOT NULL,
22+
FOREIGN KEY (packed_assets_id) REFERENCES build_report_packed_assets(id),
23+
FOREIGN KEY (source_asset_id) REFERENCES build_report_source_assets(id)
24+
);
25+
26+
CREATE VIEW build_report_packed_assets_view AS
27+
SELECT
28+
pa.id,
29+
o.object_id,
30+
brac.assetbundle,
31+
pa.path,
32+
pa.file_header_size,
33+
br_obj.id as build_report_id,
34+
sf.name as build_report_filename
35+
FROM build_report_packed_assets pa
36+
INNER JOIN objects o ON pa.id = o.id
37+
INNER JOIN serialized_files sf ON o.serialized_file = sf.id
38+
LEFT JOIN objects br_obj ON o.serialized_file = br_obj.serialized_file AND br_obj.type = 1125
39+
LEFT JOIN build_report_archive_contents brac ON br_obj.id = brac.build_report_id AND pa.path = brac.assetbundle_content;
40+
41+
CREATE VIEW build_report_packed_asset_contents_view AS
42+
SELECT
43+
sf.name as serialized_file,
44+
brac.assetbundle,
45+
pa.path,
46+
pac.packed_assets_id,
47+
pac.object_id,
48+
pac.type,
49+
pac.size,
50+
pac.offset,
51+
sa.source_asset_guid,
52+
sa.build_time_asset_path,
53+
br_obj.id as build_report_id
54+
FROM build_report_packed_asset_info pac
55+
LEFT JOIN build_report_packed_assets pa ON pac.packed_assets_id = pa.id
56+
LEFT JOIN objects o ON o.id = pa.id
57+
INNER JOIN serialized_files sf ON o.serialized_file = sf.id
58+
LEFT JOIN build_report_source_assets sa ON pac.source_asset_id = sa.id
59+
LEFT JOIN objects br_obj ON o.serialized_file = br_obj.serialized_file AND br_obj.type = 1125
60+
LEFT JOIN build_report_archive_contents brac ON br_obj.id = brac.build_report_id AND pa.path = brac.assetbundle_content;
61+

0 commit comments

Comments
 (0)