Skip to content

Commit

Permalink
Remove cmake command. Add done log.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 12, 2024
1 parent b6d2057 commit 624631a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 152 deletions.
70 changes: 0 additions & 70 deletions src/cmd/cmake.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/cmd/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,27 +367,6 @@ namespace mob {
std::vector<fs::path> get_repos() const;
};

// runs cmake in a directory with the same parameters as `build` would
//
class cmake_command : public command {
public:
cmake_command();
meta_t meta() const override;

protected:
clipp::group do_group() override;
int do_run() override;
std::string do_doc() override;

private:
std::string gen_;
std::string cmd_;
bool x64_ = true;
bool debug_ = false;
std::string prefix_;
std::string path_;
};

// lists the inis found by mob
//
class inis_command : public command {
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ namespace mob {
std::make_unique<list_command>(),
std::make_unique<release_command>(),
std::make_unique<git_command>(),
std::make_unique<cmake_command>(),
std::make_unique<inis_command>(),
std::make_unique<tx_command>()};

Expand Down
69 changes: 29 additions & 40 deletions src/tasks/modorganizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

namespace mob::tasks {

// build CMAKE_PREFIX_PATH for MO2 tasks
//
std::string cmake_prefix_path()
{
return conf().path().qt_install().string() + ";" +
(conf().path().install() / "lib" / "cmake").string();
}

// given a vector of names (some projects have more than one, see add_tasks() in
// main.cpp), this prepends the simplified name to the vector and returns it
//
Expand Down Expand Up @@ -86,15 +94,6 @@ namespace mob::tasks {
return super_path() / name();
}

fs::path modorganizer::project_file_path() const
{
// ask cmake for the build path it would use
const auto build_path = create_cmake_tool(source_path()).build_path();

// use the INSTALL project
return build_path / (project_ + ".sln");
}

fs::path modorganizer::super_path()
{
return conf().path().build();
Expand Down Expand Up @@ -127,7 +126,7 @@ namespace mob::tasks {

// cmake clean
if (is_set(c, clean::reconfigure))
run_tool(create_cmake_tool(cmake::clean));
run_tool(cmake(cmake::clean).root(source_path()));
}

void modorganizer::do_fetch()
Expand Down Expand Up @@ -163,48 +162,38 @@ namespace mob::tasks {

// not all modorganizer projects need to actually be built, such as
// cmake_common, so don't try if there's no cmake file
if (!fs::exists(source_path() / "CMakeLists.txt")) {
if (!exists(source_path() / "CMakeLists.txt")) {
cx().trace(context::generic, "{} has no CMakeLists.txt, not building",
repo_);

return;
}

// if there is a CMakeLists.txt, there must be a CMakePresets.json otherwise
// we cannot build
if (!exists(source_path() / "CMakePresets.json")) {
gcx().bail_out(context::generic,
"{} has no CMakePresets.txt, aborting build", repo_);
}

// run cmake
run_tool(create_cmake_tool());
run_tool(cmake(cmake::generate)
.generator(cmake::vs)
.def("CMAKE_INSTALL_PREFIX:PATH", conf().path().install())
.def("CMAKE_PREFIX_PATH", cmake_prefix_path())
.preset("vs2022-windows")
.root(source_path()));

// run cmake --build with default target
// TODO: handle rebuild by adding `--clean-first`
run_tool(cmake(cmake::build).configuration(mob::config::relwithdebinfo));
run_tool(cmake(cmake::build)
.root(source_path())
.configuration(mob::config::relwithdebinfo));

// run cmake --install
run_tool(cmake(cmake::install).configuration(mob::config::relwithdebinfo));
}

cmake modorganizer::create_cmake_tool(cmake::ops o)
{
return create_cmake_tool(source_path(), o, task_conf().configuration());
}

cmake modorganizer::create_cmake_tool(const fs::path& root, cmake::ops o, config c)
{

if (!exists(root / "CMakePresets.json")) {
gcx().bail_out(context::generic, "missing CMakePresets.json in {}",
root.string());
}

cmake g(o);

g.generator(cmake::vs)
.def("CMAKE_INSTALL_PREFIX:PATH", conf().path().install())
.def("CMAKE_PREFIX_PATH",
conf().path().qt_install().string() + ";" +
(conf().path().install() / "lib" / "cmake").string())
.preset("vs2022-windows")
.root(root);

return std::move(g);
run_tool(cmake(cmake::install)
.root(source_path())
.configuration(mob::config::relwithdebinfo));
}

} // namespace mob::tasks
1 change: 1 addition & 0 deletions src/tasks/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ namespace mob {

cx().info(context::generic, "build and install");
do_build_and_install();
cx().info(context::generic, "done");
}

void task::check_bailed()
Expand Down
20 changes: 0 additions & 20 deletions src/tasks/tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,6 @@ namespace mob::tasks {
private:
std::string repo_;
std::string project_;

// creates the cmake tool for this MO project
//
cmake create_cmake_tool(cmake::ops o = cmake::generate);

// creates the msbuild tool for this MO project
//
msbuild create_msbuild_tool(msbuild::ops o = msbuild::build);

// this is the file targeted by the msbuild tool
//
// it's not actually the .sln file because the cmake files have historically
// been inconsistent in what the main project in the solution is and whether
// the INSTALL project was enabled or not, so just building the .sln itself
// might not actually build everything
//
// by targeting the INSTALL project directly, everything will always be
// built correctly, regardless of how the solution file is generated
//
fs::path project_file_path() const;
};

class ncc : public basic_task<ncc> {
Expand Down

0 comments on commit 624631a

Please sign in to comment.