From 7c6de87310b79acdee318eb52ebc3f1da112a92d Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sat, 30 Jan 2021 09:14:23 -0500 Subject: [PATCH] add BOOST_PATH to the environment for usvfs --- src/core/env.cpp | 4 ++-- src/tasks/usvfs.cpp | 8 +++++++- src/tools/msbuild.cpp | 11 ++++------- src/tools/msbuild.h | 9 ++++++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/core/env.cpp b/src/core/env.cpp index eab1a01..51cc203 100644 --- a/src/core/env.cpp +++ b/src/core/env.cpp @@ -436,7 +436,7 @@ env this_env::get() // keep track of the current directory, those start with an equal sign, // so just ignore them if (!key.empty()) - g_sys_env.set(utf16_to_utf8(key), utf16_to_utf8(value)); + g_sys_env.set(key, value); // next string is one past end of value to account for null byte name = value_start + value.length() + 1; @@ -481,7 +481,7 @@ void this_env::set(const std::string& k, const std::string& v, env::flags f) { std::scoped_lock lock(g_sys_env_mutex); if (g_sys_env_inited) - g_sys_env.set(k, utf16_to_utf8(wv)); + g_sys_env.set(utf8_to_utf16(k), wv); } } diff --git a/src/tasks/usvfs.cpp b/src/tasks/usvfs.cpp index a38e66f..19f354e 100644 --- a/src/tasks/usvfs.cpp +++ b/src/tasks/usvfs.cpp @@ -173,11 +173,17 @@ msbuild usvfs::create_msbuild_tool(arch a, msbuild::ops o) const // udis requires python in its custom build step, so make sure it's on the // path + // + // BOOST_PATH is in the env because external_dependencies.props will + // use it if it exists or reverts to a hardcoded path which might not be using + // the same version as mob if it wasn't updated return std::move(msbuild(o) .platform(plat) .targets({"usvfs_proxy"}) .solution(source_path() / "vsbuild" / "usvfs.sln") - .prepend_path(python::build_path())); + .env(env::vs(a) + .prepend_path(python::build_path()) + .set("BOOST_PATH", path_to_utf8(boost::source_path())))); } std::vector> diff --git a/src/tools/msbuild.cpp b/src/tools/msbuild.cpp index 83ae9a3..80bf64e 100644 --- a/src/tools/msbuild.cpp +++ b/src/tools/msbuild.cpp @@ -2,6 +2,7 @@ #include "tools.h" #include "../core/conf.h" #include "../core/process.h" +#include "../core/env.h" namespace mob { @@ -59,9 +60,9 @@ msbuild& msbuild::flags(flags_t f) return *this; } -msbuild& msbuild::prepend_path(const fs::path& p) +msbuild& msbuild::env(const mob::env& e) { - prepend_path_.push_back(p); + env_ = e; return *this; } @@ -184,14 +185,10 @@ void msbuild::run_for_targets(const std::vector& targets) for (auto&& prop : props_) p.arg("-property:" + prop); - env e = env::vs(arch_); - for (auto&& path : prepend_path_) - e.prepend_path(path); - p .arg(sln_) .cwd(sln_.parent_path()) - .env(e); + .env(env_ ? *env_ : env::vs(arch_)); execute_and_join(p); } diff --git a/src/tools/msbuild.h b/src/tools/msbuild.h index 4067082..45379cd 100644 --- a/src/tools/msbuild.h +++ b/src/tools/msbuild.h @@ -1,5 +1,7 @@ #pragma once +#include "../core/env.h" + namespace mob { @@ -62,10 +64,10 @@ public: // flags msbuild& flags(flags_t f); - // can be called multiple times, the given paths will be prepended to PATH - // before invoking msbuild + // override the environment variables, which normally defaults to env::vs() + // for the arch given in architecture() // - msbuild& prepend_path(const fs::path& p); + msbuild& env(const mob::env& e); // exit code // @@ -83,6 +85,7 @@ private: std::string platform_; arch arch_; flags_t flags_; + std::optional env_; std::vector prepend_path_; // runs msbuild with ":Clean" for each target given in targets(), giving