]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
chore: Finalize renaming of namespaces to lowercase
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 21 Jul 2025 11:17:26 +0000 (13:17 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 21 Jul 2025 12:37:36 +0000 (14:37 +0200)
18 files changed:
CONTRIBUTING.md
src/ccache/argprocessing.cpp
src/ccache/ccache.cpp
src/ccache/core/cacheentry.cpp
src/ccache/core/mainoptions.cpp
src/ccache/core/result.cpp
src/ccache/core/result.hpp
src/ccache/core/resultextractor.cpp
src/ccache/core/resultextractor.hpp
src/ccache/core/resultinspector.cpp
src/ccache/core/resultinspector.hpp
src/ccache/core/resultretriever.cpp
src/ccache/core/resultretriever.hpp
src/ccache/depfile.cpp
src/ccache/depfile.hpp
src/ccache/storage/local/localstorage.cpp
src/ccache/storage/local/localstorage.hpp
unittest/test_depfile.cpp

index 0b679df4c527ee89fa84145653dc9976ed461949..f77dce991bff597e8737b4126c33f066059dc496 100644 (file)
@@ -94,8 +94,7 @@ Please follow these conventions:
 * Use `UpperCamelCase` for types (e.g. classes and structs).
 * Use `UPPER_CASE` names for macros and (non-class) enum values.
 * Use `snake_case` for other names (namespaces, functions, variables, enum class
-  values, etc.). (Namespaces used to be in `UpperCamelCase`; transition is work
-  in progress.)
+  values, etc.).
 * Use an `m_` prefix for non-public member variables.
 * Use a `g_` prefix for global mutable variables.
 * Use a `k_` prefix for global constants.
index 7122d294cd06ac1c1ec6582bcda81896077915aa..fcb2b8deb172d7bb0562d02972f32f97b5f7d0d4 100644 (file)
@@ -865,7 +865,7 @@ process_option_arg(const Context& ctx,
       args_info.dependency_target = "";
     }
     *args_info.dependency_target +=
-      is_mq ? Depfile::escape_filename(dep_target) : dep_target;
+      is_mq ? depfile::escape_filename(dep_target) : dep_target;
 
     return Statistic::none;
   }
@@ -1612,7 +1612,7 @@ process_args(Context& ctx)
       }
 
       args_info.dependency_target =
-        Depfile::escape_filename(util::pstr(dep_target).str());
+        depfile::escape_filename(util::pstr(dep_target).str());
     }
   }
 
index 1dce4eda51357c2942184439b8abf23826c2e4ca..4ab2eaccd6b8a97875da627b730c788f2f5fa7ae 100644 (file)
@@ -713,7 +713,7 @@ result_key_from_depfile(Context& ctx, Hash& hash)
   }
 
   bool seen_colon = false;
