2017-04-30 19:09:05 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-05-24 15:44:00 +08:00
|
|
|
#include "CStringView.h"
|
2017-04-30 19:09:05 +08:00
|
|
|
#include "PackageSpec.h"
|
|
|
|
#include "StatusParagraphs.h"
|
|
|
|
#include "VcpkgPaths.h"
|
|
|
|
#include "vcpkg_Files.h"
|
2017-05-03 11:34:11 +08:00
|
|
|
#include "vcpkg_optional.h"
|
2017-05-24 15:44:00 +08:00
|
|
|
|
2017-06-07 07:30:01 +08:00
|
|
|
#include <array>
|
2017-04-30 19:09:05 +08:00
|
|
|
#include <map>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace vcpkg::Build
|
|
|
|
{
|
2017-05-23 11:18:40 +08:00
|
|
|
enum class UseHeadVersion
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
|
|
|
inline UseHeadVersion to_use_head_version(const bool value)
|
|
|
|
{
|
|
|
|
return value ? UseHeadVersion::YES : UseHeadVersion::NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool to_bool(const UseHeadVersion value) { return value == UseHeadVersion::YES; }
|
|
|
|
|
|
|
|
enum class AllowDownloads
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
|
|
|
inline AllowDownloads to_allow_downloads(const bool value)
|
|
|
|
{
|
|
|
|
return value ? AllowDownloads::YES : AllowDownloads::NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool to_bool(const AllowDownloads value) { return value == AllowDownloads::YES; }
|
|
|
|
|
|
|
|
struct BuildPackageOptions
|
|
|
|
{
|
|
|
|
UseHeadVersion use_head_version;
|
|
|
|
AllowDownloads allow_downloads;
|
|
|
|
};
|
|
|
|
|
2017-04-30 19:09:05 +08:00
|
|
|
enum class BuildResult
|
|
|
|
{
|
|
|
|
NULLVALUE = 0,
|
|
|
|
SUCCEEDED,
|
|
|
|
BUILD_FAILED,
|
|
|
|
POST_BUILD_CHECKS_FAILED,
|
|
|
|
CASCADED_DUE_TO_MISSING_DEPENDENCIES
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr std::array<BuildResult, 4> BuildResult_values = {
|
|
|
|
BuildResult::SUCCEEDED,
|
|
|
|
BuildResult::BUILD_FAILED,
|
|
|
|
BuildResult::POST_BUILD_CHECKS_FAILED,
|
|
|
|
BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES};
|
|
|
|
|
|
|
|
const std::string& to_string(const BuildResult build_result);
|
|
|
|
std::string create_error_message(const BuildResult build_result, const PackageSpec& spec);
|
|
|
|
std::string create_user_troubleshooting_message(const PackageSpec& spec);
|
|
|
|
|
2017-05-25 06:54:12 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Settings from the triplet file which impact the build environment and post-build checks
|
|
|
|
/// </summary>
|
2017-05-04 07:33:02 +08:00
|
|
|
struct PreBuildInfo
|
|
|
|
{
|
2017-05-25 06:54:12 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Runs the triplet file in a "capture" mode to create a PreBuildInfo
|
|
|
|
/// </summary>
|
2017-05-04 07:33:02 +08:00
|
|
|
static PreBuildInfo from_triplet_file(const VcpkgPaths& paths, const Triplet& triplet);
|
|
|
|
|
|
|
|
std::string target_architecture;
|
|
|
|
std::string cmake_system_name;
|
|
|
|
std::string cmake_system_version;
|
|
|
|
std::string platform_toolset;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::wstring make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
|
2017-04-30 19:09:05 +08:00
|
|
|
|
|
|
|
struct ExtendedBuildResult
|
|
|
|
{
|
|
|
|
BuildResult code;
|
|
|
|
std::vector<PackageSpec> unmet_dependencies;
|
|
|
|
};
|
|
|
|
|
2017-05-03 08:52:59 +08:00
|
|
|
struct BuildPackageConfig
|
|
|
|
{
|
2017-05-23 11:18:40 +08:00
|
|
|
BuildPackageConfig(const SourceParagraph& src,
|
|
|
|
const Triplet& triplet,
|
|
|
|
fs::path&& port_dir,
|
|
|
|
const BuildPackageOptions& build_package_options)
|
|
|
|
: src(src), triplet(triplet), port_dir(std::move(port_dir)), build_package_options(build_package_options)
|
2017-05-03 08:52:59 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SourceParagraph& src;
|
|
|
|
const Triplet& triplet;
|
|
|
|
fs::path port_dir;
|
2017-05-23 11:18:40 +08:00
|
|
|
const BuildPackageOptions& build_package_options;
|
2017-05-03 08:52:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ExtendedBuildResult build_package(const VcpkgPaths& paths,
|
|
|
|
const BuildPackageConfig& config,
|
2017-04-30 19:09:05 +08:00
|
|
|
const StatusParagraphs& status_db);
|
|
|
|
|
2017-05-24 15:44:00 +08:00
|
|
|
enum class BuildPolicy
|
|
|
|
{
|
|
|
|
EMPTY_PACKAGE,
|
|
|
|
DLLS_WITHOUT_LIBS,
|
|
|
|
ONLY_RELEASE_CRT,
|
|
|
|
EMPTY_INCLUDE_FOLDER,
|
|
|
|
ALLOW_OBSOLETE_MSVCRT,
|
|
|
|
// Must be last
|
|
|
|
COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
Optional<BuildPolicy> to_build_policy(const std::string& str);
|
|
|
|
|
|
|
|
const std::string& to_string(BuildPolicy policy);
|
|
|
|
CStringView to_cmake_variable(BuildPolicy policy);
|
|
|
|
|
|
|
|
struct BuildPolicies
|
2017-04-30 19:09:05 +08:00
|
|
|
{
|
2017-05-24 15:44:00 +08:00
|
|
|
BuildPolicies() {}
|
|
|
|
BuildPolicies(std::map<BuildPolicy, bool>&& map) : m_policies(std::move(map)) {}
|
2017-04-30 19:09:05 +08:00
|
|
|
|
2017-05-24 15:44:00 +08:00
|
|
|
inline bool is_enabled(BuildPolicy policy) const
|
|
|
|
{
|
|
|
|
auto it = m_policies.find(policy);
|
|
|
|
if (it != m_policies.cend()) return it->second;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<BuildPolicy, bool> m_policies;
|
|
|
|
};
|
|
|
|
|
2017-06-07 07:30:01 +08:00
|
|
|
enum class LinkageType : char
|
|
|
|
{
|
|
|
|
DYNAMIC,
|
|
|
|
STATIC,
|
|
|
|
};
|
|
|
|
|
|
|
|
Optional<LinkageType> to_linkage_type(const std::string& str);
|
|
|
|
|
2017-05-24 15:44:00 +08:00
|
|
|
struct BuildInfo
|
|
|
|
{
|
2017-06-07 07:30:01 +08:00
|
|
|
LinkageType crt_linkage;
|
|
|
|
LinkageType library_linkage;
|
2017-04-30 19:09:05 +08:00
|
|
|
|
2017-05-03 11:34:11 +08:00
|
|
|
Optional<std::string> version;
|
|
|
|
|
2017-05-24 15:44:00 +08:00
|
|
|
BuildPolicies policies;
|
2017-04-30 19:09:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
BuildInfo read_build_info(const Files::Filesystem& fs, const fs::path& filepath);
|
|
|
|
}
|