* 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.
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;
}
}
args_info.dependency_target =
- Depfile::escape_filename(util::pstr(dep_target).str());
+ depfile::escape_filename(util::pstr(dep_target).str());
}
}
}
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;
// (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);
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;
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;
// 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;
}
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) {
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");
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);
-// 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.
//
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_()),
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;
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;
-// 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.
//
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;
}
// 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;
return m_raw_files;
}
-} // namespace core::Result
+} // namespace core::result
-// 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.
//
class CacheEntryDataParser;
-namespace Result {
+namespace result {
extern const uint8_t k_format_version;
std::vector<RawFile> m_raw_files;
};
-} // namespace Result
+} // namespace result
} // namespace core
-// 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.
//
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);
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) {
-// 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 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)>;
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:
-// 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.
//
}
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);
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);
}
-// 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:
-// 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 {
-using Result::FileType;
+using result::FileType;
ResultRetriever::ResultRetriever(const Context& ctx,
std::optional<Hash::Digest> result_key)
{
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) {
{
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) {
// 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));
}
}
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;
-// 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 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
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);
-// 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 fs = util::filesystem;
-namespace Depfile {
+namespace depfile {
std::string
escape_filename(std::string_view filename)
return result;
}
-} // namespace Depfile
+} // namespace depfile
-// 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.
//
#include <string_view>
#include <vector>
-namespace Depfile {
+namespace depfile {
std::string escape_filename(std::string_view filename);
// Return text from `tokens` that originate from `tokenize`.
std::string untokenize(const std::vector<std::string>& tokens);
-} // namespace Depfile
+} // namespace depfile
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());
-// 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.
//
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
-// 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.
//
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;
"\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"
" {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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
{
// 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] == ":");
SUBCASE("Multiple entries")
{
- auto result = Depfile::tokenize(
+ auto result = depfile::tokenize(
"foo.o bar.o: a.h \\\n"
" b.h\\\n"
" c.h\n"
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
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] == ":");
// 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] == ":");
// 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] == ":");
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] == ":");
// 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] == ":");
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] == ":");
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] == ":");
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] == ":");
// 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] == ":");
}
}
-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"));
}