Skip to content

[QOL] Target include refactor #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 19, 2021
Merged
2 changes: 2 additions & 0 deletions buildcc/lib/target/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Target mocks and tests
include(cmake/common_target_src.cmake)

if (${TESTING})
set(TARGET_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
include(cmake/mock_target.cmake)
Expand Down
70 changes: 70 additions & 0 deletions buildcc/lib/target/cmake/common_target_src.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
set(COMMON_TARGET_SRCS
# Interfaces
include/target/interface/loader_interface.h
include/target/interface/builder_interface.h

# Common
src/common/target_config.cpp
src/common/target_state.cpp
include/target/common/target_file_ext.h
include/target/common/target_config.h
include/target/common/target_state.h
include/target/common/target_env.h
include/target/common/target_type.h

src/common/util.cpp
include/target/common/util.h

include/target/common/path.h

# API
src/api/source_api.cpp
src/api/include_api.cpp
src/api/lib_api.cpp
src/api/pch_api.cpp
src/api/flag_api.cpp
src/api/deps_api.cpp
include/target/api/source_api.h
include/target/api/include_api.h
include/target/api/lib_api.h
include/target/api/pch_api.h
include/target/api/flag_api.h
include/target/api/deps_api.h

src/api/copy_api.cpp
include/target/api/copy_api.h

src/api/target_info_getter.cpp
src/api/target_getter.cpp
include/target/api/target_info_getter.h
include/target/api/target_getter.h

# Base Generator
src/generator/generator_loader.cpp
src/generator/generator_storer.cpp
include/target/base/generator_loader.h

# Generator
src/generator/generator.cpp
include/target/generator.h

# Target friend
src/target/friend/compile_pch.cpp
src/target/friend/compile_object.cpp
src/target/friend/link_target.cpp
include/target/friend/compile_pch.h
include/target/friend/compile_object.h
include/target/friend/link_target.h

# Base Target
src/target/target_loader.cpp
src/target/target_storer.cpp
include/target/base/target_loader.h
include/target/base/target_storer.h

# Target
src/target/target.cpp
src/target/build.cpp
include/target/target_info.h
include/target/target.h
)
39 changes: 2 additions & 37 deletions buildcc/lib/target/cmake/mock_target.cmake
Original file line number Diff line number Diff line change
@@ -1,48 +1,13 @@
add_library(mock_target STATIC
# Utils
src/util/util.cpp

# Common
src/common/target_config.cpp
src/common/target_state.cpp

# API
src/api/source_api.cpp
src/api/include_api.cpp
src/api/lib_api.cpp
src/api/pch_api.cpp
src/api/flag_api.cpp
src/api/deps_api.cpp

src/api/copy_api.cpp

src/api/target_info_getter.cpp
src/api/target_getter.cpp

# Generator
src/generator/generator_loader.cpp
src/generator/generator_storer.cpp
src/generator/generator.cpp
${COMMON_TARGET_SRCS}

# Generator mocks
mock/generator/task.cpp
mock/generator/recheck_states.cpp

# Target friend
src/target/friend/compile_pch.cpp
src/target/friend/compile_object.cpp
src/target/friend/link_target.cpp

# Target
src/target/target.cpp
src/target/target_loader.cpp
src/target/target_storer.cpp

src/target/build.cpp

# Target mocks
mock/target/recheck_states.cpp
mock/target/tasks.cpp
mock/target/recheck_states.cpp
)
target_include_directories(mock_target PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
Expand Down
64 changes: 1 addition & 63 deletions buildcc/lib/target/cmake/target.cmake
Original file line number Diff line number Diff line change
@@ -1,72 +1,10 @@
set(TARGET_SRCS
# Interfaces
include/target/loader_interface.h
include/target/builder_interface.h
${COMMON_TARGET_SRCS}

# Utils
src/util/util.cpp
include/target/path.h
include/target/util.h

# Common
src/common/target_config.cpp
src/common/target_state.cpp
include/target/common/target_file_ext.h
include/target/common/target_config.h
include/target/common/target_state.h
include/target/common/target_env.h
include/target/common/target_type.h

# API
src/api/source_api.cpp
src/api/include_api.cpp
src/api/lib_api.cpp
src/api/pch_api.cpp
src/api/flag_api.cpp
src/api/deps_api.cpp
include/target/api/source_api.h
include/target/api/include_api.h
include/target/api/lib_api.h
include/target/api/pch_api.h
include/target/api/flag_api.h
include/target/api/deps_api.h

src/api/copy_api.cpp
include/target/api/copy_api.h

src/api/target_info_getter.cpp
src/api/target_getter.cpp
include/target/api/target_info_getter.h
include/target/api/target_getter.h

# Generator
src/generator/generator_loader.cpp
src/generator/generator_storer.cpp
src/generator/generator.cpp
src/generator/task.cpp
src/generator/recheck_states.cpp
include/target/generator_loader.h
include/target/generator.h

# Target friend
src/target/friend/compile_pch.cpp
src/target/friend/compile_object.cpp
src/target/friend/link_target.cpp
include/target/friend/compile_pch.h
include/target/friend/compile_object.h
include/target/friend/link_target.h

# Target
src/target/target.cpp
src/target/target_loader.cpp
src/target/target_storer.cpp
include/target/target_loader.h
include/target/target_storer.h
include/target/target.h

src/target/recheck_states.cpp

src/target/build.cpp
src/target/tasks.cpp
)

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/api/target_info_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef TARGET_API_TARGET_INFO_GETTER_H_
#define TARGET_API_TARGET_INFO_GETTER_H_

#include "target/path.h"
#include "target/common/path.h"

#include "target/common/target_config.h"
#include "target/common/target_state.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
* limitations under the License.
*/

#ifndef TARGET_GENERATOR_LOADER_H_
#define TARGET_GENERATOR_LOADER_H_
#ifndef TARGET_BASE_GENERATOR_LOADER_H_
#define TARGET_BASE_GENERATOR_LOADER_H_

#include "target/loader_interface.h"
#include "target/interface/loader_interface.h"

#include <string>
#include <unordered_map>
#include <unordered_set>

#include "fmt/format.h"

#include "target/path.h"
#include "target/common/path.h"

namespace buildcc::internal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
* limitations under the License.
*/

#ifndef TARGET_TARGET_LOADER_H_
#define TARGET_TARGET_LOADER_H_
#ifndef TARGET_BASE_TARGET_LOADER_H_
#define TARGET_BASE_TARGET_LOADER_H_

#include "target/loader_interface.h"
#include "target/interface/loader_interface.h"

#include <string>
#include <unordered_set>

#include "fmt/format.h"

#include "target/path.h"
#include "target/common/path.h"

namespace buildcc::internal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

#ifndef TARGET_TARGET_STORER_H_
#define TARGET_TARGET_STORER_H_
#ifndef TARGET_BASE_TARGET_STORER_H_
#define TARGET_BASE_TARGET_STORER_H_

#include <unordered_set>

#include "target/path.h"
#include "target/common/path.h"

namespace buildcc::internal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef TARGET_PATH_H_
#define TARGET_PATH_H_
#ifndef TARGET_COMMON_PATH_H_
#define TARGET_COMMON_PATH_H_

#include <filesystem>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

#ifndef TARGET_UTIL_H_
#define TARGET_UTIL_H_
#ifndef TARGET_COMMON_UTIL_H_
#define TARGET_COMMON_UTIL_H_

#include <string>
#include <vector>

#include "target/path.h"
#include "target/common/path.h"

namespace buildcc::internal {

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/friend/compile_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <filesystem>

#include "target/path.h"
#include "target/common/path.h"

#include "taskflow/core/task.hpp"
#include "taskflow/taskflow.hpp"
Expand Down
6 changes: 3 additions & 3 deletions buildcc/lib/target/include/target/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

#include "command/command.h"

#include "target/builder_interface.h"
#include "target/interface/builder_interface.h"

#include "target/generator_loader.h"
#include "target/path.h"
#include "target/base/generator_loader.h"
#include "target/common/path.h"

namespace buildcc::base {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
* limitations under the License.
*/

#ifndef TARGET_BUILDER_INTERFACE_H_
#define TARGET_BUILDER_INTERFACE_H_
#ifndef TARGET_INTERFACE_BUILDER_INTERFACE_H_
#define TARGET_INTERFACE_BUILDER_INTERFACE_H_

#include <algorithm>
#include <functional>
#include <unordered_set>

#include "target/path.h"
#include "target/util.h"
#include "target/common/path.h"
#include "target/common/util.h"

namespace buildcc::base {

// TODO, 1. Consider updating Recheck* APIs - do not modify internal `dirty_`
// flag
// TODO, 2. Consider removing dependency on target/util.h
// TODO, 2. Consider removing dependency on target/common/util.h
// TODO, 3. Consider making Recheck* APIs free namespaced functions instead of
// only within the scope of BuilderInterfaces (See TODO 1. and 2. first)
class BuilderInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef TARGET_LOADER_INTERFACE_H_
#define TARGET_LOADER_INTERFACE_H_
#ifndef TARGET_INTERFACE_LOADER_INTERFACE_H_
#define TARGET_INTERFACE_LOADER_INTERFACE_H_

#include <filesystem>

Expand Down
2 changes: 1 addition & 1 deletion buildcc/lib/target/include/target/private/schema_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <algorithm>

#include "target/path.h"
#include "target/common/path.h"

namespace fbs = schema::internal;

Expand Down
8 changes: 4 additions & 4 deletions buildcc/lib/target/include/target/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <vector>

// Interface
#include "target/builder_interface.h"
#include "target/interface/builder_interface.h"

// API
#include "target/api/target_getter.h"
Expand All @@ -43,9 +43,9 @@
#include "target/friend/link_target.h"

// Internal
#include "target/path.h"
#include "target/target_loader.h"
#include "target/target_storer.h"
#include "target/base/target_loader.h"
#include "target/base/target_storer.h"
#include "target/common/path.h"

// Components
#include "command/command.h"
Expand Down
Loading