Skip to content

Commit 251f244

Browse files
committed
chore: Improve source tree structure
In preparation for adding support for using dependencies from the system in addition to bundled or downloaded dependencies, restructure the source tree so that: - Third party headers are included without a third_party/ prefix, e.g. #include <xxhash.h> instead of #include <third_party/xxhash.h>. - Ccache headers are included with a ccache/ prefix, e.g. #include <ccache/util/string.hpp> instead of #include <util/string.hpp>. This keeps ccache and other headers separated but in another way than before.
1 parent 1dc07d3 commit 251f244

File tree

197 files changed

+918
-938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+918
-938
lines changed

.clang-format

+9-11
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,18 @@ ConstructorInitializerIndentWidth: 2
2424
ContinuationIndentWidth: 2
2525
IncludeBlocks: Regroup
2626
IncludeCategories:
27-
- Regex: '^"system.hpp"$'
28-
Priority: 1
29-
- Regex: '^["<]third_party/'
30-
Priority: 4
31-
# System headers:
32-
- Regex: '\.h>$'
33-
Priority: 5
34-
# C++ headers:
35-
- Regex: '^<[^.]+>$'
36-
Priority: 6
27+
# Relative headers
3728
- Regex: '^"'
29+
Priority: 1
30+
# Ccache headers:
31+
- Regex: '^<ccache/'
3832
Priority: 2
39-
- Regex: '.*'
33+
# System headers:
34+
- Regex: '\.h.*>$'
4035
Priority: 3
36+
# C++ headers:
37+
- Regex: '^<'
38+
Priority: 4
4139
IndentPPDirectives: AfterHash
4240
KeepEmptyLinesAtTheStartOfBlocks: false
4341
PointerAlignment: Left

ARCHITECTURE.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
1717

1818
### Subdirectories of `src`
1919

20+
* `ccache`: Ccache source code.
21+
* `third_party`: Bundled third party code.
22+
23+
### Subdirectories of `src/ccache`
24+
2025
This section describes the directory structure that the project aims to
21-
transform the `src` directory into in the long run to make the code base easier
22-
to understand and work with. In other words, this is work in progress.
26+
transform the `src/ccache` directory into in the long run to make the code base
27+
easier to understand and work with. In other words, this is work in progress.
2328

2429
* `compiler`: Knowledge about things like compiler options, compiler behavior,
2530
preprocessor output format, etc. Ideally this code should in the future be
@@ -29,6 +34,5 @@ to understand and work with. In other words, this is work in progress.
2934
* `storage`: Storage backends.
3035
* `storage/local`: Code for the local storage backend.
3136
* `storage/remote`: Code for remote storage backends.
32-
* `third_party`: Bundled third party code.
3337
* `util`: Generic utility functionality that does not depend on ccache-specific
3438
things.

CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ include(CodeAnalysis)
121121
#
122122
# Source code
123123
#
124-
add_subdirectory(src)
124+
add_subdirectory(src/ccache)
125+
add_subdirectory(src/third_party)
125126

126127
#
127128
# ccache executable
128129
#
129-
add_executable(ccache src/main.cpp)
130+
add_executable(ccache src/ccache/main.cpp)
130131
target_link_libraries(ccache PRIVATE standard_settings standard_warnings ccache_framework)
131132

132133
#

cmake/GenerateVersionFile.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configure_file(
22
${CMAKE_SOURCE_DIR}/cmake/version.cpp.in
3-
${CMAKE_BINARY_DIR}/src/version.cpp
3+
${CMAKE_BINARY_DIR}/src/ccache/version.cpp
44
@ONLY)
File renamed without changes.

src/Args.cpp src/ccache/Args.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
#include "Args.hpp"
2020

21-
#include <core/exceptions.hpp>
22-
#include <util/file.hpp>
23-
#include <util/logging.hpp>
24-
#include <util/string.hpp>
21+
#include <ccache/core/exceptions.hpp>
22+
#include <ccache/util/file.hpp>
23+
#include <ccache/util/logging.hpp>
24+
#include <ccache/util/string.hpp>
2525

