Skip to content

Commit e351f5b

Browse files
authored
[QOL] Target include refactor (#157)
1 parent ae6ac77 commit e351f5b

32 files changed

+126
-151
lines changed

buildcc/lib/target/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Target mocks and tests
2+
include(cmake/common_target_src.cmake)
3+
24
if (${TESTING})
35
set(TARGET_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
46
include(cmake/mock_target.cmake)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
set(COMMON_TARGET_SRCS
2+
# Interfaces
3+
include/target/interface/loader_interface.h
4+
include/target/interface/builder_interface.h
5+
6+
# Common
7+
src/common/target_config.cpp
8+
src/common/target_state.cpp
9+
include/target/common/target_file_ext.h
10+
include/target/common/target_config.h
11+
include/target/common/target_state.h
12+
include/target/common/target_env.h
13+
include/target/common/target_type.h
14+
15+
src/common/util.cpp
16+
include/target/common/util.h
17+
18+
include/target/common/path.h
19+
20+
# API
21+
src/api/source_api.cpp
22+
src/api/include_api.cpp
23+
src/api/lib_api.cpp
24+
src/api/pch_api.cpp
25+
src/api/flag_api.cpp
26+
src/api/deps_api.cpp
27+
include/target/api/source_api.h
28+
include/target/api/include_api.h
29+
include/target/api/lib_api.h
30+
include/target/api/pch_api.h
31+
include/target/api/flag_api.h
32+
include/target/api/deps_api.h
33+
34+
src/api/copy_api.cpp
35+
include/target/api/copy_api.h
36+
37+
src/api/target_info_getter.cpp
38+
src/api/target_getter.cpp
39+
include/target/api/target_info_getter.h
40+
include/target/api/target_getter.h
41+
42+
# Base Generator
43+
src/generator/generator_loader.cpp
44+
src/generator/generator_storer.cpp
45+
include/target/base/generator_loader.h
46+
47+
# Generator
48+
src/generator/generator.cpp
49+
include/target/generator.h
50+
51+
# Target friend
52+
src/target/friend/compile_pch.cpp
53+
src/target/friend/compile_object.cpp
54+
src/target/friend/link_target.cpp
55+
include/target/friend/compile_pch.h
56+
include/target/friend/compile_object.h
57+
include/target/friend/link_target.h
58+
59+
# Base Target
60+
src/target/target_loader.cpp
61+
src/target/target_storer.cpp
62+
include/target/base/target_loader.h
63+
include/target/base/target_storer.h
64+
65+
# Target
66+
src/target/target.cpp
67+
src/target/build.cpp
68+
include/target/target_info.h
69+
include/target/target.h
70+
)

buildcc/lib/target/cmake/mock_target.cmake

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,13 @@
11
add_library(mock_target STATIC
2-
# Utils
3-
src/util/util.cpp
4-
5-
# Common
6-
src/common/target_config.cpp
7-
src/common/target_state.cpp
8-
9-
# API
10-
src/api/source_api.cpp
11-
src/api/include_api.cpp
12-
src/api/lib_api.cpp
13-
src/api/pch_api.cpp
14-
src/api/flag_api.cpp
15-
src/api/deps_api.cpp
16-
17-
src/api/copy_api.cpp
18-
19-
src/api/target_info_getter.cpp
20-
src/api/target_getter.cpp
21-
22-
# Generator
23-
src/generator/generator_loader.cpp
24-
src/generator/generator_storer.cpp
25-
src/generator/generator.cpp
2+
${COMMON_TARGET_SRCS}
263

274
# Generator mocks
285
mock/generator/task.cpp
296
mock/generator/recheck_states.cpp
307

31-
# Target friend
32-
src/target/friend/compile_pch.cpp
33-
src/target/friend/compile_object.cpp
34-
src/target/friend/link_target.cpp
35-
36-
# Target
37-
src/target/target.cpp
38-
src/target/target_loader.cpp
39-
src/target/target_storer.cpp
40-
41-
src/target/build.cpp
42-
438
# Target mocks
44-
mock/target/recheck_states.cpp
459
mock/target/tasks.cpp
10+
mock/target/recheck_states.cpp
4611
)
4712
target_include_directories(mock_target PUBLIC
4813
${CMAKE_CURRENT_SOURCE_DIR}/include

buildcc/lib/target/cmake/target.cmake

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,10 @@
11
set(TARGET_SRCS
2-
# Interfaces
3-
include/target/loader_interface.h
4-
include/target/builder_interface.h
2+
${COMMON_TARGET_SRCS}
53

6-
# Utils
7-
src/util/util.cpp
8-
include/target/path.h
9-
include/target/util.h
10-
11-
# Common
12-
src/common/target_config.cpp
13-
src/common/target_state.cpp
14-
include/target/common/target_file_ext.h
15-
include/target/common/target_config.h
16-
include/target/common/target_state.h
17-
include/target/common/target_env.h
18-
include/target/common/target_type.h
19-
20-
# API
21-
src/api/source_api.cpp
22-
src/api/include_api.cpp
23-
src/api/lib_api.cpp
24-
src/api/pch_api.cpp
25-
src/api/flag_api.cpp
26-
src/api/deps_api.cpp
27-
include/target/api/source_api.h
28-
include/target/api/include_api.h
29-
include/target/api/lib_api.h
30-
include/target/api/pch_api.h
31-
include/target/api/flag_api.h
32-
include/target/api/deps_api.h
33-
34-
src/api/copy_api.cpp
35-
include/target/api/copy_api.h
36-
37-
src/api/target_info_getter.cpp
38-
src/api/target_getter.cpp
39-
include/target/api/target_info_getter.h
40-
include/target/api/target_getter.h
41-
42-
# Generator
43-
src/generator/generator_loader.cpp
44-
src/generator/generator_storer.cpp
45-
src/generator/generator.cpp
464
src/generator/task.cpp
475
src/generator/recheck_states.cpp
48-
include/target/generator_loader.h
49-
include/target/generator.h
50-
51-
# Target friend
52-
src/target/friend/compile_pch.cpp
53-
src/target/friend/compile_object.cpp
54-
src/target/friend/link_target.cpp
55-
include/target/friend/compile_pch.h
56-
include/target/friend/compile_object.h
57-
include/target/friend/link_target.h
58-
59-
# Target
60-
src/target/target.cpp
61-
src/target/target_loader.cpp
62-
src/target/target_storer.cpp
63-
include/target/target_loader.h
64-
include/target/target_storer.h
65-
include/target/target.h
666

677
src/target/recheck_states.cpp
68-
69-
src/target/build.cpp
708
src/target/tasks.cpp
719
)
7210

buildcc/lib/target/include/target/api/target_info_getter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef TARGET_API_TARGET_INFO_GETTER_H_
1818
#define TARGET_API_TARGET_INFO_GETTER_H_
1919

20-
#include "target/path.h"
20+
#include "target/common/path.h"
2121

2222
#include "target/common/target_config.h"
2323
#include "target/common/target_state.h"

buildcc/lib/target/include/target/generator_loader.h renamed to buildcc/lib/target/include/target/base/generator_loader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef TARGET_GENERATOR_LOADER_H_
18-
#define TARGET_GENERATOR_LOADER_H_
17+
#ifndef TARGET_BASE_GENERATOR_LOADER_H_
18+
#define TARGET_BASE_GENERATOR_LOADER_H_
1919

20-
#include "target/loader_interface.h"
20+
#include "target/interface/loader_interface.h"
2121

2222
#include <string>
2323
#include <unordered_map>
2424
#include <unordered_set>
2525

2626
#include "fmt/format.h"
2727

28-
#include "target/path.h"
28+
#include "target/common/path.h"
2929

3030
namespace buildcc::internal {
3131

buildcc/lib/target/include/target/target_loader.h renamed to buildcc/lib/target/include/target/base/target_loader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef TARGET_TARGET_LOADER_H_
18-
#define TARGET_TARGET_LOADER_H_
17+
#ifndef TARGET_BASE_TARGET_LOADER_H_
18+
#define TARGET_BASE_TARGET_LOADER_H_
1919

20-
#include "target/loader_interface.h"
20+
#include "target/interface/loader_interface.h"
2121

2222
#include <string>
2323
#include <unordered_set>
2424

2525
#include "fmt/format.h"
2626

27-
#include "target/path.h"
27+
#include "target/common/path.h"
2828

2929
namespace buildcc::internal {
3030

buildcc/lib/target/include/target/target_storer.h renamed to buildcc/lib/target/include/target/base/target_storer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef TARGET_TARGET_STORER_H_
18-
#define TARGET_TARGET_STORER_H_
17+
#ifndef TARGET_BASE_TARGET_STORER_H_
18+
#define TARGET_BASE_TARGET_STORER_H_
1919

2020
#include <unordered_set>
2121

22-
#include "target/path.h"
22+
#include "target/common/path.h"
2323

2424
namespace buildcc::internal {
2525

buildcc/lib/target/include/target/path.h renamed to buildcc/lib/target/include/target/common/path.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef TARGET_PATH_H_
18-
#define TARGET_PATH_H_
17+
#ifndef TARGET_COMMON_PATH_H_
18+
#define TARGET_COMMON_PATH_H_
1919

2020
#include <filesystem>
2121
#include <string>

buildcc/lib/target/include/target/util.h renamed to buildcc/lib/target/include/target/common/util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef TARGET_UTIL_H_
18-
#define TARGET_UTIL_H_
17+
#ifndef TARGET_COMMON_UTIL_H_
18+
#define TARGET_COMMON_UTIL_H_
1919

2020
#include <string>
2121
#include <vector>
2222

23-
#include "target/path.h"
23+
#include "target/common/path.h"
2424

2525
namespace buildcc::internal {
2626

buildcc/lib/target/include/target/friend/compile_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <filesystem>
2121

22-
#include "target/path.h"
22+
#include "target/common/path.h"
2323

2424
#include "taskflow/core/task.hpp"
2525
#include "taskflow/taskflow.hpp"

buildcc/lib/target/include/target/generator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
#include "command/command.h"
3030

31-
#include "target/builder_interface.h"
31+
#include "target/interface/builder_interface.h"
3232

33-
#include "target/generator_loader.h"
34-
#include "target/path.h"
33+
#include "target/base/generator_loader.h"
34+
#include "target/common/path.h"
3535

3636
namespace buildcc::base {
3737

buildcc/lib/target/include/target/builder_interface.h renamed to buildcc/lib/target/include/target/interface/builder_interface.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef TARGET_BUILDER_INTERFACE_H_
18-
#define TARGET_BUILDER_INTERFACE_H_
17+
#ifndef TARGET_INTERFACE_BUILDER_INTERFACE_H_
18+
#define TARGET_INTERFACE_BUILDER_INTERFACE_H_
1919

2020
#include <algorithm>
2121
#include <functional>
2222
#include <unordered_set>
2323

24-
#include "target/path.h"
25-
#include "target/util.h"
24+
#include "target/common/path.h"
25+
#include "target/common/util.h"
2626

2727
namespace buildcc::base {
2828

2929
// TODO, 1. Consider updating Recheck* APIs - do not modify internal `dirty_`
3030
// flag
31-
// TODO, 2. Consider removing dependency on target/util.h
31+
// TODO, 2. Consider removing dependency on target/common/util.h
3232
// TODO, 3. Consider making Recheck* APIs free namespaced functions instead of
3333
// only within the scope of BuilderInterfaces (See TODO 1. and 2. first)
3434
class BuilderInterface {

buildcc/lib/target/include/target/loader_interface.h renamed to buildcc/lib/target/include/target/interface/loader_interface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef TARGET_LOADER_INTERFACE_H_
18-
#define TARGET_LOADER_INTERFACE_H_
17+
#ifndef TARGET_INTERFACE_LOADER_INTERFACE_H_
18+
#define TARGET_INTERFACE_LOADER_INTERFACE_H_
1919

2020
#include <filesystem>
2121

buildcc/lib/target/include/target/private/schema_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <algorithm>
2323

24-
#include "target/path.h"
24+
#include "target/common/path.h"
2525

2626
namespace fbs = schema::internal;
2727

buildcc/lib/target/include/target/target.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <vector>
2929

3030
// Interface
31-
#include "target/builder_interface.h"
31+
#include "target/interface/builder_interface.h"
3232

3333
// API
3434
#include "target/api/target_getter.h"
@@ -43,9 +43,9 @@
4343
#include "target/friend/link_target.h"
4444

4545
// Internal
46-
#include "target/path.h"
47-
#include "target/target_loader.h"
48-
#include "target/target_storer.h"
46+
#include "target/base/target_loader.h"
47+
#include "target/base/target_storer.h"
48+
#include "target/common/path.h"
4949

5050
// Components
5151
#include "command/command.h"

0 commit comments

Comments
 (0)