[vcpkg] Initial experimental support for VCPKG_BUILD_TYPE release
MODIFY
VERSION.txt
VERSION.txt
-"0.0.97"
\ No newline at end of file
+"0.0.98"
\ No newline at end of file

MODIFY
include/vcpkg/build.h
include/vcpkg/build.h
@@ -44,6 +44,12 @@ namespace vcpkg::Build
YES
};
+ enum class ConfigurationType
+ {
+ DEBUG,
+ RELEASE,
+ };
+
struct BuildPackageOptions
{
UseHeadVersion use_head_version;
@@ -90,6 +96,7 @@ namespace vcpkg::Build
Optional<std::string> platform_toolset;
Optional<fs::path> visual_studio_path;
Optional<std::string> external_toolchain_file;
+ Optional<ConfigurationType> build_type;
};
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);

MODIFY
include/vcpkg/postbuildlint.buildtype.h
include/vcpkg/postbuildlint.buildtype.h
namespace vcpkg::PostBuildLint
{
- enum class ConfigurationType
- {
- DEBUG,
- RELEASE,
- };
-
struct BuildType
{
enum class BackingEnum
@@ -24,12 +18,12 @@ namespace vcpkg::PostBuildLint
RELEASE_DYNAMIC
};
- static BuildType value_of(const ConfigurationType& config, const Build::LinkageType& linkage);
+ static BuildType value_of(const Build::ConfigurationType& config, const Build::LinkageType& linkage);
BuildType() = delete;
constexpr BuildType(const BackingEnum backing_enum,
- const ConfigurationType config,
+ const Build::ConfigurationType config,
const Build::LinkageType linkage)
: backing_enum(backing_enum), m_config(config), m_linkage(linkage)
{
@@ -37,14 +31,14 @@ namespace vcpkg::PostBuildLint
constexpr operator BackingEnum() const { return backing_enum; }
- const ConfigurationType& config() const;
+ const Build::ConfigurationType& config() const;
const Build::LinkageType& linkage() const;
const std::regex& crt_regex() const;
const std::string& to_string() const;
private:
BackingEnum backing_enum;
- ConfigurationType m_config;
+ Build::ConfigurationType m_config;
Build::LinkageType m_linkage;
};
@@ -55,12 +49,14 @@ namespace vcpkg::PostBuildLint
static constexpr CStringView ENUM_NAME = "vcpkg::PostBuildLint::BuildType";
- static constexpr BuildType DEBUG_STATIC = {BE::DEBUG_STATIC, ConfigurationType::DEBUG, LinkageType::STATIC};
- static constexpr BuildType DEBUG_DYNAMIC = {BE::DEBUG_DYNAMIC, ConfigurationType::DEBUG, LinkageType::DYNAMIC};
+ static constexpr BuildType DEBUG_STATIC = {
+ BE::DEBUG_STATIC, Build::ConfigurationType::DEBUG, LinkageType::STATIC};
+ static constexpr BuildType DEBUG_DYNAMIC = {
+ BE::DEBUG_DYNAMIC, Build::ConfigurationType::DEBUG, LinkageType::DYNAMIC};
static constexpr BuildType RELEASE_STATIC = {
- BE::RELEASE_STATIC, ConfigurationType::RELEASE, LinkageType::STATIC};
+ BE::RELEASE_STATIC, Build::ConfigurationType::RELEASE, LinkageType::STATIC};
static constexpr BuildType RELEASE_DYNAMIC = {
- BE::RELEASE_DYNAMIC, ConfigurationType::RELEASE, LinkageType::DYNAMIC};
+ BE::RELEASE_DYNAMIC, Build::ConfigurationType::RELEASE, LinkageType::DYNAMIC};
static constexpr std::array<BuildType, 4> VALUES = {
DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC};

MODIFY
src/vcpkg/build.cpp
src/vcpkg/build.cpp
@@ -565,6 +565,20 @@ namespace vcpkg::Build
continue;
}
+ if (variable_name == "VCPKG_BUILD_TYPE")
+ {
+ if (variable_value.empty())
+ pre_build_info.build_type = nullopt;
+ else if (Strings::case_insensitive_ascii_equals(variable_value, "debug"))
+ pre_build_info.build_type = ConfigurationType::DEBUG;
+ else if (Strings::case_insensitive_ascii_equals(variable_value, "release"))
+ pre_build_info.build_type = ConfigurationType::RELEASE;
+ else
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO, "Unknown setting for VCPKG_BUILD_TYPE: %s", variable_value);
+ continue;
+ }
+
Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown variable name %s", line);
}

MODIFY
src/vcpkg/postbuildlint.buildtype.cpp
src/vcpkg/postbuildlint.buildtype.cpp
#include <vcpkg/base/checks.h>
#include <vcpkg/postbuildlint.buildtype.h>
+using vcpkg::Build::ConfigurationType;
+
namespace vcpkg::PostBuildLint
{
BuildType BuildType::value_of(const ConfigurationType& config, const Build::LinkageType& linkage)

MODIFY
src/vcpkg/postbuildlint.cpp
src/vcpkg/postbuildlint.cpp
@@ -758,6 +758,7 @@ namespace vcpkg::PostBuildLint
std::vector<fs::path> release_libs = fs.get_files_recursive(release_lib_dir);
Util::unstable_keep_if(release_libs, has_extension_pred(fs, ".lib"));
+ if (!pre_build_info.build_type)
error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs);
{
@@ -777,6 +778,7 @@ namespace vcpkg::PostBuildLint
{
case Build::LinkageType::DYNAMIC:
{
+ if (!pre_build_info.build_type)
error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls);
error_count += check_lib_files_are_available_if_dlls_are_available(
@@ -805,13 +807,13 @@ namespace vcpkg::PostBuildLint
if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT))
{
- error_count +=
- check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, build_info.crt_linkage),
+ error_count += check_crt_linkage_of_libs(
+ BuildType::value_of(Build::ConfigurationType::DEBUG, build_info.crt_linkage),
debug_libs,
toolset.dumpbin);
}
- error_count +=
- check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, build_info.crt_linkage),
+ error_count += check_crt_linkage_of_libs(
+ BuildType::value_of(Build::ConfigurationType::RELEASE, build_info.crt_linkage),
release_libs,
toolset.dumpbin);
break;

MODIFY
vcpkg/vcpkg.vcxproj
vcpkg/vcpkg.vcxproj
<ItemGroup>
<ClCompile Include="..\src\vcpkg.cpp" />
</ItemGroup>
+ <ItemGroup>
+ <Text Include="..\VERSION.txt" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

MODIFY
vcpkg/vcpkg.vcxproj.filters
vcpkg/vcpkg.vcxproj.filters
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
+ <ItemGroup>
+ <Text Include="..\VERSION.txt">
+ <Filter>Source Files</Filter>
+ </Text>
+ </ItemGroup>
</Project>
\ No newline at end of file

[vcpkg] Initial experimental support for VCPKG_BUILD_TYPE release