Skip to content

Commit 4b39bb3

Browse files
scripts: Add HTML build report script
This change adds a script to generate an HTML report, invoked via west, providing a consolidated and user-friendly view of various build artifacts and metrics. This includes footprint information (as both tables and plots), configuration tracing, sys init levels, an interactive devicetree browser, and more. Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
1 parent 6159cb3 commit 4b39bb3

File tree

20 files changed

+2041
-12
lines changed

20 files changed

+2041
-12
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
build*/
1818
!doc/build/
1919
!scripts/build
20+
!scripts/buildreport
2021
!share/sysbuild/build
2122
!tests/drivers/build_all
2223
!scripts/pylib/build_helpers

‎cmake/reports/CMakeLists.txt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,14 @@ if(NOT ${PAHOLE} STREQUAL PAHOLE-NOTFOUND)
156156
USES_TERMINAL
157157
)
158158
endif()
159+
160+
add_custom_target(
161+
buildreport
162+
${PYTHON_EXECUTABLE}
163+
${ZEPHYR_BASE}/scripts/buildreport/buildreport.py
164+
--output ${CMAKE_BINARY_DIR}/report
165+
--zephyr-base ${ZEPHYR_BASE}
166+
${CMAKE_BINARY_DIR}
167+
DEPENDS ${logical_target_for_zephyr_elf}
168+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
169+
)

‎cmake/usage/usage.cmake‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ message(" ram_plot - Build and create RAM usage in a sunburst chart as a vi
3333
message(" rom_plot - Build and create ROM usage in a sunburst chart as a visual representation")
3434
message(" traceconfig - Generate a file in the build directory that details how each symbol got its final value")
3535
message(" footprint - Create JSON RAM/ROM usage report in the build directory")
36+
message(" buildreport - Generate an HTML report with footprint, traceconfig, initlevels, devicetree, and other details")
3637
message(" initlevels - Display the initialization sequence")
3738
message(" boards - Display supported boards")
3839
message(" shields - Display supported shields")
58.5 KB
Loading

‎doc/develop/optimizations/tools.rst‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Optimization Tools
55

66
The available optimization tools let you analyse :ref:`footprint_tools`
77
and :ref:`data_structure_tools` using different build system targets.
8+
An :ref:`HTML report <build_report>` can be also be generated for a
9+
user-friendly view of build artifacts and metrics.
810

911
.. _footprint_tools:
1012

@@ -300,3 +302,37 @@ Pahole will generate something similar to the output below in the console::
300302
};
301303
...
302304
...
305+
306+
.. _build_report:
307+
308+
Build Report
309+
************
310+
311+
An HTML build report can be generated that consolidates the various tool
312+
outputs and artifacts into one simple view. In addition to a basic summary of
313+
the build results, the following details are included:
314+
315+
* Full memory reports (ram, rom) in drill-down table form as well as
316+
:ref:`plots <footprint_tools_plot>` (as per the ``footprint``, ``ram_plot``,
317+
and ``rom_plot`` build targets).
318+
* Kconfig symbol values and sources (as per the ``traceconfig`` build target).
319+
* Init-levels with function names, and report on any priority issues with sys-init
320+
against devicetree (as per the ``initlevels`` build target).
321+
* Navigable devicetree view with property values and details from any bindings.
322+
323+
Use the ``buildreport`` target with your board, as in the following example.
324+
If you are using :ref:`sysbuild`, see :ref:`sysbuild_dedicated_image_build_targets` instead.
325+
326+
.. zephyr-app-commands::
327+
:tool: all
328+
:zephyr-app: samples/hello_world
329+
:board: reel_board
330+
:goals: buildreport
331+
332+
This will generate the following output file::
333+
334+
build/report/index.html
335+
336+
.. image:: build_report.png
337+
:align: center
338+
:alt: Build report

‎scripts/build/check_init_priorities.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ def check_edt(self):
343343
for dep in dev.depends_on:
344344
self._check_dep(dev_ord, dep.dep_ordinal)
345345

346+
@property
347+
def initlevels(self):
348+
"""Get the dictionary of initlevels."""
349+
return self._obj.initlevels
350+
346351
def print_initlevels(self):
347352
for level, calls in self._obj.initlevels.items():
348353
print(level)

0 commit comments

Comments
 (0)