aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2016-09-30 14:59:58 -0700
committerRobert Schumacher <roschuma@microsoft.com>2016-09-30 14:59:58 -0700
commit17786b865a9f004df391be69e8ad687d095f739b (patch)
tree6c2047da6ac4a4a50775cc7ae7f92218cadd07d1 /toolsrc/src
parent4ab32c520daa821250c6b4669dda7ce91b71d5e7 (diff)
parent8ed88af8c9cf2ed2e6fd573b2cd5dc2b41b55625 (diff)
downloadvcpkg-17786b865a9f004df391be69e8ad687d095f739b.tar.gz
vcpkg-17786b865a9f004df391be69e8ad687d095f739b.zip
Merge branch 'master' of https://github.com/microsoft/vcpkg
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/commands_create.cpp14
-rw-r--r--toolsrc/src/commands_edit.cpp2
-rw-r--r--toolsrc/src/commands_installation.cpp24
-rw-r--r--toolsrc/src/commands_integration.cpp4
-rw-r--r--toolsrc/src/main.cpp6
-rw-r--r--toolsrc/src/metrics.cpp2
-rw-r--r--toolsrc/src/post_build_lint.cpp12
-rw-r--r--toolsrc/src/triplet.cpp37
-rw-r--r--toolsrc/src/vcpkg_Environment.cpp22
-rw-r--r--toolsrc/src/vcpkg_Strings.cpp2
-rw-r--r--toolsrc/src/vcpkg_System.cpp4
-rw-r--r--toolsrc/src/vcpkg_paths.cpp15
12 files changed, 66 insertions, 78 deletions
diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp
index 2712d3e6a..85b98d667 100644
--- a/toolsrc/src/commands_create.cpp
+++ b/toolsrc/src/commands_create.cpp
@@ -28,15 +28,15 @@ namespace vcpkg
Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name),
R"(Filename cannot contain invalid chars %s, but was %s)",
Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name);
- custom_filename = Strings::format(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name));
+ custom_filename = Strings::wformat(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(zip_file_name));
}
- const std::wstring cmdline = Strings::format(LR"(cmake -DCMD=CREATE -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")",
- Strings::utf8_to_utf16(spec->name),
- Strings::utf8_to_utf16(spec->target_triplet.value),
- Strings::utf8_to_utf16(args.command_arguments.at(1)),
- custom_filename,
- paths.ports_cmake.generic_wstring());
+ const std::wstring cmdline = Strings::wformat(LR"(cmake -DCMD=CREATE -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")",
+ Strings::utf8_to_utf16(spec->name),
+ Strings::utf8_to_utf16(spec->target_triplet.value),
+ Strings::utf8_to_utf16(args.command_arguments.at(1)),
+ custom_filename,
+ paths.ports_cmake.generic_wstring());
exit(System::cmd_execute(cmdline));
}
diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp
index 71ae8b2c8..fe02bfa26 100644
--- a/toolsrc/src/commands_edit.cpp
+++ b/toolsrc/src/commands_edit.cpp
@@ -15,7 +15,7 @@ namespace vcpkg
env_EDITOR = LR"(C:\Program Files (x86)\Microsoft VS Code\Code.exe)";
auto portpath = paths.ports / spec.name;
- std::wstring cmdLine = Strings::format(LR"("%s" "%s" "%s")", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native());
+ std::wstring cmdLine = Strings::wformat(LR"("%s" "%s" "%s")", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native());
exit(System::cmd_execute(cmdLine));
}
}
diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp
index e94791efa..2890184fb 100644
--- a/toolsrc/src/commands_installation.cpp
+++ b/toolsrc/src/commands_installation.cpp
@@ -22,12 +22,12 @@ namespace vcpkg
static void build_internal(const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir)
{
const fs::path ports_cmake_script_path = paths.ports_cmake;
- const std::wstring command = Strings::format(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
- Strings::utf8_to_utf16(spec.target_triplet.architecture()),
- Strings::utf8_to_utf16(spec.name),
- Strings::utf8_to_utf16(spec.target_triplet.value),
- port_dir.generic_wstring(),
- ports_cmake_script_path.generic_wstring());
+ const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
+ Strings::utf8_to_utf16(spec.target_triplet.architecture()),
+ Strings::utf8_to_utf16(spec.name),
+ Strings::utf8_to_utf16(spec.target_triplet.value),
+ port_dir.generic_wstring(),
+ ports_cmake_script_path.generic_wstring());
System::Stopwatch timer;
timer.start();
@@ -39,12 +39,12 @@ namespace vcpkg
{
System::println(System::color::error, "Error: building package %s failed", to_string(spec));
System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n"
- "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n"
- " Package: %s\n"
- " Vcpkg version: %s\n"
- "\n"
- "Additionally, attach any relevant sections from the log files above."
- , to_string(spec), version());
+ "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n"
+ " Package: %s\n"
+ " Vcpkg version: %s\n"
+ "\n"
+ "Additionally, attach any relevant sections from the log files above."
+ , to_string(spec), version());
TrackProperty("error", "build failed");
TrackProperty("build_error", to_string(spec));
exit(EXIT_FAILURE);
diff --git a/toolsrc/src/commands_integration.cpp b/toolsrc/src/commands_integration.cpp
index aa10e210b..743a57a70 100644
--- a/toolsrc/src/commands_integration.cpp
+++ b/toolsrc/src/commands_integration.cpp
@@ -238,7 +238,7 @@ namespace vcpkg
exit(EXIT_SUCCESS);
}
- const std::wstring cmd_line = Strings::format(LR"(DEL "%s")", get_appdata_targets_path().native());
+ const std::wstring cmd_line = Strings::wformat(LR"(DEL "%s")", get_appdata_targets_path().native());
const int exit_code = System::cmd_execute(cmd_line);
if (exit_code)
{
@@ -269,7 +269,7 @@ namespace vcpkg
std::ofstream(nuspec_file_path) << create_nuspec_file(paths.root, nuget_id, nupkg_version);
// Using all forward slashes for the command line
- const std::wstring cmd_line = Strings::format(LR"(nuget.exe pack -OutputDirectory "%s" "%s" > nul)", buildsystems_dir.native(), nuspec_file_path.native());
+ const std::wstring cmd_line = Strings::wformat(LR"(nuget.exe pack -OutputDirectory "%s" "%s" > nul)", buildsystems_dir.native(), nuspec_file_path.native());
const int exit_code = System::cmd_execute(cmd_line);
diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp
index a2f6fa10f..a317330ff 100644
--- a/toolsrc/src/main.cpp
+++ b/toolsrc/src/main.cpp
@@ -70,14 +70,14 @@ static void inner(const vcpkg_cmd_arguments& args)
}
triplet default_target_triplet;
- if(args.target_triplet != nullptr)
+ if (args.target_triplet != nullptr)
{
default_target_triplet = {*args.target_triplet};
}
else
{
const auto vcpkg_default_triplet_env = System::wdupenv_str(L"VCPKG_DEFAULT_TRIPLET");
- if(!vcpkg_default_triplet_env.empty())
+ if (!vcpkg_default_triplet_env.empty())
{
default_target_triplet = {Strings::utf16_to_utf8(vcpkg_default_triplet_env)};
}
@@ -87,7 +87,7 @@ static void inner(const vcpkg_cmd_arguments& args)
}
}
- if(!default_target_triplet.validate(paths))
+ if (!paths.is_valid_triplet(default_target_triplet))
{
System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value);
TrackProperty("error", "invalid triplet: " + default_target_triplet.value);
diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp
index 610c71ed1..ada065fd6 100644
--- a/toolsrc/src/metrics.cpp
+++ b/toolsrc/src/metrics.cpp
@@ -419,7 +419,7 @@ true
const fs::path vcpkg_metrics_txt_path = temp_folder_path / ("vcpkg" + GenerateRandomUUID() + ".txt");
std::ofstream(vcpkg_metrics_txt_path) << payload;
- const std::wstring cmdLine = Strings::format(L"start %s %s", temp_folder_path_exe.native(), vcpkg_metrics_txt_path.native());
+ const std::wstring cmdLine = Strings::wformat(L"start %s %s", temp_folder_path_exe.native(), vcpkg_metrics_txt_path.native());
System::cmd_execute(cmdLine);
}
}
diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp
index 1d4ca0f67..8bd9838c6 100644
--- a/toolsrc/src/post_build_lint.cpp
+++ b/toolsrc/src/post_build_lint.cpp
@@ -71,12 +71,10 @@ namespace vcpkg
System::println(System::color::warning, "Include files should not be duplicated into the /debug/include directory. If this cannot be disabled in the project cmake, use\n"
" file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)"
);
- return
- lint_status::ERROR;
+ return lint_status::ERROR;
}
- return
- lint_status::SUCCESS;
+ return lint_status::SUCCESS;
}
static lint_status check_for_files_in_debug_share_directory(const package_spec& spec, const vcpkg_paths& paths)
@@ -221,7 +219,7 @@ namespace vcpkg
std::vector<fs::path> dlls_with_no_exports;
for (const fs::path& dll : dlls)
{
- const std::wstring cmd_line = Strings::format(LR"("%s" /exports "%s")", DUMPBIN_EXE.native(), dll.native());
+ const std::wstring cmd_line = Strings::wformat(LR"("%s" /exports "%s")", DUMPBIN_EXE.native(), dll.native());
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
@@ -252,7 +250,7 @@ namespace vcpkg
std::vector<fs::path> dlls_with_improper_uwp_bit;
for (const fs::path& dll : dlls)
{
- const std::wstring cmd_line = Strings::format(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), dll.native());
+ const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), dll.native());
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
@@ -284,7 +282,7 @@ namespace vcpkg
std::vector<file_and_arch> binaries_with_invalid_architecture;
for (const fs::path& f : files)
{
- const std::wstring cmd_line = Strings::format(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native());
+ const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native());
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp
index 4270c458d..e3a935958 100644
--- a/toolsrc/src/triplet.cpp
+++ b/toolsrc/src/triplet.cpp
@@ -1,6 +1,4 @@
#include "triplet.h"
-#include "vcpkg.h"
-#include "vcpkg_System.h"
#include "vcpkg_Checks.h"
namespace vcpkg
@@ -38,38 +36,15 @@ namespace vcpkg
std::string triplet::architecture() const
{
- if (*this == X86_WINDOWS || *this == X86_UWP)
- return "x86";
- if (*this == X64_WINDOWS || *this == X64_UWP)
- return "x64";
- if (*this == ARM_UWP)
- return "arm";
-
- Checks::exit_with_message("Unknown architecture: %s", value);
+ auto it = std::find(this->value.cbegin(), this->value.cend(), '-');
+ Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value);
+ return std::string(this->value.cbegin(), it);
}
std::string triplet::system() const
{
- if (*this == X86_WINDOWS || *this == X64_WINDOWS)
- return "windows";
- if (*this == X86_UWP || *this == X64_UWP || *this == ARM_UWP)
- return "uwp";
-
- Checks::exit_with_message("Unknown system: %s", value);
- }
-
- bool triplet::validate(const vcpkg_paths& paths) const
- {
- auto it = fs::directory_iterator(paths.triplets);
- for (; it != fs::directory_iterator(); ++it)
- {
- std::string triplet_file_name = it->path().stem().generic_u8string();
- if (value == triplet_file_name) // TODO: fuzzy compare
- {
- //value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
- return true;
- }
- }
- return false;
+ auto it = std::find(this->value.cbegin(), this->value.cend(), '-');
+ Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value);
+ return std::string(it + 1, this->value.cend());
}
}
diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp
index f70f2b893..d98b0f220 100644
--- a/toolsrc/src/vcpkg_Environment.cpp
+++ b/toolsrc/src/vcpkg_Environment.cpp
@@ -48,11 +48,11 @@ namespace vcpkg {namespace Environment
void ensure_git_on_path(const vcpkg_paths& paths)
{
const fs::path downloaded_git = paths.downloads / "PortableGit" / "cmd";
- const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s",
- downloaded_git.native(),
- System::wdupenv_str(L"PATH"),
- default_git_installation_dir.native(),
- default_git_installation_dir_x86.native());
+ const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s",
+ downloaded_git.native(),
+ System::wdupenv_str(L"PATH"),
+ default_git_installation_dir.native(),
+ default_git_installation_dir_x86.native());
_wputenv_s(L"PATH", path_buf.c_str());
static constexpr std::array<int, 3> git_version = {2,0,0};
@@ -63,11 +63,11 @@ namespace vcpkg {namespace Environment
void ensure_cmake_on_path(const vcpkg_paths& paths)
{
const fs::path downloaded_cmake = paths.downloads / "cmake-3.5.2-win32-x86" / "bin";
- const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s",
- downloaded_cmake.native(),
- System::wdupenv_str(L"PATH"),
- default_cmake_installation_dir.native(),
- default_cmake_installation_dir_x86.native());
+ const std::wstring path_buf = Strings::wformat(L"%s;%s;%s;%s",
+ downloaded_cmake.native(),
+ System::wdupenv_str(L"PATH"),
+ default_cmake_installation_dir.native(),
+ default_cmake_installation_dir_x86.native());
_wputenv_s(L"PATH", path_buf.c_str());
static constexpr std::array<int, 3> cmake_version = {3,5,0};
@@ -77,7 +77,7 @@ namespace vcpkg {namespace Environment
void ensure_nuget_on_path(const vcpkg_paths& paths)
{
- const std::wstring path_buf = Strings::format(L"%s;%s", paths.downloads.native(), System::wdupenv_str(L"PATH"));
+ const std::wstring path_buf = Strings::wformat(L"%s;%s", paths.downloads.native(), System::wdupenv_str(L"PATH"));
_wputenv_s(L"PATH", path_buf.c_str());
static constexpr std::array<int, 3> nuget_version = {1,0,0};
diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp
index b0312536a..9a81bbbfd 100644
--- a/toolsrc/src/vcpkg_Strings.cpp
+++ b/toolsrc/src/vcpkg_Strings.cpp
@@ -20,7 +20,7 @@ namespace vcpkg {namespace Strings {namespace details
return output;
}
- std::wstring format_internal(const wchar_t* fmtstr, ...)
+ std::wstring wformat_internal(const wchar_t* fmtstr, ...)
{
va_list lst;
va_start(lst, fmtstr);
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp
index 71b4087d2..4dc37857d 100644
--- a/toolsrc/src/vcpkg_System.cpp
+++ b/toolsrc/src/vcpkg_System.cpp
@@ -19,14 +19,14 @@ namespace vcpkg {namespace System
int cmd_execute(const wchar_t* cmd_line)
{
// Basically we are wrapping it in quotes
- const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line);
+ const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
int exit_code = _wsystem(actual_cmd_line.c_str());
return exit_code;
}
exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line)
{
- const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line);
+ const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line);
std::string output;
char buf[1024];
diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp
index 30d32a99b..463f62c80 100644
--- a/toolsrc/src/vcpkg_paths.cpp
+++ b/toolsrc/src/vcpkg_paths.cpp
@@ -56,4 +56,19 @@ namespace vcpkg
{
return this->ports / spec.name;
}
+
+ bool vcpkg_paths::is_valid_triplet(const triplet& t) const
+ {
+ auto it = fs::directory_iterator(this->triplets);
+ for (; it != fs::directory_iterator(); ++it)
+ {
+ std::string triplet_file_name = it->path().stem().generic_u8string();
+ if (t.value == triplet_file_name) // TODO: fuzzy compare
+ {
+ //t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
+ return true;
+ }
+ }
+ return false;
+ }
}