mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 05:57:59 +01:00
Merge bitcoin/bitcoin#29494: build: Assume HAVE_CONFIG_H, Add IWYU pragma keep to bitcoin-config.h includes
fa09451f8eAdd lint check for bitcoin-config.h include IWYU pragma (MarcoFalke)dddd40ba82scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes (MarcoFalke) Pull request description: The `bitcoin-config.h` includes have issues: * The header is incompatible with iwyu, because symbols may be defined or not defined. So the `IWYU pragma: keep` is needed to keep the include when a symbol is not defined on a platform. Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29408#issuecomment-1948959711 * Guarding the includes by `HAVE_CONFIG_H` is verbose and brittle. Now that all build config dependencies have been removed from low level headers, the benefits are questionable, and the guard can be removed. The linter could also be tricked by guarding the include by `#if defined(HAVE_C0NFIG_H)` (`O` replaced by `0`). Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29404#discussion_r1483189853 . ACKs for top commit: achow101: ACKfa09451f8eTheCharlatan: ACKfa09451f8ehebasto: re-ACKfa09451f8e, only rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/29494#pullrequestreview-2028864535) (`timedata.cpp` removed in https://github.com/bitcoin/bitcoin/pull/29623). Tree-SHA512: 47cb973f7f24bc625acc4e78683371863675d186780236d55d886cf4130e05a78bb04f1d731aae7088313b8e963a9677cc77cf518187dbd99d776f6421ca9b52
This commit is contained in:
@@ -178,7 +178,6 @@ Please add any false positives, such as subtrees, or externally sourced files to
|
||||
|
||||
fn lint_includes_build_config() -> LintResult {
|
||||
let config_path = "./src/config/bitcoin-config.h.in";
|
||||
let include_directive = "#include <config/bitcoin-config.h>";
|
||||
if !Path::new(config_path).is_file() {
|
||||
assert!(Command::new("./autogen.sh")
|
||||
.status()
|
||||
@@ -235,7 +234,11 @@ fn lint_includes_build_config() -> LintResult {
|
||||
} else {
|
||||
"--files-with-matches"
|
||||
},
|
||||
include_directive,
|
||||
if mode {
|
||||
"^#include <config/bitcoin-config.h> // IWYU pragma: keep$"
|
||||
} else {
|
||||
"#include <config/bitcoin-config.h>" // Catch redundant includes with and without the IWYU pragma
|
||||
},
|
||||
"--",
|
||||
])
|
||||
.args(defines_files.lines())
|
||||
@@ -256,6 +259,11 @@ even though bitcoin-config.h indicates that a faster feature is available and sh
|
||||
|
||||
If you are unsure which symbol is used, you can find it with this command:
|
||||
git grep --perl-regexp '{}' -- file_name
|
||||
|
||||
Make sure to include it with the IWYU pragma. Otherwise, IWYU may falsely instruct to remove the
|
||||
include again.
|
||||
|
||||
#include <config/bitcoin-config.h> // IWYU pragma: keep
|
||||
"#,
|
||||
defines_regex
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user