diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-08 14:12:49 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-08 14:12:49 -0800 |
| commit | 6e9d17f73c01c3ad07875ca79196ed2f5e2d3896 (patch) | |
| tree | 4b4b22f0bd6aaca36ca56ea1d31ac68c297f0b8e /toolsrc/src | |
| parent | eaebe2888ab97de74200904807ae884419ccc195 (diff) | |
| download | vcpkg-6e9d17f73c01c3ad07875ca79196ed2f5e2d3896.tar.gz vcpkg-6e9d17f73c01c3ad07875ca79196ed2f5e2d3896.zip | |
Introduce BUILD_INFO file. Significant change in the way static/dynamic is
handled
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/BuildInfo.cpp | 46 | ||||
| -rw-r--r-- | toolsrc/src/post_build_lint.cpp | 18 | ||||
| -rw-r--r-- | toolsrc/src/triplet.cpp | 10 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_paths.cpp | 5 |
4 files changed, 64 insertions, 15 deletions
diff --git a/toolsrc/src/BuildInfo.cpp b/toolsrc/src/BuildInfo.cpp new file mode 100644 index 000000000..dc8d90e2e --- /dev/null +++ b/toolsrc/src/BuildInfo.cpp @@ -0,0 +1,46 @@ +#include "BuildInfo.h" +#include "vcpkg_Checks.h" +#include "vcpkglib_helpers.h" + +namespace vcpkg +{ + // + namespace BuildInfoRequiredField + { + static const std::string CRT_LINKAGE = "CRTLinkage"; + static const std::string LIBRARY_LINKAGE = "LibraryLinkage"; + } + + BuildInfo BuildInfo::create(const std::unordered_map<std::string, std::string>& pgh) + { + BuildInfo build_info; + build_info.crt_linkage = details::required_field(pgh, BuildInfoRequiredField::CRT_LINKAGE); + build_info.library_linkage = details::required_field(pgh, BuildInfoRequiredField::LIBRARY_LINKAGE); + + return build_info; + } + + LinkageType linkage_type_value_of(const std::string& as_string) + + { + if (as_string == "dynamic") + { + return LinkageType::DYNAMIC; + } + + if (as_string == "static") + { + return LinkageType::STATIC; + } + + return LinkageType::UNKNOWN; + } + + BuildInfo read_build_info(const fs::path& filepath) + { + const std::vector<std::unordered_map<std::string, std::string>> pghs = Paragraphs::get_paragraphs(filepath); + Checks::check_throw(pghs.size() == 1, "Invalid BUILD_INFO file for package"); + + return BuildInfo::create(pghs[0]); + } +} diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 8301e74cc..4b784952a 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -5,6 +5,7 @@ #include <functional> #include "vcpkg_System.h" #include "coff_file_reader.h" +#include "BuildInfo.h" namespace fs = std::tr2::sys; @@ -495,6 +496,9 @@ namespace vcpkg void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths) { System::println("-- Performing post-build validation"); + + BuildInfo build_info = read_build_info(paths.build_info_file_path(spec)); + size_t error_count = 0; error_count += check_for_files_in_include_directory(spec, paths); error_count += check_for_files_in_debug_include_directory(spec, paths); @@ -506,10 +510,9 @@ namespace vcpkg error_count += check_for_copyright_file(spec, paths); error_count += check_for_exes(spec, paths); - triplet::BuildType build_type = spec.target_triplet().build_type(); - switch (build_type) + switch (linkage_type_value_of(build_info.library_linkage)) { - case triplet::BuildType::DYNAMIC: + case LinkageType::DYNAMIC: { const std::vector<fs::path> debug_dlls = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "bin", ".dll"); const std::vector<fs::path> release_dlls = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "bin", ".dll"); @@ -525,7 +528,7 @@ namespace vcpkg error_count += check_dll_architecture(spec.target_triplet().architecture(), dlls); break; } - case triplet::BuildType::STATIC: + case LinkageType::STATIC: { std::vector<fs::path> dlls; recursive_find_files_with_extension_in_dir(paths.packages / spec.dir(), ".dll", &dlls); @@ -534,7 +537,12 @@ namespace vcpkg error_count += check_bin_folders_are_not_present_in_static_build(spec, paths); break; } - + case LinkageType::UNKNOWN: + { + error_count += 1; + System::println(System::color::warning, "Unknown library_linkage architecture: [ %s ]", build_info.library_linkage); + break; + } default: Checks::unreachable(); } diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp index af2ca2a72..a6816b445 100644 --- a/toolsrc/src/triplet.cpp +++ b/toolsrc/src/triplet.cpp @@ -64,14 +64,4 @@ namespace vcpkg auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-'); return std::string(it + 1, this->m_canonical_name.cend()); } - - triplet::BuildType triplet::build_type() const - { - if (this->m_canonical_name.find("static") != std::string::npos) - { - return BuildType::STATIC; - } - - return BuildType::DYNAMIC; - } } diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp index 28ab22ec3..5347b79d8 100644 --- a/toolsrc/src/vcpkg_paths.cpp +++ b/toolsrc/src/vcpkg_paths.cpp @@ -55,6 +55,11 @@ namespace vcpkg return this->ports / spec.name(); } + fs::path vcpkg_paths::build_info_file_path(const package_spec& spec) const + { + return this->package_dir(spec) / "BUILD_INFO"; + } + fs::path vcpkg_paths::listfile_path(const BinaryParagraph& pgh) const { return this->vcpkg_dir_info / (pgh.fullstem() + ".list"); |
