[vcpkg] Miscellaneous internal improvements extracted from #15424 (#15677)

* [vcpkg] Miscellaneous internal improvements extracted from #15424

* [vcpkg] CR comments

* [armadillo] Use vcpkg_from_git() to workaround gitlab missing archive

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
This commit is contained in:
ras0219 2021-02-02 15:00:33 -08:00 committed by GitHub
parent 3b4a4e4b5c
commit 5793c4bd9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 151 additions and 109 deletions

View File

@ -1,5 +1,6 @@
Source: armadillo
Version: 10.1.0
Port-Version: 1
Homepage: https://gitlab.com/conradsnicta/armadillo-code
Description: Armadillo is a high quality linear algebra library (matrix maths) for the C++ language, aiming towards a good balance between speed and ease of use
Build-Depends: blas, lapack

View File

@ -1,12 +1,9 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_gitlab(
GITLAB_URL https://gitlab.com
vcpkg_from_git(
OUT_SOURCE_PATH SOURCE_PATH
REPO conradsnicta/armadillo-code
REF 24b4762cbfbd3ad14c99a4854acd3560559a3195 #v 10.1.0
SHA512 224a875d21168f80e00604185ef72cb559a86a350a037c9cd1660a6f4dcc68f2ebf6dbc073f234a3cb03d35d959adb44ec49af88b11e3aaca9e0017c9c3fcee6
HEAD_REF 10.1.x
URL https://gitlab.com/conradsnicta/armadillo-code
REF 24b4762cbfbd3ad14c99a4854acd3560559a3195 # v10.1.0
PATCHES
remove_custom_modules.patch
fix-CMakePath.patch

View File

@ -36,6 +36,8 @@ jobs:
arguments: '-buildTests'
- bash: toolsrc/build.rel/vcpkg-test
displayName: 'Run vcpkg tests'
env:
VCPKG_DEBUG: 1
- task: PowerShell@2
displayName: 'Run vcpkg end-to-end tests'
inputs:

View File

@ -33,6 +33,8 @@ jobs:
arguments: '-buildTests'
- bash: toolsrc/build.rel/vcpkg-test
displayName: 'Run vcpkg tests'
env:
VCPKG_DEBUG: 1
- task: PowerShell@2
displayName: 'Run vcpkg end-to-end tests'
inputs:

View File

@ -45,6 +45,7 @@ jobs:
rmdir /s /q build.x86.debug > nul 2> nul
cmake.exe -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DVCPKG_DEVELOPMENT_WARNINGS=ON -DVCPKG_WARNINGS_AS_ERRORS=ON -DVCPKG_BUILD_FUZZING=ON -B build.x86.debug -S toolsrc
ninja.exe -C build.x86.debug
set VCPKG_DEBUG=1
build.x86.debug\vcpkg-test.exe
cmake -G "Visual Studio 16 2019" -A Win32 -T v140 -DBUILD_TESTING=OFF -DVCPKG_DEVELOPMENT_WARNINGS=OFF -DVCPKG_WARNINGS_AS_ERRORS=ON -DVCPKG_BUILD_FUZZING=OFF -B build.x86.vs2015 -S toolsrc
cmake --build build.x86.vs2015

View File

@ -32,6 +32,12 @@ namespace Catch
value.package_spec.triplet());
}
};
template<>
struct StringMaker<vcpkg::Triplet>
{
static const std::string& convert(const vcpkg::Triplet& triplet) { return triplet.canonical_name(); }
};
}
namespace vcpkg::Test

View File

