aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorPhil Christensen <philc@microsoft.com>2018-12-13 11:13:43 -0800
committerPhil Christensen <philc@microsoft.com>2018-12-13 11:13:43 -0800
commit5fc3a10651dc80201b4a870043a0cef6b3c72ff3 (patch)
tree22a3a9073a29a555540539f1c5f6c0f5360b506d /toolsrc/src
parent9e773bd912e42a413f87e9fb1a6712461e10c4bf (diff)
parente04b4ed5b5ff5c1b61e5ce3d70ac101ffe3237c4 (diff)
downloadvcpkg-5fc3a10651dc80201b4a870043a0cef6b3c72ff3.tar.gz
vcpkg-5fc3a10651dc80201b4a870043a0cef6b3c72ff3.zip
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/philc/4914
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg.cpp4
-rw-r--r--toolsrc/src/vcpkg/base/downloads.cpp34
-rw-r--r--toolsrc/src/vcpkg/base/system.cpp2
-rw-r--r--toolsrc/src/vcpkg/build.cpp39
-rw-r--r--toolsrc/src/vcpkg/commands.autocomplete.cpp52
-rw-r--r--toolsrc/src/vcpkg/commands.edit.cpp11
-rw-r--r--toolsrc/src/vcpkg/dependencies.cpp59
-rw-r--r--toolsrc/src/vcpkg/postbuildlint.cpp35
-rw-r--r--toolsrc/src/vcpkg/statusparagraph.cpp2
-rw-r--r--toolsrc/src/vcpkg/tools.cpp13
-rw-r--r--toolsrc/src/vcpkg/vcpkgpaths.cpp37
-rw-r--r--toolsrc/src/vcpkg/visualstudio.cpp32
12 files changed, 195 insertions, 125 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 3589881a7..fc7283599 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -171,8 +171,10 @@ static void inner(const VcpkgCmdArguments& args)
default_triplet = Triplet::from_canonical_name("x64-osx");
#elif defined(__FreeBSD__)
default_triplet = Triplet::from_canonical_name("x64-freebsd");
-#else
+#elif defined(__GLIBC__)
default_triplet = Triplet::from_canonical_name("x64-linux");
+#else
+ default_triplet = Triplet::from_canonical_name("x64-linux-musl");
#endif
}
}
diff --git a/toolsrc/src/vcpkg/base/downloads.cpp b/toolsrc/src/vcpkg/base/downloads.cpp
index 1d7b3527d..571562244 100644
--- a/toolsrc/src/vcpkg/base/downloads.cpp
+++ b/toolsrc/src/vcpkg/base/downloads.cpp
@@ -42,6 +42,28 @@ namespace vcpkg::Downloads
0);
Checks::check_exit(VCPKG_LINE_INFO, hSession, "WinHttpOpen() failed: %d", GetLastError());
+ // Win7 IE Proxy fallback
+ if (IsWindows7OrGreater() && !IsWindows8Point1OrGreater()) {
+ // First check if any proxy has been found automatically
+ WINHTTP_PROXY_INFO proxyInfo;
+ DWORD proxyInfoSize = sizeof(WINHTTP_PROXY_INFO);
+ auto noProxyFound =
+ !WinHttpQueryOption(hSession, WINHTTP_OPTION_PROXY, &proxyInfo, &proxyInfoSize)
+ || proxyInfo.dwAccessType == WINHTTP_ACCESS_TYPE_NO_PROXY;
+
+ // If no proxy was found automatically, use IE's proxy settings, if any
+ if (noProxyFound) {
+ WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxy;
+ if (WinHttpGetIEProxyConfigForCurrentUser(&ieProxy) && ieProxy.lpszProxy != nullptr) {
+ WINHTTP_PROXY_INFO proxy;
+ proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
+ proxy.lpszProxy = ieProxy.lpszProxy;
+ proxy.lpszProxyBypass = ieProxy.lpszProxyBypass;
+ WinHttpSetOption(hSession, WINHTTP_OPTION_PROXY, &proxy, sizeof(proxy));
+ }
+ }
+ }
+
// Use Windows 10 defaults on Windows 7
DWORD secure_protocols(WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 |
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2);
@@ -102,7 +124,17 @@ namespace vcpkg::Downloads
const fs::path& path,
const std::string& sha512)
{
- const std::string actual_hash = vcpkg::Hash::get_file_hash(fs, path, "SHA512");
+ std::string actual_hash = vcpkg::Hash::get_file_hash(fs, path, "SHA512");
+
+ // <HACK to handle NuGet.org changing nupkg hashes.>
+ // This is the NEW hash for 7zip
+ if (actual_hash == "a9dfaaafd15d98a2ac83682867ec5766720acf6e99d40d1a00d480692752603bf3f3742623f0ea85647a92374df"
+ "405f331afd6021c5cf36af43ee8db198129c0")
+ // This is the OLD hash for 7zip
+ actual_hash = "8c75314102e68d2b2347d592f8e3eb05812e1ebb525decbac472231633753f1d4ca31c8e6881a36144a8da26b257"
+ "1305b3ae3f4e2b85fc4a290aeda63d1a13b8";
+ // </HACK>
+
Checks::check_exit(VCPKG_LINE_INFO,
sha512 == actual_hash,
"File does not have the expected hash:\n"
diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp
index 6797111c2..9c72f8401 100644
--- a/toolsrc/src/vcpkg/base/system.cpp
+++ b/toolsrc/src/vcpkg/base/system.cpp
@@ -168,6 +168,8 @@ namespace vcpkg::System
L"CUDA_PATH",
// Environmental variable generated automatically by CUDA after installation
L"NVCUDASAMPLES_ROOT",
+ // Enables find_package(Vulkan) in CMake. Environmental variable generated by Vulkan SDK installer
+ L"VULKAN_SDK",
};
std::wstring env_cstr;
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index 9b97701ef..67d9b63ed 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -63,7 +63,7 @@ namespace vcpkg::Build::Command
spec.name());
const StatusParagraphs status_db = database_load_check(paths);
- const Build::BuildPackageOptions build_package_options {
+ const Build::BuildPackageOptions build_package_options{
Build::UseHeadVersion::NO,
Build::AllowDownloads::YES,
Build::CleanBuildtrees::NO,
@@ -76,8 +76,8 @@ namespace vcpkg::Build::Command
std::set<std::string> features_as_set(full_spec.features.begin(), full_spec.features.end());
features_as_set.emplace("core");
- const Build::BuildPackageConfig build_config {
- *scf, spec.triplet(), fs::path {port_dir}, build_package_options, features_as_set};
+ const Build::BuildPackageConfig build_config{
+ *scf, spec.triplet(), fs::path{port_dir}, build_package_options, features_as_set};
const auto build_timer = Chrono::ElapsedTimer::create_started();
const auto result = Build::build_package(paths, build_config, status_db);
@@ -372,7 +372,8 @@ namespace vcpkg::Build
{"TARGET_TRIPLET", spec.triplet().canonical_name()},
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
{"VCPKG_USE_HEAD_VERSION",
- Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
+ Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
+ {"DOWNLOADS", paths.downloads},
{"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(config.build_package_options.allow_downloads) ? "1" : "0"},
{"_VCPKG_DOWNLOAD_TOOL", to_string(config.build_package_options.download_tool)},
{"GIT", git_exe_path},
@@ -470,22 +471,22 @@ namespace vcpkg::Build
std::vector<AbiEntry> abi_tag_entries(dependency_abis.begin(), dependency_abis.end());
- abi_tag_entries.emplace_back(AbiEntry {"cmake", paths.get_tool_version(Tools::CMAKE)});
+ abi_tag_entries.emplace_back(AbiEntry{"cmake", paths.get_tool_version(Tools::CMAKE)});
abi_tag_entries.emplace_back(
- AbiEntry {"portfile", vcpkg::Hash::get_file_hash(fs, config.port_dir / "portfile.cmake", "SHA1")});
+ AbiEntry{"portfile", vcpkg::Hash::get_file_hash(fs, config.port_dir / "portfile.cmake", "SHA1")});
abi_tag_entries.emplace_back(
- AbiEntry {"control", vcpkg::Hash::get_file_hash(fs, config.port_dir / "CONTROL", "SHA1")});
+ AbiEntry{"control", vcpkg::Hash::get_file_hash(fs, config.port_dir / "CONTROL", "SHA1")});
abi_tag_entries.emplace_back(AbiEntry{"vcpkg_fixup_cmake_targets", "1"});
abi_tag_entries.emplace_back(AbiEntry{"triplet", pre_build_info.triplet_abi_tag});
const std::string features = Strings::join(";", config.feature_list);
- abi_tag_entries.emplace_back(AbiEntry {"features", features});
+ abi_tag_entries.emplace_back(AbiEntry{"features", features});
if (config.build_package_options.use_head_version == UseHeadVersion::YES)
- abi_tag_entries.emplace_back(AbiEntry {"head", ""});
+ abi_tag_entries.emplace_back(AbiEntry{"head", ""});
Util::sort(abi_tag_entries);
@@ -503,7 +504,7 @@ namespace vcpkg::Build
}
auto abi_tag_entries_missing = abi_tag_entries;
- Util::stable_keep_if(abi_tag_entries_missing, [](const AbiEntry& p) { return p.value.empty(); });
+ Util::erase_remove_if(abi_tag_entries_missing, [](const AbiEntry& p) { return !p.value.empty(); });
if (abi_tag_entries_missing.empty())
{
@@ -512,7 +513,7 @@ namespace vcpkg::Build
const auto abi_file_path = paths.buildtrees / name / (triplet.canonical_name() + ".vcpkg_abi_info.txt");
fs.write_contents(abi_file_path, full_abi_info);
- return AbiTagAndFile {Hash::get_file_hash(fs, abi_file_path, "SHA1"), abi_file_path};
+ return AbiTagAndFile{Hash::get_file_hash(fs, abi_file_path, "SHA1"), abi_file_path};
}
System::println(
@@ -581,8 +582,8 @@ namespace vcpkg::Build
Util::sort_unique_erase(dep_pspecs);
// Find all features that aren't installed. This mutates required_fspecs.
- Util::unstable_keep_if(required_fspecs, [&](FeatureSpec const& fspec) {
- return !status_db.is_installed(fspec) && fspec.name() != name;
+ Util::erase_remove_if(required_fspecs, [&](FeatureSpec const& fspec) {
+ return status_db.is_installed(fspec) || fspec.name() == name;
});
if (!required_fspecs.empty())
@@ -602,7 +603,7 @@ namespace vcpkg::Build
const auto status_it = status_db.find_installed(pspec);
Checks::check_exit(VCPKG_LINE_INFO, status_it != status_db.end());
dependency_abis.emplace_back(
- AbiEntry {status_it->get()->package.spec.name(), status_it->get()->package.abi});
+ AbiEntry{status_it->get()->package.spec.name(), status_it->get()->package.abi});
}
const auto pre_build_info = PreBuildInfo::from_triplet_file(paths, triplet);
@@ -648,7 +649,7 @@ namespace vcpkg::Build
System::println("Could not locate cached archive: %s", archive_path.u8string());
ExtendedBuildResult result = do_build_package_and_clean_buildtrees(
- paths, pre_build_info, spec, maybe_abi_tag_and_file.value_or(AbiTagAndFile {}).tag, config);
+ paths, pre_build_info, spec, maybe_abi_tag_and_file.value_or(AbiTagAndFile{}).tag, config);
std::error_code ec;
fs.create_directories(paths.package_dir(spec) / "share" / spec.name(), ec);
@@ -685,7 +686,7 @@ namespace vcpkg::Build
}
return do_build_package_and_clean_buildtrees(
- paths, pre_build_info, spec, maybe_abi_tag_and_file.value_or(AbiTagAndFile {}).tag, config);
+ paths, pre_build_info, spec, maybe_abi_tag_and_file.value_or(AbiTagAndFile{}).tag, config);
}
const std::string& to_string(const BuildResult build_result)
@@ -850,21 +851,21 @@ namespace vcpkg::Build
if (variable_name == "VCPKG_PLATFORM_TOOLSET")
{
pre_build_info.platform_toolset =
- variable_value.empty() ? nullopt : Optional<std::string> {variable_value};
+ variable_value.empty() ? nullopt : Optional<std::string>{variable_value};
continue;
}
if (variable_name == "VCPKG_VISUAL_STUDIO_PATH")
{
pre_build_info.visual_studio_path =
- variable_value.empty() ? nullopt : Optional<fs::path> {variable_value};
+ variable_value.empty() ? nullopt : Optional<fs::path>{variable_value};
continue;
}
if (variable_name == "VCPKG_CHAINLOAD_TOOLCHAIN_FILE")
{
pre_build_info.external_toolchain_file =
- variable_value.empty() ? nullopt : Optional<std::string> {variable_value};
+ variable_value.empty() ? nullopt : Optional<std::string>{variable_value};
continue;
}
diff --git a/toolsrc/src/vcpkg/commands.autocomplete.cpp b/toolsrc/src/vcpkg/commands.autocomplete.cpp
index 564404421..3b353feec 100644
--- a/toolsrc/src/vcpkg/commands.autocomplete.cpp
+++ b/toolsrc/src/vcpkg/commands.autocomplete.cpp
@@ -40,26 +40,25 @@ namespace vcpkg::Commands::Autocomplete
const std::string requested_command = match[1].str();
// First try public commands
- std::vector<std::string> public_commands = {
- "install",
- "search",
- "remove",
- "list",
- "update",
- "hash",
- "help",
- "integrate",
- "export",
- "edit",
- "create",
- "owns",
- "cache",
- "version",
- "contact",
- };
-
- Util::unstable_keep_if(public_commands, [&](const std::string& s) {
- return Strings::case_insensitive_ascii_starts_with(s, requested_command);
+ std::vector<std::string> public_commands = {"install",
+ "search",
+ "remove",
+ "list",
+ "update",
+ "hash",
+ "help",
+ "integrate",
+ "export",
+ "edit",
+ "create",
+ "owns",
+ "cache",
+ "version",
+ "contact",
+ "upgrade"};
+
+ Util::erase_remove_if(public_commands, [&](const std::string& s) {
+ return !Strings::case_insensitive_ascii_starts_with(s, requested_command);
});
if (!public_commands.empty())
@@ -78,8 +77,8 @@ namespace vcpkg::Commands::Autocomplete
"portsdiff",
};
- Util::unstable_keep_if(private_commands, [&](const std::string& s) {
- return Strings::case_insensitive_ascii_starts_with(s, requested_command);
+ Util::erase_remove_if(private_commands, [&](const std::string& s) {
+ return !Strings::case_insensitive_ascii_starts_with(s, requested_command);
});
output_sorted_results_and_exit(VCPKG_LINE_INFO, std::move(private_commands));
@@ -98,8 +97,8 @@ namespace vcpkg::Commands::Autocomplete
}
std::vector<std::string> triplets = paths.get_available_triplets();
- Util::unstable_keep_if(triplets, [&](const std::string& s) {
- return Strings::case_insensitive_ascii_starts_with(s, triplet_prefix);
+ Util::erase_remove_if(triplets, [&](const std::string& s) {
+ return !Strings::case_insensitive_ascii_starts_with(s, triplet_prefix);
});
auto result = combine_port_with_triplets(port_name, triplets);
@@ -124,6 +123,7 @@ namespace vcpkg::Commands::Autocomplete
CommandEntry{"edit", R"###(^edit\s(.*\s|)(\S*)$)###", Edit::COMMAND_STRUCTURE},
CommandEntry{"remove", R"###(^remove\s(.*\s|)(\S*)$)###", Remove::COMMAND_STRUCTURE},
CommandEntry{"integrate", R"###(^integrate(\s+)(\S*)$)###", Integrate::COMMAND_STRUCTURE},
+ CommandEntry{"upgrade", R"###(^upgrade(\s+)(\S*)$)###", Upgrade::COMMAND_STRUCTURE},
};
for (auto&& command : COMMANDS)
@@ -150,8 +150,8 @@ namespace vcpkg::Commands::Autocomplete
}
}
- Util::unstable_keep_if(results, [&](const std::string& s) {
- return Strings::case_insensitive_ascii_starts_with(s, prefix);
+ Util::erase_remove_if(results, [&](const std::string& s) {
+ return !Strings::case_insensitive_ascii_starts_with(s, prefix);
});
if (command.name == "install" && results.size() == 1 && !is_option)
diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp
index b9d9d8c1a..044ae1c47 100644
--- a/toolsrc/src/vcpkg/commands.edit.cpp
+++ b/toolsrc/src/vcpkg/commands.edit.cpp
@@ -107,9 +107,6 @@ namespace vcpkg::Commands::Edit
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const fs::path VS_CODE_INSIDERS = fs::path{"Microsoft VS Code Insiders"} / "Code - Insiders.exe";
- static const fs::path VS_CODE = fs::path{"Microsoft VS Code"} / "Code.exe";
-
auto& fs = paths.get_filesystem();
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
@@ -129,6 +126,10 @@ namespace vcpkg::Commands::Edit
candidate_paths.emplace_back(*editor_path);
}
+#ifdef _WIN32
+ static const fs::path VS_CODE_INSIDERS = fs::path{"Microsoft VS Code Insiders"} / "Code - Insiders.exe";
+ static const fs::path VS_CODE = fs::path{"Microsoft VS Code"} / "Code.exe";
+
const auto& program_files = System::get_program_files_platform_bitness();
if (const fs::path* pf = program_files.get())
{
@@ -153,6 +154,10 @@ namespace vcpkg::Commands::Edit
const std::vector<fs::path> from_registry = find_from_registry();
candidate_paths.insert(candidate_paths.end(), from_registry.cbegin(), from_registry.cend());
+#elif defined(__APPLE__)
+ candidate_paths.push_back(fs::path{"/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code"});
+ candidate_paths.push_back(fs::path{"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"});
+#endif
const auto it = Util::find_if(candidate_paths, [&](const fs::path& p) { return fs.exists(p); });
if (it == candidate_paths.cend())
diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp
index 8fb35b0da..60c43e4a8 100644
--- a/toolsrc/src/vcpkg/dependencies.cpp
+++ b/toolsrc/src/vcpkg/dependencies.cpp
@@ -488,26 +488,23 @@ namespace vcpkg::Dependencies
if (plus) return MarkPlusResult::SUCCESS;
plus = true;
+ auto p_source = cluster.source.get();
+ Checks::check_exit(VCPKG_LINE_INFO,
+ p_source != nullptr,
+ "Error: Cannot find definition for package `%s`.",
+ cluster.spec.name());
+
if (feature.empty())
{
// Add default features for this package. This is an exact reference, so ignore prevent_default_features.
- if (auto p_source = cluster.source.get())
+ for (auto&& default_feature : p_source->scf->core_paragraph.get()->default_features)
{
- for (auto&& default_feature : p_source->scf->core_paragraph.get()->default_features)
+ auto res = mark_plus(default_feature, cluster, graph, graph_plan, prevent_default_features);
+ if (res != MarkPlusResult::SUCCESS)
{
- auto res = mark_plus(default_feature, cluster, graph, graph_plan, prevent_default_features);
- if (res != MarkPlusResult::SUCCESS)
- {
- return res;
- }
+ return res;
}
}
- else
- {
- Checks::exit_with_message(VCPKG_LINE_INFO,
- "Error: Unable to install default features because can't find CONTROL for %s",
- cluster.spec);
- }
// "core" is always required.
return mark_plus("core", cluster, graph, graph_plan, prevent_default_features);
@@ -515,28 +512,20 @@ namespace vcpkg::Dependencies
if (feature == "*")
{
- if (auto p_source = cluster.source.get())
+ for (auto&& fpgh : p_source->scf->feature_paragraphs)
{
- for (auto&& fpgh : p_source->scf->feature_paragraphs)
- {
- auto res = mark_plus(fpgh->name, cluster, graph, graph_plan, prevent_default_features);
+ auto res = mark_plus(fpgh->name, cluster, graph, graph_plan, prevent_default_features);
- Checks::check_exit(VCPKG_LINE_INFO,
- res == MarkPlusResult::SUCCESS,
- "Error: Unable to locate feature %s in %s",
- fpgh->name,
- cluster.spec);
- }
+ Checks::check_exit(VCPKG_LINE_INFO,
+ res == MarkPlusResult::SUCCESS,
+ "Error: Internal error while installing feature %s in %s",
+ fpgh->name,
+ cluster.spec);
+ }
- auto res = mark_plus("core", cluster, graph, graph_plan, prevent_default_features);
+ auto res = mark_plus("core", cluster, graph, graph_plan, prevent_default_features);
- Checks::check_exit(VCPKG_LINE_INFO, res == MarkPlusResult::SUCCESS);
- }
- else
- {
- Checks::exit_with_message(
- VCPKG_LINE_INFO, "Error: Unable to handle '*' because can't find CONTROL for %s", cluster.spec);
- }
+ Checks::check_exit(VCPKG_LINE_INFO, res == MarkPlusResult::SUCCESS);
return MarkPlusResult::SUCCESS;
}
@@ -643,7 +632,7 @@ namespace vcpkg::Dependencies
}
/// <summary>Figure out which actions are required to install features specifications in `specs`.</summary>
- /// <param name="map">Map of all source files in the current environment.</param>
+ /// <param name="map">Map of all source control files in the current environment.</param>
/// <param name="specs">Feature specifications to resolve dependencies for.</param>
/// <param name="status_db">Status of installed packages in the current environment.</param>
std::vector<AnyAction> create_feature_install_plan(const std::unordered_map<std::string, SourceControlFile>& map,
@@ -666,7 +655,11 @@ namespace vcpkg::Dependencies
auto res = mark_plus(spec.feature(), spec_cluster, *m_graph, *m_graph_plan, prevent_default_features);
- Checks::check_exit(VCPKG_LINE_INFO, res == MarkPlusResult::SUCCESS, "Error: Unable to locate feature %s", spec);
+ Checks::check_exit(VCPKG_LINE_INFO,
+ res == MarkPlusResult::SUCCESS,
+ "Error: `%s` is not a feature of package `%s`",
+ spec.feature(),
+ spec.name());
m_graph_plan->install_graph.add_vertex(ClusterPtr{&spec_cluster});
}
diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp
index 90dcb7d64..a62d4ece5 100644
--- a/toolsrc/src/vcpkg/postbuildlint.cpp
+++ b/toolsrc/src/vcpkg/postbuildlint.cpp
@@ -16,9 +16,9 @@ using vcpkg::Build::PreBuildInfo;
namespace vcpkg::PostBuildLint
{
- static auto has_extension_pred(const Files::Filesystem& fs, const std::string& ext)
+ static auto not_extension_pred(const Files::Filesystem& fs, const std::string& ext)
{
- return [&fs, ext](const fs::path& path) { return !fs.is_directory(path) && path.extension() == ext; };
+ return [&fs, ext](const fs::path& path) { return fs.is_directory(path) || path.extension() != ext; };
}
enum class LintStatus
@@ -104,8 +104,8 @@ namespace vcpkg::PostBuildLint
std::vector<fs::path> files_found = fs.get_files_recursive(debug_include_dir);
- Util::unstable_keep_if(
- files_found, [&fs](const fs::path& path) { return !fs.is_directory(path) && path.extension() != ".ifc"; });
+ Util::erase_remove_if(
+ files_found, [&fs](const fs::path& path) { return fs.is_directory(path) || path.extension() == ".ifc"; });
if (!files_found.empty())
{
@@ -206,7 +206,7 @@ namespace vcpkg::PostBuildLint
static LintStatus check_for_dlls_in_lib_dir(const Files::Filesystem& fs, const fs::path& package_dir)
{
std::vector<fs::path> dlls = fs.get_files_recursive(package_dir / "lib");
- Util::unstable_keep_if(dlls, has_extension_pred(fs, ".dll"));
+ Util::erase_remove_if(dlls, not_extension_pred(fs, ".dll"));
if (!dlls.empty())
{
@@ -280,7 +280,7 @@ namespace vcpkg::PostBuildLint
static LintStatus check_for_exes(const Files::Filesystem& fs, const fs::path& package_dir)
{
std::vector<fs::path> exes = fs.get_files_recursive(package_dir / "bin");
- Util::unstable_keep_if(exes, has_extension_pred(fs, ".exe"));
+ Util::erase_remove_if(exes, not_extension_pred(fs, ".exe"));
if (!exes.empty())
{
@@ -572,8 +572,8 @@ namespace vcpkg::PostBuildLint
{
std::vector<fs::path> empty_directories = fs.get_files_recursive(dir);
- Util::unstable_keep_if(empty_directories, [&fs](const fs::path& current) {
- return fs.is_directory(current) && fs.is_empty(current);
+ Util::erase_remove_if(empty_directories, [&fs](const fs::path& current) {
+ return !fs.is_directory(current) || !fs.is_empty(current);
});
if (!empty_directories.empty())
@@ -657,8 +657,6 @@ namespace vcpkg::PostBuildLint
{
fs::path file;
OutdatedDynamicCrt outdated_crt;
-
- OutdatedDynamicCrtAndFile() = delete;
};
static LintStatus check_outdated_crt_linkage_of_dlls(const std::vector<fs::path>& dlls,
@@ -707,12 +705,15 @@ namespace vcpkg::PostBuildLint
static LintStatus check_no_files_in_dir(const Files::Filesystem& fs, const fs::path& dir)
{
std::vector<fs::path> misplaced_files = fs.get_files_non_recursive(dir);
- Util::unstable_keep_if(misplaced_files, [&fs](const fs::path& path) {
+ Util::erase_remove_if(misplaced_files, [&fs](const fs::path& path) {
const std::string filename = path.filename().generic_string();
if (Strings::case_insensitive_ascii_equals(filename.c_str(), "CONTROL") ||
Strings::case_insensitive_ascii_equals(filename.c_str(), "BUILD_INFO"))
- return false;
- return !fs.is_directory(path);
+ {
+ return true;
+ }
+
+ return fs.is_directory(path);
});
if (!misplaced_files.empty())
@@ -764,9 +765,9 @@ namespace vcpkg::PostBuildLint
const fs::path release_bin_dir = package_dir / "bin";
std::vector<fs::path> debug_libs = fs.get_files_recursive(debug_lib_dir);
- Util::unstable_keep_if(debug_libs, has_extension_pred(fs, ".lib"));
+ Util::erase_remove_if(debug_libs, not_extension_pred(fs, ".lib"));
std::vector<fs::path> release_libs = fs.get_files_recursive(release_lib_dir);
- Util::unstable_keep_if(release_libs, has_extension_pred(fs, ".lib"));
+ Util::erase_remove_if(release_libs, not_extension_pred(fs, ".lib"));
if (!pre_build_info.build_type)
error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs);
@@ -780,9 +781,9 @@ namespace vcpkg::PostBuildLint
}
std::vector<fs::path> debug_dlls = fs.get_files_recursive(debug_bin_dir);
- Util::unstable_keep_if(debug_dlls, has_extension_pred(fs, ".dll"));
+ Util::erase_remove_if(debug_dlls, not_extension_pred(fs, ".dll"));
std::vector<fs::path> release_dlls = fs.get_files_recursive(release_bin_dir);
- Util::unstable_keep_if(release_dlls, has_extension_pred(fs, ".dll"));
+ Util::erase_remove_if(release_dlls, not_extension_pred(fs, ".dll"));
switch (build_info.library_linkage)
{
diff --git a/toolsrc/src/vcpkg/statusparagraph.cpp b/toolsrc/src/vcpkg/statusparagraph.cpp
index 462d8d8ed..86946a31a 100644
--- a/toolsrc/src/vcpkg/statusparagraph.cpp
+++ b/toolsrc/src/vcpkg/statusparagraph.cpp
@@ -105,7 +105,7 @@ namespace vcpkg
{
dep.erase(std::find(dep.begin(), dep.end(), '['), dep.end());
}
- Util::unstable_keep_if(deps, [&](auto&& e) { return e != l_spec.name(); });
+ Util::erase_remove_if(deps, [&](auto&& e) { return e == l_spec.name(); });
// </hack>
Util::sort_unique_erase(deps);
diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp
index 313b5997b..c623d816d 100644
--- a/toolsrc/src/vcpkg/tools.cpp
+++ b/toolsrc/src/vcpkg/tools.cpp
@@ -191,8 +191,8 @@ namespace vcpkg
if (!fs.exists(tool_data.download_path))
{
System::println("Downloading %s...", tool_name);
+ System::println(" %s -> %s", tool_data.url, tool_data.download_path.string());
Downloads::download_file(fs, tool_data.url, tool_data.download_path, tool_data.sha512);
- System::println("Downloading %s... done.", tool_name);
}
else
{
@@ -203,7 +203,6 @@ namespace vcpkg
{
System::println("Extracting %s...", tool_name);
Archives::extract_archive(paths, tool_data.download_path, tool_data.tool_dir_path);
- System::println("Extracting %s... done.", tool_name);
}
else
{
@@ -254,6 +253,11 @@ namespace vcpkg
static PathAndVersion get_path(const VcpkgPaths& paths)
{
+ if (System::get_environment_variable("VCPKG_FORCE_SYSTEM_BINARIES").has_value())
+ {
+ return {"cmake", "0"};
+ }
+
std::vector<fs::path> candidate_paths;
#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__)
static const ToolData TOOL_DATA = parse_tool_data_from_xml(paths, "cmake");
@@ -318,6 +322,11 @@ namespace vcpkg
static PathAndVersion get_path(const VcpkgPaths& paths)
{
+ if (System::get_environment_variable("VCPKG_FORCE_SYSTEM_BINARIES").has_value())
+ {
+ return {"ninja", "0"};
+ }
+
static const ToolData TOOL_DATA = parse_tool_data_from_xml(paths, "ninja");
std::vector<fs::path> candidate_paths;
diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp
index 748fd20e0..a92a5673e 100644
--- a/toolsrc/src/vcpkg/vcpkgpaths.cpp
+++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp
@@ -34,7 +34,32 @@ namespace vcpkg
paths.packages = paths.root / "packages";
paths.buildtrees = paths.root / "buildtrees";
- paths.downloads = paths.root / "downloads";
+
+ const auto overriddenDownloadsPath = System::get_environment_variable("VCPKG_DOWNLOADS");
+ if (auto odp = overriddenDownloadsPath.get())
+ {
+ auto asPath = fs::u8path(*odp);
+ if (!fs::stdfs::is_directory(asPath))
+ {
+ Metrics::g_metrics.lock()->track_property("error", "Invalid VCPKG_DOWNLOADS override directory.");
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO,
+ "Invalid downloads override directory: %s; "
+ "create that directory or unset VCPKG_DOWNLOADS to use the default downloads location.",
+ asPath.u8string());
+ }
+
+ paths.downloads = fs::stdfs::canonical(std::move(asPath), ec);
+ if (ec)
+ {
+ return ec;
+ }
+ }
+ else
+ {
+ paths.downloads = paths.root / "downloads";
+ }
+
paths.ports = paths.root / "ports";
paths.installed = paths.root / "installed";
paths.triplets = paths.root / "triplets";
@@ -137,8 +162,8 @@ namespace vcpkg
if (tsv && vsp)
{
- Util::stable_keep_if(
- candidates, [&](const Toolset* t) { return *tsv == t->version && *vsp == t->visual_studio_root_path; });
+ Util::erase_remove_if(
+ candidates, [&](const Toolset* t) { return *tsv != t->version || *vsp != t->visual_studio_root_path; });
Checks::check_exit(VCPKG_LINE_INFO,
!candidates.empty(),
"Could not find Visual Studio instance at %s with %s toolset.",
@@ -151,7 +176,7 @@ namespace vcpkg
if (tsv)
{
- Util::stable_keep_if(candidates, [&](const Toolset* t) { return *tsv == t->version; });
+ Util::erase_remove_if(candidates, [&](const Toolset* t) { return *tsv != t->version; });
Checks::check_exit(
VCPKG_LINE_INFO, !candidates.empty(), "Could not find Visual Studio instance with %s toolset.", *tsv);
}
@@ -159,8 +184,8 @@ namespace vcpkg
if (vsp)
{
const fs::path vs_root_path = *vsp;
- Util::stable_keep_if(candidates,
- [&](const Toolset* t) { return vs_root_path == t->visual_studio_root_path; });
+ Util::erase_remove_if(candidates,
+ [&](const Toolset* t) { return vs_root_path != t->visual_studio_root_path; });
Checks::check_exit(VCPKG_LINE_INFO,
!candidates.empty(),
"Could not find Visual Studio instance at %s.",
diff --git a/toolsrc/src/vcpkg/visualstudio.cpp b/toolsrc/src/vcpkg/visualstudio.cpp
index e3656a7d2..83a530a10 100644
--- a/toolsrc/src/vcpkg/visualstudio.cpp
+++ b/toolsrc/src/vcpkg/visualstudio.cpp
@@ -130,9 +130,9 @@ namespace vcpkg::VisualStudio
{
// We want lexically_normal(), but it is not available
// Correct root path might be 2 or 3 levels up, depending on if the path has trailing backslash. Try both.
- auto common7_tools = fs::path {*path_as_string};
- append_if_has_cl(fs::path {*path_as_string}.parent_path().parent_path());
- append_if_has_cl(fs::path {*path_as_string}.parent_path().parent_path().parent_path());
+ auto common7_tools = fs::path{*path_as_string};
+ append_if_has_cl(fs::path{*path_as_string}.parent_path().parent_path());
+ append_if_has_cl(fs::path{*path_as_string}.parent_path().parent_path().parent_path());
}
// VS2015 instance from Program Files
@@ -143,7 +143,7 @@ namespace vcpkg::VisualStudio
std::vector<std::string> get_visual_studio_instances(const VcpkgPaths& paths)
{
- std::vector<VisualStudioInstance> sorted {get_visual_studio_instances_internal(paths)};
+ std::vector<VisualStudioInstance> sorted{get_visual_studio_instances_internal(paths)};
std::sort(sorted.begin(), sorted.end(), VisualStudioInstance::preferred_first_comparator);
return Util::fmap(sorted, [](const VisualStudioInstance& instance) { return instance.to_string(); });
}
@@ -160,8 +160,8 @@ namespace vcpkg::VisualStudio
std::vector<Toolset> found_toolsets;
std::vector<Toolset> excluded_toolsets;
- const SortedVector<VisualStudioInstance> sorted {get_visual_studio_instances_internal(paths),
- VisualStudioInstance::preferred_first_comparator};
+ const SortedVector<VisualStudioInstance> sorted{get_visual_studio_instances_internal(paths),
+ VisualStudioInstance::preferred_first_comparator};
const bool v140_is_available = Util::find_if(sorted, [&](const VisualStudioInstance& vs_instance) {
return vs_instance.major_version() == "14";
@@ -170,7 +170,7 @@ namespace vcpkg::VisualStudio
for (const VisualStudioInstance& vs_instance : sorted)
{
const std::string major_version = vs_instance.major_version();
- if (major_version == "15")
+ if (major_version >= "15")
{
const fs::path vc_dir = vs_instance.root_path / "VC";
@@ -202,8 +202,8 @@ namespace vcpkg::VisualStudio
// Locate the "best" MSVC toolchain version
const fs::path msvc_path = vc_dir / "Tools" / "MSVC";
std::vector<fs::path> msvc_subdirectories = fs.get_files_non_recursive(msvc_path);
- Util::unstable_keep_if(msvc_subdirectories,
- [&fs](const fs::path& path) { return fs.is_directory(path); });
+ Util::erase_remove_if(msvc_subdirectories,
+ [&fs](const fs::path& path) { return !fs.is_directory(path); });
// Sort them so that latest comes first
std::sort(
@@ -217,7 +217,7 @@ namespace vcpkg::VisualStudio
paths_examined.push_back(dumpbin_path);
if (fs.exists(dumpbin_path))
{
- const Toolset v141_toolset {
+ const Toolset v141_toolset{
vs_instance.root_path, dumpbin_path, vcvarsall_bat, {}, V_141, supported_architectures};
const auto english_language_pack = dumpbin_path.parent_path() / "1033";
@@ -232,12 +232,12 @@ namespace vcpkg::VisualStudio
if (v140_is_available)
{
- const Toolset v140_toolset {vs_instance.root_path,
- dumpbin_path,
- vcvarsall_bat,
- {"-vcvars_ver=14.0"},
- V_140,
- supported_architectures};
+ const Toolset v140_toolset{vs_instance.root_path,
+ dumpbin_path,
+ vcvarsall_bat,
+ {"-vcvars_ver=14.0"},
+ V_140,
+ supported_architectures};
found_toolsets.push_back(v140_toolset);
}