mirror of
https://github.com/ModOrganizer2/mob.git
synced 2026-07-27 14:07:05 -07:00
added architectures, pass env to CreateProcess
added spdlog and usvfs gtest and boost also build other architectures boost also builds static libs moved "v" to versions to support other branches that don't start with "v"
This commit is contained in:
+11
-2
@@ -69,7 +69,7 @@ static std::map<std::string, std::string> g_conf =
|
||||
{"zlib", "1.2.11"},
|
||||
{"boost", "1.72.0-b1-rc1"},
|
||||
{"boost_vs", "14.2"},
|
||||
{"python", "3.8.1"},
|
||||
{"python", "v3.8.1"},
|
||||
{"fmt", "6.1.2"},
|
||||
{"gtest", "master"},
|
||||
{"libbsarch", "0.0.8"},
|
||||
@@ -77,8 +77,10 @@ static std::map<std::string, std::string> g_conf =
|
||||
{"libloot_hash", "gf725dd7"},
|
||||
{"openssl", "1.1.1d"},
|
||||
{"bzip2", "1.0.6"},
|
||||
{"lz4", "1.9.2"},
|
||||
{"lz4", "v1.9.2"},
|
||||
{"nmm", "0.70.11"},
|
||||
{"spdlog", "v1.4.2"},
|
||||
{"usvfs", "master"},
|
||||
|
||||
{"prefix", R"(C:\dev\projects\mobuild-out)"},
|
||||
};
|
||||
@@ -92,11 +94,16 @@ const std::string& get_conf(const std::string& name)
|
||||
return itor->second;
|
||||
}
|
||||
|
||||
bool g_clean = false;
|
||||
|
||||
|
||||
bool conf::verbose() { return true; }
|
||||
bool conf::dry() { return false; }
|
||||
std::string conf::mo_org() { return "ModOrganizer2"; }
|
||||
std::string conf::mo_branch() { return "master"; }
|
||||
bool conf::clean() { return g_clean; }
|
||||
|
||||
void conf::set_clean(bool b) { g_clean = b; }
|
||||
|
||||
fs::path third_party::sevenz() { return "7z"; }
|
||||
fs::path third_party::jom() { return "jom"; }
|
||||
@@ -128,6 +135,8 @@ const std::string& versions::openssl() { return get_conf("openssl"); }
|
||||
const std::string& versions::bzip2() { return get_conf("bzip2"); }
|
||||
const std::string& versions::lz4() { return get_conf("lz4"); }
|
||||
const std::string& versions::nmm() { return get_conf("nmm"); }
|
||||
const std::string& versions::spdlog() { return get_conf("spdlog"); }
|
||||
const std::string& versions::usvfs() { return get_conf("usvfs"); }
|
||||
|
||||
fs::path paths::prefix() { return get_conf("prefix"); }
|
||||
fs::path paths::cache() { return prefix() / "downloads"; }
|
||||
|
||||
@@ -9,6 +9,9 @@ struct conf
|
||||
static bool dry();
|
||||
static std::string mo_org();
|
||||
static std::string mo_branch();
|
||||
|
||||
static bool clean();
|
||||
static void set_clean(bool b);
|
||||
};
|
||||
|
||||
struct third_party
|
||||
@@ -49,6 +52,8 @@ struct versions
|
||||
static const std::string& bzip2();
|
||||
static const std::string& lz4();
|
||||
static const std::string& nmm();
|
||||
static const std::string& spdlog();
|
||||
static const std::string& usvfs();
|
||||
};
|
||||
|
||||
struct paths
|
||||
|
||||
+15
-1
@@ -55,12 +55,26 @@ int run(int argc, char** argv)
|
||||
add_task<lz4>();
|
||||
add_task<nmm>();
|
||||
add_task<ncc>();
|
||||
add_task<spdlog>();
|
||||
add_task<usvfs>();
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
std::vector<std::string> tasks;
|
||||
|
||||
for (int i=1; i<argc; ++i)
|
||||
{
|
||||
if (!run_task(argv[i]))
|
||||
const std::string arg = argv[i];
|
||||
|
||||
if (arg == "--clean")
|
||||
conf::set_clean(true);
|
||||
else
|
||||
tasks.push_back(arg);
|
||||
}
|
||||
|
||||
for (auto&& t : tasks)
|
||||
{
|
||||
if (!run_task(t))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+150
-4
@@ -6,6 +6,130 @@
|
||||
namespace builder
|
||||
{
|
||||
|
||||
class environment
|
||||
{
|
||||
public:
|
||||
void add(std::string k, std::string v)
|
||||
{
|
||||
vars_.push_back({std::move(k), std::move(v)});
|
||||
}
|
||||
|
||||
void create()
|
||||
{
|
||||
for (auto&& v : vars_)
|
||||
{
|
||||
string_ += v.first + "=" + v.second;
|
||||
string_.append(1, '\0');
|
||||
}
|
||||
|
||||
string_.append(1, '\0');
|
||||
}
|
||||
|
||||
void* get() const
|
||||
{
|
||||
return (void*)string_.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::string, std::string>> vars_;
|
||||
std::string string_;
|
||||
};
|
||||
|
||||
|
||||
static environment g_env_x86, g_env_x64;
|
||||
|
||||
|
||||
fs::path find_vcvars()
|
||||
{
|
||||
const std::vector<std::string> editions =
|
||||
{
|
||||
"Preview", "Enterprise", "Professional", "Community"
|
||||
};
|
||||
|
||||
for (auto&& edition : editions)
|
||||
{
|
||||
const auto p =
|
||||
paths::program_files_x86() /
|
||||
"Microsoft Visual Studio" /
|
||||
versions::vs_year() /
|
||||
edition / "VC" / "Auxiliary" / "Build" / "vcvarsall.bat";
|
||||
|
||||
if (fs::exists(p))
|
||||
{
|
||||
debug("found " + p.string());
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
bail_out("couldn't find visual studio");
|
||||
}
|
||||
|
||||
environment get_vcvars_env(arch a)
|
||||
{
|
||||
debug("vcvars");
|
||||
|
||||
std::string arch_s;
|
||||
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
arch_s = "x86";
|
||||
break;
|
||||
|
||||
case arch::x64:
|
||||
arch_s = "amd64";
|
||||
break;
|
||||
|
||||
case arch::dont_care:
|
||||
default:
|
||||
bail_out("get_vcvars_env: bad arch");
|
||||
}
|
||||
|
||||
const fs::path tmp = paths::temp_file();
|
||||
|
||||
// "vcvarsall.bat" amd64 && set > temp_file
|
||||
const std::string cmd =
|
||||
"\"" + find_vcvars().string() + "\" " + arch_s + " && "
|
||||
"set > \"" + tmp.string() + "\"";
|
||||
|
||||
op::run(arch::dont_care, cmd);
|
||||
|
||||
std::stringstream ss(read_text_file(tmp));
|
||||
op::delete_file(tmp);
|
||||
|
||||
|
||||
environment env;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
std::string line;
|
||||
std::getline(ss, line);
|
||||
if (!ss)
|
||||
break;
|
||||
|
||||
const auto sep = line.find('=');
|
||||
|
||||
if (sep == std::string::npos)
|
||||
continue;
|
||||
|
||||
std::string name = line.substr(0, sep);
|
||||
std::string value = line.substr(sep + 1);
|
||||
|
||||
env.add(std::move(name), std::move(value));
|
||||
}
|
||||
|
||||
env.create();
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
void vcvars()
|
||||
{
|
||||
g_env_x86 = get_vcvars_env(arch::x86);
|
||||
g_env_x64 = get_vcvars_env(arch::x64);
|
||||
}
|
||||
|
||||
|
||||
process::process()
|
||||
: code_(0)
|
||||
{
|
||||
@@ -307,7 +431,7 @@ void op::copy_file_to_dir_if_better(const fs::path& file, const fs::path& dir)
|
||||
}
|
||||
}
|
||||
|
||||
process op::run(const std::string& cmd, const fs::path& cwd)
|
||||
process op::run(arch a, const std::string& cmd, const fs::path& cwd)
|
||||
{
|
||||
if (!cwd.empty())
|
||||
debug("> cd " + cwd.string());
|
||||
@@ -317,7 +441,7 @@ process op::run(const std::string& cmd, const fs::path& cwd)
|
||||
if (conf::dry())
|
||||
return {};
|
||||
|
||||
return do_run(cmd, cwd);
|
||||
return do_run(a, cmd, cwd);
|
||||
}
|
||||
|
||||
void op::do_touch(const fs::path& p)
|
||||
@@ -401,7 +525,7 @@ void op::do_rename(const fs::path& src, const fs::path& dest)
|
||||
bail_out("can't rename " + src.string() + " to " + dest.string(), ec);
|
||||
}
|
||||
|
||||
process op::do_run(const std::string& what, const fs::path& cwd)
|
||||
process op::do_run(arch a, const std::string& what, const fs::path& cwd)
|
||||
{
|
||||
STARTUPINFOA si = { .cb=sizeof(si) };
|
||||
PROCESS_INFORMATION pi = {};
|
||||
@@ -412,6 +536,28 @@ process op::do_run(const std::string& what, const fs::path& cwd)
|
||||
const char* cwd_p = nullptr;
|
||||
std::string cwd_s;
|
||||
|
||||
|
||||
const environment* env = nullptr;
|
||||
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
env = &g_env_x86;
|
||||
break;
|
||||
|
||||
case arch::x64:
|
||||
env = &g_env_x64;
|
||||
break;
|
||||
|
||||
case arch::dont_care:
|
||||
// no environment
|
||||
break;
|
||||
|
||||
default:
|
||||
bail_out("op::do_run: bad arch");
|
||||
}
|
||||
|
||||
|
||||
if (!cwd.empty())
|
||||
{
|
||||
create_directories(cwd);
|
||||
@@ -422,7 +568,7 @@ process op::do_run(const std::string& what, const fs::path& cwd)
|
||||
const auto r = ::CreateProcessA(
|
||||
cmd.c_str(), const_cast<char*>(args.c_str()),
|
||||
nullptr, nullptr, FALSE, CREATE_NEW_PROCESS_GROUP,
|
||||
nullptr, cwd_p, &si, &pi);
|
||||
(env ? env->get() : nullptr), cwd_p, &si, &pi);
|
||||
|
||||
if (!r)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
namespace builder
|
||||
{
|
||||
|
||||
void vcvars();
|
||||
|
||||
|
||||
class process
|
||||
{
|
||||
public:
|
||||
@@ -43,7 +46,7 @@ public:
|
||||
static void rename(const fs::path& src, const fs::path& dest);
|
||||
static void move_to_directory(const fs::path& src, const fs::path& dest_dir);
|
||||
static void copy_file_to_dir_if_better(const fs::path& file, const fs::path& dest_dir);
|
||||
static process run(const std::string& cmd, const fs::path& cwd={});
|
||||
static process run(arch a, const std::string& cmd, const fs::path& cwd={});
|
||||
|
||||
private:
|
||||
static void do_touch(const fs::path& p);
|
||||
@@ -53,7 +56,7 @@ private:
|
||||
static void do_copy_file_to_dir(const fs::path& f, const fs::path& d);
|
||||
static void do_remove_readonly(const fs::path& p);
|
||||
static void do_rename(const fs::path& src, const fs::path& dest);
|
||||
static process do_run(const std::string& cmd, const fs::path& cwd);
|
||||
static process do_run(arch a, const std::string& cmd, const fs::path& cwd);
|
||||
static void check(const fs::path& p);
|
||||
};
|
||||
|
||||
|
||||
+58
-16
@@ -42,7 +42,7 @@ void boost::fetch_prebuilt()
|
||||
void boost::build_and_install_prebuilt()
|
||||
{
|
||||
op::copy_file_to_dir_if_better(
|
||||
lib_path() / python_dll(), paths::install_bin());
|
||||
lib_path(arch::x64) / "lib" / python_dll(), paths::install_bin());
|
||||
}
|
||||
|
||||
void boost::fetch_from_source()
|
||||
@@ -61,30 +61,54 @@ void boost::fetch_from_source()
|
||||
{
|
||||
write_config_jam();
|
||||
|
||||
run_tool(process_runner(source_path() / "bootstrap.bat", cmd::noflags)
|
||||
const auto bootstrap = source_path() / "bootstrap.bat";
|
||||
|
||||
run_tool(process_runner(arch::dont_care, bootstrap, cmd::noflags)
|
||||
.cwd(source_path()));
|
||||
}
|
||||
}
|
||||
|
||||
void boost::build_and_install_from_source()
|
||||
{
|
||||
const fs::path out = "lib64-msvc-" + versions::vs_toolset();
|
||||
do_b2(
|
||||
{"thread", "date_time", "filesystem", "locale"},
|
||||
"static", "static", arch::x64);
|
||||
|
||||
run_tool(process_runner(source_path() / "b2", cmd::noflags)
|
||||
.arg("address-model=", "64")
|
||||
.arg("link=", "shared")
|
||||
.arg("--user-config=", config_jam_file())
|
||||
.arg("toolset=msvc-" + versions::vs_toolset())
|
||||
.arg("--stagedir=", out)
|
||||
.arg("--libdir=", out)
|
||||
.arg("--with-python")
|
||||
.cwd(source_path()));
|
||||
do_b2(
|
||||
{"thread", "date_time", "filesystem", "locale"},
|
||||
"static", "static", arch::x86);
|
||||
|
||||
do_b2(
|
||||
{"python"},
|
||||
"shared", "shared", arch::x64);
|
||||
|
||||
op::copy_file_to_dir_if_better(
|
||||
source_path() / out / "lib" / python_dll(),
|
||||
lib_path(arch::x64) / "lib" / python_dll(),
|
||||
paths::install_bin());
|
||||
}
|
||||
|
||||
void boost::do_b2(
|
||||
const std::vector<std::string>& components,
|
||||
const std::string& link, const std::string& runtime_link, arch a)
|
||||
{
|
||||
process_runner p(a, source_path() / "b2", cmd::noflags);
|
||||
|
||||
p
|
||||
.arg("address-model=", address_model_for_arch(a))
|
||||
.arg("link=", link)
|
||||
.arg("runtime-link=", runtime_link)
|
||||
.arg("toolset=", "msvc-" + versions::vs_toolset())
|
||||
.arg("--user-config=", config_jam_file())
|
||||
.arg("--stagedir=", lib_path(a))
|
||||
.arg("--libdir=", lib_path(a))
|
||||
.cwd(source_path());
|
||||
|
||||
for (auto&& c : components)
|
||||
p.arg("--with-" + c);
|
||||
|
||||
run_tool(p);
|
||||
}
|
||||
|
||||
void boost::write_config_jam()
|
||||
{
|
||||
std::ofstream out(config_jam_file());
|
||||
@@ -141,10 +165,12 @@ url boost::source_url()
|
||||
boost_version_all_underscores() + ".zip";
|
||||
}
|
||||
|
||||
fs::path boost::lib_path()
|
||||
fs::path boost::lib_path(arch a)
|
||||
{
|
||||
const std::string lib = "lib64-msvc-" + versions::boost_vs();
|
||||
return source_path() / lib / "lib";
|
||||
const std::string lib =
|
||||
"lib" + address_model_for_arch(a) + "-msvc-" + versions::boost_vs();
|
||||
|
||||
return source_path() / lib;
|
||||
}
|
||||
|
||||
std::string boost::python_dll()
|
||||
@@ -228,4 +254,20 @@ std::string boost::boost_version_all_underscores()
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string boost::address_model_for_arch(arch a)
|
||||
{
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
return "32";
|
||||
|
||||
case arch::x64:
|
||||
case arch::dont_care:
|
||||
return "64";
|
||||
|
||||
default:
|
||||
bail_out("boost: bad arch");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ void fmt::do_fetch()
|
||||
void fmt::do_build_and_install()
|
||||
{
|
||||
const auto build_path = run_tool(cmake()
|
||||
.generator(cmake::nmake)
|
||||
.generator(cmake::jom)
|
||||
.root(source_path())
|
||||
.def("FMT_TEST=OFF")
|
||||
.def("FMT_DOC=OFF"));
|
||||
|
||||
+17
-3
@@ -25,12 +25,26 @@ void gtest::do_fetch()
|
||||
|
||||
void gtest::do_build_and_install()
|
||||
{
|
||||
const auto build_path = run_tool(cmake()
|
||||
.generator(cmake::nmake)
|
||||
// x64
|
||||
const auto build_path_x64 = run_tool(cmake()
|
||||
.generator(cmake::jom)
|
||||
.architecture(arch::x64)
|
||||
.root(source_path()));
|
||||
|
||||
run_tool(jom()
|
||||
.path(build_path));
|
||||
.architecture(arch::x64)
|
||||
.path(build_path_x64));
|
||||
|
||||
|
||||
// x86
|
||||
const auto build_path_x86 = run_tool(cmake()
|
||||
.generator(cmake::jom)
|
||||
.architecture(arch::x86)
|
||||
.root(source_path()));
|
||||
|
||||
run_tool(jom()
|
||||
.architecture(arch::x86)
|
||||
.path(build_path_x86));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ lz4::lz4()
|
||||
|
||||
fs::path lz4::source_path()
|
||||
{
|
||||
return paths::build() / ("lz4-v" + versions::lz4());
|
||||
return paths::build() / ("lz4-" + versions::lz4());
|
||||
}
|
||||
|
||||
void lz4::do_fetch()
|
||||
@@ -19,7 +19,7 @@ void lz4::do_fetch()
|
||||
run_tool(git_clone()
|
||||
.org("lz4")
|
||||
.repo("lz4")
|
||||
.branch("v" + versions::lz4())
|
||||
.branch(versions::lz4())
|
||||
.output(source_path()));
|
||||
|
||||
run_tool(devenv_upgrade(solution_file()));
|
||||
|
||||
+3
-1
@@ -30,7 +30,9 @@ void ncc::do_build_and_install()
|
||||
.projects({"NexusClientCLI"})
|
||||
.platform("Any CPU"));
|
||||
|
||||
run_tool(process_runner(source_path() / "publish.bat", cmd::noflags)
|
||||
const auto publish =source_path() / "publish.bat";
|
||||
|
||||
run_tool(process_runner(arch::dont_care, publish, cmd::noflags)
|
||||
.arg(paths::install_bin()));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ void openssl::do_build_and_install()
|
||||
|
||||
void openssl::configure()
|
||||
{
|
||||
run_tool(process_runner(third_party::perl(), cmd::stdout_is_verbose)
|
||||
run_tool(process_runner(arch::x64, third_party::perl(), cmd::stdout_is_verbose)
|
||||
.arg("Configure")
|
||||
.arg("--openssldir=", build_path())
|
||||
.arg("--prefix=", build_path())
|
||||
|
||||
+13
-6
@@ -11,9 +11,9 @@ python::python()
|
||||
|
||||
python::version_info python::version()
|
||||
{
|
||||
// 3.8.1
|
||||
// .1 is optional
|
||||
std::regex re(R"((\d+)\.(\d+)(?:\.(\d+))?)");
|
||||
// v3.8.1
|
||||
// v and .1 are optional
|
||||
std::regex re(R"(v?(\d+)\.(\d+)(?:\.(\d+))?)");
|
||||
std::smatch m;
|
||||
|
||||
if (!std::regex_match(versions::python(), m, re))
|
||||
@@ -32,7 +32,14 @@ python::version_info python::version()
|
||||
|
||||
fs::path python::source_path()
|
||||
{
|
||||
return paths::build() / ("python-" + versions::python());
|
||||
const auto v = version();
|
||||
|
||||
// 3.8.1
|
||||
std::string s = v.major + "." + v.minor;
|
||||
if (v.patch != "")
|
||||
s += "." + v.patch;
|
||||
|
||||
return paths::build() / ("python-" + s);
|
||||
}
|
||||
|
||||
void python::do_fetch()
|
||||
@@ -40,7 +47,7 @@ void python::do_fetch()
|
||||
run_tool(git_clone()
|
||||
.org("python")
|
||||
.repo("cpython")
|
||||
.branch("v" + versions::python())
|
||||
.branch(versions::python())
|
||||
.output(source_path()));
|
||||
|
||||
run_tool(devenv_upgrade(solution_file()));
|
||||
@@ -69,7 +76,7 @@ void python::do_build_and_install()
|
||||
{
|
||||
const auto bat = source_path() / "python.bat";
|
||||
|
||||
run_tool(process_runner(bat, cmd::stdout_is_verbose)
|
||||
run_tool(process_runner(arch::dont_care, bat, cmd::stdout_is_verbose)
|
||||
.name("package python")
|
||||
.arg(fs::path("PC/layout"))
|
||||
.arg("--source", source_path())
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "pch.h"
|
||||
#include "tasks.h"
|
||||
|
||||
namespace builder
|
||||
{
|
||||
|
||||
spdlog::spdlog()
|
||||
: basic_task("spdlog")
|
||||
{
|
||||
}
|
||||
|
||||
fs::path spdlog::source_path()
|
||||
{
|
||||
return paths::build() / ("spdlog-" + versions::spdlog());
|
||||
}
|
||||
|
||||
void spdlog::do_fetch()
|
||||
{
|
||||
run_tool(git_clone()
|
||||
.org("gabime")
|
||||
.repo("spdlog")
|
||||
.branch(versions::spdlog())
|
||||
.output(source_path()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
+29
-1
@@ -27,12 +27,16 @@ private:
|
||||
void build_and_install_from_source();
|
||||
void write_config_jam();
|
||||
|
||||
void do_b2(
|
||||
const std::vector<std::string>& components,
|
||||
const std::string& link, const std::string& runtime_link, arch a);
|
||||
|
||||
static std::smatch parse_boost_version();
|
||||
static std::string source_download_filename();
|
||||
static fs::path config_jam_file();
|
||||
static url prebuilt_url();
|
||||
static url source_url();
|
||||
static fs::path lib_path();
|
||||
static fs::path lib_path(arch a);
|
||||
static std::string python_dll();
|
||||
static std::string python_version_for_dll();
|
||||
static std::string python_version_for_jam();
|
||||
@@ -40,6 +44,7 @@ private:
|
||||
static std::string boost_version_no_tags();
|
||||
static std::string boost_version_no_tags_underscores();
|
||||
static std::string boost_version_all_underscores();
|
||||
static std::string address_model_for_arch(arch a);
|
||||
};
|
||||
|
||||
|
||||
@@ -243,6 +248,29 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class spdlog : public basic_task<spdlog>
|
||||
{
|
||||
public:
|
||||
spdlog();
|
||||
static fs::path source_path();
|
||||
|
||||
protected:
|
||||
void do_fetch() override;
|
||||
};
|
||||
|
||||
|
||||
class usvfs : public basic_task<usvfs>
|
||||
{
|
||||
public:
|
||||
usvfs();
|
||||
static fs::path source_path();
|
||||
|
||||
protected:
|
||||
void do_fetch() override;
|
||||
void do_build_and_install() override;
|
||||
};
|
||||
|
||||
|
||||
class zlib : public basic_task<zlib>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "pch.h"
|
||||
#include "tasks.h"
|
||||
|
||||
namespace builder
|
||||
{
|
||||
|
||||
usvfs::usvfs()
|
||||
: basic_task("usvfs")
|
||||
{
|
||||
}
|
||||
|
||||
fs::path usvfs::source_path()
|
||||
{
|
||||
return paths::build() / "usvfs";
|
||||
}
|
||||
|
||||
void usvfs::do_fetch()
|
||||
{
|
||||
run_tool(git_clone()
|
||||
.org(conf::mo_org())
|
||||
.repo("usvfs")
|
||||
.branch(versions::usvfs())
|
||||
.output(source_path()));
|
||||
}
|
||||
|
||||
void usvfs::do_build_and_install()
|
||||
{
|
||||
// usvfs doesn't use "Win32" for 32-bit, it uses "x86"
|
||||
//
|
||||
// note that usvfs_proxy has a custom build step in Release that runs
|
||||
// usvfs/vsbuild/stage_helper.cmd, which copies everything into install/
|
||||
|
||||
run_tool(msbuild()
|
||||
.platform("x64")
|
||||
.solution(source_path() / "vsbuild" / "usvfs.sln"));
|
||||
|
||||
run_tool(msbuild()
|
||||
.platform("x86")
|
||||
.solution(source_path() / "vsbuild" / "usvfs.sln"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
+1
-1
@@ -26,7 +26,7 @@ void zlib::do_fetch()
|
||||
void zlib::do_build_and_install()
|
||||
{
|
||||
const auto build_path = run_tool(cmake()
|
||||
.generator(cmake::nmake)
|
||||
.generator(cmake::jom)
|
||||
.root(source_path())
|
||||
.prefix(source_path()));
|
||||
|
||||
|
||||
+150
-98
@@ -7,68 +7,6 @@
|
||||
namespace builder
|
||||
{
|
||||
|
||||
fs::path find_vcvars()
|
||||
{
|
||||
const std::vector<std::string> editions =
|
||||
{
|
||||
"Preview", "Enterprise", "Professional", "Community"
|
||||
};
|
||||
|
||||
for (auto&& edition : editions)
|
||||
{
|
||||
const auto p =
|
||||
paths::program_files_x86() /
|
||||
"Microsoft Visual Studio" /
|
||||
versions::vs_year() /
|
||||
edition / "VC" / "Auxiliary" / "Build" / "vcvarsall.bat";
|
||||
|
||||
if (fs::exists(p))
|
||||
{
|
||||
debug("found " + p.string());
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
bail_out("couldn't find visual studio");
|
||||
}
|
||||
|
||||
void vcvars()
|
||||
{
|
||||
debug("vcvars");
|
||||
|
||||
const fs::path tmp = paths::temp_file();
|
||||
|
||||
const std::string cmd =
|
||||
"\"" + find_vcvars().string() + "\" amd64 && "
|
||||
"set > \"" + tmp.string() + "\"";
|
||||
|
||||
op::run(cmd);
|
||||
|
||||
std::stringstream ss(read_text_file(tmp));
|
||||
op::delete_file(tmp);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
std::string line;
|
||||
std::getline(ss, line);
|
||||
if (!ss)
|
||||
break;
|
||||
|
||||
const auto sep = line.find('=');
|
||||
|
||||
if (sep == std::string::npos)
|
||||
continue;
|
||||
|
||||
const std::string name = line.substr(0, sep);
|
||||
const std::string value = line.substr(sep + 1);
|
||||
|
||||
//debug("setting env " + name);
|
||||
SetEnvironmentVariableA(name.c_str(), nullptr);
|
||||
SetEnvironmentVariableA(name.c_str(), value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tool::tool(std::string name)
|
||||
: name_(std::move(name)), interrupted_(false)
|
||||
{
|
||||
@@ -117,23 +55,23 @@ void basic_process_runner::do_interrupt()
|
||||
process_.interrupt();
|
||||
}
|
||||
|
||||
int basic_process_runner::execute_and_join(process p, bool check_exit_code)
|
||||
int basic_process_runner::execute_and_join(process p, bool check)
|
||||
{
|
||||
process_ = std::move(p);
|
||||
join(check_exit_code);
|
||||
join(check);
|
||||
return process_.exit_code();
|
||||
}
|
||||
|
||||
int basic_process_runner::execute_and_join(const cmd& c, bool check_exit_code)
|
||||
int basic_process_runner::execute_and_join(arch a, const cmd& c, bool check)
|
||||
{
|
||||
return execute_and_join(op::run(c.string(), c.cwd()), check_exit_code);
|
||||
return execute_and_join(op::run(a, c.string(), c.cwd()), check);
|
||||
}
|
||||
|
||||
void basic_process_runner::join(bool check_exit_code)
|
||||
void basic_process_runner::join(bool check)
|
||||
{
|
||||
process_.join();
|
||||
|
||||
if (check_exit_code && !interrupted())
|
||||
if (check && !interrupted())
|
||||
{
|
||||
if (process_.exit_code() != 0)
|
||||
{
|
||||
@@ -285,7 +223,7 @@ void git_clone::do_run()
|
||||
|
||||
void git_clone::clone()
|
||||
{
|
||||
execute_and_join(cmd(third_party::git(), cmd::stdout_is_verbose)
|
||||
execute_and_join(arch::dont_care, cmd(third_party::git(), cmd::stdout_is_verbose)
|
||||
.arg("clone")
|
||||
.arg("--recurse-submodules")
|
||||
.arg("--depth", "1")
|
||||
@@ -298,7 +236,7 @@ void git_clone::clone()
|
||||
|
||||
void git_clone::pull()
|
||||
{
|
||||
execute_and_join(cmd(third_party::git(), cmd::stdout_is_verbose)
|
||||
execute_and_join(arch::dont_care, cmd(third_party::git(), cmd::stdout_is_verbose)
|
||||
.arg("pull")
|
||||
.arg("--recurse-submodules")
|
||||
.arg("--quiet", cmd::quiet)
|
||||
@@ -396,7 +334,7 @@ void decompresser::do_run()
|
||||
.string();
|
||||
}
|
||||
|
||||
execute_and_join(op::run(c));
|
||||
execute_and_join(op::run(arch::dont_care, c));
|
||||
check_duplicate_directory();
|
||||
|
||||
delete_output.cancel();
|
||||
@@ -518,7 +456,7 @@ void patcher::do_run()
|
||||
|
||||
{
|
||||
// check
|
||||
if (execute_and_join(check, false) == 0)
|
||||
if (execute_and_join(arch::dont_care, check, false) == 0)
|
||||
{
|
||||
debug("patch " + p.string() + " already applied");
|
||||
continue;
|
||||
@@ -528,7 +466,7 @@ void patcher::do_run()
|
||||
{
|
||||
// apply
|
||||
debug("applying patch " + p.string());
|
||||
execute_and_join(apply);
|
||||
execute_and_join(arch::dont_care, apply);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -536,7 +474,8 @@ void patcher::do_run()
|
||||
|
||||
cmake::cmake() :
|
||||
basic_process_runner("cmake"),
|
||||
gen_(nmake), cmd_(third_party::cmake(), cmd::stdout_is_verbose)
|
||||
gen_(jom), arch_(arch::def),
|
||||
cmd_(third_party::cmake(), cmd::stdout_is_verbose)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -564,6 +503,12 @@ cmake& cmake::def(const std::string& s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
cmake& cmake::architecture(arch a)
|
||||
{
|
||||
arch_ = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
fs::path cmake::result() const
|
||||
{
|
||||
return output_;
|
||||
@@ -571,30 +516,24 @@ fs::path cmake::result() const
|
||||
|
||||
void cmake::do_run()
|
||||
{
|
||||
std::string g;
|
||||
|
||||
switch (gen_)
|
||||
if (conf::clean())
|
||||
{
|
||||
case nmake:
|
||||
for (auto&& [k, g] : all_generators())
|
||||
{
|
||||
output_ = root_ / "build";
|
||||
g = "NMake Makefiles";
|
||||
break;
|
||||
}
|
||||
|
||||
case vs:
|
||||
{
|
||||
output_ = root_ / "vsbuild";
|
||||
g = "Visual Studio " + versions::vs() + " " + versions::vs_year();
|
||||
break;
|
||||
op::delete_directory(root_ / g.output_dir(arch::x86));
|
||||
op::delete_directory(root_ / g.output_dir(arch::x64));
|
||||
}
|
||||
}
|
||||
|
||||
const auto& g = get_generator();
|
||||
output_ = root_ / (g.output_dir(arch_));
|
||||
|
||||
cmd_
|
||||
.arg("-G", "\"" + g + "\"")
|
||||
.arg("-G", "\"" + g.name + "\"")
|
||||
.arg("-DCMAKE_BUILD_TYPE=Release")
|
||||
.arg("-DCMAKE_INSTALL_MESSAGE=NEVER", cmd::quiet)
|
||||
.arg("--log-level", "WARNING", cmd::quiet);
|
||||
.arg("--log-level", "WARNING", cmd::quiet)
|
||||
.arg(g.get_arch(arch_));
|
||||
|
||||
if (!prefix_.empty())
|
||||
cmd_.arg("-DCMAKE_INSTALL_PREFIX=", prefix_, cmd::nospace);
|
||||
@@ -602,14 +541,88 @@ void cmake::do_run()
|
||||
cmd_.arg("..");
|
||||
cmd_.cwd(output_);
|
||||
|
||||
execute_and_join(cmd_);
|
||||
execute_and_join(arch_, cmd_);
|
||||
}
|
||||
|
||||
const std::map<cmake::generators, cmake::gen_info>&
|
||||
cmake::all_generators() const
|
||||
{
|
||||
static const std::map<generators, gen_info> map =
|
||||
{
|
||||
{ generators::jom, {"build", "NMake Makefiles JOM", "", "" }},
|
||||
|
||||
{ generators::vs, {
|
||||
"vsbuild",
|
||||
"Visual Studio " + versions::vs() + " " + versions::vs_year(),
|
||||
"Win32",
|
||||
"x64"
|
||||
}}
|
||||
};
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
const cmake::gen_info& cmake::get_generator() const
|
||||
{
|
||||
const auto& map = all_generators();
|
||||
|
||||
auto itor = map.find(gen_);
|
||||
if (itor == map.end())
|
||||
bail_out("unknown generator");
|
||||
|
||||
return itor->second;
|
||||
}
|
||||
|
||||
std::string cmake::gen_info::get_arch(arch a) const
|
||||
{
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
{
|
||||
if (x86.empty())
|
||||
return {};
|
||||
else
|
||||
return "-A " + x86;
|
||||
}
|
||||
|
||||
case arch::x64:
|
||||
{
|
||||
if (x64.empty())
|
||||
return {};
|
||||
else
|
||||
return "-A" + x64;
|
||||
}
|
||||
|
||||
case arch::dont_care:
|
||||
return {};
|
||||
|
||||
default:
|
||||
bail_out("gen_info::get_arch(): bad arch");
|
||||
}
|
||||
}
|
||||
|
||||
std::string cmake::gen_info::output_dir(arch a) const
|
||||
{
|
||||
switch (a)
|
||||
{
|
||||
case arch::x86:
|
||||
return (dir + "_32");
|
||||
|
||||
case arch::x64:
|
||||
case arch::dont_care:
|
||||
return dir;
|
||||
|
||||
default:
|
||||
bail_out("gen_info::get_arch(): bad arch");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
jom::jom() :
|
||||
basic_process_runner("jom"),
|
||||
cmd_(third_party::jom(), cmd::stdout_is_verbose), flags_(noflags)
|
||||
cmd_(third_party::jom(), cmd::stdout_is_verbose), flags_(noflags),
|
||||
arch_(arch::def)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -637,6 +650,12 @@ jom& jom::flag(flags f)
|
||||
return *this;
|
||||
}
|
||||
|
||||
jom& jom::architecture(arch a)
|
||||
{
|
||||
arch_ = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int jom::result() const
|
||||
{
|
||||
return exit_code();
|
||||
@@ -655,12 +674,12 @@ void jom::do_run()
|
||||
cmd_.arg(target_);
|
||||
|
||||
const bool check_exit_code = !(flags_ & accept_failure);
|
||||
execute_and_join(cmd_, check_exit_code);
|
||||
execute_and_join(arch_, cmd_, check_exit_code);
|
||||
}
|
||||
|
||||
|
||||
msbuild::msbuild()
|
||||
: basic_process_runner("msbuild"), config_("Release"), platform_("x64")
|
||||
: basic_process_runner("msbuild"), config_("Release"), arch_(arch::def)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -694,20 +713,51 @@ msbuild& msbuild::platform(const std::string& s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
msbuild& msbuild::architecture(arch a)
|
||||
{
|
||||
arch_ = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void msbuild::do_run()
|
||||
{
|
||||
// 14.2 to v142
|
||||
const auto toolset = "v" + replace_all(versions::vs_toolset(), ".", "");
|
||||
|
||||
std::string plat;
|
||||
|
||||
if (platform_.empty())
|
||||
{
|
||||
switch (arch_)
|
||||
{
|
||||
case arch::x86:
|
||||
plat = "Win32";
|
||||
break;
|
||||
|
||||
case arch::x64:
|
||||
plat = "x64";
|
||||
break;
|
||||
|
||||
case arch::dont_care:
|
||||
default:
|
||||
bail_out("msbuild::do_run(): bad arch");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plat = platform_;
|
||||
}
|
||||
|
||||
|
||||
auto c = cmd(third_party::msbuild(), cmd::noflags)
|
||||
.arg("-nologo")
|
||||
.arg("-maxCpuCount")
|
||||
.arg("-property:UseMultiToolTask=true")
|
||||
.arg("-property:EnforceProcessCountAcrossBuilds=true")
|
||||
.arg("-property:Configuration=", config_, cmd::quote)
|
||||
.arg("-property:Platform=", platform_, cmd::quote)
|
||||
.arg("-property:PlatformToolset=" + toolset)
|
||||
.arg("-property:WindowsTargetPlatformVersion=" + versions::sdk())
|
||||
.arg("-property:Platform=", plat, cmd::quote)
|
||||
.arg("-verbosity:minimal", cmd::quiet)
|
||||
.arg("-consoleLoggerParameters:ErrorsOnly", cmd::quiet);
|
||||
|
||||
@@ -721,7 +771,7 @@ void msbuild::do_run()
|
||||
.arg(sln_)
|
||||
.cwd(sln_.parent_path());
|
||||
|
||||
execute_and_join(c);
|
||||
execute_and_join(arch_, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -738,7 +788,9 @@ void devenv_upgrade::do_run()
|
||||
return;
|
||||
}
|
||||
|
||||
execute_and_join(cmd(third_party::devenv(), cmd::stdout_is_verbose)
|
||||
// don't care about arch, but it can't be dont_care because it doesn't
|
||||
// use vcvars at all
|
||||
execute_and_join(arch::def, cmd(third_party::devenv(), cmd::stdout_is_verbose)
|
||||
.arg("/upgrade")
|
||||
.arg(sln_));
|
||||
}
|
||||
@@ -751,7 +803,7 @@ nuget::nuget(fs::path sln)
|
||||
|
||||
void nuget::do_run()
|
||||
{
|
||||
execute_and_join(cmd(third_party::nuget(), cmd::noflags)
|
||||
execute_and_join(arch::dont_care, cmd(third_party::nuget(), cmd::noflags)
|
||||
.arg("restore")
|
||||
.arg(sln_)
|
||||
.cwd(sln_.parent_path()));
|
||||
|
||||
+27
-8
@@ -6,9 +6,6 @@
|
||||
namespace builder
|
||||
{
|
||||
|
||||
void vcvars();
|
||||
|
||||
|
||||
class tool
|
||||
{
|
||||
public:
|
||||
@@ -71,7 +68,7 @@ protected:
|
||||
void do_interrupt() override;
|
||||
|
||||
int execute_and_join(process p, bool check_exit_code=true);
|
||||
int execute_and_join(const cmd& c, bool check_exit_code=true);
|
||||
int execute_and_join(arch a, const cmd& c, bool check_exit_code=true);
|
||||
|
||||
private:
|
||||
std::string cmd_;
|
||||
@@ -83,8 +80,9 @@ private:
|
||||
class process_runner : public basic_process_runner
|
||||
{
|
||||
public:
|
||||
process_runner(fs::path exe, cmd::flags flags)
|
||||
: basic_process_runner(exe.filename().string()), cmd_(exe, flags)
|
||||
process_runner(arch a, fs::path exe, cmd::flags flags) :
|
||||
basic_process_runner(exe.filename().string()),
|
||||
arch_(a), cmd_(exe, flags)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -125,10 +123,11 @@ public:
|
||||
protected:
|
||||
void do_run() override
|
||||
{
|
||||
execute_and_join(cmd_);
|
||||
execute_and_join(arch_, cmd_);
|
||||
}
|
||||
|
||||
private:
|
||||
arch arch_;
|
||||
cmd cmd_;
|
||||
};
|
||||
|
||||
@@ -200,7 +199,7 @@ public:
|
||||
enum generators
|
||||
{
|
||||
vs = 0x01,
|
||||
nmake = 0x02
|
||||
jom = 0x02
|
||||
};
|
||||
|
||||
cmake();
|
||||
@@ -209,6 +208,7 @@ public:
|
||||
cmake& root(const fs::path& p);
|
||||
cmake& prefix(const fs::path& s);
|
||||
cmake& def(const std::string& s);
|
||||
cmake& architecture(arch a);
|
||||
|
||||
fs::path result() const;
|
||||
|
||||
@@ -216,11 +216,26 @@ protected:
|
||||
void do_run() override;
|
||||
|
||||
private:
|
||||
struct gen_info
|
||||
{
|
||||
std::string dir;
|
||||
std::string name;
|
||||
std::string x86;
|
||||
std::string x64;
|
||||
|
||||
std::string get_arch(arch a) const;
|
||||
std::string output_dir(arch a) const;
|
||||
};
|
||||
|
||||
fs::path root_;
|
||||
generators gen_;
|
||||
fs::path prefix_;
|
||||
fs::path output_;
|
||||
arch arch_;
|
||||
cmd cmd_;
|
||||
|
||||
const std::map<generators, gen_info>& all_generators() const;
|
||||
const gen_info& get_generator() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -240,6 +255,7 @@ public:
|
||||
jom& target(const std::string& s);
|
||||
jom& def(const std::string& s);
|
||||
jom& flag(flags f);
|
||||
jom& architecture(arch a);
|
||||
|
||||
int result() const;
|
||||
|
||||
@@ -250,6 +266,7 @@ private:
|
||||
cmd cmd_;
|
||||
std::string target_;
|
||||
flags flags_;
|
||||
arch arch_;
|
||||
};
|
||||
|
||||
|
||||
@@ -263,6 +280,7 @@ public:
|
||||
msbuild& parameters(const std::vector<std::string>& params);
|
||||
msbuild& config(const std::string& s);
|
||||
msbuild& platform(const std::string& s);
|
||||
msbuild& architecture(arch a);
|
||||
|
||||
protected:
|
||||
void do_run() override;
|
||||
@@ -273,6 +291,7 @@ private:
|
||||
std::vector<std::string> params_;
|
||||
std::string config_;
|
||||
std::string platform_;
|
||||
arch arch_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -141,6 +141,16 @@ std::string replace_all(
|
||||
std::string join(const std::vector<std::string>& v, const std::string& sep);
|
||||
|
||||
|
||||
enum class arch
|
||||
{
|
||||
x86 = 1,
|
||||
x64,
|
||||
dont_care,
|
||||
|
||||
def = x64
|
||||
};
|
||||
|
||||
|
||||
class cmd
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -98,7 +98,9 @@
|
||||
<ClCompile Include="..\src\tasks\openssl.cpp" />
|
||||
<ClCompile Include="..\src\tasks\python.cpp" />
|
||||
<ClCompile Include="..\src\tasks\sevenz.cpp" />
|
||||
<ClCompile Include="..\src\tasks\spdlog.cpp" />
|
||||
<ClCompile Include="..\src\tasks\task.cpp" />
|
||||
<ClCompile Include="..\src\tasks\usvfs.cpp" />
|
||||
<ClCompile Include="..\src\tasks\zlib.cpp" />
|
||||
<ClCompile Include="..\src\tools.cpp" />
|
||||
<ClCompile Include="..\src\utility.cpp" />
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user