aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorStanislav Ershov <digital.stream.of.mind@gmail.com>2017-12-23 17:26:05 +0300
committerStanislav Ershov <digital.stream.of.mind@gmail.com>2017-12-23 17:26:05 +0300
commit7cc7c28e209b6fe7b037c59c9fa83a763e337bb8 (patch)
tree561db019a1b222b978ad158ce17055947d9ee397 /toolsrc/src
parent2d0a76370ead152896411d17aa19934235b93d1c (diff)
downloadvcpkg-7cc7c28e209b6fe7b037c59c9fa83a763e337bb8.tar.gz
vcpkg-7cc7c28e209b6fe7b037c59c9fa83a763e337bb8.zip
[vcpkg-hash] Replace certutil.exe with cmake built-in hash commands
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/commands.cpp7
-rw-r--r--toolsrc/src/vcpkg/commands.hash.cpp16
2 files changed, 13 insertions, 10 deletions
diff --git a/toolsrc/src/vcpkg/commands.cpp b/toolsrc/src/vcpkg/commands.cpp
index ccf6fa729..d9c0e54cd 100644
--- a/toolsrc/src/vcpkg/commands.cpp
+++ b/toolsrc/src/vcpkg/commands.cpp
@@ -41,7 +41,9 @@ namespace vcpkg::Commands
{"import", &Import::perform_and_exit},
{"cache", &Cache::perform_and_exit},
{"portsdiff", &PortsDiff::perform_and_exit},
- {"autocomplete", &Autocomplete::perform_and_exit}};
+ {"autocomplete", &Autocomplete::perform_and_exit},
+ {"hash", &Hash::perform_and_exit},
+ };
return t;
}
@@ -49,8 +51,7 @@ namespace vcpkg::Commands
{
static std::vector<PackageNameAndFunction<CommandTypeC>> t = {
{"version", &Version::perform_and_exit},
- {"contact", &Contact::perform_and_exit},
- {"hash", &Hash::perform_and_exit},
+ {"contact", &Contact::perform_and_exit}
};
return t;
}
diff --git a/toolsrc/src/vcpkg/commands.hash.cpp b/toolsrc/src/vcpkg/commands.hash.cpp
index a5940ea1e..1e3e5b23d 100644
--- a/toolsrc/src/vcpkg/commands.hash.cpp
+++ b/toolsrc/src/vcpkg/commands.hash.cpp
@@ -7,15 +7,17 @@
namespace vcpkg::Commands::Hash
{
- static void do_file_hash(fs::path const& path, std::string const& hash_type)
+ static void do_file_hash(fs::path const &cmake_exe_path, fs::path const& path, std::string const& hash_type)
{
- const auto cmd_line = Strings::format(R"(CertUtil.exe -hashfile "%s" %s)", path.u8string().c_str(), hash_type);
+ const std::string cmd_line = Strings::format(
+ R"("%s" -E %ssum %s)", cmake_exe_path.u8string(), Strings::ascii_to_lowercase(hash_type), path.u8string());
+
const auto ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", cmd_line);
std::string const& output = ec_data.output;
- const auto start = output.find_first_of("\r\n");
+ const auto start = output.find_first_of(" ");
Checks::check_exit(
VCPKG_LINE_INFO, start != std::string::npos, "Unexpected output format from command: %s", cmd_line);
@@ -23,7 +25,7 @@ namespace vcpkg::Commands::Hash
Checks::check_exit(
VCPKG_LINE_INFO, end != std::string::npos, "Unexpected output format from command: %s", cmd_line);
- auto hash = output.substr(start, end - start);
+ auto hash = output.substr(0, start);
Util::erase_remove_if(hash, isspace);
System::println(hash);
}
@@ -37,17 +39,17 @@ namespace vcpkg::Commands::Hash
nullptr,
};
- void perform_and_exit(const VcpkgCmdArguments& args)
+ void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
args.parse_arguments(COMMAND_STRUCTURE);
if (args.command_arguments.size() == 1)
{
- do_file_hash(args.command_arguments[0], "SHA512");
+ do_file_hash(paths.get_cmake_exe(), args.command_arguments[0], "SHA512");
}
if (args.command_arguments.size() == 2)
{
- do_file_hash(args.command_arguments[0], args.command_arguments[1]);
+ do_file_hash(paths.get_cmake_exe(), args.command_arguments[0], args.command_arguments[1]);
}
Checks::exit_success(VCPKG_LINE_INFO);