+++ /dev/null
-FROM ubuntu:14.04
-
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- asciidoc \
- bash \
- build-essential \
- ccache \
- clang-3.4 \
- curl \
- docbook-xml \
- docbook-xsl \
- elfutils \
- g++-multilib \
- ninja-build \
- wget \
- xsltproc \
- && rm -rf /var/lib/apt/lists/*
-
-# Redirect all compilers to ccache.
-RUN for t in gcc g++ cc c++ clang clang++; do ln -vs /usr/bin/ccache /usr/local/bin/$t; done
-
-# The distribution's CMake it too old (2.8.12.2).
-RUN curl -sSL https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz | sudo tar -xzC /opt \
- && cp -a /opt/cmake-3.5.2-Linux-x86_64/bin /usr/local \
- && cp -a /opt/cmake-3.5.2-Linux-x86_64/share /usr/local
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
{
m_args.erase(std::remove_if(m_args.begin(),
m_args.end(),
- [&prefix](const std::string& s) {
+ [&prefix](const auto& s) {
return Util::starts_with(s, prefix);
}),
m_args.end());
bool
Config::update_from_file(const std::string& path)
{
- return parse_config_file(path,
- [&](const std::string& /*line*/,
- const std::string& key,
- const std::string& value) {
- if (!key.empty()) {
- set_item(key, value, nullopt, false, path);
- }
- });
+ return parse_config_file(
+ path, [&](const auto& /*line*/, const auto& key, const auto& value) {
+ if (!key.empty()) {
+ this->set_item(key, value, nullopt, false, path);
+ }
+ });
}
void
AtomicFile output(resolved_path, AtomicFile::Mode::text);
bool found = false;
- if (!parse_config_file(path,
- [&](const std::string& c_line,
- const std::string& c_key,
- const std::string& /*c_value*/) {
- if (c_key == key) {
- output.write(FMT("{} = {}\n", key, value));
- found = true;
- } else {
- output.write(FMT("{}\n", c_line));
- }
- })) {
+ if (!parse_config_file(
+ path,
+ [&](const auto& c_line, const auto& c_key, const auto& /*c_value*/) {
+ if (c_key == key) {
+ output.write(FMT("{} = {}\n", key, value));
+ found = true;
+ } else {
+ output.write(FMT("{}\n", c_line));
+ }
+ })) {
throw Error("failed to open {}: {}", path, strerror(errno));
}
}
bool found = false;
- const bool success = with_bucket(key_digest, [&](Bucket* const bucket) {
+ const bool success = with_bucket(key_digest, [&](const auto bucket) {
for (uint32_t i = 0; i < k_num_entries; ++i) {
if (bucket->entries[i].key_digest == key_digest) {
if (i > 0) {
return false;
}
- const bool success = with_bucket(key_digest, [&](Bucket* const bucket) {
+ const bool success = with_bucket(key_digest, [&](const auto bucket) {
memmove(&bucket->entries[1],
&bucket->entries[0],
sizeof(Entry) * (k_num_entries - 1));
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
time_t last_updated = 0;
// Add up the stats in each directory.
- for_each_level_1_and_2_stats_file(
- config.cache_dir(), [&](const std::string& path) {
- counters.set(Statistic::stats_zeroed_timestamp, 0); // Don't add
- counters.increment(Statistics::read(path));
- zero_timestamp = std::max(counters.get(Statistic::stats_zeroed_timestamp),
- zero_timestamp);
- last_updated = std::max(last_updated, Stat::stat(path).mtime());
- });
+ for_each_level_1_and_2_stats_file(config.cache_dir(), [&](const auto& path) {
+ counters.set(Statistic::stats_zeroed_timestamp, 0); // Don't add
+ counters.increment(Statistics::read(path));
+ zero_timestamp =
+ std::max(counters.get(Statistic::stats_zeroed_timestamp), zero_timestamp);
+ last_updated = std::max(last_updated, Stat::stat(path).mtime());
+ });
counters.set(Statistic::stats_zeroed_timestamp, zero_timestamp);
return std::make_pair(counters, last_updated);
const auto path_suffix = std::string(original_path.substr(path.length()));
const auto real_path = Util::real_path(std::string(path));
- const auto add_relpath_candidates = [&](nonstd::string_view path) {
+ const auto add_relpath_candidates = [&](auto path) {
const std::string normalized_path = Util::normalize_absolute_path(path);
relpath_candidates.push_back(
Util::get_relative_path(actual_cwd, normalized_path));
// Find best (i.e. shortest existing) match:
std::sort(relpath_candidates.begin(),
relpath_candidates.end(),
- [](const std::string& path1, const std::string& path2) {
+ [](const auto& path1, const auto& path2) {
return path1.length() < path2.length();
});
for (const auto& relpath : relpath_candidates) {
const auto stats_file =
FMT("{}/{}/stats", ctx.config.cache_dir(), level_string);
- auto counters =
- Statistics::update(stats_file, [&counter_updates](Counters& cs) {
- cs.increment(counter_updates);
- });
+ auto counters = Statistics::update(stats_file, [&counter_updates](auto& cs) {
+ cs.increment(counter_updates);
+ });
if (!counters) {
return nullopt;
}
const auto bucket = getpid() % 256;
const auto stats_file =
FMT("{}/{:x}/{:x}/stats", config.cache_dir(), bucket / 16, bucket % 16);
- Statistics::update(
- stats_file, [&ctx](Counters& cs) { cs.increment(ctx.counter_updates); });
+ Statistics::update(stats_file,
+ [&ctx](auto& cs) { cs.increment(ctx.counter_updates); });
return;
}
// Copyright (C) 2002-2006 Andrew Tridgell
-// Copyright (C) 2009-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2009-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
bool cleanup_performed)
{
const std::string stats_file = dir + "/stats";
- Statistics::update(stats_file, [=](Counters& cs) {
+ Statistics::update(stats_file, [=](auto& cs) {
if (cleanup_performed) {
cs.increment(Statistic::cleanups_performed);
}
{
Util::for_each_level_1_subdir(
ctx.config.cache_dir(),
- [&](const std::string& subdir,
- const Util::ProgressReceiver& sub_progress_receiver) {
+ [&](const auto& subdir, const auto& sub_progress_receiver) {
clean_up_dir(subdir, 0, 0, max_age, sub_progress_receiver);
},
progress_receiver);
}
// Sort according to modification time, oldest first.
- std::sort(
- files.begin(), files.end(), [](const CacheFile& f1, const CacheFile& f2) {
- return f1.lstat().mtime() < f2.lstat().mtime();
- });
+ std::sort(files.begin(), files.end(), [](const auto& f1, const auto& f2) {
+ return f1.lstat().mtime() < f2.lstat().mtime();
+ });
LOG("Before cleanup: {:.0f} KiB, {:.0f} files",
static_cast<double>(cache_size) / 1024,
{
Util::for_each_level_1_subdir(
config.cache_dir(),
- [&](const std::string& subdir,
- const Util::ProgressReceiver& sub_progress_receiver) {
+ [&](const auto& subdir, const auto& sub_progress_receiver) {
clean_up_dir(subdir,
config.max_size() / 16,
config.max_files() / 16,
-// Copyright (C) 2019-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
atomic_new_file.commit();
auto new_stat = Stat::stat(cache_file.path(), Stat::OnError::log);
- Statistics::update(stats_file, [=](Counters& cs) {
+ Statistics::update(stats_file, [=](auto& cs) {
cs.increment(Statistic::cache_size_kibibyte,
Util::size_change_kibibyte(old_stat, new_stat));
});
Util::for_each_level_1_subdir(
config.cache_dir(),
- [&](const std::string& subdir,
- const Util::ProgressReceiver& sub_progress_receiver) {
+ [&](const auto& subdir, const auto& sub_progress_receiver) {
const std::vector<CacheFile> files = Util::get_level_1_files(
subdir, [&](double progress) { sub_progress_receiver(progress / 2); });
Util::for_each_level_1_subdir(
ctx.config.cache_dir(),
- [&](const std::string& subdir,
- const Util::ProgressReceiver& sub_progress_receiver) {
+ [&](const auto& subdir, const auto& sub_progress_receiver) {
std::vector<CacheFile> files =
Util::get_level_1_files(subdir, [&](double progress) {
sub_progress_receiver(0.1 * progress);
std::vector<std::string> received_items;
- config.visit_items([&](const std::string& key,
- const std::string& value,
- const std::string& origin) {
- received_items.push_back(FMT("({}) {} = {}", origin, key, value));
- });
+ config.visit_items(
+ [&](const auto& key, const auto& value, const auto& origin) {
+ received_items.push_back(FMT("({}) {} = {}", origin, key, value));
+ });
std::vector<std::string> expected = {
"(test.conf) absolute_paths_in_stderr = true",
-// Copyright (C) 2011-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2011-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
Util::write_file("test", "0 1 2 3 27 5\n");
- auto counters = Statistics::update("test", [](Counters& cs) {
+ auto counters = Statistics::update("test", [](auto& cs) {
cs.increment(Statistic::internal_error, 1);
cs.increment(Statistic::cache_miss, 6);
});
TestContext test_context;
auto counters = Statistics::update(
- "test", [](Counters& cs) { cs.increment(Statistic::cache_miss, 1); });
+ "test", [](auto& cs) { cs.increment(Statistic::cache_miss, 1); });
REQUIRE(counters);
auto result = Statistics::get_result_message(*counters);
TestContext test_context;
auto counters = Statistics::update(
- "test", [](Counters& cs) { cs.increment(Statistic::cache_miss, 1); });
+ "test", [](auto& cs) { cs.increment(Statistic::cache_miss, 1); });
REQUIRE(counters);
auto result_id = Statistics::get_result_id(*counters);
-// Copyright (C) 2019-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
std::vector<std::string> actual;
Util::for_each_level_1_subdir(
"cache_dir",
- [&](const std::string& subdir, const Util::ProgressReceiver&) {
- actual.push_back(subdir);
- },
+ [&](const auto& subdir, const auto&) { actual.push_back(subdir); },
[](double) {});
std::vector<std::string> expected = {
// Files within a level are in arbitrary order, sort them to be able to
// verify them.
- std::sort(
- files.begin(), files.end(), [](const CacheFile& f1, const CacheFile& f2) {
- return f1.path() < f2.path();
- });
+ std::sort(files.begin(), files.end(), [](const auto& f1, const auto& f2) {
+ return f1.path() < f2.path();
+ });
CHECK(files[0].path() == os_path("0/1/file_b"));
CHECK(files[0].lstat().size() == 1);
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
const char* find_executable_return_string = nullptr)
{
const auto find_executable_stub =
- [&find_executable_return_string](
- const Context&, const std::string& s, const std::string&) -> std::string {
- return find_executable_return_string ? find_executable_return_string
- : "resolved_" + s;
- };
+ [&find_executable_return_string](const auto&, const auto& s, const auto&) {
+ return find_executable_return_string ? find_executable_return_string
+ : "resolved_" + s;
+ };
Context ctx;
ctx.config.set_compiler(config_compiler);