Skip to content
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

Enable move to VCPKG #142

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions mob.ini
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ install_licenses =
install_pythoncore =
install_translations =
vs =
vcpkg =
qt_install =
qt_bin =
qt_translations =
Expand Down
70 changes: 0 additions & 70 deletions src/cmd/cmake.cpp

This file was deleted.

43 changes: 43 additions & 0 deletions src/cmd/cmake_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "pch.h"

#include "../core/conf.h"
#include "../tasks/tasks.h"

#include "commands.h"

namespace mob {

cmake_config_command::cmake_config_command() : command(requires_options) {}

command::meta_t cmake_config_command::meta() const
{
return {"cmake-config", "print CMake configuration variables"};
}

clipp::group cmake_config_command::do_group()
{
return clipp::group(
clipp::command("cmake-config").set(picked_),
(clipp::option("-h", "--help") >> help_) % ("shows this message"),
clipp::command("prefix-path").set(var_, variable::prefix_path) |
clipp::command("install-prefix").set(var_, variable::install_prefix));
}

std::string cmake_config_command::do_doc()
{
return "Print CMake variables to be used when configuring projects.\n";
}

int cmake_config_command::do_run()
{
switch (var_) {
case variable::prefix_path:
u8cout << tasks::modorganizer::cmake_prefix_path();
break;
case variable::install_prefix:
u8cout << conf().path().install().string();
break;
}
return 0;
}
} // namespace mob
37 changes: 16 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 Expand Up @@ -427,4 +406,20 @@ namespace mob {
void do_build();
};

