aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/cache.h4
-rw-r--r--toolsrc/include/vcpkg/base/system.process.h42
-rw-r--r--toolsrc/include/vcpkg/build.h4
-rw-r--r--toolsrc/include/vcpkg/buildenvironment.h6
4 files changed, 32 insertions, 24 deletions
diff --git a/toolsrc/include/vcpkg/base/cache.h b/toolsrc/include/vcpkg/base/cache.h
index 1996f2587..7efae1361 100644
--- a/toolsrc/include/vcpkg/base/cache.h
+++ b/toolsrc/include/vcpkg/base/cache.h
@@ -4,7 +4,7 @@
namespace vcpkg
{
- template<class Key, class Value>
+ template<class Key, class Value, class Less = std::less<Key>>
struct Cache
{
template<class F>
@@ -16,6 +16,6 @@ namespace vcpkg
}
private:
- mutable std::map<Key, Value> m_cache;
+ mutable std::map<Key, Value, Less> m_cache;
};
}
diff --git a/toolsrc/include/vcpkg/base/system.process.h b/toolsrc/include/vcpkg/base/system.process.h
index 1c62fa285..68d4da4e4 100644
--- a/toolsrc/include/vcpkg/base/system.process.h
+++ b/toolsrc/include/vcpkg/base/system.process.h
@@ -20,10 +20,6 @@ namespace vcpkg::System
std::string s;
};
- std::string make_basic_cmake_cmd(const fs::path& cmake_tool_path,
- const fs::path& cmake_script,
- const std::vector<CMakeVariable>& pass_variables);
-
struct CmdLineBuilder
{
CmdLineBuilder() = default;
@@ -46,15 +42,27 @@ namespace vcpkg::System
CmdLineBuilder&& raw_arg(StringView s) && { return std::move(raw_arg(s)); }
std::string&& extract() && { return std::move(buf); }
- operator StringView() noexcept { return buf; }
StringView command_line() const { return buf; }
void clear() { buf.clear(); }
+ bool empty() const { return buf.empty(); }
private:
std::string buf;
};
+ struct CmdLineBuilderMapLess
+ {
+ bool operator()(const CmdLineBuilder& lhs, const CmdLineBuilder& rhs) const
+ {
+ return lhs.command_line() < rhs.command_line();
+ }
+ };
+
+ CmdLineBuilder make_basic_cmake_cmd(const fs::path& cmake_tool_path,
+ const fs::path& cmake_script,
+ const std::vector<CMakeVariable>& pass_variables);
+
fs::path get_exe_path_of_current_process();
struct ExitCodeAndOutput
@@ -79,48 +87,48 @@ namespace vcpkg::System
const fs::path& working_directory;
};
- int cmd_execute(StringView cmd_line, InWorkingDirectory wd, const Environment& env = {});
- inline int cmd_execute(StringView cmd_line, const Environment& env = {})
+ int cmd_execute(const CmdLineBuilder& cmd_line, InWorkingDirectory wd, const Environment& env = {});
+ inline int cmd_execute(const CmdLineBuilder& cmd_line, const Environment& env = {})
{
return cmd_execute(cmd_line, InWorkingDirectory{fs::path()}, env);
}
- int cmd_execute_clean(StringView cmd_line, InWorkingDirectory wd);
- inline int cmd_execute_clean(StringView cmd_line)
+ int cmd_execute_clean(const CmdLineBuilder& cmd_line, InWorkingDirectory wd);
+ inline int cmd_execute_clean(const CmdLineBuilder& cmd_line)
{
return cmd_execute_clean(cmd_line, InWorkingDirectory{fs::path()});
}
#if defined(_WIN32)
- Environment cmd_execute_modify_env(StringView cmd_line, const Environment& env = {});
+ Environment cmd_execute_modify_env(const CmdLineBuilder& cmd_line, const Environment& env = {});
- void cmd_execute_background(const StringView cmd_line);
+ void cmd_execute_background(const CmdLineBuilder& cmd_line);
#endif
- ExitCodeAndOutput cmd_execute_and_capture_output(StringView cmd_line,
+ ExitCodeAndOutput cmd_execute_and_capture_output(const CmdLineBuilder& cmd_line,
InWorkingDirectory wd,
const Environment& env = {});
- inline ExitCodeAndOutput cmd_execute_and_capture_output(StringView cmd_line, const Environment& env = {})
+ inline ExitCodeAndOutput cmd_execute_and_capture_output(const CmdLineBuilder& cmd_line, const Environment& env = {})
{
return cmd_execute_and_capture_output(cmd_line, InWorkingDirectory{fs::path()}, env);
}
- int cmd_execute_and_stream_lines(StringView cmd_line,
+ int cmd_execute_and_stream_lines(const CmdLineBuilder& cmd_line,
InWorkingDirectory wd,
std::function<void(StringView)> per_line_cb,
const Environment& env = {});
- inline int cmd_execute_and_stream_lines(StringView cmd_line,
+ inline int cmd_execute_and_stream_lines(const CmdLineBuilder& cmd_line,
std::function<void(StringView)> per_line_cb,
const Environment& env = {})
{
return cmd_execute_and_stream_lines(cmd_line, InWorkingDirectory{fs::path()}, std::move(per_line_cb), env);
}
- int cmd_execute_and_stream_data(StringView cmd_line,
+ int cmd_execute_and_stream_data(const CmdLineBuilder& cmd_line,
InWorkingDirectory wd,
std::function<void(StringView)> data_cb,
const Environment& env = {});
- inline int cmd_execute_and_stream_data(StringView cmd_line,
+ inline int cmd_execute_and_stream_data(const CmdLineBuilder& cmd_line,
std::function<void(StringView)> data_cb,
const Environment& env = {})
{
diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h
index bd5188b9f..0659eedcd 100644
--- a/toolsrc/include/vcpkg/build.h
+++ b/toolsrc/include/vcpkg/build.h
@@ -232,7 +232,7 @@ namespace vcpkg::Build
const VcpkgPaths& m_paths;
};
- std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
+ System::CmdLineBuilder make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
struct ExtendedBuildResult
{
@@ -369,7 +369,7 @@ namespace vcpkg::Build
struct EnvMapEntry
{
std::unordered_map<std::string, std::string> env_map;
- Cache<std::string, System::Environment> cmd_cache;
+ Cache<System::CmdLineBuilder, System::Environment, System::CmdLineBuilderMapLess> cmd_cache;
};
Cache<std::vector<std::string>, EnvMapEntry> envs;
diff --git a/toolsrc/include/vcpkg/buildenvironment.h b/toolsrc/include/vcpkg/buildenvironment.h
index aa69708b6..549772320 100644
--- a/toolsrc/include/vcpkg/buildenvironment.h
+++ b/toolsrc/include/vcpkg/buildenvironment.h
@@ -9,7 +9,7 @@
namespace vcpkg
{
- std::string make_cmake_cmd(const VcpkgPaths& paths,
- const fs::path& cmake_script,
- std::vector<System::CMakeVariable>&& pass_variables);
+ System::CmdLineBuilder make_cmake_cmd(const VcpkgPaths& paths,
+ const fs::path& cmake_script,
+ std::vector<System::CMakeVariable>&& pass_variables);
}