mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-04 10:48:08 +00:00
Introduce BUILD_INFO file. Significant change in the way static/dynamic is
handled
This commit is contained in:
parent
eaebe2888a
commit
6e9d17f73c
@ -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)
|
||||
|
28
toolsrc/include/BuildInfo.h
Normal file
28
toolsrc/include/BuildInfo.h
Normal file
@ -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);
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
46
toolsrc/src/BuildInfo.cpp
Normal file
46
toolsrc/src/BuildInfo.cpp
Normal file
@ -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]);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
Loading…
x
Reference in New Issue
Block a user