aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-04-03 10:44:14 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-04-03 10:44:29 -0700
commitcb5cbc4d84d84e8199d58740e0e7ed3c6d3ba473 (patch)
tree091af6fccadb4597d55cf53c161c1a3635fe33c7
parentf9c01a893e79d5ae086294d0f11543cd37283438 (diff)
downloadvcpkg-cb5cbc4d84d84e8199d58740e0e7ed3c6d3ba473.tar.gz
vcpkg-cb5cbc4d84d84e8199d58740e0e7ed3c6d3ba473.zip
[vcpkg-env] Added internal 'env' command to help diagnose environment issues.
-rw-r--r--toolsrc/include/vcpkg_Commands.h7
-rw-r--r--toolsrc/src/commands_available_commands.cpp1
-rw-r--r--toolsrc/src/commands_build.cpp9
-rw-r--r--toolsrc/src/commands_env.cpp17
-rw-r--r--toolsrc/vcpkglib/vcpkglib.vcxproj1
-rw-r--r--toolsrc/vcpkglib/vcpkglib.vcxproj.filters3
6 files changed, 37 insertions, 1 deletions
diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h
index d73181bf4..23575ca23 100644
--- a/toolsrc/include/vcpkg_Commands.h
+++ b/toolsrc/include/vcpkg_Commands.h
@@ -29,6 +29,8 @@ namespace vcpkg::Commands
std::string create_error_message(const BuildResult build_result, const package_spec& spec);
std::string create_user_troubleshooting_message(const package_spec& spec);
+ std::wstring make_build_env_cmd(const triplet& target_triplet, const toolset_t& toolset);
+
BuildResult build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir, const StatusParagraphs& status_db);
void perform_and_exit(const package_spec& spec, const fs::path& port_dir, const std::unordered_set<std::string>& options, const vcpkg_paths& paths);
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
@@ -69,6 +71,11 @@ namespace vcpkg::Commands
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
}
+ namespace Env
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_triplet);
+ }
+
namespace Create
{
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
diff --git a/toolsrc/src/commands_available_commands.cpp b/toolsrc/src/commands_available_commands.cpp
index 4c7e0df2c..70e528704 100644
--- a/toolsrc/src/commands_available_commands.cpp
+++ b/toolsrc/src/commands_available_commands.cpp
@@ -10,6 +10,7 @@ namespace vcpkg::Commands
{ "ci", &CI::perform_and_exit },
{"remove", &Remove::perform_and_exit},
{"build", &Build::perform_and_exit},
+ {"env", &Env::perform_and_exit},
{"build_external", &BuildExternal::perform_and_exit}
};
return t;
diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp
index 8791ef1c1..3c3fbeb66 100644
--- a/toolsrc/src/commands_build.cpp
+++ b/toolsrc/src/commands_build.cpp
@@ -25,6 +25,13 @@ namespace vcpkg::Commands::Build
std::ofstream(binary_control_file) << bpgh;
}
+ std::wstring make_build_env_cmd(const triplet& target_triplet, const toolset_t& toolset)
+ {
+ return Strings::wformat(LR"("%s" %s >nul 2>&1)",
+ toolset.vcvarsall.native(),
+ Strings::utf8_to_utf16(target_triplet.architecture()));
+ }
+
BuildResult build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir, const StatusParagraphs& status_db)
{
Checks::check_exit(VCPKG_LINE_INFO, spec.name() == source_paragraph.name, "inconsistent arguments to build_package()");
@@ -43,7 +50,7 @@ namespace vcpkg::Commands::Build
const fs::path ports_cmake_script_path = paths.ports_cmake;
const toolset_t& toolset = paths.get_toolset();
- const std::wstring cmd_set_environment = Strings::wformat(LR"("%s" %s >nul 2>&1)", toolset.vcvarsall.native(), Strings::utf8_to_utf16(target_triplet.architecture()));
+ const auto cmd_set_environment = make_build_env_cmd(target_triplet, toolset);
const std::wstring cmd_launch_cmake = make_cmake_cmd(cmake_exe_path, ports_cmake_script_path,
{
diff --git a/toolsrc/src/commands_env.cpp b/toolsrc/src/commands_env.cpp
new file mode 100644
index 000000000..314afb779
--- /dev/null
+++ b/toolsrc/src/commands_env.cpp
@@ -0,0 +1,17 @@
+#include "pch.h"
+#include "vcpkg_Commands.h"
+#include "vcpkg_System.h"
+
+namespace vcpkg::Commands::Env
+{
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_triplet)
+ {
+ static const std::string example = Commands::Help::create_example_string(R"(env --triplet x64-windows)");
+ args.check_exact_arg_count(0, example);
+ args.check_and_get_optional_command_arguments({});
+
+ System::cmd_execute_clean(Build::make_build_env_cmd(default_triplet, paths.get_toolset()) + L" && cmd");
+
+ Checks::exit_success(VCPKG_LINE_INFO);
+ }
+}
diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj
index d79c77a94..9234f9c77 100644
--- a/toolsrc/vcpkglib/vcpkglib.vcxproj
+++ b/toolsrc/vcpkglib/vcpkglib.vcxproj
@@ -185,6 +185,7 @@
<ClCompile Include="..\include\version_t.cpp" />
<ClCompile Include="..\src\BinaryParagraph.cpp" />
<ClCompile Include="..\src\commands_ci.cpp" />
+ <ClCompile Include="..\src\commands_env.cpp" />
<ClCompile Include="..\src\LineInfo.cpp" />
<ClCompile Include="..\src\paragraph_parse_result.cpp" />
<ClCompile Include="..\src\PostBuildLint_BuildInfo.cpp" />
diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
index acfecbcc5..9901bcd95 100644
--- a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
+++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
@@ -177,6 +177,9 @@
<ClCompile Include="..\include\version_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\src\commands_env.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\package_spec.h">