-  for (std::string_view token : Depfile::tokenize(*file_content)) {
+  for (std::string_view token : depfile::tokenize(*file_content)) {
     if (token.empty()) {
       seen_colon = false;
       continue;
@@ -936,8 +936,8 @@ find_coverage_file(const Context& ctx)
   // (in CWD) if -fprofile-dir=DIR is present (regardless of DIR) instead of the
   // traditional /dir/to/example.gcno.
 
-  fs::path mangled_form = core::Result::gcno_file_in_mangled_form(ctx);
-  fs::path unmangled_form = core::Result::gcno_file_in_unmangled_form(ctx);
+  fs::path mangled_form = core::result::gcno_file_in_mangled_form(ctx);
+  fs::path unmangled_form = core::result::gcno_file_in_unmangled_form(ctx);
   fs::path found_file;
   if (DirEntry(mangled_form).is_regular_file()) {
     LOG("Found coverage file {}", mangled_form);
@@ -966,29 +966,29 @@ write_result(Context& ctx,
              const util::Bytes& stdout_data,
              const util::Bytes& stderr_data)
 {
-  core::Result::Serializer serializer(ctx.config);
+  core::result::Serializer serializer(ctx.config);
 
   if (!stderr_data.empty()) {
-    serializer.add_data(core::Result::FileType::stderr_output, stderr_data);
+    serializer.add_data(core::result::FileType::stderr_output, stderr_data);
   }
   // Write stdout only after stderr (better with MSVC), as ResultRetriever
   // will later print process them in the order they are read.
   if (!stdout_data.empty()) {
-    serializer.add_data(core::Result::FileType::stdout_output, stdout_data);
+    serializer.add_data(core::result::FileType::stdout_output, stdout_data);
   }
   if (ctx.args_info.expect_output_obj
-      && !serializer.add_file(core::Result::FileType::object,
+      && !serializer.add_file(core::result::FileType::object,
                               ctx.args_info.output_obj)) {
     LOG("Object file {} missing", ctx.args_info.output_obj);
     return false;
   }
   if (ctx.args_info.generating_pch
-      && !serializer.add_file(core::Result::FileType::included_pch_file,
+      && !serializer.add_file(core::result::FileType::included_pch_file,
                               ctx.args_info.included_pch_file)) {
     LOG("PCH file {} missing", ctx.args_info.included_pch_file);
   }
   if (ctx.args_info.generating_dependencies
-      && !serializer.add_file(core::Result::FileType::dependency,
+      && !serializer.add_file(core::result::FileType::dependency,
                               ctx.args_info.output_dep)) {
     LOG("Dependency file {} missing", ctx.args_info.output_dep);
     return false;
@@ -1000,33 +1000,33 @@ write_result(Context& ctx,
       return false;
     }
     if (!serializer.add_file(coverage_file.mangled
-                               ? core::Result::FileType::coverage_mangled
-                               : core::Result::FileType::coverage_unmangled,
+                               ? core::result::FileType::coverage_mangled
+                               : core::result::FileType::coverage_unmangled,
                              coverage_file.path)) {
       LOG("Coverage file {} missing", coverage_file.path);
       return false;
     }
   }
   if (ctx.args_info.generating_stackusage
-      && !serializer.add_file(core::Result::FileType::stackusage,
+      && !serializer.add_file(core::result::FileType::stackusage,
                               ctx.args_info.output_su)) {
     LOG("Stack usage file {} missing", ctx.args_info.output_su);
     return false;
   }
   if (ctx.args_info.generating_callgraphinfo
-      && !serializer.add_file(core::Result::FileType::callgraph_info,
+      && !serializer.add_file(core::result::FileType::callgraph_info,
                               ctx.args_info.output_ci)) {
     LOG("Callgraph info file {} missing", ctx.args_info.output_ci);
     return false;
   }
   if (ctx.args_info.generating_ipa_clones
-      && !serializer.add_file(core::Result::FileType::ipa_clones,
+      && !serializer.add_file(core::result::FileType::ipa_clones,
                               ctx.args_info.output_ipa)) {
     LOG("IPA clones file {} missing", ctx.args_info.output_ipa);
     return false;
   }
   if (ctx.args_info.generating_diagnostics
-      && !serializer.add_file(core::Result::FileType::diagnostic,
+      && !serializer.add_file(core::result::FileType::diagnostic,
                               ctx.args_info.output_dia)) {
     LOG("Diagnostics file {} missing", ctx.args_info.output_dia);
     return false;
@@ -1035,13 +1035,13 @@ write_result(Context& ctx,
       // Only store .dwo file if it was created by the compiler (GCC and Clang
       // behave differently e.g. for "-gsplit-dwarf -g1").
       && DirEntry(ctx.args_info.output_dwo).is_regular_file()
-      && !serializer.add_file(core::Result::FileType::dwarf_object,
+      && !serializer.add_file(core::result::FileType::dwarf_object,
                               ctx.args_info.output_dwo)) {
     LOG("Split dwarf file {} missing", ctx.args_info.output_dwo);
     return false;
   }
   if (!ctx.args_info.output_al.empty()
-      && !serializer.add_file(core::Result::FileType::assembler_listing,
+      && !serializer.add_file(core::result::FileType::assembler_listing,
                               ctx.args_info.output_al)) {
     LOG("Assembler listing file {} missing", ctx.args_info.output_al);
     return false;
@@ -1289,7 +1289,7 @@ to_cache(Context& ctx,
   }
 
   if (ctx.args_info.generating_dependencies) {
-    Depfile::make_paths_relative_in_output_dep(ctx);
+    depfile::make_paths_relative_in_output_dep(ctx);
   }
 
   if (!ctx.args_info.expect_output_obj) {
@@ -2251,7 +2251,7 @@ calculate_result_and_manifest_key(Context& ctx,
   hash.hash(core::CacheEntry::k_format_version);
 
   hash.hash_delimiter("result version");
-  hash.hash(core::Result::k_format_version);
+  hash.hash(core::result::k_format_version);
 
   if (direct_mode) {
     hash.hash_delimiter("manifest version");
@@ -2384,7 +2384,7 @@ from_cache(Context& ctx, FromCacheCallMode mode, const Hash::Digest& result_key)
   try {
     core::CacheEntry cache_entry(cache_entry_data);
     cache_entry.verify_checksum();
-    core::Result::Deserializer deserializer(cache_entry.payload());
+    core::result::Deserializer deserializer(cache_entry.payload());
     core::ResultRetriever result_retriever(ctx, result_key);
     util::UmaskScope umask_scope(ctx.original_umask);
     deserializer.visit(result_retriever);
index 805fd8ab8b7d2ff32fec90c364b83587f7d6ad78..c64cdca1e9bcb243d7b587aa348f3d33b3ee1705 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2022-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2022-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -91,7 +91,7 @@ CacheEntry::Header::Header(const Config& config,
     compression_type(compression_type_from_config(config)),
     compression_level(compression_level_from_config(config)),
     self_contained(entry_type != CacheEntryType::result
-                   || !core::Result::Serializer::use_raw_files(config)),
+                   || !core::result::Serializer::use_raw_files(config)),
     creation_time(util::TimePoint::now().sec()),
     ccache_version(CCACHE_VERSION),
     namespace_(config.namespace_()),
index d0d2a5f9b2c6b41b250f3833233b41829b09ff71..e4507e8717821ebcd80778435ce8485f75dd087f 100644 (file)
@@ -238,7 +238,7 @@ inspect_path(const fs::path& path)
     break;
   }
   case core::CacheEntryType::result:
-    Result::Deserializer result_deserializer(payload);
+    result::Deserializer result_deserializer(payload);
     ResultInspector result_inspector(stdout);
     result_deserializer.visit(result_inspector);
     break;
@@ -651,7 +651,7 @@ process_main_options(int argc, const char* const* argv)
       core::CacheEntry cache_entry(*cache_entry_data);
       const auto payload = cache_entry.payload();
 
-      Result::Deserializer result_deserializer(payload);
+      result::Deserializer result_deserializer(payload);
       result_deserializer.visit(result_extractor);
       cache_entry.verify_checksum();
       return EXIT_SUCCESS;
index bd046069eb7315ed6ad50400f3bc3f18b2ab99a2..344f0bf95ad0c845fda614cc6f6417a7b5cc082a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -81,9 +81,9 @@ const uint8_t k_raw_file_marker = 1;
 const uint8_t k_max_raw_file_entries = 10;
 
 bool
-should_store_raw_file(const Config& config, core::Result::FileType type)
+should_store_raw_file(const Config& config, core::result::FileType type)
 {
-  if (!core::Result::Serializer::use_raw_files(config)) {
+  if (!core::result::Serializer::use_raw_files(config)) {
     return false;
   }
 
@@ -103,12 +103,12 @@ should_store_raw_file(const Config& config, core::Result::FileType type)
   // files that become large enough that it's of interest to clone or hard link
   // them, so we keep things simple for now. This will also save i-nodes in the
   // cache.
-  return type == core::Result::FileType::object;
+  return type == core::result::FileType::object;
 }
 
 } // namespace
 
-namespace core::Result {
+namespace core::result {
 
 const uint8_t k_format_version = 0;
 
@@ -338,4 +338,4 @@ Serializer::get_raw_files() const
   return m_raw_files;
 }
 
-} // namespace core::Result
+} // namespace core::result
index 2bf94222c8cfbe376767f2f09c00748549b04dec..9e577da19180a17c792ccccf9dbefbbe7e3e7fca 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -36,7 +36,7 @@ namespace core {
 
 class CacheEntryDataParser;
 
-namespace Result {
+namespace result {
 
 extern const uint8_t k_format_version;
 
@@ -186,6 +186,6 @@ private:
   std::vector<RawFile> m_raw_files;
 };
 
-} // namespace Result
+} // namespace result
 
 } // namespace core
index ed2cafaf6b6d2f1d1daa0e8bbe79c03515573742..afb7162780c35c0c7fa49a75feba835a29ea35ea 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -49,13 +49,13 @@ ResultExtractor::ResultExtractor(
 
 void
 ResultExtractor::on_embedded_file(uint8_t /*file_number*/,
-                                  Result::FileType file_type,
+                                  result::FileType file_type,
                                   nonstd::span<const uint8_t> data)
 {
-  std::string suffix = Result::file_type_to_string(file_type);
-  if (suffix == Result::k_unknown_file_type) {
+  std::string suffix = result::file_type_to_string(file_type);
+  if (suffix == result::k_unknown_file_type) {
     suffix =
-      FMT(".type_{}", static_cast<Result::UnderlyingFileTypeInt>(file_type));
+      FMT(".type_{}", static_cast<result::UnderlyingFileTypeInt>(file_type));
   } else if (suffix[0] == '<') {
     suffix[0] = '.';
     suffix.resize(suffix.length() - 1);
@@ -68,7 +68,7 @@ ResultExtractor::on_embedded_file(uint8_t /*file_number*/,
 
 void
 ResultExtractor::on_raw_file(uint8_t file_number,
-                             Result::FileType file_type,
+                             result::FileType file_type,
                              uint64_t file_size)
 {
   if (!m_get_raw_file_path) {
index 5be41a05e06af92c1938cff7dcbe2c01e64ed0dd..f99e89724b0a2ff661868c2a9125ce5f355247e2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -31,7 +31,7 @@
 namespace core {
 
 // This class extracts the parts of a result entry to a directory.
-class ResultExtractor : public Result::Deserializer::Visitor
+class ResultExtractor : public result::Deserializer::Visitor
 {
 public:
   using GetRawFilePathFunction = std::function<std::filesystem::path(uint8_t)>;
@@ -43,10 +43,10 @@ public:
     std::optional<GetRawFilePathFunction> get_raw_file_path = std::nullopt);
 
   void on_embedded_file(uint8_t file_number,
-                        Result::FileType file_type,
+                        result::FileType file_type,
                         nonstd::span<const uint8_t> data) override;
   void on_raw_file(uint8_t file_number,
-                   Result::FileType file_type,
+                   result::FileType file_type,
                    uint64_t file_size) override;
 
 private:
index ab81036061bd055f5ca73b95820534648cd827cf..f636c8699bb282b2b4f900c0cb3c896cfb1e643a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -30,7 +30,7 @@ ResultInspector::ResultInspector(FILE* stream)
 }
 
 void
-ResultInspector::on_header(const Result::Deserializer::Header& header)
+ResultInspector::on_header(const result::Deserializer::Header& header)
 {
   PRINT(m_stream, "Result format version: {}\n", header.format_version);
   PRINT(m_stream, "Number of files: {}\n", header.n_files);
@@ -38,25 +38,25 @@ ResultInspector::on_header(const Result::Deserializer::Header& header)
 
 void
 ResultInspector::on_embedded_file(uint8_t file_number,
-                                  Result::FileType file_type,
+                                  result::FileType file_type,
                                   nonstd::span<const uint8_t> data)
 {
   PRINT(m_stream,
         "Embedded file #{}: {} ({} bytes)\n",
         file_number,
-        Result::file_type_to_string(file_type),
+        result::file_type_to_string(file_type),
         data.size());
 }
 
 void
 ResultInspector::on_raw_file(uint8_t file_number,
-                             Result::FileType file_type,
+                             result::FileType file_type,
                              uint64_t file_size)
 {
   PRINT(m_stream,
         "Raw file #{}: {} ({} bytes)\n",
         file_number,
-        Result::file_type_to_string(file_type),
+        result::file_type_to_string(file_type),
         file_size);
 }
 
index 49b3368bcb50d822fff0d89689b6d45a69e9d989..da764a1fe50ddf4d910aae7f21f1e382765b5799 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
 namespace core {
 
 // This class writes information about the result entry to `stream`.
-class ResultInspector : public Result::Deserializer::Visitor
+class ResultInspector : public result::Deserializer::Visitor
 {
 public:
   ResultInspector(FILE* stream);
 
-  void on_header(const Result::Deserializer::Header& header) override;
+  void on_header(const result::Deserializer::Header& header) override;
 
   void on_embedded_file(uint8_t file_number,
-                        Result::FileType file_type,
+                        result::FileType file_type,
                         nonstd::span<const uint8_t> data) override;
   void on_raw_file(uint8_t file_number,
-                   Result::FileType file_type,
+                   result::FileType file_type,
                    uint64_t file_size) override;
 
 private:
index 5212016a84782c1d877e223df1b1dada29c23d35..866324832da29096c663c735ae2ce960b75856f9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -48,7 +48,7 @@ using util::DirEntry;
 
 namespace core {
 
-using Result::FileType;
+using result::FileType;
 
 ResultRetriever::ResultRetriever(const Context& ctx,
                                  std::optional<Hash::Digest> result_key)
@@ -64,7 +64,7 @@ ResultRetriever::on_embedded_file(uint8_t file_number,
 {
   LOG("Reading embedded entry #{} {} ({} bytes)",
       file_number,
-      Result::file_type_to_string(file_type),
+      result::file_type_to_string(file_type),
       data.size());
 
   if (file_type == FileType::stdout_output) {
@@ -100,7 +100,7 @@ ResultRetriever::on_raw_file(uint8_t file_number,
 {
   LOG("Reading raw entry #{} {} ({} bytes)",
       file_number,
-      Result::file_type_to_string(file_type),
+      result::file_type_to_string(file_type),
       file_size);
 
   if (!m_result_key) {
@@ -140,7 +140,7 @@ ResultRetriever::on_raw_file(uint8_t file_number,
     // Should never happen.
     LOG("Did not copy {} since destination path is unknown for type {}",
         raw_file_path,
-        static_cast<Result::UnderlyingFileTypeInt>(file_type));
+        static_cast<result::UnderlyingFileTypeInt>(file_type));
   }
 }
 
@@ -189,7 +189,7 @@ ResultRetriever::get_dest_path(FileType file_type) const
 
   case FileType::coverage_mangled:
     if (m_ctx.args_info.generating_coverage) {
-      return Result::gcno_file_in_mangled_form(m_ctx);
+      return result::gcno_file_in_mangled_form(m_ctx);
     }
     break;
 
index ab8ee0fbd774c78f1b4e9a0d234e0d74b430abe2..1c24efb4ef1c6a8194bbd37df0c35ed59dbc5571 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -33,7 +33,7 @@ class Context;
 namespace core {
 
 // This class retrieves a result entry to the local file system.
-class ResultRetriever : public Result::Deserializer::Visitor
+class ResultRetriever : public result::Deserializer::Visitor
 {
 public:
   class WriteError : public Error
@@ -47,17 +47,17 @@ public:
                   std::optional<Hash::Digest> result_key = std::nullopt);
 
   void on_embedded_file(uint8_t file_number,
-                        Result::FileType file_type,
+                        result::FileType file_type,
                         nonstd::span<const uint8_t> data) override;
   void on_raw_file(uint8_t file_number,
-                   Result::FileType file_type,
+                   result::FileType file_type,
                    uint64_t file_size) override;
 
 private:
   const Context& m_ctx;
   std::optional<Hash::Digest> m_result_key;
 
-  std::filesystem::path get_dest_path(Result::FileType file_type) const;
+  std::filesystem::path get_dest_path(result::FileType file_type) const;
 
   void write_dependency_file(const std::filesystem::path& path,
                              nonstd::span<const uint8_t> data);
index 5ebf23228f9d81230694e7e74db25f2ef08308c2..f3c0497492a96418927d15dbbe1a3239d4e71bf6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -35,7 +35,7 @@
 
 namespace fs = util::filesystem;
 
-namespace Depfile {
+namespace depfile {
 
 std::string
 escape_filename(std::string_view filename)
@@ -254,4 +254,4 @@ untokenize(const std::vector<std::string>& tokens)
   return result;
 }
 
-} // namespace Depfile
+} // namespace depfile
index bb0ac6d596724005761157e07cf4ce3799f5a10f..d3b69924261b88b64efee80652b6b4196ae0a1fd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -25,7 +25,7 @@ class Context;
 #include <string_view>
 #include <vector>
 
-namespace Depfile {
+namespace depfile {
 
 std::string escape_filename(std::string_view filename);
 
@@ -41,4 +41,4 @@ std::vector<std::string> tokenize(std::string_view text);
 // Return text from `tokens` that originate from `tokenize`.
 std::string untokenize(const std::vector<std::string>& tokens);
 
-} // namespace Depfile
+} // namespace depfile
index 2e97762f35c1a3d0339f408858d204985eb17715..20aa37af570f50eacb57b469bae3c387d18aabc5 100644 (file)
@@ -643,7 +643,7 @@ LocalStorage::get_raw_file_path(const Hash::Digest& result_key,
 void
 LocalStorage::put_raw_files(
   const Hash::Digest& key,
-  const std::vector<core::Result::Serializer::RawFile>& raw_files)
+  const std::vector<core::result::Serializer::RawFile>& raw_files)
 {
   const auto cache_file = look_up_cache_file(key, core::CacheEntryType::result);
   core::ensure_dir_exists(cache_file.path.parent_path());
index 01b8861acbfa266785c799196d886608f2841f9a..962cfed08f052d2963ef983191b8d3f43fa235fb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -88,7 +88,7 @@ public:
 
   void put_raw_files(
     const Hash::Digest& key,
-    const std::vector<core::Result::Serializer::RawFile>& raw_files);
+    const std::vector<core::result::Serializer::RawFile>& raw_files);
 
   // Clone, hard link or copy a file from `source` to `dest` depending on
   // settings in `ctx`. If cloning or hard linking cannot and should not be done
index f5c8b212600f48ed1c06ecf2d09bb2713da75a4a..0be8c53d30bfa7149294ae4958fd98f8aaab37cd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -33,21 +33,21 @@ namespace fs = util::filesystem;
 
 using TestUtil::TestContext;
 
-TEST_SUITE_BEGIN("Depfile");
+TEST_SUITE_BEGIN("depfile");
 
-TEST_CASE("Depfile::escape_filename")
+TEST_CASE("depfile::escape_filename")
 {
-  CHECK(Depfile::escape_filename("") == "");
-  CHECK(Depfile::escape_filename("foo") == "foo");
-  CHECK(Depfile::escape_filename("foo\\bar") == "foo\\\\bar");
-  CHECK(Depfile::escape_filename("foo#bar") == "foo\\#bar");
-  CHECK(Depfile::escape_filename("foo:bar") == "foo\\:bar");
-  CHECK(Depfile::escape_filename("foo bar") == "foo\\ bar");
-  CHECK(Depfile::escape_filename("foo\tbar") == "foo\\\tbar");
-  CHECK(Depfile::escape_filename("foo$bar") == "foo$$bar");
+  CHECK(depfile::escape_filename("") == "");
+  CHECK(depfile::escape_filename("foo") == "foo");
+  CHECK(depfile::escape_filename("foo\\bar") == "foo\\\\bar");
+  CHECK(depfile::escape_filename("foo#bar") == "foo\\#bar");
+  CHECK(depfile::escape_filename("foo:bar") == "foo\\:bar");
+  CHECK(depfile::escape_filename("foo bar") == "foo\\ bar");
+  CHECK(depfile::escape_filename("foo\tbar") == "foo\\\tbar");
+  CHECK(depfile::escape_filename("foo$bar") == "foo$$bar");
 }
 
-TEST_CASE("Depfile::rewrite_source_paths")
+TEST_CASE("depfile::rewrite_source_paths")
 {
   Context ctx;
 
@@ -59,27 +59,27 @@ TEST_CASE("Depfile::rewrite_source_paths")
     "\n"
     " {0}/bar/bar.h: \n"
     " {1}/fie.h:\n",
-    Depfile::escape_filename(util::pstr(cwd).str()),
-    Depfile::escape_filename(util::pstr(cwd.parent_path()).str()));
+    depfile::escape_filename(util::pstr(cwd).str()),
+    depfile::escape_filename(util::pstr(cwd.parent_path()).str()));
 
   SUBCASE("Base directory not in dep file content")
   {
     ctx.config.set_base_dir("/foo/bar");
-    CHECK(!Depfile::rewrite_source_paths(ctx, ""));
-    CHECK(!Depfile::rewrite_source_paths(ctx, content));
+    CHECK(!depfile::rewrite_source_paths(ctx, ""));
+    CHECK(!depfile::rewrite_source_paths(ctx, content));
   }
 
   SUBCASE("Base directory in dep file content but not matching")
   {
     ctx.config.set_base_dir((cwd.parent_path() / "other").string());
-    CHECK(!Depfile::rewrite_source_paths(ctx, ""));
-    CHECK(!Depfile::rewrite_source_paths(ctx, content));
+    CHECK(!depfile::rewrite_source_paths(ctx, ""));
+    CHECK(!depfile::rewrite_source_paths(ctx, content));
   }
 
   SUBCASE("Absolute paths under base directory rewritten")
   {
     ctx.config.set_base_dir(cwd.string());
-    const auto actual = Depfile::rewrite_source_paths(ctx, content);
+    const auto actual = depfile::rewrite_source_paths(ctx, content);
     const auto expected = FMT(
       "{0}/foo.o: \\\n"
       " bar.c \\\n"
@@ -87,26 +87,26 @@ TEST_CASE("Depfile::rewrite_source_paths")
       " {1}/fie.h\n"
       "{2}:\n"
       "{1}/fie.h:\n",
-      Depfile::escape_filename(util::pstr(cwd).str()),
-      Depfile::escape_filename(util::pstr(cwd.parent_path()).str()),
-      Depfile::escape_filename(
+      depfile::escape_filename(util::pstr(cwd).str()),
+      depfile::escape_filename(util::pstr(cwd.parent_path()).str()),
+      depfile::escape_filename(
         util::pstr(fs::path("bar/bar.h").lexically_normal()).str()));
     REQUIRE(actual);
     CHECK(*actual == expected);
   }
 }
 
-TEST_CASE("Depfile::tokenize")
+TEST_CASE("depfile::tokenize")
 {
   SUBCASE("Empty")
   {
-    auto result = Depfile::tokenize("");
+    auto result = depfile::tokenize("");
     CHECK(result.size() == 0);
   }
 
   SUBCASE("Simple")
   {
-    auto result = Depfile::tokenize("cat.o: meow meow purr");
+    auto result = depfile::tokenize("cat.o: meow meow purr");
     REQUIRE(result.size() == 6);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -118,7 +118,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Dollar sign followed by a dollar sign")
   {
-    auto result = Depfile::tokenize("cat.o: meow$$");
+    auto result = depfile::tokenize("cat.o: meow$$");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -128,7 +128,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Dollar sign followed by an alphabet")
   {
-    auto result = Depfile::tokenize("cat.o: meow$w");
+    auto result = depfile::tokenize("cat.o: meow$w");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -138,7 +138,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Backslash followed by a number sign or a colon")
   {
-    auto result = Depfile::tokenize("cat.o: meow\\# meow\\:");
+    auto result = depfile::tokenize("cat.o: meow\\# meow\\:");
     REQUIRE(result.size() == 5);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -149,7 +149,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Backslash followed by an alphabet")
   {
-    auto result = Depfile::tokenize("cat.o: meow\\w purr\\r");
+    auto result = depfile::tokenize("cat.o: meow\\w purr\\r");
     REQUIRE(result.size() == 5);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -160,7 +160,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Backslash followed by a space or a tab")
   {
-    auto result = Depfile::tokenize("cat.o: meow\\ meow purr\\\tpurr");
+    auto result = depfile::tokenize("cat.o: meow\\ meow purr\\\tpurr");
     REQUIRE(result.size() == 5);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -171,7 +171,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Backslashes followed by a space or a tab")
   {
-    auto result = Depfile::tokenize("cat.o: meow\\\\\\ meow purr\\\\ purr");
+    auto result = depfile::tokenize("cat.o: meow\\\\\\ meow purr\\\\ purr");
     REQUIRE(result.size() == 6);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -183,7 +183,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Backslash newline")
   {
-    auto result = Depfile::tokenize("cat.o: meow\\\nmeow\\\n purr\\\n\tpurr");
+    auto result = depfile::tokenize("cat.o: meow\\\nmeow\\\n purr\\\n\tpurr");
     REQUIRE(result.size() == 7);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -198,8 +198,8 @@ TEST_CASE("Depfile::tokenize")
   {
     // This is an invalid dependency file since it has multiple lines without
     // backslash, which is not valid Makefile syntax. However, the
-    // Depfile::tokenize's simplistic parser accepts them.
-    auto result = Depfile::tokenize("cat.o: meow\nmeow\npurr\n");
+    // depfile::tokenize's simplistic parser accepts them.
+    auto result = depfile::tokenize("cat.o: meow\nmeow\npurr\n");
     REQUIRE(result.size() == 8);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -213,7 +213,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Multiple entries")
   {
-    auto result = Depfile::tokenize(
+    auto result = depfile::tokenize(
       "foo.o bar.o: a.h \\\n"
       "  b.h\\\n"
       " c.h\n"
@@ -237,7 +237,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Trailing dollar sign")
   {
-    auto result = Depfile::tokenize("cat.o: meow$");
+    auto result = depfile::tokenize("cat.o: meow$");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -247,7 +247,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Trailing backslash")
   {
-    auto result = Depfile::tokenize("cat.o: meow\\");
+    auto result = depfile::tokenize("cat.o: meow\\");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -257,7 +257,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Trailing backslash newline")
   {
-    auto result = Depfile::tokenize("cat.o: meow\\\n");
+    auto result = depfile::tokenize("cat.o: meow\\\n");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -267,7 +267,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Space before the colon but not after")
   {
-    auto result = Depfile::tokenize("cat.o :meow");
+    auto result = depfile::tokenize("cat.o :meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -277,7 +277,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Space around the colon")
   {
-    auto result = Depfile::tokenize("cat.o    :    meow");
+    auto result = depfile::tokenize("cat.o    :    meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -287,7 +287,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("No space between colon and dependency")
   {
-    auto result = Depfile::tokenize("cat.o:meow");
+    auto result = depfile::tokenize("cat.o:meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -297,7 +297,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename (with backslashes in target)")
   {
-    auto result = Depfile::tokenize("e:\\cat.o: meow");
+    auto result = depfile::tokenize("e:\\cat.o: meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "e:\\cat.o");
     CHECK(result[1] == ":");
@@ -307,7 +307,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename (with backslashes in prerequisite)")
   {
-    auto result = Depfile::tokenize("cat.o: c:\\meow\\purr");
+    auto result = depfile::tokenize("cat.o: c:\\meow\\purr");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -317,7 +317,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename (with slashes in target)")
   {
-    auto result = Depfile::tokenize("e:/cat.o: meow");
+    auto result = depfile::tokenize("e:/cat.o: meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "e:/cat.o");
     CHECK(result[1] == ":");
@@ -327,7 +327,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename (with slashes in prerequisite)")
   {
-    auto result = Depfile::tokenize("cat.o: c:/meow/purr");
+    auto result = depfile::tokenize("cat.o: c:/meow/purr");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat.o");
     CHECK(result[1] == ":");
@@ -337,7 +337,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: cat:/meow")
   {
-    auto result = Depfile::tokenize("cat:/meow");
+    auto result = depfile::tokenize("cat:/meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -347,7 +347,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: cat:\\meow")
   {
-    auto result = Depfile::tokenize("cat:\\meow");
+    auto result = depfile::tokenize("cat:\\meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -357,7 +357,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: cat:\\ meow")
   {
-    auto result = Depfile::tokenize("cat:\\ meow");
+    auto result = depfile::tokenize("cat:\\ meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -367,7 +367,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: cat:c:/meow")
   {
-    auto result = Depfile::tokenize("cat:c:/meow");
+    auto result = depfile::tokenize("cat:c:/meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -377,7 +377,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: cat:c:\\meow")
   {
-    auto result = Depfile::tokenize("cat:c:\\meow");
+    auto result = depfile::tokenize("cat:c:\\meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -388,7 +388,7 @@ TEST_CASE("Depfile::tokenize")
   // Invalid pattern but tested for documentative purposes.
   SUBCASE("Windows filename: cat:c:")
   {
-    auto result = Depfile::tokenize("cat:c:");
+    auto result = depfile::tokenize("cat:c:");
     REQUIRE(result.size() == 5);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -400,7 +400,7 @@ TEST_CASE("Depfile::tokenize")
   // Invalid pattern but tested for documentative purposes.
   SUBCASE("Windows filename: cat:c:\\")
   {
-    auto result = Depfile::tokenize("cat:c:\\");
+    auto result = depfile::tokenize("cat:c:\\");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -410,7 +410,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: cat:c:/")
   {
-    auto result = Depfile::tokenize("cat:c:/");
+    auto result = depfile::tokenize("cat:c:/");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -421,7 +421,7 @@ TEST_CASE("Depfile::tokenize")
   // Invalid pattern but tested for documentative purposes.
   SUBCASE("Windows filename: cat:c:meow")
   {
-    auto result = Depfile::tokenize("cat:c:meow");
+    auto result = depfile::tokenize("cat:c:meow");
     REQUIRE(result.size() == 6);
     CHECK(result[0] == "cat");
     CHECK(result[1] == ":");
@@ -433,7 +433,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: c:c:/meow")
   {
-    auto result = Depfile::tokenize("c:c:/meow");
+    auto result = depfile::tokenize("c:c:/meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "c");
     CHECK(result[1] == ":");
@@ -443,7 +443,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: c:c:\\meow")
   {
-    auto result = Depfile::tokenize("c:c:\\meow");
+    auto result = depfile::tokenize("c:c:\\meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "c");
     CHECK(result[1] == ":");
@@ -453,7 +453,7 @@ TEST_CASE("Depfile::tokenize")
 
   SUBCASE("Windows filename: c:z:\\meow")
   {
-    auto result = Depfile::tokenize("c:z:\\meow");
+    auto result = depfile::tokenize("c:z:\\meow");
     REQUIRE(result.size() == 4);
     CHECK(result[0] == "c");
     CHECK(result[1] == ":");
@@ -464,7 +464,7 @@ TEST_CASE("Depfile::tokenize")
   // Invalid pattern but tested for documentative purposes.
   SUBCASE("Windows filename: c:cd:\\meow")
   {
-    auto result = Depfile::tokenize("c:cd:\\meow");
+    auto result = depfile::tokenize("c:cd:\\meow");
     REQUIRE(result.size() == 6);
     CHECK(result[0] == "c");
     CHECK(result[1] == ":");
@@ -475,12 +475,12 @@ TEST_CASE("Depfile::tokenize")
   }
 }
 
-TEST_CASE("Depfile::untokenize")
+TEST_CASE("depfile::untokenize")
 {
-  CHECK(Depfile::untokenize({}) == "");
-  CHECK(Depfile::untokenize({"foo.o"}) == "foo.o\n");
-  CHECK(Depfile::untokenize({"foo.o", ":"}) == "foo.o:\n");
-  CHECK(Depfile::untokenize({"foo.o", ":", "bar.h"})
+  CHECK(depfile::untokenize({}) == "");
+  CHECK(depfile::untokenize({"foo.o"}) == "foo.o\n");
+  CHECK(depfile::untokenize({"foo.o", ":"}) == "foo.o:\n");
+  CHECK(depfile::untokenize({"foo.o", ":", "bar.h"})
         == ("foo.o: \\\n"
             " bar.h\n"));
 }