// print CMake configuration variables
//
class cmake_config_command : public command {
public:
cmake_config_command();
meta_t meta() const override;

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

enum class variable { prefix_path, install_prefix };
variable var_;
};

} // namespace mob
3 changes: 2 additions & 1 deletion src/core/conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ namespace mob {
set_path_if_empty("pf_x86", find_program_files_x86);
set_path_if_empty("pf_x64", find_program_files_x64);
set_path_if_empty("vs", find_vs);
set_path_if_empty("vcpkg", find_vcpkg); // set after vs as it will use the VS
set_path_if_empty("qt_install", find_qt);
set_path_if_empty("temp_dir", find_temp_dir);
set_path_if_empty("patches", find_in_root("patches"));
Expand All @@ -530,7 +531,7 @@ namespace mob {
resolve_path("install", p.prefix(), "install");
resolve_path("install_installer", p.install(), "installer");
resolve_path("install_bin", p.install(), "bin");
resolve_path("install_libs", p.install(), "libs");
resolve_path("install_libs", p.install(), "lib");
resolve_path("install_pdbs", p.install(), "pdb");
resolve_path("install_dlls", p.install_bin(), "dlls");
resolve_path("install_loot", p.install_bin(), "loot");
Expand Down
1 change: 1 addition & 0 deletions src/core/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ namespace mob {
VALUE(install_translations);

VALUE(vs);
VALUE(vcpkg);
VALUE(qt_install);
VALUE(qt_bin);
VALUE(qt_translations);
Expand Down
18 changes: 18 additions & 0 deletions src/core/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ namespace mob {
}
}

fs::path find_vcpkg()
{
const auto env_path = this_env::get().get("VCPKG_ROOT");

if (!env_path.empty()) {
return fs::absolute(env_path);
}

const auto vs_path = conf().path().vs();
const auto vcpkg_vs_path = vs_path / "VC" / "vcpkg";
if (!exists(vcpkg_vs_path)) {
gcx().bail_out(context::conf, "vcpkg is not part of VS installation at {}",
vs_path);
}

return vcpkg_vs_path;
}

fs::path find_qt()
{
// check from the ini first
Expand Down
5 changes: 5 additions & 0 deletions src/core/paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ namespace mob {
//
fs::path find_vs();

// returns the absolute path to VCPKG root directory to be used as VCPKG_ROOT when
// building
//
fs::path find_vcpkg();

// returns the absolute path to Qt's root directory, the one that contains
// bin, include, etc.; bails if not found
//
Expand Down
97 changes: 39 additions & 58 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@ namespace mob {

// third-party tasks

add_task<parallel_tasks>()
.add_task<sevenz>()
.add_task<zlib>()
.add_task<gtest>()
.add_task<libbsarch>()
.add_task<libloot>()
.add_task<openssl>()
.add_task<bzip2>()
.add_task<directxtex>();

add_task<parallel_tasks>()
.add_task<tasks::python>()
.add_task<lz4>()
.add_task<spdlog>();

add_task<parallel_tasks>()
.add_task<boost>()
.add_task<boost_di>()
.add_task<sip>();

add_task<parallel_tasks>()
.add_task<pyqt>()
.add_task<pybind11>()
.add_task<usvfs>()
.add_task<stylesheets>()
.add_task<licenses>()
.add_task<explorerpp>();
// add_task<parallel_tasks>()
// .add_task<sevenz>()
// .add_task<zlib>()
// .add_task<gtest>()
// .add_task<libbsarch>()
// .add_task<libloot>()
// .add_task<openssl>()
// .add_task<bzip2>()
// .add_task<directxtex>();

// add_task<parallel_tasks>()
// .add_task<tasks::python>()
// .add_task<lz4>()
// .add_task<spdlog>();

// add_task<parallel_tasks>()
// .add_task<boost>()
// .add_task<boost_di>()
// .add_task<sip>();

// add_task<parallel_tasks>()
// .add_task<pyqt>()
// .add_task<pybind11>()
// .add_task<usvfs>()
// .add_task<stylesheets>()
// .add_task<licenses>()
// .add_task<explorerpp>();

// super tasks

Expand All @@ -61,9 +61,9 @@ namespace mob {
// most of the alternate names below are from the transifex slugs, which
// are sometimes different from the project names, for whatever reason

add_task<parallel_tasks>()
.add_task<mo>("cmake_common")
.add_task<mo>("modorganizer-uibase");
add_task<parallel_tasks>().add_task<usvfs>().add_task<mo>("cmake_common");

add_task<mo>("modorganizer-uibase");

add_task<parallel_tasks>()
.add_task<mo>("modorganizer-archive")
Expand All @@ -72,34 +72,13 @@ namespace mob {
.add_task<mo>("modorganizer-bsatk")
.add_task<mo>("modorganizer-nxmhandler")
.add_task<mo>("modorganizer-helper")
.add_task<mo>("githubpp")
.add_task<mo>("modorganizer-game_gamebryo")
.add_task<mo>({"modorganizer-bsapacker", "bsa_packer"})
.add_task<mo>("modorganizer-preview_bsa");

// the gamebryo flag must be set for all game plugins that inherit from
// the gamebryo classes; this will merge the .ts file from gamebryo with
// the one from the specific plugin
add_task<parallel_tasks>()
.add_task<mo>("modorganizer-game_oblivion", mo::gamebryo)
.add_task<mo>("modorganizer-game_nehrim", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout3", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout4", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout4vr", mo::gamebryo)
.add_task<mo>("modorganizer-game_fallout76", mo::gamebryo)
.add_task<mo>("modorganizer-game_falloutnv", mo::gamebryo)
.add_task<mo>("modorganizer-game_morrowind", mo::gamebryo)
.add_task<mo>("modorganizer-game_skyrim", mo::gamebryo)
.add_task<mo>("modorganizer-game_skyrimse", mo::gamebryo)
.add_task<mo>("modorganizer-game_skyrimvr", mo::gamebryo)
.add_task<mo>("modorganizer-game_starfield", mo::gamebryo)
.add_task<mo>("modorganizer-game_ttw", mo::gamebryo)
.add_task<mo>("modorganizer-game_enderal", mo::gamebryo)
.add_task<mo>("modorganizer-game_enderalse", mo::gamebryo);
.add_task<mo>("modorganizer-game_bethesda");

add_task<parallel_tasks>()
.add_task<mo>({"modorganizer-bsapacker", "bsa_packer"})
.add_task<mo>({"modorganizer-tool_inieditor", "inieditor"})
.add_task<mo>({"modorganizer-tool_inibakery", "inibakery"})
.add_task<mo>("modorganizer-preview_bsa")
.add_task<mo>("modorganizer-preview_base")
.add_task<mo>("modorganizer-diagnose_basic")
.add_task<mo>("modorganizer-check_fnis")
Expand All @@ -109,12 +88,15 @@ namespace mob {
.add_task<mo>("modorganizer-installer_quick")
.add_task<mo>("modorganizer-installer_fomod")
.add_task<mo>("modorganizer-installer_fomod_csharp")
.add_task<mo>("modorganizer-installer_omod", mo::nuget)
.add_task<mo>("modorganizer-installer_omod")
.add_task<mo>("modorganizer-installer_wizard")
.add_task<mo>("modorganizer-bsa_extractor")
.add_task<mo>("modorganizer-plugin_python");

add_task<parallel_tasks>()
.add_task<stylesheets>()
.add_task<licenses>()
.add_task<explorerpp>()
.add_task<mo>({"modorganizer-tool_configurator", "pycfg"})
.add_task<mo>("modorganizer-fnistool")
.add_task<mo>("modorganizer-basic_games")
Expand All @@ -125,7 +107,6 @@ namespace mob {
.add_task<mo>({"modorganizer", "organizer"});

// other tasks

add_task<translations>();
add_task<installer>();
}
Expand All @@ -147,9 +128,9 @@ 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>()};
std::make_unique<tx_command>(),
std::make_unique<cmake_config_command>()};

// commands are shown in the help
help->set_commands(commands);
Expand Down
Loading
Loading