mirror of
https://github.com/ModOrganizer2/mob.git
synced 2026-07-27 14:07:05 -07:00
prepend python to path when building usvfs, udis requires it
install certifi, prebuilt python fails with ssl errors when downloading
This commit is contained in:
+63
-10
@@ -4,6 +4,7 @@
|
||||
#include "process.h"
|
||||
#include "op.h"
|
||||
#include "context.h"
|
||||
#include "utility.h"
|
||||
#include "tools/tools.h"
|
||||
|
||||
namespace mob
|
||||
@@ -135,27 +136,79 @@ env& env::operator=(env&& e)
|
||||
|
||||
env& env::append_path(const fs::path& p)
|
||||
{
|
||||
return append_path(std::vector<fs::path>{p});
|
||||
append_path(std::vector<fs::path>{p});
|
||||
return *this;
|
||||
}
|
||||
|
||||
env& env::prepend_path(const fs::path& p)
|
||||
{
|
||||
prepend_path(std::vector<fs::path>{p});
|
||||
return *this;
|
||||
}
|
||||
|
||||
env& env::prepend_path(const std::vector<fs::path>& v)
|
||||
{
|
||||
change_path(v, prepend);
|
||||
return *this;
|
||||
}
|
||||
|
||||
env& env::append_path(const std::vector<fs::path>& v)
|
||||
{
|
||||
change_path(v, append);
|
||||
return *this;
|
||||
}
|
||||
|
||||
env& env::change_path(const std::vector<fs::path>& v, flags f)
|
||||
{
|
||||
copy_for_write();
|
||||
|
||||
std::wstring path;
|
||||
|
||||
switch (f)
|
||||
{
|
||||
auto current = find(L"PATH");
|
||||
if (current)
|
||||
path = *current;
|
||||
}
|
||||
case replace:
|
||||
{
|
||||
const auto strings =
|
||||
mob::map(v, [&](auto&& p){ return p.native(); });
|
||||
|
||||
for (auto&& p : v)
|
||||
{
|
||||
if (!path.empty())
|
||||
path += L";";
|
||||
path = join(strings, L";");
|
||||
|
||||
path += p.native();
|
||||
break;
|
||||
}
|
||||
|
||||
case append:
|
||||
{
|
||||
auto current = find(L"PATH");
|
||||
if (current)
|
||||
path = *current;
|
||||
|
||||
for (auto&& p : v)
|
||||
{
|
||||
if (!path.empty())
|
||||
path += L";";
|
||||
|
||||
path += p.native();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case prepend:
|
||||
{
|
||||
auto current = find(L"PATH");
|
||||
if (current)
|
||||
path = *current;
|
||||
|
||||
for (auto&& p : v)
|
||||
{
|
||||
if (!path.empty())
|
||||
path = L";" + path;
|
||||
|
||||
path = p.native() + path;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
set(L"PATH", path, replace);
|
||||
|
||||
@@ -25,8 +25,11 @@ public:
|
||||
env& operator=(const env& e);
|
||||
env& operator=(env&& e);
|
||||
|
||||
env& prepend_path(const fs::path& p);
|
||||
env& prepend_path(const std::vector<fs::path>& v);
|
||||
env& append_path(const fs::path& p);
|
||||
env& append_path(const std::vector<fs::path>& v);
|
||||
|
||||
env& set(std::string_view k, std::string_view v, flags f=replace);
|
||||
env& set(std::wstring k, std::wstring v, flags f=replace);
|
||||
|
||||
@@ -54,6 +57,7 @@ private:
|
||||
const std::wstring* find(std::wstring_view name) const;
|
||||
void set_impl(std::wstring k, std::wstring v, flags f);
|
||||
void copy_for_write();
|
||||
env& change_path(const std::vector<fs::path>& v, flags f);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -244,6 +244,13 @@ void python::install_pip()
|
||||
.arg("-m pip")
|
||||
.arg("install")
|
||||
.arg("--upgrade pip")));
|
||||
|
||||
// ssl errors while downloading through python without certifi
|
||||
run_tool(process_runner(process()
|
||||
.binary(python_exe())
|
||||
.arg("pip")
|
||||
.arg("install")
|
||||
.arg("certifi")));
|
||||
}
|
||||
|
||||
msbuild python::create_msbuild_tool(msbuild::ops o)
|
||||
|
||||
+3
-1
@@ -172,10 +172,12 @@ msbuild usvfs::create_msbuild_tool(arch a, msbuild::ops o) const
|
||||
|
||||
const std::string plat = (a == arch::x64 ? "x64" : "x86");
|
||||
|
||||
// udis requires python in its custom build step
|
||||
return std::move(msbuild(o)
|
||||
.platform(plat)
|
||||
.targets({"usvfs_proxy"})
|
||||
.solution(source_path() / "vsbuild" / "usvfs.sln"));
|
||||
.solution(source_path() / "vsbuild" / "usvfs.sln")
|
||||
.prepend_path(python::build_path()));
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<downloader>>
|
||||
|
||||
+12
-1
@@ -58,6 +58,12 @@ msbuild& msbuild::flags(flags_t f)
|
||||
return *this;
|
||||
}
|
||||
|
||||
msbuild& msbuild::prepend_path(const fs::path& p)
|
||||
{
|
||||
prepend_path_.push_back(p);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int msbuild::result() const
|
||||
{
|
||||
return exit_code();
|
||||
@@ -161,11 +167,16 @@ void msbuild::do_run(const std::vector<std::string>& targets)
|
||||
for (auto&& p : params_)
|
||||
process_.arg("-property:" + p);
|
||||
|
||||
env e = env::vs(arch_);
|
||||
|
||||
for (auto&& p : prepend_path_)
|
||||
e.prepend_path(p);
|
||||
|
||||
process_
|
||||
.arg(sln_)
|
||||
.flags(pflags)
|
||||
.cwd(sln_.parent_path())
|
||||
.env(env::vs(arch_));
|
||||
.env(e);
|
||||
|
||||
execute_and_join();
|
||||
}
|
||||
|
||||
@@ -464,6 +464,7 @@ public:
|
||||
msbuild& platform(const std::string& s);
|
||||
msbuild& architecture(arch a);
|
||||
msbuild& flags(flags_t f);
|
||||
msbuild& prepend_path(const fs::path& p);
|
||||
|
||||
int result() const;
|
||||
|
||||
@@ -479,6 +480,7 @@ private:
|
||||
std::string platform_;
|
||||
arch arch_;
|
||||
flags_t flags_;
|
||||
std::vector<fs::path> prepend_path_;
|
||||
|
||||
void do_clean();
|
||||
void do_build();
|
||||
|
||||
@@ -352,21 +352,6 @@ std::string replace_all(
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string join(const std::vector<std::string>& v, const std::string& sep)
|
||||
{
|
||||
std::string s;
|
||||
|
||||
for (auto&& e : v)
|
||||
{
|
||||
if (!s.empty())
|
||||
s += sep;
|
||||
|
||||
s += e;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::vector<std::string> split(const std::string& s, const std::string& seps)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
+19
-2
@@ -315,7 +315,24 @@ bool glob_match(const std::string& pattern, const std::string& s);
|
||||
std::string replace_all(
|
||||
std::string s, const std::string& from, const std::string& to);
|
||||
|
||||
std::string join(const std::vector<std::string>& v, const std::string& sep);
|
||||
template <class T, class Sep>
|
||||
T join(const std::vector<T>& v, const Sep& sep)
|
||||
{
|
||||
T s;
|
||||
bool first = true;
|
||||
|
||||
for (auto&& e : v)
|
||||
{
|
||||
if (first)
|
||||
s += sep;
|
||||
|
||||
s += e;
|
||||
first = false;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::vector<std::string> split(const std::string& s, const std::string& sep);
|
||||
|
||||
std::string pad_right(std::string s, std::size_t n, char c=' ');
|
||||
@@ -528,7 +545,7 @@ template <
|
||||
class Container=std::vector<std::pair<
|
||||
typename Range1::value_type,
|
||||
typename Range2::value_type>>>
|
||||
Container zip(const Range1& range1, const Range2& range2)
|
||||
Container zip(const Range1& range1, const Range2& range2)
|
||||
{
|
||||
Container out;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user