Skip to content

Commit

Permalink
Build googletest in both Debug and Release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jun 9, 2024
1 parent f7b95ab commit a3a3312
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
48 changes: 32 additions & 16 deletions src/tasks/gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ namespace mob::tasks {

namespace {

cmake create_cmake_tool(arch a, cmake::ops o = cmake::generate)
cmake create_cmake_tool(arch a, const std::string& config,
cmake::ops o = cmake::generate)
{
const std::string build_dir = (a == arch::x64 ? "build" : "build_32");

return std::move(cmake(o)
.generator(cmake::vs)
.architecture(a)
.arg("-Wno-deprecated")
.arg("-Dgtest_force_shared_crt=ON")
.prefix(gtest::source_path() / build_dir)
.prefix(gtest::build_path(a, config))
.root(gtest::source_path()));
}

msbuild create_msbuild_tool(arch a, msbuild::ops o = msbuild::build)
msbuild create_msbuild_tool(arch a, std::string const& config,
msbuild::ops o = msbuild::build)
{
const fs::path build_path = create_cmake_tool(a).build_path();
const fs::path build_path = create_cmake_tool(a, config).build_path();

return std::move(
msbuild(o).architecture(a).solution(build_path / "INSTALL.vcxproj"));
return std::move(msbuild(o).architecture(a).config(config).solution(
build_path / "INSTALL.vcxproj"));
}

} // namespace
Expand All @@ -45,6 +45,11 @@ namespace mob::tasks {
return conf().path().build() / "googletest";
}

fs::path gtest::build_path(arch a, const std::string& c)
{
return source_path() / "build" / (a == arch::x64 ? "x64" : "Win32") / c;
}

void gtest::do_clean(clean c)
{
if (is_set(c, clean::reclone)) {
Expand All @@ -53,13 +58,15 @@ namespace mob::tasks {
}

if (is_set(c, clean::reconfigure)) {
run_tool(create_cmake_tool(arch::x86, cmake::clean));
run_tool(create_cmake_tool(arch::x64, cmake::clean));
run_tool(create_cmake_tool(arch::x86, "Release", cmake::clean));
run_tool(create_cmake_tool(arch::x64, "Release", cmake::clean));
}

if (is_set(c, clean::rebuild)) {
run_tool(create_msbuild_tool(arch::x86, msbuild::clean));
run_tool(create_msbuild_tool(arch::x64, msbuild::clean));
run_tool(create_msbuild_tool(arch::x86, "Release", msbuild::clean));
run_tool(create_msbuild_tool(arch::x86, "Debug", msbuild::clean));
run_tool(create_msbuild_tool(arch::x64, "Release", msbuild::clean));
run_tool(create_msbuild_tool(arch::x64, "Debug", msbuild::clean));
}
}

Expand All @@ -73,15 +80,24 @@ namespace mob::tasks {

void gtest::do_build_and_install()
{
op::create_directories(cx(), gtest::build_path(arch::x64).parent_path());
op::create_directories(cx(), gtest::build_path(arch::x86).parent_path());

parallel({{"gtest64",
[&] {
run_tool(create_cmake_tool(arch::x64));
run_tool(create_msbuild_tool(arch::x64));
run_tool(create_cmake_tool(arch::x64, "Release"));
run_tool(create_msbuild_tool(arch::x64, "Release"));

run_tool(create_cmake_tool(arch::x64, "Debug"));
run_tool(create_msbuild_tool(arch::x64, "Debug"));
}},

{"gtest32", [&] {
run_tool(create_cmake_tool(arch::x86));
run_tool(create_msbuild_tool(arch::x86));
run_tool(create_cmake_tool(arch::x86, "Release"));
run_tool(create_msbuild_tool(arch::x86, "Release"));

run_tool(create_cmake_tool(arch::x86, "Debug"));
run_tool(create_msbuild_tool(arch::x86, "Debug"));
}}});
}

Expand Down
2 changes: 1 addition & 1 deletion src/tasks/modorganizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ namespace mob::tasks {
.def("SEVENZ_ROOT", sevenz::source_path())
.def("LIBBSARCH_ROOT", libbsarch::source_path())
.def("BOOST_DI_ROOT", boost_di::source_path())
.def("GTEST_ROOT", gtest::source_path())
.def("GTEST_ROOT", gtest::build_path())
.def("OPENSSL_ROOT_DIR", openssl::source_path())
.root(root));
}
Expand Down
2 changes: 2 additions & 0 deletions src/tasks/tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ namespace mob::tasks {
static std::string version();
static bool prebuilt();
static fs::path source_path();
static fs::path build_path(arch arch = arch::x64,
const std::string& config = "Release");

protected:
void do_clean(clean c) override;
Expand Down

0 comments on commit a3a3312

Please sign in to comment.