Skip to content

Compilation speedup #211

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 11 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ _BuildCC_ is licensed under the Apache License, Version 2.0. See [LICENSE](LICEN

> Developers who would like to suggest an alternative library, raise an issue with the **license** and **advantages** clearly outlined.

- [Fmtlib](https://github.com/fmtlib/fmt) (Formatting) [MIT License] [Header Only]
- [Spdlog](https://github.com/gabime/spdlog) (Logging) [MIT License] [Header Only]
- [Fmtlib](https://github.com/fmtlib/fmt) (Formatting) [MIT License]
- [Spdlog](https://github.com/gabime/spdlog) (Logging) [MIT License]
- [Tiny Process Library](https://gitlab.com/eidheim/tiny-process-library) (Process handling) [MIT License]
- [Taskflow](https://github.com/taskflow/taskflow) (Parallel Programming) [MIT License] [Header Only]
- See also [3rd-Party](https://github.com/taskflow/taskflow/tree/master/3rd-party) used by Taskflow
- [Flatbuffers](https://github.com/google/flatbuffers) (Serialization) [Apache-2.0 License] [Header Only]
- [Flatbuffers](https://github.com/google/flatbuffers) (Serialization) [Apache-2.0 License]
- [CLI11](https://github.com/CLIUtils/CLI11) (Argument Parsing) [BSD-3-Clause License] [Header Only]
- [CppUTest](https://github.com/cpputest/cpputest) (Unit Testing/Mocking) [BSD-3-Clause License]
8 changes: 3 additions & 5 deletions buildcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ if(${BUILDCC_BUILD_AS_SINGLE_LIB})
$<INSTALL_INTERFACE:${BUILDCC_INSTALL_HEADER_PREFIX}>
)
target_link_libraries(buildcc PUBLIC
fmt::fmt-header-only
flatbuffers_header_only
fmt::fmt
flatbuffers
Taskflow
CLI11::CLI11
)
target_link_libraries(buildcc PRIVATE
spdlog::spdlog_header_only
spdlog::spdlog
tiny-process-library::tiny-process-library
)
target_compile_options(buildcc PRIVATE ${BUILD_COMPILE_FLAGS})
target_link_options(buildcc PRIVATE ${BUILD_LINK_FLAGS})
if(${BUILDCC_PRECOMPILE_HEADERS})
target_precompile_headers(buildcc INTERFACE buildcc.h)
target_precompile_headers(buildcc INTERFACE ${FBS_DIR}/pch/pch.h)
endif()
endif()

Expand Down Expand Up @@ -65,7 +64,6 @@ if (${BUILDCC_BUILD_AS_INTERFACE})
)
if(${BUILDCC_PRECOMPILE_HEADERS})
target_precompile_headers(buildcc_i INTERFACE buildcc.h)
target_precompile_headers(buildcc_i INTERFACE ${FBS_DIR}/pch/pch.h)
endif()
endif()

Expand Down
40 changes: 24 additions & 16 deletions buildcc/lib/args/test/test_register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ TEST(RegisterTestGroup, Register_Build) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");

Expand Down Expand Up @@ -160,8 +161,9 @@ TEST(RegisterTestGroup, Register_Run_PostCb) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");

Expand Down Expand Up @@ -203,8 +205,9 @@ TEST(RegisterTestGroup, Register_NoBuildAndDep) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
buildcc::BaseTarget dependency("depT", buildcc::TargetType::Executable,
Expand Down Expand Up @@ -292,8 +295,9 @@ TEST(RegisterTestGroup, Register_BuildAndDep) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
buildcc::BaseTarget dependency("depT", buildcc::TargetType::Executable,
Expand Down Expand Up @@ -389,8 +393,9 @@ TEST(RegisterTestGroup, Register_DepDuplicate) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
buildcc::BaseTarget dependency("depT", buildcc::TargetType::Executable,
Expand Down Expand Up @@ -465,8 +470,9 @@ TEST(RegisterTestGroup, Register_DepCyclic) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
buildcc::BaseTarget dependency("depT", buildcc::TargetType::Executable,
Expand Down Expand Up @@ -542,8 +548,9 @@ TEST(RegisterTestGroup, Register_Test) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
buildcc::BaseTarget dependency("depT", buildcc::TargetType::Executable,
Expand Down Expand Up @@ -632,8 +639,9 @@ TEST(RegisterTestGroup, Register_TestWithOutput) {

// Make dummy toolchain and target
buildcc::Project::Init(fs::current_path(), fs::current_path());
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "", "", "", "", "",
"");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "",
buildcc::ToolchainExecutables("", "", "", "", ""));
buildcc::BaseTarget target("dummyT", buildcc::TargetType::Executable,
toolchain, "");
buildcc::BaseTarget dependency("depT", buildcc::TargetType::Executable,
Expand Down
6 changes: 3 additions & 3 deletions buildcc/lib/env/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (${TESTING})
${CMAKE_CURRENT_SOURCE_DIR}/mock/include
)
target_link_libraries(mock_env PUBLIC
fmt::fmt-header-only
fmt::fmt
Taskflow

CppUTest
Expand Down Expand Up @@ -96,11 +96,11 @@ if(${BUILDCC_BUILD_AS_INTERFACE})
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${BUILDCC_INSTALL_HEADER_PREFIX}>
)
target_link_libraries(env PUBLIC fmt::fmt-header-only)
target_link_libraries(env PUBLIC fmt::fmt)
target_compile_options(env PRIVATE ${BUILD_COMPILE_FLAGS})
target_link_options(env PRIVATE ${BUILD_LINK_FLAGS})
target_link_libraries(env PRIVATE
spdlog::spdlog_header_only
spdlog::spdlog
tiny-process-library::tiny-process-library
)
endif()
Expand Down
4 changes: 2 additions & 2 deletions buildcc/lib/env/include/env/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class ScopedStorage {
* @param ptr Can hold data of any type
* @param typeid_name We cannot store a template type so this is the next
* best thing
* @param desstructor Destructor callback to delete ptr
* @param destructor Destructor callback to delete ptr
*/
struct PtrMetadata {
void *ptr;
void *ptr{nullptr};
std::string typeid_name;
std::function<void(void)> destructor;
};
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_base_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ TEST_GROUP(TargetBaseTestGroup)
}
};
// clang-format on
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

TEST(TargetBaseTestGroup, InvalidTargetType) {
constexpr const char *const INVALID_NAME = "Invalid.random";
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_compile_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ TEST_GROUP(TargetCompileObjectTestGroup)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

TEST(TargetCompileObjectTestGroup, CacheCompileCommand_Invalid) {
buildcc::BaseTarget target("CacheCompileCommand_Invalid",
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_external_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ TEST_GROUP(TargetTestExternalLib)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

static const fs::path intermediate_path =
fs::path(BUILD_TARGET_EXTERNAL_LIB_INTERMEDIATE_DIR) / gcc.GetName();
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_failure_states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ TEST_GROUP(TargetTestFailureStates)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

TEST(TargetTestFailureStates, StartTaskEnvFailure) {
buildcc::env::set_task_state(buildcc::env::TaskState::FAILURE);
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_flags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

// Constants

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

// ------------- PREPROCESSOR FLAGS ---------------

Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_include_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ TEST_GROUP(TargetTestIncludeDirGroup)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

static const fs::path target_include_dir_intermediate_path =
fs::path(BUILD_TARGET_INCLUDE_DIR_INTERMEDIATE_DIR) / gcc.GetName();
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_lib_dep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ TEST_GROUP(TargetTestLibDep)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

static const fs::path intermediate_path =
fs::path(BUILD_TARGET_LIB_DEP_INTERMEDIATE_DIR) / gcc.GetName();
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ TEST_GROUP(TargetTestLock)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

TEST(TargetTestLock, LockState) {
constexpr const char *const NAME = "LockState.exe";
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_pch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ TEST_GROUP(TargetPchTestGroup)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

TEST(TargetPchTestGroup, Target_AddPch) {
constexpr const char *const NAME = "AddPch.exe";
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ TEST_GROUP(TargetTestSourceGroup)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

static const fs::path target_source_intermediate_path =
fs::path(BUILD_TARGET_SOURCE_INTERMEDIATE_DIR) / gcc.GetName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ TEST_GROUP(TargetTestSourceOutOfRootGroup)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

static const fs::path target_source_intermediate_path =
fs::path(BUILD_TARGET_SOURCE_OUT_OF_ROOT_INTERMEDIATE_DIR) / gcc.GetName();
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ TEST_GROUP(TargetTestSyncGroup)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ldd");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

TEST(TargetTestSyncGroup, CopyByConstRef) {
buildcc::BaseTarget srcTarget("srcTarget", buildcc::TargetType::Executable,
Expand Down
5 changes: 3 additions & 2 deletions buildcc/lib/target/test/target/test_target_user_deps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ TEST_GROUP(TargetTestUserDepsGroup)
};
// clang-format on

static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
static buildcc::Toolchain gcc(buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++",
"ar", "ld"));

static const fs::path target_source_intermediate_path =
fs::path(BUILD_TARGET_USER_DEPS_INTERMEDIATE_DIR) / gcc.GetName();
Expand Down
15 changes: 9 additions & 6 deletions buildcc/lib/target/test/target/test_toolchain_flag_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ TEST_GROUP(ToolchainFlagApiTestGroup)
// clang-format on

TEST(ToolchainFlagApiTestGroup, BasicToolchainTest_Lock) {
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++", "ar", "ld"));
toolchain.Lock();
CHECK_THROWS(std::exception, toolchain.AddPreprocessorFlag("-preprocessor"));
CHECK_THROWS(std::exception, toolchain.AddAsmCompileFlag("-asm"));
Expand All @@ -29,8 +30,9 @@ TEST(ToolchainFlagApiTestGroup, BasicToolchainTest_Lock) {
}

TEST(ToolchainFlagApiTestGroup, BasicToolchainTest_Unlock) {
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++", "ar", "ld"));
toolchain.AddPreprocessorFlag("-preprocessor");
toolchain.AddAsmCompileFlag("-asm");
toolchain.AddPchCompileFlag("-pchcompile");
Expand All @@ -55,8 +57,9 @@ TEST(ToolchainFlagApiTestGroup, BasicToolchainTest_Unlock) {
}

TEST(ToolchainFlagApiTestGroup, BasicTargetTest) {
buildcc::Toolchain toolchain(buildcc::ToolchainId::Gcc, "gcc", "as", "gcc",
"g++", "ar", "ld");
buildcc::Toolchain toolchain(
buildcc::ToolchainId::Gcc, "gcc",
buildcc::ToolchainExecutables("as", "gcc", "g++", "ar", "ld"));

toolchain.AddPreprocessorFlag("-preprocessor");
toolchain.AddAsmCompileFlag("-asm");
Expand Down
11 changes: 0 additions & 11 deletions buildcc/lib/toolchain/include/toolchain/toolchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ class Toolchain : public internal::FlagApi<Toolchain>,
: id_(id), name_(name), executables_(executables), config_(config),
lock_(false) {}

[[deprecated]] Toolchain(ToolchainId id, std::string_view name,
std::string_view assembler,
std::string_view c_compiler,
std::string_view cpp_compiler,
std::string_view archiver, std::string_view linker,
const ToolchainConfig &config = ToolchainConfig())
: Toolchain(id, name,
ToolchainExecutables(assembler, c_compiler, cpp_compiler,
archiver, linker),
config) {}

virtual ~Toolchain() = default;
Toolchain(Toolchain &&) = default;
Toolchain &operator=(Toolchain &&) = default;
Expand Down
Loading