aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCurtis J Bezault <curtbezault@gmail.com>2019-08-20 08:47:26 -0700
committerGitHub <noreply@github.com>2019-08-20 08:47:26 -0700
commit4da95d667c8600c80b4b5731631ebb7bcbc91f1b (patch)
treefaa447f7b1beb0d784bbd353a8aa6b449ae71ba2
parent463a67897c8249d996f7b41cabb9ac1fb5a35af9 (diff)
downloadvcpkg-4da95d667c8600c80b4b5731631ebb7bcbc91f1b.tar.gz
vcpkg-4da95d667c8600c80b4b5731631ebb7bcbc91f1b.zip
[vcpkg]Port toolchains (#7687)
* checkpoint commit * Only set VCPKG_ENV_OVERRIDES_FILE if it exists * First pass at working port-toolchain * Update VERSION.txt * Return rvalue * Fix compilation error * Some fixes are requested by @ubsan * Fix another compilation error
-rw-r--r--scripts/get_triplet_environment.cmake4
-rw-r--r--scripts/ports.cmake11
-rw-r--r--toolsrc/VERSION.txt2
-rw-r--r--toolsrc/include/vcpkg/base/util.h11
-rw-r--r--toolsrc/include/vcpkg/build.h3
-rw-r--r--toolsrc/src/vcpkg/build.cpp84
-rw-r--r--toolsrc/src/vcpkg/dependencies.cpp2
7 files changed, 79 insertions, 38 deletions
diff --git a/scripts/get_triplet_environment.cmake b/scripts/get_triplet_environment.cmake
index 0457cee9b..3b0b9fbef 100644
--- a/scripts/get_triplet_environment.cmake
+++ b/scripts/get_triplet_environment.cmake
@@ -1,6 +1,6 @@
include(${CMAKE_TRIPLET_FILE})
-if (DEFINED CMAKE_ENV_OVERRIDES_FILE)
- include(${CMAKE_ENV_OVERRIDES_FILE} OPTIONAL)
+if (DEFINED VCPKG_ENV_OVERRIDES_FILE)
+ include(${VCPKG_ENV_OVERRIDES_FILE})
endif()
# GUID used as a flag - "cut here line"
diff --git a/scripts/ports.cmake b/scripts/ports.cmake
index 86b2719d5..7130825e2 100644
--- a/scripts/ports.cmake
+++ b/scripts/ports.cmake
@@ -67,7 +67,16 @@ if(CMD MATCHES "^BUILD$")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR})
include(${CMAKE_TRIPLET_FILE})
- include(${ENV_OVERRIDES_FILE} OPTIONAL)
+
+ if (DEFINED VCPKG_ENV_OVERRIDES_FILE)
+ include(${VCPKG_ENV_OVERRIDES_FILE})
+ endif()
+
+ if (DEFINED VCPKG_PORT_TOOLCHAINS)
+ foreach(VCPKG_PORT_TOOLCHAIN ${VCPKG_PORT_TOOLCHAINS})
+ include(${VCPKG_PORT_TOOLCHAIN})
+ endforeach()
+ endif()
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
include(${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_common_definitions.cmake)
diff --git a/toolsrc/VERSION.txt b/toolsrc/VERSION.txt
index 0342c24ab..43464a247 100644
--- a/toolsrc/VERSION.txt
+++ b/toolsrc/VERSION.txt
@@ -1 +1 @@
-"2019.07.19"
+"2019.08.16"
diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h
index 40022a012..3d32e3aa8 100644
--- a/toolsrc/include/vcpkg/base/util.h
+++ b/toolsrc/include/vcpkg/base/util.h
@@ -1,6 +1,7 @@
#pragma once
#include <algorithm>
+#include <functional>
#include <map>
#include <mutex>
#include <type_traits>
@@ -121,21 +122,23 @@ namespace vcpkg::Util
}
}
- template<class Range>
- void sort(Range& cont)
+ template<class Range, class Comp = std::less<typename Range::value_type>>
+ void sort(Range& cont, Comp comp = Comp())
{
using std::begin;
using std::end;
- std::sort(begin(cont), end(cont));
+ std::sort(begin(cont), end(cont), comp);
}
template<class Range>
- void sort_unique_erase(Range& cont)
+ Range&& sort_unique_erase(Range&& cont)
{
using std::begin;
using std::end;
std::sort(begin(cont), end(cont));
cont.erase(std::unique(begin(cont), end(cont)), end(cont));
+
+ return std::forward<Range>(cont);
}
template<class Range1, class Range2>
diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h
index cd1821b32..4f6397662 100644
--- a/toolsrc/include/vcpkg/build.h
+++ b/toolsrc/include/vcpkg/build.h
@@ -270,6 +270,9 @@ namespace vcpkg::Build
std::string key;
std::string value;
+ AbiEntry() = default;
+ AbiEntry(const std::string& key, const std::string& value) : key(key), value(value) {}
+
bool operator<(const AbiEntry& other) const
{
return key < other.key || (key == other.key && value < other.value);
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);