@ -287,6 +287,16 @@ namespace vcpkg
template<class F>
using map_t = decltype(std::declval<F&>()(std::declval<const T&>()));
template<class F, class U = map_t<F>>
Optional<U> map(F f) const&
{
if (has_value())
{
return f(this->m_base.value());
}
return nullopt;
}
template<class F, class U = map_t<F>>
U then(F f) const&
{
@ -294,15 +304,22 @@ namespace vcpkg
{
return f(this->m_base.value());
}
else
{
return nullopt;
}
return nullopt;
}
template<class F>
using move_map_t = decltype(std::declval<F&>()(std::declval<T&&>()));
template<class F, class U = move_map_t<F>>
Optional<U> map(F f) &&
{
if (has_value())
{
return f(std::move(this->m_base.value()));
}
return nullopt;
}
template<class F, class U = move_map_t<F>>
U then(F f) &&
{
@ -310,10 +327,7 @@ namespace vcpkg
{
return f(std::move(this->m_base.value()));
}
else
{
return nullopt;
}
return nullopt;
}
friend bool operator==(const Optional& lhs, const Optional& rhs)

View File

@ -132,7 +132,7 @@ namespace vcpkg::Dependencies
RequestType request_type;
Optional<const BinaryParagraph&> core_paragraph() const;
std::vector<PackageSpec> dependencies(Triplet triplet) const;
std::vector<PackageSpec> dependencies() const;
private:
Optional<InstalledPackageView> m_installed_package;

View File

@ -23,7 +23,6 @@ namespace vcpkg::Remove
extern const CommandStructure COMMAND_STRUCTURE;
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet);
void remove_package(const VcpkgPaths& paths, const PackageSpec& spec, StatusParagraphs* status_db);
struct RemoveCommand : Commands::TripletCommand

View File

@ -2,10 +2,11 @@
#include <catch2/catch.hpp>
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.h>
int main(int argc, char** argv)
{
vcpkg::Debug::g_debugging = true;
if (vcpkg::System::get_environment_variable("VCPKG_DEBUG").value_or("") == "1") vcpkg::Debug::g_debugging = true;
return Catch::Session().run(argc, argv);
}

View File

@ -1,38 +0,0 @@
#include <catch2/catch.hpp>
#include <vcpkg/base/files.h>
#include <vcpkg/build.h>
#include <vcpkg/commands.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>
#include <iterator>
#include <string>
#include <vcpkg-test/util.h>
using namespace vcpkg;
TEST_CASE ("build smoke test", "[commands-build]")
{
static const std::string args_raw[] = {"build", "zlib"};
auto& fs_wrapper = Files::get_real_filesystem();
VcpkgCmdArguments args = VcpkgCmdArguments::create_from_arg_sequence(std::begin(args_raw), std::end(args_raw));
args.binary_caching = false;
args.buildtrees_root_dir =
std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("buildtrees")));
args.install_root_dir =
std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("installed")));
args.packages_root_dir =
std::make_unique<std::string>(fs::u8string(Test::base_temporary_directory() / fs::u8path("packages")));
VcpkgPaths paths(fs_wrapper, args);
if (fs_wrapper.exists(paths.buildtrees)) fs_wrapper.remove_all_inside(paths.buildtrees, VCPKG_LINE_INFO);
if (fs_wrapper.exists(paths.packages)) fs_wrapper.remove_all_inside(paths.packages, VCPKG_LINE_INFO);
if (fs_wrapper.exists(paths.installed)) fs_wrapper.remove_all_inside(paths.installed, VCPKG_LINE_INFO);
auto triplet = default_triplet(args);
const auto exit_code = Build::Command::perform(args, paths, triplet);
REQUIRE(exit_code == 0);
REQUIRE(paths.get_filesystem().is_directory(paths.buildtrees / fs::u8path("zlib")));
}

View File

