Enable move to VCPKG (#142)

* Use CMake with presets to generate USVFS solution.
* Use preset when building super repository.
* Allow overriding VCPKG_ROOT with [paths] entry.
* Remove non needed stuff (gamebryo, nuget, third party dependencies, etc.).
* Use VCPKG from VS if no VCPKG_ROOT or path setting.
* Remove uibase from releases.

---------

Co-authored-by: Jeremy Rimpo <jrim@rimpo.org>
This commit is contained in:
Mikaël Capelle
2025-05-29 10:48:30 +02:00
committed by GitHub
co-authored by Jeremy Rimpo
parent c29b1adca1
commit 044a158340
42 changed files with 179 additions and 3961 deletions
+1 -34
View File
@@ -47,6 +47,7 @@ git_shallow = false
[usvfs:task]
git_shallow = false
configuration = Release
[installer:task]
enabled = false
@@ -84,40 +85,14 @@ force = false
configure = true
pull = true
[prebuilt]
boost = true
lz4 = true
openssl = true
pyqt = true
python = true
[versions]
vs = 17
vs_year = 2022
vs_toolset = 14.3
sdk = 10.0.26100.0
sevenz = 24.09
boost = 1.88.0
boost_vs = 14.3
fmt = 11.1.4
gtest = main
directxtex = main
libloot = 0.26.1
lz4 = v1.10.0
nmm = 0.71.2
openssl = 3.5.0
pyqt = 6.7.1
pyqt_builder = 1.16.4
pyqt_sip = 13.8.0
python = v3.12.10
pybind11 = v2.12.1
bzip2 = 1.0.8
sip = 6.8.6
spdlog = v1.15.2
qt = 6.7.3
qt_vs = 2022
zlib = v1.3.1
libbsarch = 0.0.12
usvfs = master
explorerpp = 1.4.0
ss_paper_lad_6788 = 7.2
@@ -130,16 +105,10 @@ ss_starfield_trosski = V1.11
ss_fallout3_trosski = v1.11
ss_fallout4_trosski = v1.11
[build-types]
libbsarch = release
pyqt = release
python = release
[paths]
third_party =
prefix =
cache =
patches =
licenses =
build =
install =
@@ -148,11 +117,9 @@ install_installer =
install_libs =
install_pdbs =
install_dlls =
install_loot =
install_plugins =
install_stylesheets =
install_licenses =
install_pythoncore =
install_translations =
vs =
vcpkg =
-36
View File
@@ -1,36 +0,0 @@
--- builder.py (date 1575938575861)
+++ builder.py (date 1575938575861)
@@ -402,17 +402,29 @@
'QMAKE_LFLAGS += -Wl,--version-script={}.exp'.format(
buildable.target))
- pro_lines.append(
+ if project.py_platform == 'win32':
+ for include_dir in project.py_include_dir.split(';'):
+ pro_lines.append(
+ 'INCLUDEPATH += {}'.format(
+ self.qmake_quote(include_dir)))
+ else:
+ pro_lines.append(
'INCLUDEPATH += {}'.format(
- self.qmake_quote(project.py_include_dir)))
+ self.qmake_quote(project.py_include_dir)))
+ if project.py_pylib_shlib != "":
+ pro_lines.append(
+ 'DEFINES += {}'.format(
+ self.qmake_quote("PYTHON_LIB=\"{}\"".format(
+ project.py_pylib_shlib))))
+
# Python.h on Windows seems to embed the need for pythonXY.lib, so tell
# it where it is.
# TODO: is this still necessary for Python v3.8?
if not buildable.static:
pro_lines.extend(['win32 {',
- ' LIBS += -L{}'.format(
- self.qmake_quote(project.py_pylib_dir)),
+ ' LIBS += -L{}{}'.format(
+ self.qmake_quote(project.py_pylib_dir), '' if project.py_pylib_lib == '' else ' -l' + project.py_pylib_lib),
'}'])
# Add any installables from the buildable
@@ -1,10 +0,0 @@
--- PCbuild/openssl.props (revision 5c02a39a0b31a330e06b4d6f44835afb205dc7cc)
+++ PCbuild/openssl.props (date 1575994670797)
@@ -13,6 +13,7 @@
<_DLLSuffix>-3</_DLLSuffix>
<_DLLSuffix Condition="$(Platform) == 'ARM'">$(_DLLSuffix)-arm</_DLLSuffix>
<_DLLSuffix Condition="$(Platform) == 'ARM64'">$(_DLLSuffix)-arm64</_DLLSuffix>
+ <_DLLSuffix Condition="$(Platform) == 'x64'">$(_DLLSuffix)-x64</_DLLSuffix>
<OpenSSLDLLSuffix Condition="$(OpenSSLDLLSuffix) == ''">$(_DLLSuffix)</OpenSSLDLLSuffix>
</PropertyGroup>
<ItemGroup>
-70
View File
@@ -1,70 +0,0 @@
#include "pch.h"
#include "../tasks/tasks.h"
#include "commands.h"
namespace mob {
cmake_command::cmake_command() : command(requires_options) {}
command::meta_t cmake_command::meta() const
{
return {"cmake", "runs cmake in a directory"};
}
clipp::group cmake_command::do_group()
{
return clipp::group(
clipp::command("cmake").set(picked_),
(clipp::option("-h", "--help") >> help_) % "shows this message",
(clipp::option("-G", "--generator") & clipp::value("GEN") >> gen_) %
("sets the -G option for cmake [default: VS]"),
(clipp::option("-c", "--cmd") & clipp::value("CMD") >> cmd_) %
"overrides the cmake command line [default: \"..\"]",
(clipp::option("--x64").set(x64_, true) |
clipp::option("--x86").set(x64_, false)) %
"whether to use the x64 or x86 vcvars; if -G is not set, "
"whether to pass \"-A Win32\" or \"-A x64\" for the default "
"VS generator [default: x64]",
(clipp::option("--install-prefix") & clipp::value("PATH") >> prefix_) %
"sets CMAKE_INSTALL_PREFIX [default: empty]",
(clipp::option("-d", "--debug").set(debug_, true)) %
"whether to configure for debug mode [default: false]",
(clipp::value("PATH") >> path_) % "path from which to run `cmake`");
}
int cmake_command::do_run()
{
auto t = tasks::modorganizer::create_cmake_tool(
fs::path(utf8_to_utf16(path_)), mob::cmake::generate,
debug_ ? config::debug : config::relwithdebinfo);
t.generator(gen_);
t.cmd(cmd_);
t.prefix(prefix_);
t.output(path_);
if (!x64_)
t.architecture(arch::x86);
// copy the global context, the tool will modify it
context cxcopy(gcx());
t.run(cxcopy);
return 0;
}
std::string cmake_command::do_doc()
{
return "Runs `cmake ..` in the given directory with the same command line\n"
"as the one used for modorganizer projects.";
}
} // namespace mob
+43
View File
@@ -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
+16 -23
View File
@@ -281,7 +281,6 @@ namespace mob {
void make_bin();
void make_pdbs();
void make_src();
void make_uibase();
void make_installer();
protected:
@@ -297,7 +296,6 @@ namespace mob {
bool bin_ = true;
bool src_ = true;
bool pdbs_ = true;
bool uibase_ = true;
bool installer_ = false;
std::string utf8out_;
fs::path out_;
@@ -367,27 +365,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 {
@@ -427,4 +404,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
+13 -31
View File
@@ -44,9 +44,19 @@ namespace mob {
u8cout << "making src archive " << path_to_utf8(out) << "\n";
const std::vector<std::string> ignore = {"\\..+", // dot files
".*\\.log", ".*\\.tlog", ".*\\.dll",
".*\\.exe", ".*\\.lib", ".*\\.obj",
".*\\.ts", ".*\\.aps", "vsbuild"};
"explorer\\+\\+",
"stylesheets",
"transifex-translations"
".*\\.log",
".*\\.tlog",
".*\\.dll",
".*\\.exe",
".*\\.lib",
".*\\.obj",
".*\\.ts",
".*\\.aps",
"(bin|lib)",
"vsbuild(32|64)?"};
const std::vector<std::regex> ignore_re(ignore.begin(), ignore.end());
@@ -77,25 +87,6 @@ namespace mob {
op::archive_from_files(gcx(), files, tasks::modorganizer::super_path(), out);
}
void release_command::make_uibase()
{
const auto out = out_ / make_filename("uibase");
u8cout << "making uibase archive " << path_to_utf8(out) << "\n";
std::vector<fs::path> files;
if (!fs::exists(tasks::modorganizer::super_path())) {
gcx().bail_out(context::generic, "modorganizer super path not found: {}",
tasks::modorganizer::super_path());
}
op::archive_from_glob(
gcx(), tasks::modorganizer::super_path() / "uibase" / "src" / "*.h", out,
{});
op::archive_from_files(gcx(), {conf().path().install_libs() / "uibase.lib"},
conf().path().install_libs(), out);
}
void release_command::make_installer()
{
const auto file = "Mod.Organizer-" + version_ + ".exe";
@@ -178,11 +169,6 @@ namespace mob {
clipp::option("--no-src").set(src_, false)) %
"sets whether the source archive is created [default: yes]",
//(
// clipp::option("--uibase").set(uibase_, true) |
// clipp::option("--no-uibase").set(uibase_, false)
//) % "sets whether the uibase archive is created [default: yes]",
(clipp::option("--inst").set(installer_, true) |
clipp::option("--no-inst").set(installer_, false)) %
"sets whether the installer is copied [default: no]",
@@ -271,9 +257,6 @@ namespace mob {
if (src_)
make_src();
if (uibase_)
make_uibase();
if (installer_)
make_installer();
@@ -299,7 +282,6 @@ namespace mob {
make_bin();
make_pdbs();
make_src();
make_uibase();
make_installer();
return 0;
-8
View File
@@ -512,7 +512,6 @@ namespace mob {
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"));
set_path_if_empty("licenses", find_in_root("licenses"));
set_path_if_empty("qt_bin", qt::installation_path() / "bin");
set_path_if_empty("qt_translations", qt::installation_path() / "translations");
@@ -534,10 +533,8 @@ namespace mob {
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");
resolve_path("install_plugins", p.install_bin(), "plugins");
resolve_path("install_licenses", p.install_bin(), "licenses");
resolve_path("install_pythoncore", p.install_bin(), "pythoncore");
resolve_path("install_stylesheets", p.install_bin(), "stylesheets");
resolve_path("install_translations", p.install_bin(), "translations");
@@ -685,11 +682,6 @@ namespace mob {
return {};
}
conf_prebuilt conf::prebuilt()
{
return {};
}
conf_versions conf::version()
{
return {};
-3
View File
@@ -245,7 +245,6 @@ namespace mob {
VALUE(third_party);
VALUE(prefix);
VALUE(cache);
VALUE(patches);
VALUE(licenses);
VALUE(build);
@@ -256,11 +255,9 @@ namespace mob {
VALUE(install_pdbs);
VALUE(install_dlls);
VALUE(install_loot);
VALUE(install_plugins);
VALUE(install_stylesheets);
VALUE(install_licenses);
VALUE(install_pythoncore);
VALUE(install_translations);
VALUE(vs);
+13 -63
View File
@@ -24,36 +24,6 @@ namespace mob {
// mob doesn't have a concept of task dependencies, just task ordering, so
// if a task depends on another, it has to be earlier in the order
// 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>();
// super tasks
using mo = modorganizer;
@@ -61,9 +31,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")
@@ -72,35 +42,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-game_bethesda");
add_task<parallel_tasks>()
.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_fallout4london", 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<parallel_tasks>()
.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")
@@ -110,12 +58,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")
@@ -126,7 +77,6 @@ namespace mob {
.add_task<mo>({"modorganizer", "organizer"});
// other tasks
add_task<translations>();
add_task<installer>();
}
@@ -148,9 +98,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);
-336
View File
@@ -1,336 +0,0 @@
#include "pch.h"
#include "../core/process.h"
#include "tasks.h"
namespace mob::tasks {
namespace {
std::string boost_version_no_tags()
{
const auto v = boost::parsed_version();
// 1.72[.1]
std::string s = v.major + "." + v.minor;
if (v.patch != "")
s += "." + v.patch;
return s;
}
std::string boost_version_dash()
{
const auto v = boost::parsed_version();
// boost_1_72[_0[_b1_rc1]]
std::string s = "Boost-" + v.major + "." + v.minor;
if (v.patch != "")
s += "." + v.patch;
return s;
}
std::string boost_version_no_tags_underscores()
{
return replace_all(boost_version_no_tags(), ".", "_");
}
std::string boost_version_all_underscores()
{
const auto v = boost::parsed_version();
// boost_1_72[_0[_b1_rc1]]
std::string s = "boost_" + v.major + "_" + v.minor;
if (v.patch != "")
s += "_" + v.patch;
if (v.rest != "")
s += "_" + replace_all(v.rest, "-", "_");
return s;
}
std::string address_model_for_arch(arch a)
{
switch (a) {
case arch::x86:
return "32";
case arch::x64:
case arch::dont_care:
return "64";
default:
gcx().bail_out(context::generic, "boost: bad arch");
}
}
fs::path config_jam_file()
{
return boost::source_path() / "user-config-64.jam";
}
url prebuilt_url()
{
const auto underscores = replace_all(boost::version(), ".", "_");
return make_prebuilt_url("boost_prebuilt_" + underscores + ".7z");
}
url source_url()
{
return "https://archives.boost.io/release/" + boost_version_no_tags() +
"/source/" + boost_version_all_underscores() + ".7z";
}
fs::path b2_exe()
{
return boost::source_path() / "b2.exe";
}
} // namespace
boost::boost() : basic_task("boost") {}
std::string boost::version()
{
return conf().version().get("boost");
}
std::string boost::version_vs()
{
return conf().version().get("boost_vs");
}
bool boost::prebuilt()
{
return conf().prebuilt().get<bool>("boost");
}
fs::path boost::source_path()
{
// ex: build/boost_1_74_0
return conf().path().build() / ("boost_" + boost_version_no_tags_underscores());
}
fs::path boost::cmake_path(arch a)
{
return lib_path(a) / "cmake" / boost_version_dash();
}
fs::path boost::lib_path(arch a)
{
// ex: build/boost_1_74_0/lib64-msvc-14.2/lib
return root_lib_path(a) / "lib";
}
fs::path boost::root_lib_path(arch a)
{
// ex: build/boost_1_74_0/lib64-msvc-14.2
const std::string lib =
"lib" + address_model_for_arch(a) + "-msvc-" + version_vs();
return source_path() / lib;
}
void boost::do_clean(clean c)
{
if (is_set(c, clean::redownload)) {
// delete downloaded file
if (prebuilt())
run_tool(downloader(prebuilt_url(), downloader::clean));
else
run_tool(downloader(source_url(), downloader::clean));
}
if (is_set(c, clean::reextract)) {
// delete the whole thing
cx().trace(context::reextract, "deleting {}", source_path());
op::delete_directory(cx(), source_path(), op::optional);
// no need for the rest
return;
}
// those don't make sense for prebults
if (!prebuilt()) {
if (is_set(c, clean::reconfigure)) {
// delete bin and b2.exe to make sure bootstrap runs again
op::delete_directory(cx(), source_path() / "bin.v2", op::optional);
op::delete_file(cx(), b2_exe(), op::optional);
// delete jam files
op::delete_file(cx(), config_jam_file(), op::optional);
op::delete_file(cx(), source_path() / "project-config.jam",
op::optional);
}
if (is_set(c, clean::rebuild)) {
// delete libs
op::delete_directory(cx(), root_lib_path(arch::x86), op::optional);
op::delete_directory(cx(), root_lib_path(arch::x64), op::optional);
}
}
}
void boost::do_fetch()
{
if (prebuilt())
fetch_prebuilt();
else
fetch_from_source();
}
void boost::do_build_and_install()
{
if (prebuilt())
build_and_install_prebuilt();
else
build_and_install_from_source();
}
void boost::fetch_prebuilt()
{
cx().trace(context::generic, "using prebuilt boost");
const auto file = run_tool(downloader(prebuilt_url()));
run_tool(extractor().file(file).output(source_path()));
}
void boost::build_and_install_prebuilt() {}
void boost::fetch_from_source()
{
const auto file = run_tool(downloader(source_url()));
run_tool(extractor().file(file).output(source_path()));
}
void boost::bootstrap()
{
// bootstrap b2
write_config_jam();
const auto bootstrap = source_path() / "bootstrap.bat";
run_tool(process_runner(process()
.binary(bootstrap)
.external_error_log(source_path() / "bootstrap.log")
.cwd(source_path())));
}
void boost::build_and_install_from_source()
{
// bypass boostrap
if (fs::exists(b2_exe())) {
cx().trace(context::bypass, "{} exists, boost already bootstrapped",
b2_exe());
}
else {
bootstrap();
}
// we do not need all variants of all components but since people should
// usually be using the pre-built, we can build everything without losing too
// much time and it is much easier to deal when mixing
//
// note: filesystem is only required by USVFS I think, so maybe think about
// removing it if we switch to std::filesystem in USVFS
//
clipp::arg_list components{"thread", "date_time", "filesystem", "locale",
"program_options"};
// static link, static runtime, x64
do_b2(components, "static", "static", arch::x64);
// static link, static/shared runtime, x86, required by usvfs 32-bit
do_b2(components, "static", "static", arch::x86);
do_b2(components, "static", "shared", arch::x86);
// static link, shared runtime, x64
do_b2(components, "static", "shared", arch::x64);
// shared link, shared runtime, x64
do_b2(components, "shared", "shared", arch::x64);
}
void boost::do_b2(const std::vector<std::string>& components,
const std::string& link, const std::string& runtime_link, arch a)
{
// will transform all components to --with-X
run_tool(process_runner(process()
.binary(b2_exe())
.arg("address-model=", address_model_for_arch(a))
.arg("link=", link)
.arg("runtime-link=", runtime_link)
.arg("toolset=", "msvc-" + vs::toolset())
.arg("--user-config=", config_jam_file())
.arg("--stagedir=", root_lib_path(a))
.arg("--libdir=", root_lib_path(a))
.args(map(components,
[](auto&& c) {
return "--with-" + c;
}))
.env(env::vs(a))
.cwd(source_path())));
}
void boost::write_config_jam()
{
// b2 requires forward slashes
auto forward_slashes = [](auto&& p) {
std::string s = path_to_utf8(p);
return replace_all(s, "\\", "/");
};
// this currently writes an empty configuration file, at some point it was used
// to configure the Boost.Python built
//
// kept here in case we need a custom user-configuration in the future
//
std::ostringstream oss;
// logging
{
cx().trace(context::generic,
"writing config file at {}:", config_jam_file());
for_each_line(oss.str(), [&](auto&& line) {
cx().trace(context::generic, " {}", line);
});
}
// writing
op::write_text_file(cx(), encodings::utf8, config_jam_file(), oss.str());
}
boost::version_info boost::parsed_version()
{
// 1.72.0-b1-rc1
// everything but 1.72 is optional
std::regex re("(\\d+)\\." // 1.
"(\\d+)" // 72
"(?:"
"\\.(\\d+)" // .0
"(?:" //
"-(.+)" // -b1-rc1
")?"
")?");
std::smatch m;
const auto s = version();
if (!std::regex_match(s, m, re))
gcx().bail_out(context::generic, "bad boost version '{}'", s);
return {m[1], m[2], m[3], m[4]};
}
} // namespace mob::tasks
-41
View File
@@ -1,41 +0,0 @@
#include "pch.h"
#include "tasks.h"
namespace mob::tasks {
// boost-di is needed by bsapacker
boost_di::boost_di() : basic_task("boost-di", "boostdi", "boost_di") {}
std::string boost_di::version()
{
return {};
}
bool boost_di::prebuilt()
{
// prebuilts don't exist for this, it's headers only
return false;
}
fs::path boost_di::source_path()
{
return conf().path().build() / "di";
}
void boost_di::do_clean(clean c)
{
// delete the whole thing
if (is_set(c, clean::reclone))
git_wrap::delete_directory(cx(), source_path());
}
void boost_di::do_fetch()
{
run_tool(make_git()
.url(make_git_url("boost-experimental", "di"))
.branch("cpp14")
.root(source_path()));
}
} // namespace mob::tasks
-58
View File
@@ -1,58 +0,0 @@
#include "pch.h"
#include "tasks.h"
namespace mob::tasks {
// required by python
namespace {
url source_url()
{
return "https://sourceware.org/pub/bzip2/"
"bzip2-" +
bzip2::version() + ".tar.gz";
}
} // namespace
bzip2::bzip2() : basic_task("bzip2") {}
std::string bzip2::version()
{
return conf().version().get("bzip2");
}
bool bzip2::prebuilt()
{
// no prebuilts, just the source, required by python, which uses the
// source files directly
return false;
}
fs::path bzip2::source_path()
{
return conf().path().build() / ("bzip2-" + version());
}
void bzip2::do_clean(clean c)
{
// delete download
if (is_set(c, clean::redownload))
run_tool(downloader(source_url(), downloader::clean));
// delete the whole directory
if (is_set(c, clean::reextract)) {
cx().trace(context::reextract, "deleting {}", source_path());
op::delete_directory(cx(), source_path(), op::optional);
}
}
void bzip2::do_fetch()
{
const auto file = run_tool(downloader(source_url()));
run_tool(extractor().file(file).output(source_path()));
}
} // namespace mob::tasks
-80
View File
@@ -1,80 +0,0 @@
#include "pch.h"
#include "tasks.h"
namespace mob::tasks {
namespace {
msbuild create_msbuild_tool(arch a, config config,
msbuild::ops o = msbuild::build)
{
return std::move(msbuild(o).architecture(a).configuration(config).solution(
directxtex::source_path() / "DirectXTex" /
"DirectXTex_Desktop_2022.vcxproj"));
}
} // namespace
directxtex::directxtex() : basic_task("directxtex") {}
std::string directxtex::version()
{
return conf().version().get("directxtex");
}
bool directxtex::prebuilt()
{
return false;
}
fs::path directxtex::source_path()
{
return conf().path().build() / "DirectXTex";
}
void directxtex::do_clean(clean c)
{
if (is_set(c, clean::reclone)) {
git_wrap::delete_directory(cx(), source_path());
return;
}
if (is_set(c, clean::rebuild)) {
run_tool(create_msbuild_tool(arch::x64, config::release, msbuild::clean));
run_tool(create_msbuild_tool(arch::x64, config::debug, msbuild::clean));
}
}
void directxtex::do_fetch()
{
run_tool(make_git()
.url(make_git_url("microsoft", "DirectXTex"))
.branch(version())
.root(source_path()));
}
void directxtex::do_build_and_install()
{
op::create_directories(cx(), directxtex::source_path() / "Include");
op::create_directories(cx(), directxtex::source_path() / "Lib" / "Debug");
op::create_directories(cx(), directxtex::source_path() / "Lib" / "Release");
// DO NOT run these in parallel because both generate files that are shared
// between release and debug
run_tool(create_msbuild_tool(arch::x64, config::release));
run_tool(create_msbuild_tool(arch::x64, config::debug));
const auto binary_path =
source_path() / "DirectXTex" / "Bin" / "Desktop_2022" / "x64";
for (const auto& header : {"DDS.h", "DirectXTex.h", "DirectXTex.inl "}) {
op::copy_file_to_dir_if_better(cx(), source_path() / "DirectXTex" / header,
source_path() / "Include");
}
op::copy_file_to_dir_if_better(cx(), binary_path / "Debug" / "DirectXTex.lib",
source_path() / "Lib" / "Debug");
op::copy_file_to_dir_if_better(cx(), binary_path / "Release" / "DirectXTex.lib",
source_path() / "Lib" / "Release");
}
} // namespace mob::tasks
-104
View File
@@ -1,104 +0,0 @@
#include "pch.h"
#include "tasks.h"
namespace mob::tasks {
namespace {
cmake create_cmake_tool(arch a, config config, cmake::ops o = cmake::generate)
{
return std::move(cmake(o)
.generator(cmake::vs)
.architecture(a)
.arg("-Wno-deprecated")
.arg("-Dgtest_force_shared_crt=ON")
.prefix(gtest::build_path(a, config))
.root(gtest::source_path()));
}
msbuild create_msbuild_tool(arch a, config config,
msbuild::ops o = msbuild::build)
{
const fs::path build_path = create_cmake_tool(a, config).build_path();
return std::move(msbuild(o).architecture(a).configuration(config).solution(
build_path / "INSTALL.vcxproj"));
}
} // namespace
gtest::gtest() : basic_task("gtest", "googletest") {}
std::string gtest::version()
{
return conf().version().get("gtest");
}
bool gtest::prebuilt()
{
return false;
}
fs::path gtest::source_path()
{
return conf().path().build() / "googletest";
}
fs::path gtest::build_path(arch a, config c)
{
return source_path() / "build" / (a == arch::x64 ? "x64" : "Win32") /
msbuild::configuration_name(c);
}
void gtest::do_clean(clean c)
{
if (is_set(c, clean::reclone)) {
git_wrap::delete_directory(cx(), source_path());
return;
}
if (is_set(c, clean::reconfigure)) {
run_tool(create_cmake_tool(arch::x86, config::release, cmake::clean));
run_tool(create_cmake_tool(arch::x64, config::release, cmake::clean));
}
if (is_set(c, clean::rebuild)) {
run_tool(create_msbuild_tool(arch::x86, config::release, msbuild::clean));
run_tool(create_msbuild_tool(arch::x86, config::debug, msbuild::clean));
run_tool(create_msbuild_tool(arch::x64, config::release, msbuild::clean));
run_tool(create_msbuild_tool(arch::x64, config::debug, msbuild::clean));
}
}
void gtest::do_fetch()
{
run_tool(make_git()
.url(make_git_url("google", "googletest"))
.branch(version())
.root(source_path()));
}
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, config::release));
run_tool(create_msbuild_tool(arch::x64, config::release));
run_tool(create_cmake_tool(arch::x64, config::debug));
run_tool(create_msbuild_tool(arch::x64, config::debug));
}},
{"gtest32", [&] {
run_tool(create_cmake_tool(arch::x86, config::release));
run_tool(create_msbuild_tool(arch::x86, config::release));
run_tool(create_cmake_tool(arch::x86, config::debug));
run_tool(create_msbuild_tool(arch::x86, config::debug));
}}});
}
} // namespace mob::tasks
+13 -1
View File
@@ -36,9 +36,21 @@ namespace mob::tasks {
{
const std::string repo = "modorganizer-Installer";
// find the best suitable branch
const auto fallback = task_conf().mo_fallback_branch();
auto branch = task_conf().mo_branch();
if (!fallback.empty() &&
!git_wrap::remote_branch_exists(make_git_url(task_conf().mo_org(), repo),
branch)) {
cx().warning(context::generic,
"{} has no remote {} branch, switching to {}", repo, branch,
fallback);
branch = fallback;
}
run_tool(make_git()
.url(make_git_url(task_conf().mo_org(), repo))
.branch(task_conf().mo_branch())
.branch(branch)
.root(source_path()));
}
-72
View File
@@ -1,72 +0,0 @@
#include "pch.h"
#include "tasks.h"
namespace mob::tasks {
namespace {
std::string dir_name()
{
return "libbsarch-" + libbsarch::version() + "-" +
(libbsarch::build_type() == config::debug ? "debug" : "release") +
"-x64";
}
url source_url()
{
return "https://github.com/ModOrganizer2/libbsarch/releases/download/" +
libbsarch::version() + "/" + dir_name() + ".7z";
}
} // namespace
libbsarch::libbsarch() : basic_task("libbsarch") {}
std::string libbsarch::version()
{
return conf().version().get("libbsarch");
}
config libbsarch::build_type()
{
return conf().build_types().get("libbsarch");
}
bool libbsarch::prebuilt()
{
return false;
}
fs::path libbsarch::source_path()
{
return conf().path().build() / dir_name();
}
void libbsarch::do_clean(clean c)
{
// delete the download
if (is_set(c, clean::redownload))
run_tool(downloader(source_url(), downloader::clean));
// delete the whole directory
if (is_set(c, clean::reextract)) {
cx().trace(context::reextract, "deleting {}", source_path());
op::delete_directory(cx(), source_path(), op::optional);
}
}
void libbsarch::do_fetch()
{
const auto file = run_tool(downloader(source_url()));
run_tool(extractor().file(file).output(source_path()));
}
void libbsarch::do_build_and_install()
{
// copy dll
op::copy_file_to_dir_if_better(cx(), source_path() / "libbsarch.dll",
conf().path().install_dlls());
}
} // namespace mob::tasks
-67
View File
@@ -1,67 +0,0 @@
#include "pch.h"
#include "tasks.h"
namespace mob::tasks {
namespace {
std::string release_name()
{
// the naming convention is `libloot-version-win64.7z`,
// such as libloot-0.19.3-win64.7z.
return "libloot-" + libloot::version() + "-" + "win64";
}
url source_url()
{
return "https://github.com/loot/libloot/releases/download/" +
libloot::version() + "/" + release_name() + ".7z";
}
} // namespace
libloot::libloot() : basic_task("libloot") {}
std::string libloot::version()
{
return conf().version().get("libloot");
}
bool libloot::prebuilt()
{
return false;
}
fs::path libloot::source_path()
{
return conf().path().build() / release_name();
}
void libloot::do_clean(clean c)
{
// delete download
if (is_set(c, clean::redownload))
run_tool(downloader(source_url(), downloader::clean));
// delete the whole directory
if (is_set(c, clean::reextract)) {
cx().trace(context::reextract, "deleting {}", source_path());
op::delete_directory(cx(), source_path(), op::optional);
}
}
void libloot::do_fetch()
{
const auto file = run_tool(downloader(source_url()));
run_tool(extractor().file(file).output(source_path()));
}
void libloot::do_build_and_install()
{
// copy dll
op::copy_file_to_dir_if_better(cx(), source_path() / "bin" / "loot.dll",
conf().path().install_loot());
}
} // namespace mob::tasks
-142
View File
@@ -1,142 +0,0 @@
#include "pch.h"
#include "tasks.h"
namespace mob::tasks {
namespace {
fs::path solution_dir()
{
return lz4::source_path() / "build" / "VS2022";
}
fs::path solution_file()
{
return solution_dir() / "lz4.sln";
}
fs::path out_dir()
{
return solution_dir() / "bin" / "x64_Release";
}
url prebuilt_url()
{
return make_prebuilt_url("lz4_prebuilt_" + lz4::version() + ".7z");
}
} // namespace
lz4::lz4() : basic_task("lz4") {}
std::string lz4::version()
{
return conf().version().get("lz4");
}
bool lz4::prebuilt()
{
return conf().prebuilt().get<bool>("lz4");
}
fs::path lz4::source_path()
{
return conf().path().build() / ("lz4-" + version());
}
void lz4::do_clean(clean c)
{
if (prebuilt()) {
// delete download
if (is_set(c, clean::redownload))
run_tool(downloader(prebuilt_url(), downloader::clean));
// delete the whole directory
if (is_set(c, clean::reextract)) {
cx().trace(context::reextract, "deleting {}", source_path());
op::delete_directory(cx(), source_path(), op::optional);
}
}
else {
// delete the whole directory
if (is_set(c, clean::reclone)) {
git_wrap::delete_directory(cx(), source_path());
// no point in doing anything more
return;
}
// msbuild clean
if (is_set(c, clean::rebuild))
run_tool(create_msbuild_tool(msbuild::clean));
}
}
void lz4::do_fetch()
{
if (prebuilt())
fetch_prebuilt();
else
fetch_from_source();
}
void lz4::do_build_and_install()
{
if (prebuilt())
build_and_install_prebuilt();
else
build_and_install_from_source();
}
void lz4::fetch_prebuilt()
{
cx().trace(context::generic, "using prebuilt lz4");
const auto file = run_tool(downloader(prebuilt_url()));
run_tool(extractor().file(file).output(source_path()));
}
void lz4::build_and_install_prebuilt()
{
// copy pdb and dll
op::copy_file_to_dir_if_better(cx(), source_path() / "bin" / "liblz4.pdb",
conf().path().install_pdbs());
op::copy_file_to_dir_if_better(cx(), source_path() / "bin" / "liblz4.dll",
conf().path().install_dlls());
}
void lz4::fetch_from_source()
{
// clone
run_tool(make_git()
.url(make_git_url("lz4", "lz4"))
.branch(version())
.root(source_path()));
}
void lz4::build_and_install_from_source()
{
run_tool(create_msbuild_tool());
// cmake_common looks for the lib files in the bin/ directory, which is
// correct for prebuilts, but not from source, so copy the files in there
op::copy_glob_to_dir_if_better(cx(), out_dir() / "*", source_path() / "bin",
op::copy_files);
// copy dll and pdb
op::copy_file_to_dir_if_better(cx(), source_path() / "bin" / "liblz4.dll",
conf().path().install_dlls());
op::copy_file_to_dir_if_better(cx(), source_path() / "bin" / "liblz4.pdb",
conf().path().install_pdbs());
}
msbuild lz4::create_msbuild_tool(msbuild::ops o)
{
return std::move(msbuild(o).solution(solution_file()).targets({"liblz4-dll"}));
}
} // namespace mob::tasks
+42 -80
View File
@@ -59,18 +59,18 @@ namespace mob::tasks {
g.init_repo();
}
modorganizer::modorganizer(std::string long_name, flags f)
: modorganizer(std::vector<std::string>{long_name}, f)
modorganizer::modorganizer(std::string long_name)
: modorganizer(std::vector<std::string>{long_name})
{
}
modorganizer::modorganizer(std::vector<const char*> names, flags f)
: modorganizer(std::vector<std::string>(names.begin(), names.end()), f)
modorganizer::modorganizer(std::vector<const char*> names)
: modorganizer(std::vector<std::string>(names.begin(), names.end()))
{
}
modorganizer::modorganizer(std::vector<std::string> names, flags f)
: task(make_names(names)), repo_(names[0]), flags_(f)
modorganizer::modorganizer(std::vector<std::string> names)
: task(make_names(names)), repo_(names[0])
{
if (names.size() > 1) {
project_ = names[1];
@@ -80,14 +80,11 @@ namespace mob::tasks {
}
}
bool modorganizer::is_gamebryo_plugin() const
std::string modorganizer::cmake_prefix_path()
{
return is_set(flags_, gamebryo);
}
bool modorganizer::is_nuget_plugin() const
{
return is_set(flags_, nuget);
return conf().path().qt_install().string() + ";" +
(modorganizer::super_path() / "cmake_common").string() + ";" +
(conf().path().install() / "lib" / "cmake").string();
}
fs::path modorganizer::source_path() const
@@ -96,18 +93,9 @@ 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() / "modorganizer_super";
return conf().path().build();
}
url modorganizer::git_url() const
@@ -137,11 +125,7 @@ namespace mob::tasks {
// cmake clean
if (is_set(c, clean::reconfigure))
run_tool(create_cmake_tool(cmake::clean));
// msbuild clean
if (is_set(c, clean::rebuild))
run_tool(create_msbuild_tool(msbuild::clean));
run_tool(cmake(cmake::clean).root(source_path()));
}
void modorganizer::do_fetch()
@@ -165,7 +149,7 @@ namespace mob::tasks {
void modorganizer::do_build_and_install()
{
// adds a git submodule in modorganizer_super for this project; note that
// adds a git submodule in build for this project; note that
// git_submodule_adder runs a thread because adding submodules is slow, but
// can happen while stuff is building
git_submodule_adder::instance().queue(
@@ -177,66 +161,44 @@ 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())
.configuration_types({task_conf().configuration()})
.preset("vs2022-windows")
.root(source_path()));
// run restore for nuget
//
// until https://gitlab.kitware.com/cmake/cmake/-/issues/20646 is resolved,
// we need a manual way of running the msbuild -t:restore
if (is_nuget_plugin())
run_tool(create_msbuild_tool().targets({"restore"}));
// run cmake --build with default target
// TODO: handle rebuild by adding `--clean-first`
// TODO: have a way to specify the `--parallel` value - 16 is useful to build
// game_bethesda that has 15 games, so 15 projects
run_tool(cmake(cmake::build)
.root(source_path())
.arg("--parallel")
.arg("16")
.configuration(task_conf().configuration()));
// run msbuild
run_tool(create_msbuild_tool());
}
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)
{
return std::move(
cmake(o)
.generator(cmake::vs)
.def("CMAKE_INSTALL_PREFIX:PATH", conf().path().install())
.def("DEPENDENCIES_DIR", conf().path().build())
.def("BOOST_ROOT", boost::source_path())
.def("BOOST_LIBRARYDIR", boost::lib_path(arch::x64))
.def("Boost_DIR", boost::cmake_path(arch::x64))
.def("SPDLOG_ROOT", spdlog::source_path())
.def("LOOT_PATH", libloot::source_path())
.def("LZ4_ROOT", lz4::source_path())
.def("QT_ROOT", qt::installation_path())
.def("ZLIB_ROOT", zlib::source_path())
.def("PYTHON_ROOT", python::source_path())
.def("SEVENZ_ROOT", sevenz::source_path())
.def("LIBBSARCH_ROOT", libbsarch::source_path())
.def("BOOST_DI_ROOT", boost_di::source_path())
// gtest has no RelWithDebInfo, so simply use Debug/Release
.def("GTEST_ROOT",
gtest::build_path(arch::x64, c == config::debug ? config::debug
: config::release))
.def("OPENSSL_ROOT_DIR", openssl::source_path())
.def("DIRECTXTEX_ROOT", directxtex::source_path())
.root(root));
}
msbuild modorganizer::create_msbuild_tool(msbuild::ops o)
{
return std::move(msbuild(o)
.solution(project_file_path())
.configuration(task_conf().configuration())
.architecture(arch::x64));
// run cmake --install
run_tool(cmake(cmake::build)
.root(source_path())
.targets("INSTALL")
.configuration(task_conf().configuration()));
}
} // namespace mob::tasks

Some files were not shown because too many files have changed in this diff Show More