aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorPhil Christensen <philc@microsoft.com>2019-08-23 11:18:34 -0700
committerGitHub <noreply@github.com>2019-08-23 11:18:34 -0700
commitbd4678610b221ae6cd4911295e84808ea7924cc6 (patch)
tree1e51033d924c41cd147f33665990b75fe19ff4b7 /toolsrc/src
parent1245f1dbfc383d33b2fa576f010644de9687280e (diff)
parentcf447c050c734fc71e5254ea9e05e1bc4a9d208d (diff)
downloadvcpkg-bd4678610b221ae6cd4911295e84808ea7924cc6.tar.gz
vcpkg-bd4678610b221ae6cd4911295e84808ea7924cc6.zip
Merge branch 'master' into multi_line_depends
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/base/files.cpp32
-rw-r--r--toolsrc/src/vcpkg/build.cpp84
-rw-r--r--toolsrc/src/vcpkg/dependencies.cpp2
-rw-r--r--toolsrc/src/vcpkg/export.cpp37
4 files changed, 104 insertions, 51 deletions
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp
index bbf37fd25..5ebe8d834 100644
--- a/toolsrc/src/vcpkg/base/files.cpp
+++ b/toolsrc/src/vcpkg/base/files.cpp
@@ -8,9 +8,8 @@
#include <vcpkg/base/util.h>
#include <vcpkg/base/work_queue.h>
-#if defined(__linux__) || defined(__APPLE__)
+#if !defined(_WIN32)
#include <fcntl.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -396,7 +395,7 @@ namespace vcpkg::Files
{
this->rename(oldpath, newpath, ec);
Util::unused(temp_suffix);
-#if defined(__linux__) || defined(__APPLE__)
+#if !defined(_WIN32)
if (ec)
{
auto dst = newpath;
@@ -419,6 +418,33 @@ namespace vcpkg::Files
auto written_bytes = sendfile(o_fd, i_fd, &bytes, info.st_size);
#elif defined(__APPLE__)
auto written_bytes = fcopyfile(i_fd, o_fd, 0, COPYFILE_ALL);
+#else
+ ssize_t written_bytes = 0;
+ {
+ constexpr std::size_t buffer_length = 4096;
+ auto buffer = std::make_unique<unsigned char[]>(buffer_length);
+ while (auto read_bytes = read(i_fd, buffer.get(), buffer_length))
+ {
+ if (read_bytes == -1)
+ {
+ written_bytes = -1;
+ break;
+ }
+ auto remaining = read_bytes;
+ while (remaining > 0) {
+ auto read_result = write(o_fd, buffer.get(), remaining);
+ if (read_result == -1)
+ {
+ written_bytes = -1;
+ // break two loops
+ goto copy_failure;
+ }
+ remaining -= read_result;
+ }
+ }
+
+ copy_failure: ;
+ }
#endif
if (written_bytes == -1)
{
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index 2114b7415..aeb01b27d 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -311,8 +311,8 @@ namespace vcpkg::Build
const std::set<std::string>& feature_list,
const Triplet& triplet)
{
- return Util::fmap(get_dependencies(scf, feature_list, triplet),
- [&](const Features& feat) { return feat.name; });
+ return Util::sort_unique_erase(
+ Util::fmap(get_dependencies(scf, feature_list, triplet), [&](const Features& feat) { return feat.name; }));
}
static std::vector<FeatureSpec> compute_required_feature_specs(const BuildPackageConfig& config,
@@ -397,7 +397,6 @@ namespace vcpkg::Build
{"CURRENT_PORT_DIR", config.port_dir},
{"TARGET_TRIPLET", triplet.canonical_name()},
{"TARGET_TRIPLET_FILE", paths.get_triplet_file_path(triplet).u8string()},
- {"ENV_OVERRIDES_FILE", config.port_dir / "environment-overrides.cmake"},
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
{"VCPKG_USE_HEAD_VERSION", Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
{"DOWNLOADS", paths.downloads},
@@ -413,6 +412,33 @@ namespace vcpkg::Build
variables.push_back({"GIT", git_exe_path});
}
+ const Files::Filesystem& fs = paths.get_filesystem();
+ if (fs.is_regular_file(config.port_dir / "environment-overrides.cmake"))
+ {
+ variables.emplace_back("VCPKG_ENV_OVERRIDES_FILE", config.port_dir / "environment-overrides.cmake");
+ }
+
+ std::vector<FeatureSpec> dependencies =
+ filter_dependencies_to_specs(config.scfl.source_control_file->core_paragraph->depends, triplet);
+
+ std::vector<std::string> port_toolchains;
+ for (const FeatureSpec& dependency : dependencies)
+ {
+ const fs::path port_toolchain_path = paths.installed / dependency.triplet().canonical_name() / "share" /
+ dependency.spec().name() / "port-toolchain.cmake";
+
+ if (fs.is_regular_file(port_toolchain_path))
+ {
+ System::print2(port_toolchain_path.u8string());
+ port_toolchains.emplace_back(port_toolchain_path.u8string());
+ }
+ }
+
+ if (!port_toolchains.empty())
+ {
+ variables.emplace_back("VCPKG_PORT_TOOLCHAINS", Strings::join(";", port_toolchains));
+ }
+
return variables;
}
@@ -620,58 +646,53 @@ namespace vcpkg::Build
const int max_port_file_count = 100;
// the order of recursive_directory_iterator is undefined so save the names to sort
- std::vector<std::pair<std::string, std::string>> hashes_files;
+ std::vector<AbiEntry> port_files;
for (auto& port_file : fs::stdfs::recursive_directory_iterator(config.port_dir))
{
if (fs::is_regular_file(fs.status(VCPKG_LINE_INFO, port_file)))
{
- hashes_files.emplace_back(vcpkg::Hash::get_file_hash(fs, port_file, "SHA1"),
- port_file.path().filename().u8string());
+ port_files.emplace_back(port_file.path().filename().u8string(),
+ vcpkg::Hash::get_file_hash(fs, port_file, "SHA1"));
- if (hashes_files.size() > max_port_file_count)
+ if (port_files.size() > max_port_file_count)
{
- abi_tag_entries.emplace_back(AbiEntry{"no_hash_max_portfile", ""});
+ abi_tag_entries.emplace_back("no_hash_max_portfile", "");
break;
}
}
}
- if (hashes_files.size() <= max_port_file_count)
+ if (port_files.size() <= max_port_file_count)
{
- Util::sort(hashes_files);
+ Util::sort(port_files, [](const AbiEntry& l, const AbiEntry& r) {
+ return l.value < r.value || (l.value == r.value && l.key < r.key);
+ });
- for (auto& hash_file : hashes_files)
- {
- // We've already sorted by hash so it's safe to write down the
- // filename, which will be consistent across machines.
- abi_tag_entries.emplace_back(AbiEntry{std::move(hash_file.second), std::move(hash_file.first)});
- }
+ std::move(port_files.begin(), port_files.end(), std::back_inserter(abi_tag_entries));
}
- abi_tag_entries.emplace_back(AbiEntry{"cmake", paths.get_tool_version(Tools::CMAKE)});
+ abi_tag_entries.emplace_back("cmake", paths.get_tool_version(Tools::CMAKE));
#if defined(_WIN32)
- abi_tag_entries.emplace_back(AbiEntry{"powershell", paths.get_tool_version("powershell-core")});
+ abi_tag_entries.emplace_back("powershell", paths.get_tool_version("powershell-core"));
#endif
- abi_tag_entries.emplace_back(AbiEntry{
+ abi_tag_entries.emplace_back(
"vcpkg_fixup_cmake_targets",
- vcpkg::Hash::get_file_hash(fs, paths.scripts / "cmake" / "vcpkg_fixup_cmake_targets.cmake", "SHA1")});
-
- abi_tag_entries.emplace_back(AbiEntry{"triplet", pre_build_info.triplet_abi_tag});
+ vcpkg::Hash::get_file_hash(fs, paths.scripts / "cmake" / "vcpkg_fixup_cmake_targets.cmake", "SHA1"));
- const std::string features = Strings::join(";", config.feature_list);
- abi_tag_entries.emplace_back(AbiEntry{"features", features});
+ abi_tag_entries.emplace_back("triplet", pre_build_info.triplet_abi_tag);
+ abi_tag_entries.emplace_back("features", Strings::join(";", config.feature_list));
if (pre_build_info.public_abi_override)
{
- abi_tag_entries.emplace_back(AbiEntry{
+ abi_tag_entries.emplace_back(
"public_abi_override",
- Hash::get_string_hash(pre_build_info.public_abi_override.value_or_exit(VCPKG_LINE_INFO), "SHA1")});
+ Hash::get_string_hash(pre_build_info.public_abi_override.value_or_exit(VCPKG_LINE_INFO), "SHA1"));
}
if (config.build_package_options.use_head_version == UseHeadVersion::YES)
- abi_tag_entries.emplace_back(AbiEntry{"head", ""});
+ abi_tag_entries.emplace_back("head", "");
const std::string full_abi_info =
Strings::join("", abi_tag_entries, [](const AbiEntry& p) { return p.key + " " + p.value + "\n"; });
@@ -765,6 +786,7 @@ namespace vcpkg::Build
const std::string& name = config.scf.core_paragraph->name;
std::vector<FeatureSpec> required_fspecs = compute_required_feature_specs(config, status_db);
+ std::vector<FeatureSpec> required_fspecs_copy = required_fspecs;
// extract out the actual package ids
auto dep_pspecs = Util::fmap(required_fspecs, [](FeatureSpec const& fspec) { return fspec.spec(); });
@@ -1027,8 +1049,12 @@ namespace vcpkg::Build
if (port)
{
- args.emplace_back("CMAKE_ENV_OVERRIDES_FILE",
- port.value_or_exit(VCPKG_LINE_INFO).source_location / "environment-overrides.cmake");
+ const SourceControlFileLocation& scfl = port.value_or_exit(VCPKG_LINE_INFO);
+
+ if (paths.get_filesystem().is_regular_file(scfl.source_location / "environment-overrides.cmake"))
+ {
+ args.emplace_back("VCPKG_ENV_OVERRIDES_FILE", scfl.source_location / "environment-overrides.cmake");
+ }
}
const auto cmd_launch_cmake = System::make_cmake_cmd(cmake_exe_path, ports_cmake_script_path, args);
diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp
index ab14934a2..7c3f2df4c 100644
--- a/toolsrc/src/vcpkg/dependencies.cpp
+++ b/toolsrc/src/vcpkg/dependencies.cpp
@@ -674,7 +674,7 @@ namespace vcpkg::Dependencies
}
// The feature was not previously installed. Mark the cluster
- //(aka the entire port) to be removed before re-adding it.
+ // (aka the entire port) to be removed before re-adding it.
mark_minus(cluster, graph, graph_plan, prevent_default_features);
return follow_plus_dependencies(feature, cluster, graph, graph_plan, prevent_default_features);
diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp
index 8f5034eee..5ceb47adf 100644
--- a/toolsrc/src/vcpkg/export.cpp
+++ b/toolsrc/src/vcpkg/export.cpp
@@ -339,26 +339,27 @@ namespace vcpkg::Export
struct OptionPair
{
- const std::string& name;
+ const StringLiteral& name;
Optional<std::string>& out_opt;
};
- const auto options_implies =
- [&](const std::string& main_opt_name, bool main_opt, Span<const OptionPair> implying_opts) {
- if (main_opt)
- {
- for (auto&& opt : implying_opts)
- opt.out_opt = maybe_lookup(options.settings, opt.name);
- }
- else
- {
- for (auto&& opt : implying_opts)
- Checks::check_exit(VCPKG_LINE_INFO,
- !maybe_lookup(options.settings, opt.name),
- "%s is only valid with %s",
- opt.name,
- main_opt_name);
- }
- };
+ const auto options_implies = [&](const StringLiteral& main_opt_name,
+ bool is_main_opt,
+ const std::initializer_list<OptionPair>& implying_opts) {
+ if (is_main_opt)
+ {
+ for (auto&& opt : implying_opts)
+ opt.out_opt = maybe_lookup(options.settings, opt.name);
+ }
+ else
+ {
+ for (auto&& opt : implying_opts)
+ Checks::check_exit(VCPKG_LINE_INFO,
+ !maybe_lookup(options.settings, opt.name),
+ "%s is only valid with %s",
+ opt.name,
+ main_opt_name);
+ }
+ };
#if defined(_MSC_VER) && _MSC_VER <= 1900
// there's a bug in VS 2015 that causes a bunch of "unreferenced local variable" warnings