add_executable(test-lockfile test_lockfile.cpp)
target_link_libraries(test-lockfile PRIVATE standard_settings standard_warnings ccache_framework)
+add_subdirectory(compiler)
add_subdirectory(core)
add_subdirectory(storage)
add_subdirectory(util)
#include <ccache/argprocessing.hpp>
#include <ccache/argsinfo.hpp>
+#include <ccache/compiler/clang.hpp>
+#include <ccache/compiler/msvc.hpp>
#include <ccache/compopt.hpp>
#include <ccache/context.hpp>
#include <ccache/core/cacheentry.hpp>
#include <ccache/core/exceptions.hpp>
#include <ccache/core/mainoptions.hpp>
#include <ccache/core/manifest.hpp>
-#include <ccache/core/msvcshowincludesoutput.hpp>
#include <ccache/core/result.hpp>
#include <ccache/core/resultretriever.hpp>
#include <ccache/core/sloppiness.hpp>
#include <ccache/util/args.hpp>
#include <ccache/util/assertions.hpp>
#include <ccache/util/bytes.hpp>
-#include <ccache/util/clang.hpp>
#include <ccache/util/conversion.hpp>
#include <ccache/util/defer.hpp>
#include <ccache/util/direntry.hpp>
static tl::expected<Hash::Digest, Failure>
result_key_from_includes(Context& ctx, Hash& hash, std::string_view stdout_data)
{
- for (std::string_view include : core::MsvcShowIncludesOutput::get_includes(
+ for (std::string_view include :
+ compiler::get_includes_from_msvc_show_includes(
stdout_data, ctx.config.msvc_dep_prefix())) {
const fs::path path = core::make_relative_path(ctx, include);
TRY(remember_include_file(ctx, path, hash, false, &hash));
ctx, util::to_string_view(result->stderr_data), STDERR_FILENO);
core::send_to_console(
ctx,
- util::to_string_view(core::MsvcShowIncludesOutput::strip_includes(
+ util::to_string_view(compiler::strip_includes_from_msvc_show_includes(
ctx, std::move(result->stdout_data))),
STDOUT_FILENO);
// Send stdout after stderr, it makes the output clearer with MSVC.
core::send_to_console(
ctx,
- util::to_string_view(core::MsvcShowIncludesOutput::strip_includes(
+ util::to_string_view(compiler::strip_includes_from_msvc_show_includes(
ctx, std::move(result->stdout_data))),
STDOUT_FILENO);
return tl::unexpected(Statistic::internal_error);
}
auto chunks =
- util::split_preprocessed_file_from_clang_cuda(preprocessed_path);
+ compiler::split_preprocessed_file_from_clang_cuda(preprocessed_path);
for (size_t i = 0; i < chunks.size(); ++i) {
TRY(process_cuda_chunk(ctx, hash, chunks[i], i));
}
--- /dev/null
+set(
+ sources
+ clang.cpp
+ msvc.cpp
+)
+
+file(GLOB headers *.hpp)
+list(APPEND sources ${headers})
+
+target_sources(ccache_framework PRIVATE ${sources})
namespace fs = util::filesystem;
-namespace util {
+namespace compiler {
std::vector<std::string>
split_preprocessed_file_from_clang_cuda(const fs::path& path)
return chunks;
}
-} // namespace util
+} // namespace compiler
#include <string>
#include <vector>
-namespace util {
+namespace compiler {
std::vector<std::string>
split_preprocessed_file_from_clang_cuda(const std::filesystem::path& path);
-} // namespace util
+} // namespace compiler
// this program; if not, write to the Free Software Foundation, Inc., 51
// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#include "msvcshowincludesoutput.hpp"
+#include "msvc.hpp"
#include <ccache/context.hpp>
#include <ccache/util/string.hpp>
-namespace core::MsvcShowIncludesOutput {
+namespace compiler {
std::vector<std::string_view>
-get_includes(std::string_view file_content, std::string_view prefix)
+get_includes_from_msvc_show_includes(std::string_view file_content,
+ std::string_view prefix)
{
// /showIncludes output is written to stdout together with other messages.
// Every line of it is "<prefix> <spaces> <file>" where the prefix is "Note:
}
util::Bytes
-strip_includes(const Context& ctx, util::Bytes&& stdout_data)
+strip_includes_from_msvc_show_includes(const Context& ctx,
+ util::Bytes&& stdout_data)
{
using util::Tokenizer;
using Mode = Tokenizer::Mode;
return new_stdout_data;
}
-} // namespace core::MsvcShowIncludesOutput
+} // namespace compiler
-// 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.
//
class Context;
-namespace core::MsvcShowIncludesOutput {
+namespace compiler {
-std::vector<std::string_view> get_includes(std::string_view file_content,
- std::string_view prefix);
+std::vector<std::string_view>
+get_includes_from_msvc_show_includes(std::string_view file_content,
+ std::string_view prefix);
-util::Bytes strip_includes(const Context& ctx, util::Bytes&& stdout_data);
+util::Bytes strip_includes_from_msvc_show_includes(const Context& ctx,
+ util::Bytes&& stdout_data);
-} // namespace core::MsvcShowIncludesOutput
+} // namespace compiler
filerecompressor.cpp
mainoptions.cpp
manifest.cpp
- msvcshowincludesoutput.cpp
result.cpp
resultextractor.cpp
resultinspector.cpp
#include <ccache/context.hpp>
#include <ccache/core/common.hpp>
#include <ccache/core/exceptions.hpp>
-#include <ccache/core/msvcshowincludesoutput.hpp>
#include <ccache/depfile.hpp>
#include <ccache/util/direntry.hpp>
#include <ccache/util/expected.hpp>
if (file_type == FileType::stdout_output) {
core::send_to_console(
m_ctx,
- util::to_string_view(MsvcShowIncludesOutput::strip_includes(m_ctx, data)),
+ util::to_string_view(
+ compiler::strip_includes_from_msvc_show_includes(m_ctx, data)),
STDOUT_FILENO);
} else if (file_type == FileType::stderr_output) {
core::send_to_console(m_ctx, util::to_string_view(data), STDERR_FILENO);
args.cpp
assertions.cpp
bytes.cpp
- clang.cpp
configreader.cpp
cpu.cpp
direntry.cpp
main.cpp
test_argprocessing.cpp
test_ccache.cpp
+ test_compiler_clang.cpp
+ test_compiler_msvc.cpp
test_compopt.cpp
test_compression_types.cpp
test_config.cpp
test_core_atomicfile.cpp
test_core_common.cpp
- test_core_msvcshowincludesoutput.cpp
test_core_statistics.cpp
test_core_statisticscounters.cpp
test_core_statslog.cpp
test_util_args.cpp
test_util_bitset.cpp
test_util_bytes.cpp
- test_util_clang.cpp
test_util_configreader.cpp
test_util_conversion.cpp
test_util_direntry.cpp
#include "testutil.hpp"
-#include <ccache/util/clang.hpp>
+#include <ccache/compiler/clang.hpp>
#include <ccache/util/file.hpp>
#include <ccache/util/filesystem.hpp>
using TestUtil::TestContext;
-TEST_SUITE_BEGIN("util");
+TEST_SUITE_BEGIN("clang");
-TEST_CASE("util::split_preprocessed_file_from_clang_cuda")
+TEST_CASE("compiler::split_preprocessed_file_from_clang_cuda")
{
TestContext test_context;
# 1 "<built-in>" 3
)"));
- auto result = util::split_preprocessed_file_from_clang_cuda(filename);
+ auto result = compiler::split_preprocessed_file_from_clang_cuda(filename);
REQUIRE(result.size() == 2);
CHECK(result[0] == R"(# 1 "test_cuda.cu"
SUBCASE("non-existent file")
{
fs::path filename = "nonexistent_file.txt";
- CHECK(util::split_preprocessed_file_from_clang_cuda(filename).empty());
+ CHECK(compiler::split_preprocessed_file_from_clang_cuda(filename).empty());
}
SUBCASE("empty file")
fs::path filename = "test_empty.txt";
REQUIRE(util::write_file(filename, ""));
- CHECK(util::split_preprocessed_file_from_clang_cuda(filename).empty());
+ CHECK(compiler::split_preprocessed_file_from_clang_cuda(filename).empty());
}
}
-// 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 "testutil.hpp"
+#include <ccache/compiler/msvc.hpp>
#include <ccache/context.hpp>
-#include <ccache/core/msvcshowincludesoutput.hpp>
#include <ccache/util/string.hpp>
#include <doctest/doctest.h>
static const std::string defaultPrefix = "Note: including file:";
-TEST_SUITE_BEGIN("MsvcShowIncludesOutput");
+TEST_SUITE_BEGIN("msvc");
-TEST_CASE("MsvcShowIncludesOutput::get_includes")
+TEST_CASE("get_includes_from_msvc_show_includes")
{
SUBCASE("Parse empty output")
{
std::string contents;
const auto result =
- core::MsvcShowIncludesOutput::get_includes(contents, defaultPrefix);
+ compiler::get_includes_from_msvc_show_includes(contents, defaultPrefix);
CHECK(result.size() == 0);
}
Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\deque
)";
const auto result =
- core::MsvcShowIncludesOutput::get_includes(contents, defaultPrefix);
+ compiler::get_includes_from_msvc_show_includes(contents, defaultPrefix);
REQUIRE(result.size() == 5);
CHECK(result[0] == "F:/Projects/ccache/build-msvc/config.h");
CHECK(result[1] == R"(F:\Projects\ccache\unittest\../src/Context.hpp)");
"Note: including file: foo\r\n"
"Note: including file: bar\r\n";
const auto result =
- core::MsvcShowIncludesOutput::get_includes(contents, defaultPrefix);
+ compiler::get_includes_from_msvc_show_includes(contents, defaultPrefix);
REQUIRE(result.size() == 2);
CHECK(result[0] == "foo");
CHECK(result[1] == "bar");
"Note: including file: \n"
"Note: including file: bar\n";
const auto result =
- core::MsvcShowIncludesOutput::get_includes(contents, defaultPrefix);
+ compiler::get_includes_from_msvc_show_includes(contents, defaultPrefix);
REQUIRE(result.size() == 2);
CHECK(result[0] == "foo");
CHECK(result[1] == "bar");
custom bar
Just a line with custom in the middle)";
const auto result =
- core::MsvcShowIncludesOutput::get_includes(contents, "custom");
+ compiler::get_includes_from_msvc_show_includes(contents, "custom");
REQUIRE(result.size() == 2);
CHECK(result[0] == "foo");
CHECK(result[1] == "bar");
}
}
-TEST_CASE("MsvcShowIncludesOutput::strip_includes")
+TEST_CASE("strip_includes_from_msvc_show_includes")
{
Context ctx;
const util::Bytes input = util::to_span(
SUBCASE("Empty output")
{
const util::Bytes result =
- core::MsvcShowIncludesOutput::strip_includes(ctx, {});
+ compiler::strip_includes_from_msvc_show_includes(ctx, {});
CHECK(result.size() == 0);
}
SUBCASE("Feature disabled")
{
const util::Bytes result =
- core::MsvcShowIncludesOutput::strip_includes(ctx, util::Bytes(input));
+ compiler::strip_includes_from_msvc_show_includes(ctx, util::Bytes(input));
CHECK(result == input);
}
SUBCASE("Wrong compiler")
{
const util::Bytes result =
- core::MsvcShowIncludesOutput::strip_includes(ctx, util::Bytes(input));
+ compiler::strip_includes_from_msvc_show_includes(ctx, util::Bytes(input));
CHECK(result == input);
}
SUBCASE("Simple output")
{
const util::Bytes result =
- core::MsvcShowIncludesOutput::strip_includes(ctx, util::Bytes(input));
+ compiler::strip_includes_from_msvc_show_includes(ctx, util::Bytes(input));
CHECK(result == util::to_span("First\nSecond\n"));
}
SUBCASE("Empty lines")
{
- const util::Bytes result = core::MsvcShowIncludesOutput::strip_includes(
+ const util::Bytes result = compiler::strip_includes_from_msvc_show_includes(
ctx,
util::to_span("First\n"
"\n"
SUBCASE("CRLF")
{
- const util::Bytes result = core::MsvcShowIncludesOutput::strip_includes(
+ const util::Bytes result = compiler::strip_includes_from_msvc_show_includes(
ctx,
util::to_span("First\r\n"
"Note: including file: foo\r\n"
SUBCASE("Custom prefix")
{
ctx.config.set_msvc_dep_prefix("custom");
- const util::Bytes result = core::MsvcShowIncludesOutput::strip_includes(
+ const util::Bytes result = compiler::strip_includes_from_msvc_show_includes(
ctx,
util::to_span("First\n"
"custom: including file: foo\n"