@ -691,13 +691,21 @@ TEST_CASE ("Serialize all the ports", "[manifests]")
const auto manifest = dir / fs::u8path("vcpkg.json");
if (fs.exists(control))
{
INFO(fs::u8string(control));
auto contents = fs.read_contents(control, VCPKG_LINE_INFO);
auto pghs = Paragraphs::parse_paragraphs(contents, fs::u8string(control));
REQUIRE(pghs);
scfs.push_back(std::move(*SourceControlFile::parse_control_file(
fs::u8string(control), std::move(pghs).value_or_exit(VCPKG_LINE_INFO))
.value_or_exit(VCPKG_LINE_INFO)));
auto scf = SourceControlFile::parse_control_file(fs::u8string(control),
std::move(pghs).value_or_exit(VCPKG_LINE_INFO));
if (!scf)
{
INFO(scf.error()->name);
INFO(scf.error()->error);
REQUIRE(scf);
}
scfs.push_back(std::move(*scf.value_or_exit(VCPKG_LINE_INFO)));
}
else if (fs.exists(manifest))
{

View File

@ -80,6 +80,33 @@ TEST_CASE ("value conversion", "[optional]")
REQUIRE(o_v.get()->size() == 3);
}
TEST_CASE ("optional.map", "[optional]")
{
using vcpkg::NullOpt;
using vcpkg::nullopt;
using vcpkg::Optional;
const Optional<std::unique_ptr<int>> move_only;
Optional<int*> m = move_only.map([](auto&& p) { return p.get(); });
Optional<Optional<int*>> n =
move_only.map([](auto&& p) -> Optional<int*> { return p ? Optional<int*>{p.get()} : nullopt; });
Optional<NullOpt> o = move_only.map([](auto&&) { return nullopt; });
Optional<int> five = 5;
struct MoveTest
{
int operator()(int&&) { return 1; }
int operator()(const int&) { return -1; }
} move_test;
Optional<int> dst = std::move(five).map(move_test);
REQUIRE(dst == 1);
Optional<int> dst2 = five.map(move_test);
REQUIRE(dst2 == -1);
}
TEST_CASE ("common_projection", "[optional]")
{
using vcpkg::Util::common_projection;

View File

@ -983,7 +983,8 @@ namespace vcpkg::Build
const auto& abi_info = action.abi_info.value_or_exit(VCPKG_LINE_INFO);
const auto& triplet_abi = paths.get_triplet_info(abi_info);
abi_tag_entries.emplace_back("triplet", triplet_abi);
abi_tag_entries.emplace_back("triplet", triplet.canonical_name());
abi_tag_entries.emplace_back("triplet_abi", triplet_abi);
abi_entries_from_abi_info(abi_info, abi_tag_entries);
// If there is an unusually large number of files in the port then

View File

@ -271,7 +271,7 @@ namespace vcpkg::Commands::CI
std::vector<FullPackageSpec> unknown;
std::map<PackageSpec, Build::BuildResult> known;
std::map<PackageSpec, std::vector<std::string>> features;
std::unordered_map<std::string, SourceControlFileLocation> default_feature_provider;
Dependencies::ActionPlan plan;
std::map<PackageSpec, std::string> abi_map;
};
@ -324,28 +324,20 @@ namespace vcpkg::Commands::CI
auto timer = Chrono::ElapsedTimer::create_started();
Checks::check_exit(VCPKG_LINE_INFO,
action_plan.already_installed.empty(),
"Cannot use CI command with packages already installed.");
Checks::check_exit(VCPKG_LINE_INFO, action_plan.already_installed.empty());
Checks::check_exit(VCPKG_LINE_INFO, action_plan.remove_actions.empty());
Build::compute_all_abis(paths, action_plan, var_provider, {});
auto precheck_results = binary_provider_precheck(paths, action_plan, binaryprovider);
{
vcpkg::System::BufferedPrint stdout_print;
auto precheck_results = binary_provider_precheck(paths, action_plan, binaryprovider);
for (auto&& action : action_plan.install_actions)
{
auto p = &action;
ret->abi_map.emplace(action.spec, action.abi_info.value_or_exit(VCPKG_LINE_INFO).package_abi);
ret->features.emplace(action.spec, action.feature_list);
if (auto scfl = p->source_control_file_location.get())
{
auto emp = ret->default_feature_provider.emplace(p->spec.name(), scfl->clone());
emp.first->second.source_control_file->core_paragraph->default_features = p->feature_list;
p->build_options = vcpkg::Build::backcompat_prohibiting_package_options;
}
auto precheck_result = precheck_results.at(&action);
bool b_will_build = false;
@ -399,6 +391,30 @@ namespace vcpkg::Commands::CI
}
} // flush stdout_print
// This algorithm consumes the previous action plan to build and return a reduced one.
std::vector<InstallPlanAction>&& input_install_actions = std::move(action_plan.install_actions);
std::vector<InstallPlanAction*> rev_install_actions;
rev_install_actions.reserve(input_install_actions.size());
std::set<PackageSpec> to_keep;
for (auto it = input_install_actions.rbegin(); it != input_install_actions.rend(); ++it)
{
if (!Util::Sets::contains(ret->known, it->spec))
{
to_keep.insert(it->spec);
}
if (Util::Sets::contains(to_keep, it->spec))
{
rev_install_actions.push_back(&*it);
to_keep.insert(it->package_dependencies.begin(), it->package_dependencies.end());
}
}
for (auto it = rev_install_actions.rbegin(); it != rev_install_actions.rend(); ++it)
{
ret->plan.install_actions.push_back(std::move(**it));
}
System::printf("Time to determine pass/fail: %s\n", timer.elapsed());
return ret;
}
@ -480,10 +496,6 @@ namespace vcpkg::Commands::CI
return FullPackageSpec{spec, std::move(default_features)};
});
auto split_specs = find_unknown_ports_for_ci(
paths, exclusions_set, provider, var_provider, all_default_full_specs, binaryprovider);
PortFileProvider::MapPortFileProvider new_default_provider(split_specs->default_feature_provider);
Dependencies::CreateInstallPlanOptions serialize_options;
struct RandomizerInstance : Graphs::Randomizer
@ -503,8 +515,10 @@ namespace vcpkg::Commands::CI
serialize_options.randomizer = &randomizer_instance;
}
auto action_plan = Dependencies::create_feature_install_plan(
new_default_provider, var_provider, split_specs->unknown, status_db, serialize_options);
auto split_specs = find_unknown_ports_for_ci(
paths, exclusions_set, provider, var_provider, all_default_full_specs, binaryprovider);
auto& action_plan = split_specs->plan;
for (auto&& action : action_plan.install_actions)
{

View File

@ -503,7 +503,7 @@ namespace vcpkg::Dependencies
return nullopt;
}
std::vector<PackageSpec> ExportPlanAction::dependencies(Triplet) const
std::vector<PackageSpec> ExportPlanAction::dependencies() const
{
if (auto p_ip = m_installed_package.get())
return p_ip->dependencies();
@ -590,7 +590,7 @@ namespace vcpkg::Dependencies
std::vector<PackageSpec> adjacency_list(const ExportPlanAction& plan) const override
{
return plan.dependencies(plan.spec.triplet());
return plan.dependencies();
}
ExportPlanAction load_vertex_data(const PackageSpec& spec) const override

View File

@ -378,7 +378,7 @@ namespace vcpkg::Export::Prefab
for (const auto& action : export_plan)
{
const std::string name = action.spec.name();
auto dependencies = action.dependencies(default_triplet);
auto dependencies = action.dependencies();
const auto action_build_info = Build::read_build_info(utils, paths.build_info_file_path(action.spec));
const bool is_empty_package = action_build_info.policies.is_enabled(Build::BuildPolicy::EMPTY_PACKAGE);

View File

@ -399,6 +399,16 @@ namespace vcpkg::Paragraphs
bcf.features =
Util::fmap(*p, [&](auto&& raw_feature) -> BinaryParagraph { return BinaryParagraph(raw_feature); });
if (bcf.core_paragraph.spec != spec)
{
return Strings::concat("Mismatched spec in package at ",
fs::u8string(paths.package_dir(spec)),
": expected ",
spec,
", actual ",
bcf.core_paragraph.spec);
}
return bcf;
}

View File

@ -214,7 +214,9 @@ namespace vcpkg::Remove
&valid_arguments,
};
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet)
void RemoveCommand::perform_and_exit(const VcpkgCmdArguments& args,
const VcpkgPaths& paths,
Triplet default_triplet) const
{
if (paths.manifest_mode_enabled())
{
@ -332,11 +334,4 @@ namespace vcpkg::Remove
Checks::exit_success(VCPKG_LINE_INFO);
}
void RemoveCommand::perform_and_exit(const VcpkgCmdArguments& args,
const VcpkgPaths& paths,
Triplet default_triplet) const
{
Remove::perform_and_exit(args, paths, default_triplet);
}
}

