build(cmake,just): add ClangBuildAnalyzer recipe (#1874)

This commit is contained in:
Oleg Shparber
2026-05-13 14:59:40 +03:00
committed by GitHub
parent 7857be30b7
commit a26580c766
2 changed files with 53 additions and 0 deletions
+36
View File
@@ -72,6 +72,34 @@
{
"name": "testing",
"inherits": ["debug", "config-testing"]
},
{
"name": "timetrace-windows",
"inherits": ["release"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl",
"CMAKE_CXX_FLAGS": "/clang:-ftime-trace /EHsc"
}
},
{
"name": "timetrace-unix",
"inherits": ["release"],
"condition": {
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS": "-ftime-trace"
}
}
],
"buildPresets": [
@@ -102,6 +130,14 @@
{
"name": "testing",
"configurePreset": "testing"
},
{
"name": "timetrace-windows",
"configurePreset": "timetrace-windows"
},
{
"name": "timetrace-unix",
"configurePreset": "timetrace-unix"
}
],
"testPresets": [
+17
View File
@@ -9,6 +9,9 @@ set positional-arguments
# Default build preset; override with `just preset=name <recipe>`.
preset := env_var_or_default("PRESET", "dev")
# OS-specific preset selector for the build-time profiler.
timetrace_preset := if os() == "windows" { "timetrace-windows" } else { "timetrace-unix" }
[private]
default:
@just --list
@@ -50,6 +53,20 @@ lint *args: configure
clazy *args: configure
pwsh tools/run-clazy.ps1 {{args}}
# Profile build time with -ftime-trace and emit a ClangBuildAnalyzer report.
# Requires Clang (clang-cl on Windows) and ClangBuildAnalyzer on PATH.
[group('dev')]
analyze-build-time:
cmake --preset {{timetrace_preset}}
cmake --build --preset {{timetrace_preset}}
ClangBuildAnalyzer --all build/{{timetrace_preset}} build/{{timetrace_preset}}/cba.bin
ClangBuildAnalyzer --analyze build/{{timetrace_preset}}/cba.bin
# Re-emit the ClangBuildAnalyzer report from an existing timetrace build.
[group('dev')]
analyze-build-time-report:
ClangBuildAnalyzer --analyze build/{{timetrace_preset}}/cba.bin
# Remove all build directories.
[group('dev')]
clean: