aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2016-11-08 14:12:49 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2016-11-08 14:12:49 -0800
commit6e9d17f73c01c3ad07875ca79196ed2f5e2d3896 (patch)
tree4b4b22f0bd6aaca36ca56ea1d31ac68c297f0b8e
parenteaebe2888ab97de74200904807ae884419ccc195 (diff)
downloadvcpkg-6e9d17f73c01c3ad07875ca79196ed2f5e2d3896.tar.gz
vcpkg-6e9d17f73c01c3ad07875ca79196ed2f5e2d3896.zip
Introduce BUILD_INFO file. Significant change in the way static/dynamic is
handled
-rw-r--r--scripts/ports.cmake4
-rw-r--r--toolsrc/include/BuildInfo.h28
-rw-r--r--toolsrc/include/triplet.h8
-rw-r--r--toolsrc/include/vcpkg_paths.h2
-rw-r--r--toolsrc/src/BuildInfo.cpp46
-rw-r--r--toolsrc/src/post_build_lint.cpp18
-rw-r--r--toolsrc/src/triplet.cpp10
-rw-r--r--toolsrc/src/vcpkg_paths.cpp5
-rw-r--r--toolsrc/vcpkglib/vcpkglib.vcxproj2
-rw-r--r--toolsrc/vcpkglib/vcpkglib.vcxproj.filters6
10 files changed, 106 insertions, 23 deletions
diff --git a/scripts/ports.cmake b/scripts/ports.cmake
index 44cb386be..8d86fa6fa 100644
--- a/scripts/ports.cmake
+++ b/scripts/ports.cmake
@@ -71,6 +71,10 @@ if(CMD MATCHES "^BUILD$")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR})
include(${CURRENT_PORT_DIR}/portfile.cmake)
+
+ set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
+ file(WRITE ${BUILD_INFO_FILE_PATH} "CRTLinkage: ${VCPKG_CRT_LINKAGE}\n")
+ file(APPEND ${BUILD_INFO_FILE_PATH} "LibraryLinkage: ${VCPKG_LIBRARY_LINKAGE}")
elseif(CMD MATCHES "^CREATE$")
file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR)
file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS)
diff --git a/toolsrc/include/BuildInfo.h b/toolsrc/include/BuildInfo.h
new file mode 100644
index 000000000..2801cf49d
--- /dev/null
+++ b/toolsrc/include/BuildInfo.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <unordered_map>
+#include "Paragraphs.h"
+
+namespace fs = std::tr2::sys;
+
+namespace vcpkg
+{
+ enum class LinkageType
+ {
+ DYNAMIC,
+ STATIC,
+ UNKNOWN
+ };
+
+ LinkageType linkage_type_value_of(const std::string& as_string);
+
+ struct BuildInfo
+ {
+ static BuildInfo create(const std::unordered_map<std::string, std::string>& pgh);
+
+ std::string crt_linkage;
+ std::string library_linkage;
+ };
+
+ BuildInfo read_build_info(const fs::path& filepath);
+}
diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h
index bc99a17df..32ea2e711 100644
--- a/toolsrc/include/triplet.h
+++ b/toolsrc/include/triplet.h
@@ -8,20 +8,12 @@ namespace vcpkg
{
static triplet from_canonical_name(const std::string& triplet_as_string);
- enum class BuildType
- {
- DYNAMIC,
- STATIC
- };
-
static const triplet X86_WINDOWS;
static const triplet X64_WINDOWS;
static const triplet X86_UWP;
static const triplet X64_UWP;
static const triplet ARM_UWP;
- BuildType build_type() const;
-
const std::string& canonical_name() const;
std::string architecture() const;
diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h
index 8276242e9..2dc9c7636 100644
--- a/toolsrc/include/vcpkg_paths.h
+++ b/toolsrc/include/vcpkg_paths.h
@@ -14,7 +14,9 @@ namespace vcpkg
fs::path package_dir(const package_spec& spec) const;
fs::path port_dir(const package_spec& spec) const;
+ fs::path build_info_file_path(const package_spec& spec) const;
fs::path listfile_path(const BinaryParagraph& pgh) const;
+
bool is_valid_triplet(const triplet& t) const;
fs::path root;
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");
diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj
index 766cdf6a8..10cc32935 100644
--- a/toolsrc/vcpkglib/vcpkglib.vcxproj
+++ b/toolsrc/vcpkglib/vcpkglib.vcxproj
@@ -123,6 +123,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\include\BinaryParagraph.h" />
+ <ClInclude Include="..\include\BuildInfo.h" />
<ClInclude Include="..\include\package_spec.h" />
<ClInclude Include="..\include\package_spec_parse_result.h" />
<ClInclude Include="..\include\Paragraphs.h" />
@@ -137,6 +138,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\BinaryParagraph.cpp" />
+ <ClCompile Include="..\src\BuildInfo.cpp" />
<ClCompile Include="..\src\vcpkg.cpp" />
<ClCompile Include="..\src\package_spec.cpp" />
<ClCompile Include="..\src\package_spec_parse_result.cpp" />
diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
index 705a65a33..e8856235c 100644
--- a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
+++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters
@@ -51,6 +51,9 @@
<ClCompile Include="..\src\vcpkg_info.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\src\BuildInfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\vcpkg.h">
@@ -89,5 +92,8 @@
<ClInclude Include="..\include\vcpkg_info.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\include\BuildInfo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file