Skip to content

Commit 0d6a130

Browse files
committed
Move to VCPKG.
* Use CMake with presets to generate USVFS solution. * Use preset when building super repository. * Allow overriding VCPKG_ROOT with [paths] entry. * Remove gamebryo and nuget specific stuff. * Remove cmake command. Add done log. * Use VCPKG from VS if no VCPKG_ROOT or path setting.
1 parent b3c66b3 commit 0d6a130

File tree

19 files changed

+469
-436
lines changed

19 files changed

+469
-436
lines changed

mob.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ host =
2121
super = cmake_common modorganizer* githubpp
2222
plugins = check_fnis bsapacker bsa_extractor diagnose_basic installer_* plugin_python preview_base preview_bsa tool_* game_*
2323

24+
[translations]
25+
mo2-translations = organizer
26+
mo2-game-bethesda = game_creation game_enderal game_enderalse game_fallout3 game_fallout4 game_fallout4vr game_falloutNV game_gamebryo game_morrowind game_nehrim game_oblivion game_skyrim game_skyrimse game_skyrimvr game_ttw
27+
2428
[task]
2529
enabled = true
2630
mo_org = ModOrganizer2
@@ -150,11 +154,12 @@ install_pdbs =
150154
install_dlls =
151155
install_loot =
152156
install_plugins =
157+
install_extensions =
153158
install_stylesheets =
154159
install_licenses =
155160
install_pythoncore =
156-
install_translations =
157161
vs =
162+
vcpkg =
158163
qt_install =
159164
qt_bin =
160165
qt_translations =

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ file(GLOB_RECURSE source_files *.cpp)
44
file(GLOB_RECURSE header_files *.h)
55

66
add_executable(mob ${source_files} ${header_files})
7-
set_target_properties(mob PROPERTIES CXX_STANDARD 20)
7+
set_target_properties(mob PROPERTIES CXX_STANDARD 23)
88

99
target_compile_definitions(mob PUBLIC NOMINMAX)
1010
target_compile_options(mob PUBLIC "/MT")

src/cmd/cmake.cpp

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/cmd/commands.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -367,27 +367,6 @@ namespace mob {
367367
std::vector<fs::path> get_repos() const;
368368
};
369369

