diff --git a/bootstrap/src/build_buildcc.cpp b/bootstrap/src/build_buildcc.cpp index 7432964a..f8ae45e5 100644 --- a/bootstrap/src/build_buildcc.cpp +++ b/bootstrap/src/build_buildcc.cpp @@ -53,11 +53,6 @@ void buildcc_cb(BaseTarget &target, const BaseGenerator &schema_gen, target.AddIncludeDir("lib/env/include"); target.GlobHeaders("lib/env/include/env"); - // COMMAND - target.GlobSources("lib/command/src"); - target.AddIncludeDir("lib/command/include"); - target.GlobHeaders("lib/command/include/command"); - // TOOLCHAIN target.AddIncludeDir("lib/toolchain/include"); target.GlobHeaders("lib/toolchain/include/toolchain"); diff --git a/buildcc/CMakeLists.txt b/buildcc/CMakeLists.txt index 90bf1a23..860404be 100644 --- a/buildcc/CMakeLists.txt +++ b/buildcc/CMakeLists.txt @@ -34,9 +34,6 @@ endif() # Environment add_subdirectory(lib/env) -# -add_subdirectory(lib/command) - # Toolchain add_subdirectory(lib/toolchain) add_subdirectory(toolchains) diff --git a/buildcc/buildcc.h b/buildcc/buildcc.h index 8e533a96..84861233 100644 --- a/buildcc/buildcc.h +++ b/buildcc/buildcc.h @@ -26,9 +26,7 @@ #include "env/host_os.h" #include "env/host_compiler.h" #include "env/util.h" - -// -#include "command/command.h" +#include "env/command.h" // Base #include "toolchain/toolchain.h" diff --git a/buildcc/lib/args/src/register.cpp b/buildcc/lib/args/src/register.cpp index c6a02173..4ea1ed9e 100644 --- a/buildcc/lib/args/src/register.cpp +++ b/buildcc/lib/args/src/register.cpp @@ -129,7 +129,7 @@ void Register::Env() { void TestInfo::TestRunner() const { env::log_info(__FUNCTION__, fmt::format("Testing \'{}\'", target_.GetUniqueId())); - Command command; + env::Command command; command.AddDefaultArguments({ {"executable", fmt::format("{}", target_.GetTargetPath())}, }); @@ -173,8 +173,8 @@ void TestInfo::TestRunner() const { }; const bool success = - Command::Execute(test_command, config_.GetWorkingDirectory(), - redirect_stdout, redirect_stderr); + env::Command::Execute(test_command, config_.GetWorkingDirectory(), + redirect_stdout, redirect_stderr); env::assert_fatal(success, fmt::format("Could not run {}", target_.GetUniqueId())); diff --git a/buildcc/lib/args/src/tasks.cpp b/buildcc/lib/args/src/tasks.cpp index b459007f..a0068999 100644 --- a/buildcc/lib/args/src/tasks.cpp +++ b/buildcc/lib/args/src/tasks.cpp @@ -16,6 +16,7 @@ #include "args/register.h" #include "env/logging.h" +#include "env/util.h" namespace buildcc { @@ -33,6 +34,8 @@ void Register::RunBuild() { executor_.num_workers())); executor_.run(build_tf_); executor_.wait_for_all(); + env::assert_fatal(env::get_task_state() == env::TaskState::SUCCESS, + "Task state is not successful!"); } void Register::RunTest() { diff --git a/buildcc/lib/args/test/test_register.cpp b/buildcc/lib/args/test/test_register.cpp index a4d58e95..e68d7fa6 100644 --- a/buildcc/lib/args/test/test_register.cpp +++ b/buildcc/lib/args/test/test_register.cpp @@ -535,7 +535,7 @@ TEST(RegisterTestGroup, Register_Test) { std::vector stdout_data; std::vector stderr_data; - buildcc::m::CommandExpect_Execute(1, true, &stdout_data, &stderr_data); + buildcc::env::m::CommandExpect_Execute(1, true, &stdout_data, &stderr_data); reg.RunTest(); } @@ -588,7 +588,7 @@ TEST(RegisterTestGroup, Register_TestWithOutput) { {}, {}, buildcc::TestOutput(buildcc::TestOutput::Type::DefaultBehaviour))); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); reg.RunTest(); } @@ -606,7 +606,7 @@ TEST(RegisterTestGroup, Register_TestWithOutput) { buildcc::TestOutput(buildcc::TestOutput::Type::TestPrintOnStderr))); std::vector stderr_data; - buildcc::m::CommandExpect_Execute(1, true, nullptr, &stderr_data); + buildcc::env::m::CommandExpect_Execute(1, true, nullptr, &stderr_data); reg.RunTest(); } @@ -624,7 +624,7 @@ TEST(RegisterTestGroup, Register_TestWithOutput) { buildcc::TestOutput(buildcc::TestOutput::Type::TestPrintOnStdout))); std::vector stdout_data; - buildcc::m::CommandExpect_Execute(1, true, &stdout_data, nullptr); + buildcc::env::m::CommandExpect_Execute(1, true, &stdout_data, nullptr); reg.RunTest(); } @@ -643,7 +643,7 @@ TEST(RegisterTestGroup, Register_TestWithOutput) { std::vector stdout_data; std::vector stderr_data; - buildcc::m::CommandExpect_Execute(1, true, &stdout_data, &stderr_data); + buildcc::env::m::CommandExpect_Execute(1, true, &stdout_data, &stderr_data); reg.RunTest(); } @@ -660,7 +660,7 @@ TEST(RegisterTestGroup, Register_TestWithOutput) { buildcc::TestOutput(buildcc::TestOutput::Type::UserRedirect, nullptr, nullptr))); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); reg.RunTest(); } @@ -684,7 +684,7 @@ TEST(RegisterTestGroup, Register_TestWithOutput) { int main(int ac, char **av) { MemoryLeakWarningPlugin::turnOffNewDeleteOverloads(); - buildcc::m::VectorStringCopier copier; + buildcc::env::m::VectorStringCopier copier; mock().installCopier(TEST_VECTOR_STRING_TYPE, copier); return CommandLineTestRunner::RunAllTests(ac, av); } diff --git a/buildcc/lib/command/CMakeLists.txt b/buildcc/lib/command/CMakeLists.txt deleted file mode 100644 index 307428cc..00000000 --- a/buildcc/lib/command/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -if (${TESTING}) - add_library(mock_command - mock/execute.cpp - src/command.cpp - ) - target_include_directories(mock_command PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/mock - ) - target_link_libraries(mock_command PUBLIC - fmt::fmt-header-only - mock_env - CppUTest - CppUTestExt - gcov - ) - target_compile_options(mock_command PUBLIC ${TEST_COMPILE_FLAGS} ${BUILD_COMPILE_FLAGS}) - target_link_options(mock_command PUBLIC ${TEST_LINK_FLAGS} ${BUILD_LINK_FLAGS}) - - # Tests - add_executable(test_command test/test_command.cpp) - target_link_libraries(test_command PRIVATE mock_command) - - add_test(NAME test_command COMMAND test_command) -endif() - -set(COMMAND_SRCS - src/execute.cpp - src/command.cpp - include/command/command.h -) - -if(${BUILDCC_BUILD_AS_SINGLE_LIB}) - target_sources(buildcc PRIVATE - ${COMMAND_SRCS} - ) - target_include_directories(buildcc PUBLIC - $ - $ - ) -endif() - -if(${BUILDCC_BUILD_AS_INTERFACE}) - m_clangtidy("command") - add_library(command - ${COMMAND_SRCS} - ) - target_include_directories(command PUBLIC - $ - $ - ) - target_link_libraries(command PRIVATE - fmt::fmt-header-only - tiny-process-library::tiny-process-library - - env - ) - target_compile_options(command PRIVATE ${BUILD_COMPILE_FLAGS}) - target_link_options(command PRIVATE ${BUILD_LINK_FLAGS}) -endif() - -if (${BUILDCC_INSTALL}) - if(${BUILDCC_BUILD_AS_INTERFACE}) - install(TARGETS command DESTINATION lib EXPORT commandConfig) - install(EXPORT commandConfig DESTINATION "${BUILDCC_INSTALL_LIB_PREFIX}/command") - endif() - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION "${BUILDCC_INSTALL_HEADER_PREFIX}") -endif() diff --git a/buildcc/lib/env/CMakeLists.txt b/buildcc/lib/env/CMakeLists.txt index 29d07dba..ecc6080b 100644 --- a/buildcc/lib/env/CMakeLists.txt +++ b/buildcc/lib/env/CMakeLists.txt @@ -6,9 +6,13 @@ if (${TESTING}) src/env.cpp src/task_state.cpp + + src/command.cpp + mock/execute.cpp ) target_include_directories(mock_env PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/mock/include ) target_link_libraries(mock_env PUBLIC fmt::fmt-header-only @@ -28,8 +32,12 @@ if (${TESTING}) add_executable(test_task_state test/test_task_state.cpp) target_link_libraries(test_task_state PRIVATE mock_env) + add_executable(test_command test/test_command.cpp) + target_link_libraries(test_command PRIVATE mock_env) + add_test(NAME test_env_util COMMAND test_env_util) add_test(NAME test_task_state COMMAND test_task_state) + add_test(NAME test_command COMMAND test_command) endif() set(ENV_SRCS @@ -48,6 +56,10 @@ set(ENV_SRCS src/task_state.cpp include/env/task_state.h + + src/command.cpp + src/execute.cpp + include/env/command.h ) if(${BUILDCC_BUILD_AS_SINGLE_LIB}) @@ -74,15 +86,14 @@ if(${BUILDCC_BUILD_AS_INTERFACE}) target_link_options(env PRIVATE ${BUILD_LINK_FLAGS}) target_link_libraries(env PRIVATE spdlog::spdlog_header_only + tiny-process-library::tiny-process-library ) +endif() - # Env install - if (${BUILDCC_INSTALL}) +if (${BUILDCC_INSTALL}) + if (${BUILDCC_BUILD_AS_INTERFACE}) install(TARGETS env DESTINATION lib EXPORT envConfig) install(EXPORT envConfig DESTINATION "${BUILDCC_INSTALL_LIB_PREFIX}/env") endif() -endif() - -if (${BUILDCC_INSTALL}) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION "${BUILDCC_INSTALL_HEADER_PREFIX}") endif() diff --git a/buildcc/lib/env/include/env/assert_fatal.h b/buildcc/lib/env/include/env/assert_fatal.h index d1006d7e..b7754670 100644 --- a/buildcc/lib/env/include/env/assert_fatal.h +++ b/buildcc/lib/env/include/env/assert_fatal.h @@ -32,7 +32,8 @@ namespace buildcc::env { /** * @brief Compile time expr asserts fatally when false */ -template inline void assert_fatal(const char *message) { +template +inline void assert_fatal([[maybe_unused]] const char *message) { if constexpr (!expr) { env::log_critical("assert", message); assert_handle_fatal(); diff --git a/buildcc/lib/command/include/command/command.h b/buildcc/lib/env/include/env/command.h similarity index 96% rename from buildcc/lib/command/include/command/command.h rename to buildcc/lib/env/include/env/command.h index 7183ae97..79e763b6 100644 --- a/buildcc/lib/command/include/command/command.h +++ b/buildcc/lib/env/include/env/command.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef COMMAND_COMMAND_H_ -#define COMMAND_COMMAND_H_ +#ifndef ENV_COMMAND_H_ +#define ENV_COMMAND_H_ #include #include @@ -25,7 +25,7 @@ namespace fs = std::filesystem; -namespace buildcc { +namespace buildcc::env { class Command { public: @@ -82,6 +82,6 @@ class Command { std::unordered_map default_values_; }; -} // namespace buildcc +} // namespace buildcc::env #endif diff --git a/buildcc/lib/command/mock/execute.cpp b/buildcc/lib/env/mock/execute.cpp similarity index 95% rename from buildcc/lib/command/mock/execute.cpp rename to buildcc/lib/env/mock/execute.cpp index 8ff8555c..642411e4 100644 --- a/buildcc/lib/command/mock/execute.cpp +++ b/buildcc/lib/env/mock/execute.cpp @@ -1,10 +1,10 @@ -#include "command/command.h" +#include "env/command.h" #include "expect_command.h" #include "CppUTestExt/MockSupport.h" -namespace buildcc { +namespace buildcc::env { static constexpr const char *const EXECUTE_FUNCTION = "execute"; static constexpr const char *const STDOUT_DATA_STRING = "stdout_data"; @@ -48,4 +48,4 @@ void CommandExpect_Execute(unsigned int calls, bool expectation, } // namespace m -} // namespace buildcc +} // namespace buildcc::env diff --git a/buildcc/lib/command/mock/expect_command.h b/buildcc/lib/env/mock/include/expect_command.h similarity index 72% rename from buildcc/lib/command/mock/expect_command.h rename to buildcc/lib/env/mock/include/expect_command.h index e6eeed19..7149f594 100644 --- a/buildcc/lib/command/mock/expect_command.h +++ b/buildcc/lib/env/mock/include/expect_command.h @@ -1,17 +1,17 @@ -#ifndef COMMAND_MOCK_EXPECT_COMMAND_H_ -#define COMMAND_MOCK_EXPECT_COMMAND_H_ +#ifndef ENV_MOCK_EXPECT_COMMAND_H_ +#define ENV_MOCK_EXPECT_COMMAND_H_ #include #include constexpr const char *const TEST_VECTOR_STRING_TYPE = "vector_string"; -namespace buildcc::m { +namespace buildcc::env::m { void CommandExpect_Execute(unsigned int calls, bool expectation, std::vector *stdout_data = nullptr, std::vector *stderr_data = nullptr); -} // namespace buildcc::m +} // namespace buildcc::env::m #endif diff --git a/buildcc/lib/command/mock/mock_command_copier.h b/buildcc/lib/env/mock/include/mock_command_copier.h similarity index 78% rename from buildcc/lib/command/mock/mock_command_copier.h rename to buildcc/lib/env/mock/include/mock_command_copier.h index db86b97c..f9e0e70c 100644 --- a/buildcc/lib/command/mock/mock_command_copier.h +++ b/buildcc/lib/env/mock/include/mock_command_copier.h @@ -1,12 +1,12 @@ -#ifndef COMMAND_MOCK_MOCK_COMMAND_COPIER_H_ -#define COMMAND_MOCK_MOCK_COMMAND_COPIER_H_ +#ifndef ENV_MOCK_MOCK_COMMAND_COPIER_H_ +#define ENV_MOCK_MOCK_COMMAND_COPIER_H_ #include #include #include "CppUTestExt/MockSupport.h" -namespace buildcc::m { +namespace buildcc::env::m { class VectorStringCopier : public MockNamedValueCopier { public: @@ -23,6 +23,6 @@ class VectorStringCopier : public MockNamedValueCopier { } }; -} // namespace buildcc::m +} // namespace buildcc::env::m #endif diff --git a/buildcc/lib/command/src/command.cpp b/buildcc/lib/env/src/command.cpp similarity index 96% rename from buildcc/lib/command/src/command.cpp rename to buildcc/lib/env/src/command.cpp index 5a767b51..febb59c8 100644 --- a/buildcc/lib/command/src/command.cpp +++ b/buildcc/lib/env/src/command.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "command/command.h" +#include "env/command.h" #include @@ -24,7 +24,7 @@ #include "env/assert_fatal.h" #include "env/logging.h" -namespace buildcc { +namespace buildcc::env { void Command::AddDefaultArgument(const std::string &key, const std::string &value) { @@ -64,4 +64,4 @@ std::string Command::Construct( return fmt::vformat(pattern, store); } -} // namespace buildcc +} // namespace buildcc::env diff --git a/buildcc/lib/command/src/execute.cpp b/buildcc/lib/env/src/execute.cpp similarity index 96% rename from buildcc/lib/command/src/execute.cpp rename to buildcc/lib/env/src/execute.cpp index a0e80841..3ff6032f 100644 --- a/buildcc/lib/command/src/execute.cpp +++ b/buildcc/lib/env/src/execute.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "command/command.h" +#include "env/command.h" #include "fmt/format.h" @@ -39,7 +39,7 @@ get_working_directory(const std::optional &working_directory) { } // namespace -namespace buildcc { +namespace buildcc::env { bool Command::Execute(const std::string &command, const std::optional &working_directory, @@ -64,4 +64,4 @@ bool Command::Execute(const std::string &command, return process.get_exit_status() == 0; } -} // namespace buildcc +} // namespace buildcc::env diff --git a/buildcc/lib/command/test/test_command.cpp b/buildcc/lib/env/test/test_command.cpp similarity index 87% rename from buildcc/lib/command/test/test_command.cpp rename to buildcc/lib/env/test/test_command.cpp index 74b69edb..e1e1684c 100644 --- a/buildcc/lib/command/test/test_command.cpp +++ b/buildcc/lib/env/test/test_command.cpp @@ -1,4 +1,4 @@ -#include "command/command.h" +#include "env/command.h" // NOTE, Make sure all these includes are AFTER the system and header includes #include "CppUTest/CommandLineTestRunner.h" @@ -13,18 +13,18 @@ TEST_GROUP(CommandTestGroup) // clang-format on TEST(CommandTestGroup, Construct_InvalidFormat) { - buildcc::Command command; + buildcc::env::Command command; CHECK_THROWS(std::exception, command.Construct("{test}")); } TEST(CommandTestGroup, Construct_Basic) { - buildcc::Command command; + buildcc::env::Command command; std::string s = command.Construct("{}", {{"", "hi"}}); STRCMP_EQUAL(s.c_str(), "hi"); } TEST(CommandTestGroup, Construct_MultipleArgs) { - buildcc::Command command; + buildcc::env::Command command; command.AddDefaultArguments({ {"h", "hello"}, {"w", "world"}, @@ -37,12 +37,12 @@ TEST(CommandTestGroup, Construct_MultipleArgs) { } TEST(CommandTestGroup, Construct_BadArguments) { - buildcc::Command command; + buildcc::env::Command command; CHECK_THROWS(std::exception, command.Construct("{}", {{nullptr, "hi"}})); } TEST(CommandTestGroup, GetDefaultValueByKey) { - buildcc::Command command; + buildcc::env::Command command; command.AddDefaultArgument("key", "value"); const std::string &value = command.GetDefaultValueByKey("key"); @@ -50,7 +50,7 @@ TEST(CommandTestGroup, GetDefaultValueByKey) { } TEST(CommandTestGroup, GetDefaultValueByKey_BadKey) { - buildcc::Command command; + buildcc::env::Command command; command.AddDefaultArgument("key", "value"); CHECK_THROWS(std::exception, command.GetDefaultValueByKey("bad_key")); } diff --git a/buildcc/lib/target/include/target/generator.h b/buildcc/lib/target/include/target/generator.h index b2d6baec..0436d128 100644 --- a/buildcc/lib/target/include/target/generator.h +++ b/buildcc/lib/target/include/target/generator.h @@ -28,7 +28,7 @@ #include "env/env.h" #include "env/task_state.h" -#include "command/command.h" +#include "env/command.h" #include "target/interface/builder_interface.h" @@ -138,7 +138,7 @@ class Generator : public BuilderInterface { // Internal std::mutex task_state_mutex_; env::TaskState task_state_{env::TaskState::SUCCESS}; - Command command_; + env::Command command_; tf::Taskflow tf_; }; diff --git a/buildcc/lib/target/include/target/target.h b/buildcc/lib/target/include/target/target.h index 23b7a541..2dc6c4f5 100644 --- a/buildcc/lib/target/include/target/target.h +++ b/buildcc/lib/target/include/target/target.h @@ -52,7 +52,7 @@ #include "env/task_state.h" // Components -#include "command/command.h" +#include "env/command.h" #include "toolchain/toolchain.h" // Third Party @@ -161,7 +161,7 @@ class Target : public BuilderInterface, internal::path_unordered_set compiled_source_files_; // - Command command_; + env::Command command_; tf::Taskflow tf_; }; diff --git a/buildcc/lib/target/src/generator/task.cpp b/buildcc/lib/target/src/generator/task.cpp index e802fd97..77796998 100644 --- a/buildcc/lib/target/src/generator/task.cpp +++ b/buildcc/lib/target/src/generator/task.cpp @@ -16,7 +16,7 @@ #include "target/generator.h" -#include "command/command.h" +#include "env/command.h" namespace { constexpr const char *const kStartGeneratorTaskName = "Start Generator"; @@ -51,7 +51,7 @@ void Generator::GenerateTask() { tf::Task generate_task = tf_.emplace([&](tf::Subflow &subflow) { auto run_command = [this](const std::string &command) { try { - bool success = Command::Execute(command); + bool success = env::Command::Execute(command); env::assert_throw(success, fmt::format("{} failed", command)); } catch (...) { std::lock_guard guard(task_state_mutex_); diff --git a/buildcc/lib/target/src/target/friend/compile_pch.cpp b/buildcc/lib/target/src/target/friend/compile_pch.cpp index 6ab37919..82f35444 100644 --- a/buildcc/lib/target/src/target/friend/compile_pch.cpp +++ b/buildcc/lib/target/src/target/friend/compile_pch.cpp @@ -47,7 +47,7 @@ void AggregateToFile(const fs::path &filename, aggregated_includes.append(temp); } - buildcc::Command command; + buildcc::env::Command command; std::string constructed_output = command.Construct( kFormat, { {"aggregated_includes", aggregated_includes}, @@ -108,7 +108,7 @@ void CompilePch::BuildCompile() { env::save_file(p.c_str(), {"//Generated by BuildCC"}, false); env::assert_throw(save, fmt::format("Could not save {}", p)); } - bool success = Command::Execute(command_); + bool success = env::Command::Execute(command_); env::assert_throw(success, "Failed to compile pch"); target_.storer_.pch_compiled = true; } diff --git a/buildcc/lib/target/src/target/friend/link_target.cpp b/buildcc/lib/target/src/target/friend/link_target.cpp index 3474fb4b..ec935194 100644 --- a/buildcc/lib/target/src/target/friend/link_target.cpp +++ b/buildcc/lib/target/src/target/friend/link_target.cpp @@ -90,7 +90,7 @@ void LinkTarget::BuildLink() { } if (target_.dirty_) { - bool success = Command::Execute(command_); + bool success = env::Command::Execute(command_); env::assert_throw(success, "Failed to link target"); target_.storer_.target_linked = true; } diff --git a/buildcc/lib/target/src/target/target.cpp b/buildcc/lib/target/src/target/target.cpp index 73a7d5a1..807b1bfb 100644 --- a/buildcc/lib/target/src/target/target.cpp +++ b/buildcc/lib/target/src/target/target.cpp @@ -89,9 +89,8 @@ void Target::RecheckExternalLib( std::bind(&Target::ExternalLibChanged, this)); } -std::optional -Target::SelectCompileFlags(TargetFileExt type) const { - switch (type) { +std::optional Target::SelectCompileFlags(TargetFileExt ext) const { + switch (ext) { case TargetFileExt::Asm: return internal::aggregate(GetCurrentAsmCompileFlags()); break; @@ -107,8 +106,8 @@ Target::SelectCompileFlags(TargetFileExt type) const { return {}; } -std::optional Target::SelectCompiler(TargetFileExt type) const { - switch (type) { +std::optional Target::SelectCompiler(TargetFileExt ext) const { + switch (ext) { case TargetFileExt::Asm: return GetToolchain().GetAsmCompiler(); break; diff --git a/buildcc/lib/target/src/target/tasks.cpp b/buildcc/lib/target/src/target/tasks.cpp index 559f0798..bf779e77 100644 --- a/buildcc/lib/target/src/target/tasks.cpp +++ b/buildcc/lib/target/src/target/tasks.cpp @@ -117,8 +117,8 @@ void CompileObject::Task() { (void)subflow .emplace([this, s]() { try { - bool success = - Command::Execute(GetObjectData(s.GetPathname()).command); + bool success = env::Command::Execute( + GetObjectData(s.GetPathname()).command); env::assert_throw(success, "Could not compile source"); // NOTE, If conmpilation is successful we update the source diff --git a/buildcc/lib/target/test/target/test_generator.cpp b/buildcc/lib/target/test/target/test_generator.cpp index db63e41d..b0e927e8 100644 --- a/buildcc/lib/target/test/target/test_generator.cpp +++ b/buildcc/lib/target/test/target/test_generator.cpp @@ -40,7 +40,7 @@ TEST(GeneratorTestGroup, Generator_Build) { generator.AddCommand("{compiler} -o {gen_build_dir}/dummy_main.exe " "{gen_root_dir}/dummy_main.c"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); @@ -60,7 +60,7 @@ TEST(GeneratorTestGroup, Generator_BuildParallel) { generator.AddCommand("{compiler} -o {gen_build_dir}/dummy_main.exe " "{gen_root_dir}/dummy_main.c"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); @@ -79,7 +79,7 @@ TEST(GeneratorTestGroup, Generator_Identifier) { generator.AddOutput("{gen_build_dir}/dummy_main.exe", "dummy_main_exe"); generator.AddCommand("{compiler} -o {dummy_main_exe} {dummy_main_c}"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); @@ -98,7 +98,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild) { {"compiler", "gcc"}, }); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -130,7 +130,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Inputs) { generator.AddCommand("gcc -o {gen_build_dir}/new_source.exe " "{gen_root_dir}/new_source.cpp"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -143,7 +143,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Inputs) { "{gen_root_dir}/new_source.cpp"); buildcc::base::m::GeneratorExpect_InputRemoved(1, &generator); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -157,7 +157,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Inputs) { "{gen_root_dir}/new_source.cpp"); buildcc::base::m::GeneratorExpect_InputAdded(1, &generator); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -178,7 +178,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Inputs) { generator.AddCommand("gcc -o {gen_build_dir}/new_source.cpp.exe " "{gen_root_dir}/new_source.cpp"); buildcc::base::m::GeneratorExpect_InputUpdated(1, &generator); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -198,7 +198,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Outputs) { {"compiler", "gcc"}, }); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -213,7 +213,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Outputs) { }); buildcc::base::m::GeneratorExpect_OutputChanged(1, &generator); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -229,7 +229,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Outputs) { }); buildcc::base::m::GeneratorExpect_OutputChanged(1, &generator); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -249,7 +249,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Commands) { {"compiler", "gcc"}, }); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -264,7 +264,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Commands) { }); buildcc::base::m::GeneratorExpect_CommandChanged(1, &generator); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -277,7 +277,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Commands) { "{gen_root_dir}/dummy_main.c"); buildcc::base::m::GeneratorExpect_CommandChanged(1, &generator); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -356,7 +356,7 @@ TEST(GeneratorTestGroup, Generator_FailedGenerateCommand) { generator.AddCommand("{compiler} -o {gen_build_dir}/dummy_main.exe " "{gen_root_dir}/dummy_main.c"); - buildcc::m::CommandExpect_Execute(1, false); + buildcc::env::m::CommandExpect_Execute(1, false); generator.Build(); buildcc::base::m::GeneratorRunner(generator); @@ -381,7 +381,7 @@ TEST(GeneratorTestGroup, Generator_FailedStore) { generator.AddCommand("{compiler} -o {gen_build_dir}/dummy_main.exe " "{gen_root_dir}/dummy_main.c"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); @@ -429,7 +429,7 @@ TEST(GeneratorTestGroup, FailedEnvTaskState_Rebuild) { "{gen_root_dir}/dummy_main.c"); generator.Build(); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); buildcc::base::m::GeneratorRunner(generator); } @@ -451,7 +451,7 @@ TEST(GeneratorTestGroup, FailedGenerateCommand_Rebuild) { generator.AddCommand("{compiler} -o {gen_build_dir}/dummy_main.exe " "{gen_root_dir}/dummy_main.c"); - buildcc::m::CommandExpect_Execute(1, false); + buildcc::env::m::CommandExpect_Execute(1, false); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } @@ -472,7 +472,7 @@ TEST(GeneratorTestGroup, FailedGenerateCommand_Rebuild) { generator.AddCommand("{compiler} -o {gen_build_dir}/dummy_main.exe " "{gen_root_dir}/dummy_main.c"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); generator.Build(); buildcc::base::m::GeneratorRunner(generator); } diff --git a/buildcc/lib/target/test/target/test_target_external_lib.cpp b/buildcc/lib/target/test/target/test_target_external_lib.cpp index a8d32691..d98010fe 100644 --- a/buildcc/lib/target/test/target/test_target_external_lib.cpp +++ b/buildcc/lib/target/test/target/test_target_external_lib.cpp @@ -45,8 +45,8 @@ TEST(TargetTestExternalLib, TestAddLibDir) { exe.AddSource("foo_main.cpp"); exe.AddLibDir(exe.GetTargetPath().parent_path()); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); CHECK_TRUE(exe.IsBuilt()); @@ -73,8 +73,8 @@ TEST(TargetTestExternalLib, TestAddExternalLibDep_Simple) { exe.AddLibDir(exe.GetTargetPath().parent_path()); exe.AddLibDep("-lfoo"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); CHECK_TRUE(exe.IsBuilt()); @@ -102,8 +102,8 @@ TEST(TargetTestExternalLib, TestAddExternalLibDep_RebuildChanged) { exe.AddSource("foo_main.cpp"); exe.AddLibDir(exe.GetTargetPath().parent_path()); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); CHECK_TRUE(exe.IsBuilt()); @@ -118,7 +118,7 @@ TEST(TargetTestExternalLib, TestAddExternalLibDep_RebuildChanged) { exe.AddLibDep("-lfoo"); buildcc::base::m::TargetExpect_ExternalLibChanged(1, &exe); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); CHECK_TRUE(exe.IsBuilt()); @@ -132,7 +132,7 @@ TEST(TargetTestExternalLib, TestAddExternalLibDep_RebuildChanged) { exe.AddLibDir(exe.GetTargetPath().parent_path()); buildcc::base::m::TargetExpect_ExternalLibChanged(1, &exe); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); CHECK_TRUE(exe.IsBuilt()); diff --git a/buildcc/lib/target/test/target/test_target_failure_states.cpp b/buildcc/lib/target/test/target/test_target_failure_states.cpp index 36d4c31e..42f06eb6 100644 --- a/buildcc/lib/target/test/target/test_target_failure_states.cpp +++ b/buildcc/lib/target/test/target/test_target_failure_states.cpp @@ -51,7 +51,7 @@ TEST(TargetTestFailureStates, CompilePchFailure) { target.AddPch("include/include_header.h"); target.Build(); - buildcc::m::CommandExpect_Execute(1, false); // PCH compile + buildcc::env::m::CommandExpect_Execute(1, false); // PCH compile buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::FAILURE); @@ -67,8 +67,8 @@ TEST(TargetTestFailureStates, CompileObjectFailure) { target.AddSource("dummy_main.c"); target.Build(); - buildcc::m::CommandExpect_Execute(1, false); // compile - buildcc::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, false); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // compile buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::FAILURE); @@ -96,8 +96,8 @@ TEST(TargetTestFailureStates, LinkTargetFailure) { target.AddSource("dummy_main.cpp"); target.Build(); - buildcc::m::CommandExpect_Execute(1, true); // compile - buildcc::m::CommandExpect_Execute(1, false); // link + buildcc::env::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, false); // link buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::FAILURE); @@ -114,8 +114,8 @@ TEST(TargetTestFailureStates, EndTaskStoreFailure) { fs::remove_all( target.GetTargetBuildDir()); // removing this path causes store failure - buildcc::m::CommandExpect_Execute(1, true); // compile - buildcc::m::CommandExpect_Execute(1, true); // link + buildcc::env::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // link buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::FAILURE); @@ -152,8 +152,8 @@ TEST(TargetTestFailureStates, StartTaskEnvFailure_Rebuild) { target.AddSource("dummy_main.cpp"); target.Build(); - buildcc::m::CommandExpect_Execute(1, true); // compile - buildcc::m::CommandExpect_Execute(1, true); // link + buildcc::env::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // link buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::SUCCESS); @@ -173,7 +173,7 @@ TEST(TargetTestFailureStates, CompilePchFailure_Rebuild) { target.AddPch("include/include_header.h"); target.Build(); - buildcc::m::CommandExpect_Execute(1, false); // PCH compile + buildcc::env::m::CommandExpect_Execute(1, false); // PCH compile buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::FAILURE); @@ -193,9 +193,9 @@ TEST(TargetTestFailureStates, CompilePchFailure_Rebuild) { target.AddPch("include/include_header.h"); target.Build(); - buildcc::m::CommandExpect_Execute(1, true); // PCH compile - buildcc::m::CommandExpect_Execute(1, true); // Object compile - buildcc::m::CommandExpect_Execute(1, true); // Link target + buildcc::env::m::CommandExpect_Execute(1, true); // PCH compile + buildcc::env::m::CommandExpect_Execute(1, true); // Object compile + buildcc::env::m::CommandExpect_Execute(1, true); // Link target buildcc::base::m::TargetRunner(target); @@ -216,8 +216,8 @@ TEST(TargetTestFailureStates, CompileObjectFailure_Rebuild) { target.AddSource("dummy_main.c"); target.Build(); - buildcc::m::CommandExpect_Execute(1, false); // compile - buildcc::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, false); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // compile buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::FAILURE); @@ -246,9 +246,9 @@ TEST(TargetTestFailureStates, CompileObjectFailure_Rebuild) { // NOTE, The other one does not compile since it already compiled // successfully earlier! - buildcc::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // compile buildcc::base::m::TargetExpect_SourceAdded(1, &target); - buildcc::m::CommandExpect_Execute(1, true); // link + buildcc::env::m::CommandExpect_Execute(1, true); // link buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::SUCCESS); @@ -266,8 +266,8 @@ TEST(TargetTestFailureStates, LinkTargetFailure_Rebuild) { target.AddSource("dummy_main.cpp"); target.Build(); - buildcc::m::CommandExpect_Execute(1, true); // compile - buildcc::m::CommandExpect_Execute(1, false); // link + buildcc::env::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, false); // link buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::FAILURE); @@ -285,7 +285,7 @@ TEST(TargetTestFailureStates, LinkTargetFailure_Rebuild) { target.Build(); // we do not recompile - buildcc::m::CommandExpect_Execute(1, true); // link + buildcc::env::m::CommandExpect_Execute(1, true); // link buildcc::base::m::TargetRunner(target); CHECK(target.GetTaskState() == buildcc::env::TaskState::SUCCESS); diff --git a/buildcc/lib/target/test/target/test_target_flags.cpp b/buildcc/lib/target/test/target/test_target_flags.cpp index daafebcd..7120f3dc 100644 --- a/buildcc/lib/target/test/target/test_target_flags.cpp +++ b/buildcc/lib/target/test/target/test_target_flags.cpp @@ -54,8 +54,8 @@ TEST(TargetTestPreprocessorFlagGroup, Target_AddPreprocessorFlag) { simple.AddSource(DUMMY_MAIN); simple.AddPreprocessorFlag("-DCOMPILE=1"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -86,8 +86,8 @@ TEST(TargetTestPreprocessorFlagGroup, Target_ChangedPreprocessorFlag) { simple.AddSource(DUMMY_MAIN); simple.AddPreprocessorFlag("-DCOMPILE=1"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -98,8 +98,8 @@ TEST(TargetTestPreprocessorFlagGroup, Target_ChangedPreprocessorFlag) { gcc, "data"); simple.AddSource(DUMMY_MAIN); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -112,8 +112,8 @@ TEST(TargetTestPreprocessorFlagGroup, Target_ChangedPreprocessorFlag) { simple.AddSource(DUMMY_MAIN); simple.AddPreprocessorFlag("-DRANDOM=1"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -152,8 +152,8 @@ TEST(TargetTestCommonCompileFlagsGroup, Target_AddCommonCompileFlag) { simple.AddCommonCompileFlag("-O0"); simple.AddCommonCompileFlag("-g"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -185,8 +185,8 @@ TEST(TargetTestCommonCompileFlagsGroup, Target_ChangedCommonCompileFlag) { simple.AddCommonCompileFlag("-O0"); simple.AddCommonCompileFlag("-g"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -210,8 +210,8 @@ TEST(TargetTestCommonCompileFlagsGroup, Target_ChangedCommonCompileFlag) { simple.AddCommonCompileFlag("-O0"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -226,8 +226,8 @@ TEST(TargetTestCommonCompileFlagsGroup, Target_ChangedCommonCompileFlag) { simple.AddCommonCompileFlag("-g"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -266,8 +266,8 @@ TEST(TargetTestAsmCompileFlagGroup, Target_AddCompileFlag) { simple.AddAsmCompileFlag("-O0"); simple.AddAsmCompileFlag("-g"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -299,8 +299,8 @@ TEST(TargetTestAsmCompileFlagGroup, Target_ChangedCompileFlag) { simple.AddAsmCompileFlag("-O0"); simple.AddAsmCompileFlag("-g"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -325,8 +325,8 @@ TEST(TargetTestAsmCompileFlagGroup, Target_ChangedCompileFlag) { simple.AddAsmCompileFlag("-O0"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -341,8 +341,8 @@ TEST(TargetTestAsmCompileFlagGroup, Target_ChangedCompileFlag) { simple.AddAsmCompileFlag("-g"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -380,8 +380,8 @@ TEST(TargetTestCCompileFlagsGroup, Target_AddCompileFlag) { simple.AddSource(DUMMY_MAIN); simple.AddCCompileFlag("-std=c11"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -412,8 +412,8 @@ TEST(TargetTestCCompileFlagsGroup, Target_ChangedCompileFlag) { simple.AddSource(DUMMY_MAIN); simple.AddCCompileFlag("-std=c11"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -424,8 +424,8 @@ TEST(TargetTestCCompileFlagsGroup, Target_ChangedCompileFlag) { gcc, "data"); simple.AddSource(DUMMY_MAIN); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -438,8 +438,8 @@ TEST(TargetTestCCompileFlagsGroup, Target_ChangedCompileFlag) { simple.AddSource(DUMMY_MAIN); simple.AddCCompileFlag("-std=c11"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -477,8 +477,8 @@ TEST(TargetTestCppCompileFlagsGroup, Target_AddCompileFlag) { simple.AddSource(DUMMY_MAIN); simple.AddCppCompileFlag("-std=c++17"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -509,8 +509,8 @@ TEST(TargetTestCppCompileFlagsGroup, Target_ChangedCompileFlag) { simple.AddSource(DUMMY_MAIN); simple.AddCCompileFlag("-std=c++17"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -521,8 +521,8 @@ TEST(TargetTestCppCompileFlagsGroup, Target_ChangedCompileFlag) { gcc, "data"); simple.AddSource(DUMMY_MAIN); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -535,8 +535,8 @@ TEST(TargetTestCppCompileFlagsGroup, Target_ChangedCompileFlag) { simple.AddSource(DUMMY_MAIN); simple.AddCCompileFlag("-std=c++17"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -574,8 +574,8 @@ TEST(TargetTestLinkFlagsGroup, Target_AddLinkFlag) { simple.AddSource(DUMMY_MAIN); simple.AddLinkFlag("-lm"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -606,8 +606,8 @@ TEST(TargetTestLinkFlagsGroup, Target_ChangedLinkFlag) { simple.AddSource(DUMMY_MAIN); simple.AddLinkFlag("-lm"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -618,7 +618,7 @@ TEST(TargetTestLinkFlagsGroup, Target_ChangedLinkFlag) { gcc, "data"); simple.AddSource(DUMMY_MAIN); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); @@ -631,7 +631,7 @@ TEST(TargetTestLinkFlagsGroup, Target_ChangedLinkFlag) { simple.AddSource(DUMMY_MAIN); simple.AddLinkFlag("-lm"); buildcc::base::m::TargetExpect_FlagChanged(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); CHECK_TRUE(simple.IsBuilt()); diff --git a/buildcc/lib/target/test/target/test_target_include_dir.cpp b/buildcc/lib/target/test/target/test_target_include_dir.cpp index 454f0ad6..19086cd4 100644 --- a/buildcc/lib/target/test/target/test_target_include_dir.cpp +++ b/buildcc/lib/target/test/target/test_target_include_dir.cpp @@ -110,8 +110,8 @@ TEST(TargetTestIncludeDirGroup, TargetBuildIncludeDir) { // Duplicate include directory include_compile.AddIncludeDir(RELATIVE_INCLUDE_DIR); - buildcc::m::CommandExpect_Execute(2, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(2, true); + buildcc::env::m::CommandExpect_Execute(1, true); include_compile.Build(); buildcc::base::m::TargetRunner(include_compile); @@ -142,8 +142,8 @@ TEST(TargetTestIncludeDirGroup, TargetBuildIncludeDir) { include_compile.AddIncludeDir(""); buildcc::base::m::TargetExpect_DirChanged(1, &include_compile); - buildcc::m::CommandExpect_Execute(2, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(2, true); + buildcc::env::m::CommandExpect_Execute(1, true); include_compile.Build(); buildcc::base::m::TargetRunner(include_compile); @@ -171,8 +171,8 @@ TEST(TargetTestIncludeDirGroup, TargetBuildIncludeDir) { include_compile.AddIncludeDir(RELATIVE_INCLUDE_DIR); buildcc::base::m::TargetExpect_DirChanged(1, &include_compile); - buildcc::m::CommandExpect_Execute(2, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(2, true); + buildcc::env::m::CommandExpect_Execute(1, true); include_compile.Build(); buildcc::base::m::TargetRunner(include_compile); @@ -224,8 +224,8 @@ TEST(TargetTestIncludeDirGroup, TargetBuildHeaderFile) { add_header.AddSource(INCLUDE_HEADER_SOURCE); add_header.AddIncludeDir(RELATIVE_INCLUDE_DIR); - buildcc::m::CommandExpect_Execute(2, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(2, true); + buildcc::env::m::CommandExpect_Execute(1, true); add_header.Build(); buildcc::base::m::TargetRunner(add_header); @@ -247,8 +247,8 @@ TEST(TargetTestIncludeDirGroup, TargetBuildHeaderFile) { add_header.AddIncludeDir(RELATIVE_INCLUDE_DIR); buildcc::base::m::TargetExpect_PathAdded(1, &add_header); - buildcc::m::CommandExpect_Execute(2, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(2, true); + buildcc::env::m::CommandExpect_Execute(1, true); add_header.Build(); buildcc::base::m::TargetRunner(add_header); @@ -276,8 +276,8 @@ TEST(TargetTestIncludeDirGroup, TargetBuildHeaderFile) { add_header.AddIncludeDir(RELATIVE_INCLUDE_DIR); buildcc::base::m::TargetExpect_PathUpdated(1, &add_header); - buildcc::m::CommandExpect_Execute(2, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(2, true); + buildcc::env::m::CommandExpect_Execute(1, true); add_header.Build(); buildcc::base::m::TargetRunner(add_header); @@ -298,8 +298,8 @@ TEST(TargetTestIncludeDirGroup, TargetBuildHeaderFile) { add_header.AddIncludeDir(RELATIVE_INCLUDE_DIR); buildcc::base::m::TargetExpect_PathRemoved(1, &add_header); - buildcc::m::CommandExpect_Execute(2, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(2, true); + buildcc::env::m::CommandExpect_Execute(1, true); add_header.Build(); buildcc::base::m::TargetRunner(add_header); diff --git a/buildcc/lib/target/test/target/test_target_lib_dep.cpp b/buildcc/lib/target/test/target/test_target_lib_dep.cpp index 54363c76..593e56e0 100644 --- a/buildcc/lib/target/test/target/test_target_lib_dep.cpp +++ b/buildcc/lib/target/test/target/test_target_lib_dep.cpp @@ -47,8 +47,8 @@ TEST(TargetTestLibDep, StaticLibrary_SimpleBuildTest) { foolib.AddSource("foo.cpp", "foo"); foolib.AddIncludeDir("foo"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); foolib.Build(); buildcc::base::m::TargetRunner(foolib); @@ -77,8 +77,8 @@ TEST(TargetTestLibDep, TargetDep_RebuildTest) { foolib.AddSource("foo/foo.cpp"); foolib.AddIncludeDir("foo"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); foolib.Build(); buildcc::base::m::TargetRunner(foolib); buildcc::env::save_file(foolib.GetTargetPath().string().c_str(), @@ -91,8 +91,8 @@ TEST(TargetTestLibDep, TargetDep_RebuildTest) { exe_target.AddIncludeDir("foo"); exe_target.AddLibDep(foolib); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe_target.Build(); buildcc::base::m::TargetRunner(exe_target); } @@ -132,8 +132,8 @@ TEST(TargetTestLibDep, TargetDep_AddRemoveTest) { foolib.AddSource("foo/foo.cpp"); foolib.AddIncludeDir("foo"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); foolib.Build(); buildcc::base::m::TargetRunner(foolib); @@ -148,8 +148,8 @@ TEST(TargetTestLibDep, TargetDep_AddRemoveTest) { exe_target.AddSource("empty_main.cpp"); exe_target.AddIncludeDir("foo"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe_target.Build(); buildcc::base::m::TargetRunner(exe_target); } @@ -164,7 +164,7 @@ TEST(TargetTestLibDep, TargetDep_AddRemoveTest) { exe_target.AddLibDep(foolib); buildcc::base::m::TargetExpect_PathAdded(1, &exe_target); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe_target.Build(); buildcc::base::m::TargetRunner(exe_target); } @@ -177,7 +177,7 @@ TEST(TargetTestLibDep, TargetDep_AddRemoveTest) { exe_target.AddIncludeDir("foo"); buildcc::base::m::TargetExpect_PathRemoved(1, &exe_target); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe_target.Build(); buildcc::base::m::TargetRunner(exe_target); } @@ -199,8 +199,8 @@ TEST(TargetTestLibDep, TargetDep_UpdateExistingLibraryTest) { foolib.AddSource("foo/foo.cpp"); foolib.AddIncludeDir("foo"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); foolib.Build(); buildcc::base::m::TargetRunner(foolib); @@ -214,8 +214,8 @@ TEST(TargetTestLibDep, TargetDep_UpdateExistingLibraryTest) { exe_target.AddIncludeDir("foo"); exe_target.AddLibDep(foolib); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe_target.Build(); buildcc::base::m::TargetRunner(exe_target); } @@ -229,8 +229,8 @@ TEST(TargetTestLibDep, TargetDep_UpdateExistingLibraryTest) { foolib.AddIncludeDir(""); buildcc::base::m::TargetExpect_DirChanged(1, &foolib); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); foolib.Build(); buildcc::base::m::TargetRunner(foolib); @@ -247,7 +247,7 @@ TEST(TargetTestLibDep, TargetDep_UpdateExistingLibraryTest) { exe_target.AddLibDep(foolib); buildcc::base::m::TargetExpect_PathUpdated(1, &exe_target); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe_target.Build(); buildcc::base::m::TargetRunner(exe_target); } diff --git a/buildcc/lib/target/test/target/test_target_lock.cpp b/buildcc/lib/target/test/target/test_target_lock.cpp index 2e7512a5..7e24fae3 100644 --- a/buildcc/lib/target/test/target/test_target_lock.cpp +++ b/buildcc/lib/target/test/target/test_target_lock.cpp @@ -36,7 +36,7 @@ TEST(TargetTestLock, LockState) { CHECK_FALSE(exe.IsLocked()); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); @@ -50,7 +50,7 @@ TEST(TargetTestLock, Lock_Build) { buildcc::base::Target exe(NAME, buildcc::base::TargetType::Executable, gcc, "data"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); @@ -64,7 +64,7 @@ TEST(TargetTestLock, Lock_APIs) { buildcc::base::Target exe(NAME, buildcc::base::TargetType::Executable, gcc, "data"); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); @@ -108,8 +108,8 @@ TEST(TargetTestLock, Unlock_APIs) { CHECK_THROWS(std::exception, exe.GetTaskflow()); exe.AddSource("dummy_main.c"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); exe.Build(); buildcc::base::m::TargetRunner(exe); mock().checkExpectations(); diff --git a/buildcc/lib/target/test/target/test_target_pch.cpp b/buildcc/lib/target/test/target/test_target_pch.cpp index e8cc7c3b..fca98eeb 100644 --- a/buildcc/lib/target/test/target/test_target_pch.cpp +++ b/buildcc/lib/target/test/target/test_target_pch.cpp @@ -50,8 +50,8 @@ TEST(TargetPchTestGroup, Target_AddPch_Build) { target.AddPch("pch/pch_header_1.h"); target.AddPch("pch/pch_header_2.h"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -75,8 +75,8 @@ TEST(TargetPchTestGroup, Target_AddPch_Rebuild) { target.AddPch("pch/pch_header_1.h"); target.AddPch("pch/pch_header_2.h"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -103,8 +103,8 @@ TEST(TargetPchTestGroup, Target_AddPch_Rebuild) { target.AddPch("pch/pch_header_1.h"); buildcc::base::m::TargetExpect_PathRemoved(1, &target); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -119,8 +119,8 @@ TEST(TargetPchTestGroup, Target_AddPch_Rebuild) { target.AddPch("pch/pch_header_2.h"); buildcc::base::m::TargetExpect_PathAdded(1, &target); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -141,8 +141,8 @@ TEST(TargetPchTestGroup, Target_AddPch_Rebuild) { target.AddPch("pch/pch_header_2.h"); buildcc::base::m::TargetExpect_PathUpdated(1, &target); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -162,9 +162,9 @@ TEST(TargetPchTestGroup, Target_AddPch_CppRebuild) { target.AddPch("pch/pch_header_2.h"); target.AddSource("dummy_main.cpp"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -193,9 +193,9 @@ TEST(TargetPchTestGroup, Target_AddPch_CppRebuild) { target.AddSource("dummy_main.cpp"); buildcc::base::m::TargetExpect_PathRemoved(1, &target); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -211,9 +211,9 @@ TEST(TargetPchTestGroup, Target_AddPch_CppRebuild) { target.AddSource("dummy_main.cpp"); buildcc::base::m::TargetExpect_PathAdded(1, &target); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -235,9 +235,9 @@ TEST(TargetPchTestGroup, Target_AddPch_CppRebuild) { target.AddSource("dummy_main.cpp"); buildcc::base::m::TargetExpect_PathUpdated(1, &target); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -256,8 +256,8 @@ TEST(TargetPchTestGroup, Target_AddPchCompileFlag_Build) { target.AddPch("pch/pch_header_1.h"); target.AddPch("pch/pch_header_2.h"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); @@ -276,8 +276,8 @@ TEST(TargetPchTestGroup, Target_AddPchObjectFlag_Build) { target.AddPch("pch/pch_header_1.h"); target.AddPch("pch/pch_header_2.h"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); target.Build(); buildcc::base::m::TargetRunner(target); bool exists = fs::exists(target.GetPchHeaderPath()); diff --git a/buildcc/lib/target/test/target/test_target_source.cpp b/buildcc/lib/target/test/target/test_target_source.cpp index 9553e0f2..05cae41a 100644 --- a/buildcc/lib/target/test/target/test_target_source.cpp +++ b/buildcc/lib/target/test/target/test_target_source.cpp @@ -100,8 +100,8 @@ TEST(TargetTestSourceGroup, Target_Build_SourceCompile) { simple.AddSource(DUMMY_MAIN); simple.Build(); - buildcc::m::CommandExpect_Execute(1, true); // compile - buildcc::m::CommandExpect_Execute(1, true); // link + buildcc::env::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // link buildcc::base::m::TargetRunner(simple); CHECK(simple.GetTaskState() == buildcc::env::TaskState::SUCCESS); @@ -145,9 +145,9 @@ TEST(TargetTestSourceGroup, Target_Build_SourceRecompile) { simple.AddSource(DUMMY_MAIN_C); simple.AddSource(NEW_SOURCE); - buildcc::m::CommandExpect_Execute(1, true); // compile - buildcc::m::CommandExpect_Execute(1, true); // compile - buildcc::m::CommandExpect_Execute(1, true); // link + buildcc::env::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // compile + buildcc::env::m::CommandExpect_Execute(1, true); // link simple.Build(); buildcc::base::m::TargetRunner(simple); @@ -172,11 +172,11 @@ TEST(TargetTestSourceGroup, Target_Build_SourceRecompile) { buildcc::base::m::TargetExpect_SourceRemoved(1, &simple); // Added and compiled - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); buildcc::base::m::TargetExpect_SourceAdded(1, &simple); // Rebuild target - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); // Run the second Build to test Recompile simple.Build(); @@ -205,10 +205,10 @@ TEST(TargetTestSourceGroup, Target_Build_SourceRecompile) { simple.AddSource(NEW_SOURCE); // Run the second Build to test Recompile - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); buildcc::base::m::TargetExpect_SourceUpdated(1, &simple); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); diff --git a/buildcc/lib/target/test/target/test_target_source_out_of_root.cpp b/buildcc/lib/target/test/target/test_target_source_out_of_root.cpp index 6dc2f2e9..e37cefb2 100644 --- a/buildcc/lib/target/test/target/test_target_source_out_of_root.cpp +++ b/buildcc/lib/target/test/target/test_target_source_out_of_root.cpp @@ -42,8 +42,8 @@ TEST(TargetTestSourceOutOfRootGroup, Add_OutOfRootSource) { gcc, ""); simple.AddSource("../dummy_main.cpp"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); } @@ -59,8 +59,8 @@ TEST(TargetTestSourceOutOfRootGroup, Glob_OutOfRootSource) { simple.GlobSources(".."); // 6 files detected CHECK_EQUAL(6, simple.GetCurrentSourceFiles().size()); - buildcc::m::CommandExpect_Execute(6, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(6, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); } @@ -77,8 +77,8 @@ TEST(TargetTestSourceOutOfRootGroup, GlobAbsolute_OutOfRootSource) { OUTOFROOT, buildcc::base::TargetType::Executable, gcc, ""); simple.GlobSourcesAbsolute(fs::path(BUILD_SCRIPT_SOURCE) / "data"); // 6 files detected - buildcc::m::CommandExpect_Execute(6, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(6, true); + buildcc::env::m::CommandExpect_Execute(1, true); simple.Build(); buildcc::base::m::TargetRunner(simple); } diff --git a/buildcc/lib/target/test/target/test_target_user_deps.cpp b/buildcc/lib/target/test/target/test_target_user_deps.cpp index f1f2d491..3e57f382 100644 --- a/buildcc/lib/target/test/target/test_target_user_deps.cpp +++ b/buildcc/lib/target/test/target/test_target_user_deps.cpp @@ -42,8 +42,8 @@ TEST(TargetTestUserDepsGroup, Target_Build_CompileDeps_NoChange) { compileDep.AddSource("dummy_main.cpp"); compileDep.AddCompileDependency("new_source.cpp"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); compileDep.Build(); buildcc::base::m::TargetRunner(compileDep); @@ -57,8 +57,8 @@ TEST(TargetTestUserDepsGroup, Target_Build_LinkDeps_NoChange) { linkDep.AddSource("dummy_main.cpp"); linkDep.AddLinkDependency("new_source.cpp"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); linkDep.Build(); buildcc::base::m::TargetRunner(linkDep); @@ -73,8 +73,8 @@ TEST(TargetTestUserDepsGroup, Target_Build_CompileDeps_Rebuild) { compileDep.AddSource("dummy_main.cpp"); compileDep.AddCompileDependency("new_source.cpp"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); compileDep.Build(); buildcc::base::m::TargetRunner(compileDep); } @@ -95,8 +95,8 @@ TEST(TargetTestUserDepsGroup, Target_Build_CompileDeps_Rebuild) { compileDep.AddCompileDependency("new_source.cpp"); buildcc::base::m::TargetExpect_PathUpdated(1, &compileDep); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); compileDep.Build(); buildcc::base::m::TargetRunner(compileDep); } @@ -112,8 +112,8 @@ TEST(TargetTestUserDepsGroup, Target_Build_LinkDeps_Rebuild) { linkDep.AddSource("dummy_main.cpp"); linkDep.AddLinkDependency("new_source.cpp"); - buildcc::m::CommandExpect_Execute(1, true); - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); linkDep.Build(); buildcc::base::m::TargetRunner(linkDep); } @@ -134,7 +134,7 @@ TEST(TargetTestUserDepsGroup, Target_Build_LinkDeps_Rebuild) { linkDep.AddLinkDependency("new_source.cpp"); buildcc::base::m::TargetExpect_PathUpdated(1, &linkDep); // Only link - buildcc::m::CommandExpect_Execute(1, true); + buildcc::env::m::CommandExpect_Execute(1, true); linkDep.Build(); buildcc::base::m::TargetRunner(linkDep); } diff --git a/buildcc/lib/toolchain/CMakeLists.txt b/buildcc/lib/toolchain/CMakeLists.txt index 346fe175..edb0cc09 100644 --- a/buildcc/lib/toolchain/CMakeLists.txt +++ b/buildcc/lib/toolchain/CMakeLists.txt @@ -15,7 +15,6 @@ if (${TESTING}) target_link_options(mock_toolchain PUBLIC ${TEST_LINK_FLAGS} ${BUILD_LINK_FLAGS}) target_link_libraries(mock_toolchain PUBLIC mock_env - mock_command CppUTest CppUTestExt @@ -55,7 +54,6 @@ if(${BUILDCC_BUILD_AS_INTERFACE}) ) target_link_libraries(toolchain PUBLIC env - command ) endif() diff --git a/buildcc/lib/toolchain/src/api/toolchain_verify.cpp b/buildcc/lib/toolchain/src/api/toolchain_verify.cpp index 943017fc..71048ec4 100644 --- a/buildcc/lib/toolchain/src/api/toolchain_verify.cpp +++ b/buildcc/lib/toolchain/src/api/toolchain_verify.cpp @@ -27,7 +27,7 @@ #include "env/host_os_util.h" #include "env/util.h" -#include "command/command.h" +#include "env/command.h" namespace { // Constants @@ -47,9 +47,9 @@ std::vector ParseEnvVarToPaths(const std::string &env_var) { return paths; } -std::string GetGccCompilerVersion(const buildcc::Command &command) { +std::string GetGccCompilerVersion(const buildcc::env::Command &command) { std::vector stdout_data; - bool executed = buildcc::Command::Execute( + bool executed = buildcc::env::Command::Execute( command.Construct("{compiler} -dumpversion"), {}, &stdout_data); buildcc::env::assert_fatal( executed, "GetCompilerVersion command not executed successfully"); @@ -69,7 +69,7 @@ std::string GetMsvcCompilerVersion() { std::optional GetCompilerVersion(const fs::path &absolute_path, const buildcc::base::Toolchain &toolchain) { - buildcc::Command command; + buildcc::env::Command command; command.AddDefaultArgument( "compiler", (absolute_path / toolchain.GetCppCompiler()).make_preferred().string()); @@ -93,9 +93,9 @@ GetCompilerVersion(const fs::path &absolute_path, return compiler_version; } -std::string GetGccTargetArchitecture(const buildcc::Command &command) { +std::string GetGccTargetArchitecture(const buildcc::env::Command &command) { std::vector stdout_data; - bool executed = buildcc::Command::Execute( + bool executed = buildcc::env::Command::Execute( command.Construct("{compiler} -dumpmachine"), {}, &stdout_data); buildcc::env::assert_fatal( executed, "GetCompilerArchitecture command not executed successfully"); @@ -119,7 +119,7 @@ std::string GetMsvcTargetArchitecture() { std::optional GetCompilerArchitecture(const fs::path &absolute_path, const buildcc::base::Toolchain &toolchain) { - buildcc::Command command; + buildcc::env::Command command; command.AddDefaultArgument( "compiler", (absolute_path / toolchain.GetCppCompiler()).make_preferred().string()); diff --git a/buildcc/lib/toolchain/test/test_toolchain_verify.cpp b/buildcc/lib/toolchain/test/test_toolchain_verify.cpp index cda14c8b..4a92e7cc 100644 --- a/buildcc/lib/toolchain/test/test_toolchain_verify.cpp +++ b/buildcc/lib/toolchain/test/test_toolchain_verify.cpp @@ -32,8 +32,8 @@ TEST(ToolchainTestGroup, VerifyToolchain_Gcc) { std::vector version_stdout_data{"version"}; std::vector arch_stdout_data{"arch"}; - buildcc::m::CommandExpect_Execute(1, true, &version_stdout_data); - buildcc::m::CommandExpect_Execute(1, true, &arch_stdout_data); + buildcc::env::m::CommandExpect_Execute(1, true, &version_stdout_data); + buildcc::env::m::CommandExpect_Execute(1, true, &arch_stdout_data); std::string putenv_str = fmt::format("CUSTOM_BUILDCC_PATH={}/toolchains/gcc", fs::current_path().string()); @@ -62,8 +62,8 @@ TEST(ToolchainTestGroup, VerifyToolchain_Clang) { std::vector version_stdout_data{"version"}; std::vector arch_stdout_data{"arch"}; - buildcc::m::CommandExpect_Execute(1, true, &version_stdout_data); - buildcc::m::CommandExpect_Execute(1, true, &arch_stdout_data); + buildcc::env::m::CommandExpect_Execute(1, true, &version_stdout_data); + buildcc::env::m::CommandExpect_Execute(1, true, &arch_stdout_data); std::string putenv_str = fmt::format( "CUSTOM_BUILDCC_PATH={}/toolchains/clang", fs::current_path().string()); @@ -177,7 +177,7 @@ TEST(ToolchainTestGroup, VerifyToolchain_PathContainsDir) { } int main(int ac, char **av) { - buildcc::m::VectorStringCopier copier; + buildcc::env::m::VectorStringCopier copier; mock().installCopier(TEST_VECTOR_STRING_TYPE, copier); // NOTE, Check the GCC, MSVC and Clang compilers diff --git a/buildcc/plugins/src/clang_compile_commands.cpp b/buildcc/plugins/src/clang_compile_commands.cpp index 33207cdb..10e103fb 100644 --- a/buildcc/plugins/src/clang_compile_commands.cpp +++ b/buildcc/plugins/src/clang_compile_commands.cpp @@ -65,7 +65,7 @@ void ClangCompileCommands::Generate() { // DONE, Get std::vector CompileCommand // DONE, Get intermediate directory from env std::string sf = fmt::format("{}", source); - std::string command = t->GetCompileCommand(source); + const std::string &command = t->GetCompileCommand(source); std::string directory = fmt::format("{}", env::get_project_build_dir()); std::string temp = fmt::format( diff --git a/doc/software_architecture/buildcc_interface_lib.PNG b/doc/software_architecture/buildcc_interface_lib.PNG index 59385d6b..e2cc97aa 100644 Binary files a/doc/software_architecture/buildcc_interface_lib.PNG and b/doc/software_architecture/buildcc_interface_lib.PNG differ