View File

@ -1202,6 +1202,12 @@ namespace vcpkg
return ret;
}
static bool is_dependency_trivial(const Dependency& dep)
{
return dep.features.empty() && dep.platform.is_empty() && dep.extra_info.is_empty() &&
dep.constraint.type == Versions::Constraint::Type::None;
}
static Json::Object serialize_manifest_impl(const SourceControlFile& scf, bool debug)
{
auto serialize_paragraph =
@ -1246,8 +1252,7 @@ namespace vcpkg
}
};
auto serialize_dependency = [&](Json::Array& arr, const Dependency& dep) {
if (dep.features.empty() && dep.platform.is_empty() && dep.extra_info.is_empty() &&
dep.constraint.type == Versions::Constraint::Type::None)
if (is_dependency_trivial(dep))
{
arr.push_back(Json::Value::string(dep.name));
}

View File

@ -81,38 +81,30 @@ namespace vcpkg
}
else
{
auto vcpkg_default_triplet_env = System::get_environment_variable("VCPKG_DEFAULT_TRIPLET");
if (auto v = vcpkg_default_triplet_env.get())
{
return Triplet::from_canonical_name(std::move(*v));
}
else
{
#if defined(_WIN32)
return Triplet::from_canonical_name("x86-windows");
return Triplet::from_canonical_name("x86-windows");
#elif defined(__APPLE__)
return Triplet::from_canonical_name("x64-osx");
return Triplet::from_canonical_name("x64-osx");
#elif defined(__FreeBSD__)
return Triplet::from_canonical_name("x64-freebsd");
return Triplet::from_canonical_name("x64-freebsd");
#elif defined(__OpenBSD__)
return Triplet::from_canonical_name("x64-openbsd");
return Triplet::from_canonical_name("x64-openbsd");
#elif defined(__GLIBC__)
#if defined(__aarch64__)
return Triplet::from_canonical_name("arm64-linux");
return Triplet::from_canonical_name("arm64-linux");
#elif defined(__arm__)
return Triplet::from_canonical_name("arm-linux");
return Triplet::from_canonical_name("arm-linux");
#elif defined(__s390x__)
return Triplet::from_canonical_name("s390x-linux");
return Triplet::from_canonical_name("s390x-linux");
#elif (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) && \
defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
return Triplet::from_canonical_name("ppc64le-linux");
return Triplet::from_canonical_name("ppc64le-linux");
#else
return Triplet::from_canonical_name("x64-linux");
return Triplet::from_canonical_name("x64-linux");
#endif
#else
return Triplet::from_canonical_name("x64-linux-musl");
return Triplet::from_canonical_name("x64-linux-musl");
#endif
}
}
}
}

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "3ec327570d6731dbd87ebdee5a0cebdd8bd62ed7",
"version-string": "10.1.0",
"port-version": 1
},
{
"git-tree": "fa82d7d3b12f794825dad7fddcda2b08f268c2b2",
"version-string": "10.1.0",

View File

@ -138,7 +138,7 @@
},
"armadillo": {
"baseline": "10.1.0",
"port-version": 0
"port-version": 1
},
"arrayfire": {
"baseline": "3.7.3",