2626
Args::Args(Args&& other) noexcept : m_args(std::move(other.m_args))
2727
{

src/Args.hpp src/ccache/Args.hpp

File renamed without changes.

src/ArgsInfo.hpp src/ccache/ArgsInfo.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
1+
// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
22
//
33
// See doc/AUTHORS.adoc for a complete list of contributors.
44
//
@@ -18,7 +18,7 @@
1818

1919
#pragma once
2020

21-
#include "Args.hpp"
21+
#include <ccache/Args.hpp>
2222

2323
#include <optional>
2424
#include <string>

src/CMakeLists.txt src/ccache/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ target_link_libraries(
4747
PRIVATE standard_settings standard_warnings ZSTD::ZSTD Threads::Threads third_party
4848
)
4949

50-
target_include_directories(ccache_framework PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
50+
get_filename_component(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
51+
target_include_directories(ccache_framework PUBLIC ${CMAKE_BINARY_DIR} ${SRC_DIR})
5152

5253
if(REDIS_STORAGE_BACKEND)
5354
target_compile_definitions(ccache_framework PUBLIC -DHAVE_REDIS_STORAGE_BACKEND)
@@ -62,5 +63,4 @@ target_link_libraries(test-lockfile PRIVATE standard_settings standard_warnings
6263

6364
add_subdirectory(core)
6465
add_subdirectory(storage)
65-
add_subdirectory(third_party)
6666
add_subdirectory(util)

src/Config.cpp src/ccache/Config.cpp

+16-17
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,22 @@
1818

1919
#include "Config.hpp"
2020

21-
#include "Util.hpp"
22-
23-
#include <core/AtomicFile.hpp>
24-
#include <core/common.hpp>
25-
#include <core/exceptions.hpp>
26-
#include <core/types.hpp>
27-
#include <util/DirEntry.hpp>
28-
#include <util/Tokenizer.hpp>
29-
#include <util/UmaskScope.hpp>
30-
#include <util/assertions.hpp>
31-
#include <util/environment.hpp>
32-
#include <util/expected.hpp>
33-
#include <util/file.hpp>
34-
#include <util/filesystem.hpp>
35-
#include <util/format.hpp>
36-
#include <util/string.hpp>
37-
#include <util/wincompat.hpp>
21+
#include <ccache/Util.hpp>
22+
#include <ccache/core/AtomicFile.hpp>
23+
#include <ccache/core/common.hpp>
24+
#include <ccache/core/exceptions.hpp>
25+
#include <ccache/core/types.hpp>
26+
#include <ccache/util/DirEntry.hpp>
27+
#include <ccache/util/Tokenizer.hpp>
28+
#include <ccache/util/UmaskScope.hpp>
29+
#include <ccache/util/assertions.hpp>
30+
#include <ccache/util/environment.hpp>
31+
#include <ccache/util/expected.hpp>
32+
#include <ccache/util/file.hpp>
33+
#include <ccache/util/filesystem.hpp>
34+
#include <ccache/util/format.hpp>
35+
#include <ccache/util/string.hpp>
36+
#include <ccache/util/wincompat.hpp>
3837

3938
#ifdef HAVE_PWD_H
4039
# include <pwd.h>

src/Config.hpp src/ccache/Config.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#pragma once
2020

21-
#include <core/Sloppiness.hpp>
22-
#include <util/NonCopyable.hpp>
23-
#include <util/string.hpp>
21+
#include <ccache/core/Sloppiness.hpp>
22+
#include <ccache/util/NonCopyable.hpp>
23+
#include <ccache/util/string.hpp>
2424

2525
#include <sys/types.h>
2626

src/Context.cpp src/ccache/Context.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@
1818

1919
#include "Context.hpp"
2020

21-
#include "SignalHandler.hpp"
22-
#include "Util.hpp"
23-
#include "hashutil.hpp"
24-
25-
#include <util/TimePoint.hpp>
26-
#include <util/file.hpp>
27-
#include <util/logging.hpp>
28-
#include <util/path.hpp>
29-
#include <util/process.hpp>
30-
#include <util/string.hpp>
31-
#include <util/wincompat.hpp>
21+
#include <ccache/SignalHandler.hpp>
22+
#include <ccache/Util.hpp>
23+
#include <ccache/hashutil.hpp>
24+
#include <ccache/util/TimePoint.hpp>
25+
#include <ccache/util/file.hpp>
26+
#include <ccache/util/logging.hpp>
27+
#include <ccache/util/path.hpp>
28+
#include <ccache/util/process.hpp>
29+
#include <ccache/util/string.hpp>
30+
#include <ccache/util/wincompat.hpp>
3231

3332
#ifdef HAVE_UNISTD_H
3433
# include <unistd.h>

src/Context.hpp src/ccache/Context.hpp

+11-13
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,21 @@
1818

1919
#pragma once
2020

21-
#include "Args.hpp"
22-
#include "ArgsInfo.hpp"
23-
#include "Config.hpp"
24-
25-
#include <util/FileStream.hpp>
26-
#include <util/NonCopyable.hpp>
21+
#include <ccache/Args.hpp>
22+
#include <ccache/ArgsInfo.hpp>
23+
#include <ccache/Config.hpp>
24+
#include <ccache/Hash.hpp>
25+
#include <ccache/core/Manifest.hpp>
26+
#include <ccache/storage/Storage.hpp>
27+
#include <ccache/util/Bytes.hpp>
28+
#include <ccache/util/FileStream.hpp>
29+
#include <ccache/util/NonCopyable.hpp>
30+
#include <ccache/util/TimePoint.hpp>
2731

2832
#ifdef INODE_CACHE_SUPPORTED
29-
# include "InodeCache.hpp"
33+
# include <ccache/InodeCache.hpp>
3034
#endif
3135

32-
#include <Hash.hpp>
33-
#include <core/Manifest.hpp>
34-
#include <storage/Storage.hpp>
35-
#include <util/Bytes.hpp>
36-
#include <util/TimePoint.hpp>
37-
3836
#include <sys/types.h>
3937

4038
#include <ctime>

src/Depfile.cpp src/ccache/Depfile.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
1+
// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
22
//
33
// See doc/AUTHORS.adoc for a complete list of contributors.
44
//
@@ -18,18 +18,17 @@
1818

1919
#include "Depfile.hpp"
2020

21-
#include "Context.hpp"
22-
#include "Hash.hpp"
23-
24-
#include <Util.hpp>
25-
#include <core/exceptions.hpp>
26-
#include <util/Tokenizer.hpp>
27-
#include <util/assertions.hpp>
28-
#include <util/file.hpp>
29-
#include <util/filesystem.hpp>
30-
#include <util/logging.hpp>
31-
#include <util/path.hpp>
32-
#include <util/string.hpp>
21+
#include <ccache/Context.hpp>
22+
#include <ccache/Hash.hpp>
23+
#include <ccache/Util.hpp>
24+
#include <ccache/core/exceptions.hpp>
25+
#include <ccache/util/Tokenizer.hpp>
26+
#include <ccache/util/assertions.hpp>
27+
#include <ccache/util/file.hpp>
28+
#include <ccache/util/filesystem.hpp>
29+
#include <ccache/util/logging.hpp>
30+
#include <ccache/util/path.hpp>
31+
#include <ccache/util/string.hpp>
3332

3433
#include <algorithm>
3534

File renamed without changes.

src/Hash.cpp src/ccache/Hash.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
1+
// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
22
//
33
// See doc/AUTHORS.adoc for a complete list of contributors.
44
//
@@ -18,12 +18,12 @@
1818

1919
#include "Hash.hpp"
2020

21-
#include <util/Fd.hpp>
22-
#include <util/file.hpp>
23-
#include <util/format.hpp>
24-
#include <util/logging.hpp>
25-
#include <util/string.hpp>
26-
#include <util/wincompat.hpp>
21+
#include <ccache/util/Fd.hpp>
22+
#include <ccache/util/file.hpp>
23+
#include <ccache/util/format.hpp>
24+
#include <ccache/util/logging.hpp>
25+
#include <ccache/util/string.hpp>
26+
#include <ccache/util/wincompat.hpp>
2727

2828
#include <fcntl.h>
2929
#include <sys/stat.h>

src/Hash.hpp src/ccache/Hash.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#pragma once
2020

21-
#include "third_party/blake3/blake3.h"
22-
#include <third_party/nonstd/span.hpp>
23-
#include <third_party/tl/expected.hpp>
21+
#include <blake3/blake3.h>
22+
#include <nonstd/span.hpp>
23+
#include <tl/expected.hpp>
2424

2525
#include <array>
2626
#include <cstdint>

src/InodeCache.cpp src/ccache/InodeCache.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@
1818

1919
#include "InodeCache.hpp"
2020

21-
#include "Config.hpp"
22-
#include "Hash.hpp"
23-
#include "Util.hpp"
24-
25-
#include <util/DirEntry.hpp>
26-
#include <util/Fd.hpp>
27-
#include <util/Finalizer.hpp>
28-
#include <util/PathString.hpp>
29-
#include <util/TemporaryFile.hpp>
30-
#include <util/conversion.hpp>
31-
#include <util/file.hpp>
32-
#include <util/format.hpp>
33-
#include <util/logging.hpp>
21+
#include <ccache/Config.hpp>
22+
#include <ccache/Hash.hpp>
23+
#include <ccache/Util.hpp>
24+
#include <ccache/util/DirEntry.hpp>
25+
#include <ccache/util/Fd.hpp>
26+
#include <ccache/util/Finalizer.hpp>
27+
#include <ccache/util/PathString.hpp>
28+
#include <ccache/util/TemporaryFile.hpp>
29+
#include <ccache/util/conversion.hpp>
30+
#include <ccache/util/file.hpp>
31+
#include <ccache/util/format.hpp>
32+
#include <ccache/util/logging.hpp>
3433

3534
#include <fcntl.h>
3635

src/InodeCache.hpp src/ccache/InodeCache.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
#pragma once
2020

21-
#include <Hash.hpp>
22-
#include <hashutil.hpp>
23-
#include <util/Duration.hpp>
24-
#include <util/Fd.hpp>
25-
#include <util/MemoryMap.hpp>
26-
#include <util/TimePoint.hpp>
21+
#include <ccache/Hash.hpp>
22+
#include <ccache/hashutil.hpp>
23+
#include <ccache/util/Duration.hpp>
24+
#include <ccache/util/Fd.hpp>
25+
#include <ccache/util/MemoryMap.hpp>
26+
#include <ccache/util/TimePoint.hpp>
2727

2828
#include <sys/types.h>
2929

src/ProgressBar.cpp src/ccache/ProgressBar.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
1+
// Copyright (C) 2019-2024 Joel Rosdahl and other contributors
22
//
33
// See doc/AUTHORS.adoc for a complete list of contributors.
44
//
@@ -18,9 +18,9 @@
1818

1919
#include "ProgressBar.hpp"
2020

21-
#include <util/assertions.hpp>
22-
#include <util/format.hpp>
23-
#include <util/wincompat.hpp>
21+
#include <ccache/util/assertions.hpp>
22+
#include <ccache/util/format.hpp>
23+
#include <ccache/util/wincompat.hpp>
2424

2525
#ifdef _WIN32
2626
#else
File renamed without changes.

src/SignalHandler.cpp src/ccache/SignalHandler.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
1+
// Copyright (C) 2020-2024 Joel Rosdahl and other contributors
22
//
33
// See doc/AUTHORS.adoc for a complete list of contributors.
44
//
@@ -18,9 +18,8 @@
1818

1919
#include "SignalHandler.hpp"
2020

21-
#include "Context.hpp"
22-
23-
#include <util/assertions.hpp>
21+
#include <ccache/Context.hpp>
22+
#include <ccache/util/assertions.hpp>
2423

2524
#include <signal.h> // NOLINT: sigaddset et al are defined in signal.h
2625
#include <sys/types.h>
File renamed without changes.

0 commit comments

Comments
 (0)