370-
// runs cmake in a directory with the same parameters as `build` would
371-
//
372-
class cmake_command : public command {
373-
public:
374-
cmake_command();
375-
meta_t meta() const override;
376-
377-
protected:
378-
clipp::group do_group() override;
379-
int do_run() override;
380-
std::string do_doc() override;
381-
382-
private:
383-
std::string gen_;
384-
std::string cmd_;
385-
bool x64_ = true;
386-
bool debug_ = false;
387-
std::string prefix_;
388-
std::string path_;
389-
};
390-
391370
// lists the inis found by mob
392371
//
393372
class inis_command : public command {

src/core/conf.cpp

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,32 @@ namespace mob::details {
5151

5252
// returns a string from conf, bails out if it doesn't exist
5353
//
54-
std::string get_string(std::string_view section, std::string_view key)
54+
std::string get_string(std::string_view section, std::string_view key,
55+
std::optional<std::string> default_)
5556
{
5657
auto sitor = g_conf.find(section);
5758
if (sitor == g_conf.end())
5859
gcx().bail_out(context::conf, "[{}] doesn't exist", section);
5960

6061
auto kitor = sitor->second.find(key);
61-
if (kitor == sitor->second.end())
62-
gcx().bail_out(context::conf, "no key '{}' in [{}]", key, section);
62+
if (kitor == sitor->second.end()) {
63+
if (!default_.has_value()) {
64+
gcx().bail_out(context::conf, "no key '{}' in [{}]", key, section);
65+
}
66+
return *default_;
67+
}
6368

6469
return kitor->second;
6570
}
6671

6772
// calls get_string(), converts to int
6873
//
69-
int get_int(std::string_view section, std::string_view key)
74+
int get_int(std::string_view section, std::string_view key,
75+
std::optional<int> default_)
7076
{
71-
const auto s = get_string(section, key);
77+
const auto s = get_string(section, key, default_.transform([](auto v) {
78+
return std::to_string(v);
79+
}));
7280

7381
try {
7482
return std::stoi(s);
@@ -80,9 +88,12 @@ namespace mob::details {
8088

8189
// calls get_string(), converts to bool
8290
//
83-
bool get_bool(std::string_view section, std::string_view key)
91+
bool get_bool(std::string_view section, std::string_view key,
92+
std::optional<bool> default_)
8493
{
85-
const auto s = get_string(section, key);
94+
const auto s = get_string(section, key, default_.transform([](auto v) {
95+
return v ? "true" : "false";
96+
}));
8697
return bool_from_string(s);
8798
}
8899

@@ -428,13 +439,8 @@ namespace mob {
428439

429440
MOB_ASSERT(!tasks.empty());
430441

431-
for (auto& t : tasks) {
432-
if (t->name() != task &&
433-
details::find_string_for_task(t->name(), key)) {
434-
continue;
435-
}
442+
for (auto& t : tasks)
436443
details::set_string_for_task(t->name(), key, value);
437-
}
438444
}
439445
else {
440446
// global task option
@@ -509,6 +515,7 @@ namespace mob {
509515
set_path_if_empty("pf_x86", find_program_files_x86);
510516
set_path_if_empty("pf_x64", find_program_files_x64);
511517
set_path_if_empty("vs", find_vs);
518+
set_path_if_empty("vcpkg", find_vcpkg); // set after vs as it will use the VS
512519
set_path_if_empty("qt_install", find_qt);
513520
set_path_if_empty("temp_dir", find_temp_dir);
514521
set_path_if_empty("patches", find_in_root("patches"));
@@ -530,15 +537,15 @@ namespace mob {
530537
resolve_path("install", p.prefix(), "install");
531538
resolve_path("install_installer", p.install(), "installer");
532539
resolve_path("install_bin", p.install(), "bin");
533-
resolve_path("install_libs", p.install(), "libs");
540+
resolve_path("install_libs", p.install(), "lib");
534541
resolve_path("install_pdbs", p.install(), "pdb");
535542
resolve_path("install_dlls", p.install_bin(), "dlls");
536543
resolve_path("install_loot", p.install_bin(), "loot");
537544
resolve_path("install_plugins", p.install_bin(), "plugins");
538545
resolve_path("install_licenses", p.install_bin(), "licenses");
539546
resolve_path("install_pythoncore", p.install_bin(), "pythoncore");
540547
resolve_path("install_stylesheets", p.install_bin(), "stylesheets");
541-
resolve_path("install_translations", p.install_bin(), "translations");
548+
resolve_path("install_extensions", p.install_bin(), "extensions");
542549

543550
// finally, resolve the tools that are unlikely to be in PATH; all the
544551
// other tools (7z, jom, patch, etc.) are assumed to be in PATH (which
@@ -684,6 +691,11 @@ namespace mob {
684691
return {};
685692
}
686693

694+
conf_translations conf::translation()
695+
{
696+
return {};
697+
}
698+
687699
conf_prebuilt conf::prebuilt()
688700
{
689701
return {};
@@ -777,6 +789,8 @@ namespace mob {
777789

778790
conf_build_types::conf_build_types() : conf_section("build-types") {}
779791

792+
conf_translations::conf_translations() : conf_section("translations") {}
793+
780794
conf_prebuilt::conf_prebuilt() : conf_section("prebuilt") {}
781795

782796
conf_paths::conf_paths() : conf_section("paths") {}

src/core/conf.h

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace mob::details {
99

1010
// returns an option named `key` from the given `section`
1111
//
12-
std::string get_string(std::string_view section, std::string_view key);
12+
std::string get_string(std::string_view section, std::string_view key,
13+
std::optional<std::string> default_ = {});
1314

1415
// convert a string to the given type
1516
template <class T>
@@ -25,11 +26,13 @@ namespace mob::details {
2526

2627
// calls get_string(), converts to bool
2728
//
28-
bool get_bool(std::string_view section, std::string_view key);
29+
bool get_bool(std::string_view section, std::string_view key,
30+
std::optional<bool> default_ = {});
2931

3032
// calls get_string(), converts to in
3133
//
32-
int get_int(std::string_view section, std::string_view key);
34+
int get_int(std::string_view section, std::string_view key,
35+
std::optional<int> default_ = {});
3336

3437
// sets the given option, bails out if the option doesn't exist
3538
//
@@ -60,9 +63,17 @@ namespace mob {
6063
template <class DefaultType>
6164
class conf_section {
6265
public:
63-
DefaultType get(std::string_view key) const
66+
DefaultType get(std::string_view key,
67+
std::optional<DefaultType> default_ = {}) const
6468
{
65-
const auto value = details::get_string(name_, key);
69+
const auto value = [=] {
70+
if constexpr (std::is_same_v<DefaultType, std::string>) {
71+
return details::get_string(name_, key, default_);
72+
}
73+
else {
74+
return details::get_string(name_, key);
75+
}
76+
}();
6677

6778
if constexpr (std::is_convertible_v<std::string, DefaultType>) {
6879
return value;
@@ -74,18 +85,18 @@ namespace mob {
7485

7586
// undefined
7687
template <class T>
77-
T get(std::string_view key) const;
88+
T get(std::string_view key, std::optional<T> default_ = {}) const;
7889

7990
template <>
80-
bool get<bool>(std::string_view key) const
91+
bool get<bool>(std::string_view key, std::optional<bool> default_) const
8192
{
82-
return details::get_bool(name_, key);
93+
return details::get_bool(name_, key, default_);
8394
}
8495

8596
template <>
86-
int get<int>(std::string_view key) const
97+
int get<int>(std::string_view key, std::optional<int> default_) const
8798
{
88-
return details::get_int(name_, key);
99+
return details::get_int(name_, key, default_);
89100
}
90101

91102
void set(std::string_view key, std::string_view value)
@@ -223,6 +234,13 @@ namespace mob {
223234
conf_build_types();
224235
};
225236

237+
// options in [translations]
238+
//
239+
class conf_translations : public conf_section<std::string> {
240+
public:
241+
conf_translations();
242+
};
243+
226244
// options in [prebuilt]
227245
//
228246
class conf_prebuilt : public conf_section<std::string> {
@@ -257,13 +275,13 @@ namespace mob {
257275

258276
VALUE(install_dlls);
259277
VALUE(install_loot);
260-
VALUE(install_plugins);
278+
VALUE(install_extensions);
261279
VALUE(install_stylesheets);
262280
VALUE(install_licenses);
263281
VALUE(install_pythoncore);
264-
VALUE(install_translations);
265282

266283
VALUE(vs);
284+
VALUE(vcpkg);
267285
VALUE(qt_install);
268286
VALUE(qt_bin);
269287
VALUE(qt_translations);
@@ -285,6 +303,7 @@ namespace mob {
285303
conf_cmake cmake();
286304
conf_tools tool();
287305
conf_transifex transifex();
306+
conf_translations translation();
288307
conf_prebuilt prebuilt();
289308
conf_versions version();
290309
conf_build_types build_types();

src/core/op.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,30 @@ namespace mob::op {
116116
}
117117
}
118118

119+
void delete_file_glob_recurse(const context& cx, const fs::path& directory,
120+
const fs::path& glob, flags f)
121+
{
122+
cx.trace(context::fs, "deleting glob {}", glob);
123+
124+
const auto native = glob.native();
125+
126+
if (!fs::exists(directory))
127+
return;
128+
129+
for (auto&& e : fs::recursive_directory_iterator(directory)) {
130+
const auto p = e.path();
131+
const auto name = p.filename().native();
132+
133+
if (!PathMatchSpecW(name.c_str(), native.c_str())) {
134+
cx.trace(context::fs, "{} did not match {}; skipping", name, glob);
135+
136+
continue;
137+
}
138+
139+
delete_file(cx, p, f);
140+
}
141+
}
142+
119143
void remove_readonly(const context& cx, const fs::path& dir, flags f)
120144
{
121145
cx.trace(context::fs, "removing read-only from {}", dir);

src/core/op.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ namespace mob::op {
6565
//
6666
void delete_file_glob(const context& cx, const fs::path& glob, flags f = noflags);
6767

68+
// deletes all files matching the glob in the given directory and its subdirectories
69+
//
70+
void delete_file_glob_recurse(const context& cx, const fs::path& directory,
71+
const fs::path& glob, flags f = noflags);
72+
6873
// removes the readonly flag for all files in `dir`, recursive
6974
//
7075
void remove_readonly(const context& cx, const fs::path& dir, flags f = noflags);

0 commit comments

Comments
 (0)