option specially but shouldn't, since the option has another meaning for your
compiler than what ccache thinks.
+See also <<config_ignore_options,*ignore_options*>>.
+
== Configuration
*ignore_options* (*CCACHE_IGNOREOPTIONS*)::
This option is a space-delimited list of compiler options that ccache will
- exclude from the hash. Excluding a compiler option from the hash can be
- useful when you know it doesn't affect the result (but ccache doesn't know
- that), or when it does and you don't care. If a compiler option in the list
- is suffixed with an asterisk (`*`) it will be matched as a prefix. For
- example, `+-fmessage-length=*+` will match both `-fmessage-length=20` and
- `-fmessage-length=70`.
+ ignore. Entries in the list can optionally end with an asterisk (`*`) to
+ matching any option suffix. For example, `+-fmessage-length=*+` will match
+ both `-fmessage-length=20` and `-fmessage-length=70`. A matching compiler
+ option will neither be interpreted specially nor be part of the input hash.
+ Ignoring a compiler option from the hash can be useful when you know it
+ doesn't affect the result (and ccache doesn't know that), or when it does
+ and you don't care. See also _<<Extra options>>_.
[#config_inode_cache]
*inode_cache* (*CCACHE_INODECACHE* or *CCACHE_NOINODECACHE*, see _<<Boolean values>>_ above)::
ArgumentProcessingState& state)
{
size_t& i = args_index;
- // The user knows best: just swallow the next arg.
+
+ if (option_should_be_ignored(args[i], ctx.ignore_options())) {
+ LOG("Not processing ignored option: {}", args[i]);
+ state.common_args.push_back(args[i]);
+ return Statistic::none;
+ }
+
if (args[i] == "--ccache-skip") {
i++;
if (i == args.size()) {
state.hash_actual_cwd,
};
}
+
+bool
+option_should_be_ignored(const std::string& arg,
+ const std::vector<std::string>& patterns)
+{
+ return std::any_of(
+ patterns.cbegin(), patterns.cend(), [&arg](const auto& pattern) {
+ const auto& prefix =
+ std::string_view(pattern).substr(0, pattern.length() - 1);
+ return (
+ pattern == arg
+ || (util::ends_with(pattern, "*") && util::starts_with(arg, prefix)));
+ });
+}
-// Copyright (C) 2020-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
#include <core/Statistic.hpp>
#include <optional>
+#include <string>
+#include <vector>
class Context;
}
ProcessArgsResult process_args(Context& ctx);
+
+bool option_should_be_ignored(const std::string& arg,
+ const std::vector<std::string>& patterns);
return {};
}
-static bool
-option_should_be_ignored(const std::string& arg,
- const std::vector<std::string>& patterns)
-{
- return std::any_of(
- patterns.cbegin(), patterns.cend(), [&arg](const auto& pattern) {
- const auto& prefix =
- std::string_view(pattern).substr(0, pattern.length() - 1);
- return (
- pattern == arg
- || (util::ends_with(pattern, "*") && util::starts_with(arg, prefix)));
- });
-}
-
static std::tuple<std::optional<std::string_view>,
std::optional<std::string_view>>
get_option_and_value(std::string_view option, const Args& args, size_t& i)