build: enable cmake workflow presets (#21860)

Workflow presets allows combining configure, build, test and packaging
steps and makes it possible to run everything in a single command. So

cmake --preset iwyu
cmake --build --preset iwyu

instead becomes

cmake --workflow --preset iwyu

Workflow presets requires at least cmake version 3.25 to use.
This commit is contained in:
dundargoc 2023-01-19 10:34:45 +01:00 committed by GitHub
parent 6e3890f4ce
commit 00a976129b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 24 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": 3, "version": 6,
"configurePresets": [ "configurePresets": [
{ {
"name": "base", "name": "base",
@ -14,9 +14,7 @@
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo" "CMAKE_BUILD_TYPE": "RelWithDebInfo"
}, },
"inherits": [ "inherits": ["base"]
"base"
]
}, },
{ {
"name": "debug", "name": "debug",
@ -25,9 +23,7 @@
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug" "CMAKE_BUILD_TYPE": "Debug"
}, },
"inherits": [ "inherits": ["base"]
"base"
]
}, },
{ {
"name": "release", "name": "release",
@ -36,9 +32,7 @@
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Release" "CMAKE_BUILD_TYPE": "Release"
}, },
"inherits": [ "inherits": ["base"]
"base"
]
}, },
{ {
"name": "windows-default", "name": "windows-default",
@ -54,9 +48,7 @@
}, },
"vendor": { "vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": { "microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "hostOS": ["Windows"]
"Windows"
]
} }
}, },
"condition": { "condition": {
@ -64,9 +56,7 @@
"lhs": "${hostSystemName}", "lhs": "${hostSystemName}",
"rhs": "Windows" "rhs": "Windows"
}, },
"inherits": [ "inherits": ["base"]
"base"
]
}, },
{ {
"name": "iwyu", "name": "iwyu",
@ -75,9 +65,7 @@
"cacheVariables": { "cacheVariables": {
"ENABLE_IWYU": "ON" "ENABLE_IWYU": "ON"
}, },
"inherits": [ "inherits": ["base"]
"base"
]
} }
], ],
"buildPresets": [ "buildPresets": [
@ -106,5 +94,20 @@
"name": "iwyu", "name": "iwyu",
"configurePreset": "iwyu" "configurePreset": "iwyu"
} }
],
"workflowPresets": [
{
"name": "iwyu",
"steps": [
{
"type": "configure",
"name": "iwyu"
},
{
"type": "build",
"name": "iwyu"
}
]
}
] ]
} }

View File

@ -246,10 +246,9 @@ You can lint a single file (but this will _not_ exclude legacy errors):
For managing includes in C files, use [include-what-you-use]. For managing includes in C files, use [include-what-you-use].
- [Install include-what-you-use][include-what-you-use-install] - [Install include-what-you-use][include-what-you-use-install]
- To see which includes needs fixing just use the cmake preset `iwyu`: - To see which includes needs fixing use the cmake preset `iwyu`:
``` ```
cmake --preset iwyu cmake --workflow --preset iwyu
cmake --build --preset iwyu
``` ```
- There's also a make target that automatically fixes the suggestions from - There's also a make target that automatically fixes the suggestions from
IWYU: IWYU:

View File

@ -136,8 +136,7 @@ lintlua lintsh lintc check-single-includes generated-sources lintcommit lint for
test: functionaltest unittest test: functionaltest unittest
iwyu: build/.ran-cmake iwyu: build/.ran-cmake
cmake --preset iwyu cmake --workflow --fresh --preset iwyu > build/iwyu.log
cmake --build --preset iwyu > build/iwyu.log
iwyu-fix-includes --only_re="src/nvim" --ignore_re="src/nvim/(auto|map.h|eval/encode.c)" --safe_headers < build/iwyu.log iwyu-fix-includes --only_re="src/nvim" --ignore_re="src/nvim/(auto|map.h|eval/encode.c)" --safe_headers < build/iwyu.log
cmake -B build -U ENABLE_IWYU cmake -B build -U ENABLE_IWYU