|
|
|
@ -29,7 +29,7 @@ fn get_linter_list() -> Vec<&'static Linter> {
|
|
|
|
|
lint_fn: lint_doc
|
|
|
|
|
},
|
|
|
|
|
&Linter {
|
|
|
|
|
description: "Check that no symbol from bitcoin-config.h is used without the header being included",
|
|
|
|
|
description: "Check that no symbol from bitcoin-build-config.h is used without the header being included",
|
|
|
|
|
name: "includes_build_config",
|
|
|
|
|
lint_fn: lint_includes_build_config
|
|
|
|
|
},
|
|
|
|
@ -395,7 +395,7 @@ Please add any false positives, such as subtrees, or externally sourced files to
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn lint_includes_build_config() -> LintResult {
|
|
|
|
|
let config_path = "./cmake/bitcoin-config.h.in";
|
|
|
|
|
let config_path = "./cmake/bitcoin-build-config.h.in";
|
|
|
|
|
let defines_regex = format!(
|
|
|
|
|
r"^\s*(?!//).*({})",
|
|
|
|
|
check_output(Command::new("grep").args(["define", "--", config_path]))
|
|
|
|
@ -429,7 +429,7 @@ fn lint_includes_build_config() -> LintResult {
|
|
|
|
|
])
|
|
|
|
|
.args(get_pathspecs_exclude_subtrees())
|
|
|
|
|
.args([
|
|
|
|
|
// These are exceptions which don't use bitcoin-config.h, rather the Makefile.am adds
|
|
|
|
|
// These are exceptions which don't use bitcoin-build-config.h, rather the Makefile.am adds
|
|
|
|
|
// these cppflags manually.
|
|
|
|
|
":(exclude)src/crypto/sha256_arm_shani.cpp",
|
|
|
|
|
":(exclude)src/crypto/sha256_avx2.cpp",
|
|
|
|
@ -447,9 +447,9 @@ fn lint_includes_build_config() -> LintResult {
|
|
|
|
|
"--files-with-matches"
|
|
|
|
|
},
|
|
|
|
|
if mode {
|
|
|
|
|
"^#include <config/bitcoin-config.h> // IWYU pragma: keep$"
|
|
|
|
|
"^#include <bitcoin-build-config.h> // IWYU pragma: keep$"
|
|
|
|
|
} else {
|
|
|
|
|
"#include <config/bitcoin-config.h>" // Catch redundant includes with and without the IWYU pragma
|
|
|
|
|
"#include <bitcoin-build-config.h>" // Catch redundant includes with and without the IWYU pragma
|
|
|
|
|
},
|
|
|
|
|
"--",
|
|
|
|
|
])
|
|
|
|
@ -463,11 +463,11 @@ fn lint_includes_build_config() -> LintResult {
|
|
|
|
|
return Err(format!(
|
|
|
|
|
r#"
|
|
|
|
|
^^^
|
|
|
|
|
One or more files use a symbol declared in the bitcoin-config.h header. However, they are not
|
|
|
|
|
One or more files use a symbol declared in the bitcoin-build-config.h header. However, they are not
|
|
|
|
|
including the header. This is problematic, because the header may or may not be indirectly
|
|
|
|
|
included. If the indirect include were to be intentionally or accidentally removed, the build could
|
|
|
|
|
still succeed, but silently be buggy. For example, a slower fallback algorithm could be picked,
|
|
|
|
|
even though bitcoin-config.h indicates that a faster feature is available and should be used.
|
|
|
|
|
even though bitcoin-build-config.h indicates that a faster feature is available and should be used.
|
|
|
|
|
|
|
|
|
|
If you are unsure which symbol is used, you can find it with this command:
|
|
|
|
|
git grep --perl-regexp '{}' -- file_name
|
|
|
|
@ -475,7 +475,7 @@ 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
|
|
|
|
|
#include <bitcoin-build-config.h> // IWYU pragma: keep
|
|
|
|
|
"#,
|
|
|
|
|
defines_regex
|
|
|
|
|
));
|
|
|
|
@ -484,7 +484,7 @@ include again.
|
|
|
|
|
if redundant {
|
|
|
|
|
return Err(r#"
|
|
|
|
|
^^^
|
|
|
|
|
None of the files use a symbol declared in the bitcoin-config.h header. However, they are including
|
|
|
|
|
None of the files use a symbol declared in the bitcoin-build-config.h header. However, they are including
|
|
|
|
|
the header. Consider removing the unused include.
|
|
|
|
|
"#
|
|
|
|
|
.to_string());
|
|
|
|
|