2017-04-30 04:09:05 -07:00
|
|
|
#pragma once
|
|
|
|
|
2017-10-13 18:37:41 -07:00
|
|
|
#include <vcpkg/packagespec.h>
|
|
|
|
#include <vcpkg/statusparagraphs.h>
|
|
|
|
#include <vcpkg/triplet.h>
|
|
|
|
#include <vcpkg/vcpkgcmdarguments.h>
|
|
|
|
#include <vcpkg/vcpkgpaths.h>
|
|
|
|
|
|
|
|
#include <vcpkg/base/cstringview.h>
|
|
|
|
#include <vcpkg/base/files.h>
|
|
|
|
#include <vcpkg/base/optional.h>
|
2017-05-24 00:44:00 -07:00
|
|
|
|
2017-06-06 16:30:01 -07:00
|
|
|
#include <array>
|
2017-04-30 04:09:05 -07:00
|
|
|
#include <map>
|
2018-02-25 10:13:57 -08:00
|
|
|
#include <set>
|
2017-04-30 04:09:05 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace vcpkg::Build
|
|
|
|
{
|
2017-10-13 18:37:41 -07:00
|
|
|
namespace Command
|
|
|
|
{
|
2017-11-02 15:20:42 -07:00
|
|
|
void perform_and_exit_ex(const FullPackageSpec& full_spec,
|
2019-06-21 23:50:05 -07:00
|
|
|
const SourceControlFileLocation& scfl,
|
2017-11-02 15:20:42 -07:00
|
|
|
const ParsedArguments& options,
|
|
|
|
const VcpkgPaths& paths);
|
2017-10-13 18:37:41 -07:00
|
|
|
|
|
|
|
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet);
|
|
|
|
}
|
|
|
|
|
2017-05-22 20:18:40 -07:00
|
|
|
enum class UseHeadVersion
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class AllowDownloads
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
2017-11-16 19:29:32 -08:00
|
|
|
enum class CleanBuildtrees
|
2017-05-22 20:18:40 -07:00
|
|
|
{
|
2017-11-16 19:29:32 -08:00
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
2017-05-22 20:18:40 -07:00
|
|
|
|
2018-02-21 15:32:20 -08:00
|
|
|
enum class CleanPackages
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
2019-05-23 14:24:02 -04:00
|
|
|
enum class CleanDownloads
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
2017-11-25 15:25:18 -08:00
|
|
|
enum class ConfigurationType
|
|
|
|
{
|
|
|
|
DEBUG,
|
|
|
|
RELEASE,
|
|
|
|
};
|
|
|
|
|
2018-03-07 17:57:16 +08:00
|
|
|
enum class DownloadTool
|
|
|
|
{
|
|
|
|
BUILT_IN,
|
|
|
|
ARIA2,
|
|
|
|
};
|
2018-04-12 00:47:17 -07:00
|
|
|
const std::string& to_string(DownloadTool tool);
|
2018-03-07 17:57:16 +08:00
|
|
|
|
2018-06-29 01:33:54 -07:00
|
|
|
enum class BinaryCaching
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class FailOnTombstone
|
|
|
|
{
|
|
|
|
NO = 0,
|
|
|
|
YES
|
|
|
|
};
|
|
|
|
|
2017-05-22 20:18:40 -07:00
|
|
|
struct BuildPackageOptions
|
|
|
|
{
|
|
|
|
UseHeadVersion use_head_version;
|
|
|
|
AllowDownloads allow_downloads;
|
2017-11-16 19:29:32 -08:00
|
|
|
CleanBuildtrees clean_buildtrees;
|
2018-02-21 15:32:20 -08:00
|
|
|
CleanPackages clean_packages;
|
2019-05-23 14:24:02 -04:00
|
|
|
CleanDownloads clean_downloads;
|
2018-03-07 17:57:16 +08:00
|
|
|
DownloadTool download_tool;
|
2018-06-29 01:33:54 -07:00
|
|
|
BinaryCaching binary_caching;
|
|
|
|
FailOnTombstone fail_on_tombstone;
|
2017-05-22 20:18:40 -07:00
|
|
|
};
|
|
|
|
|
2017-04-30 04:09:05 -07:00
|
|
|
enum class BuildResult
|
|
|
|
{
|
|
|
|
NULLVALUE = 0,
|
|
|
|
SUCCEEDED,
|
|
|
|
BUILD_FAILED,
|
|
|
|
POST_BUILD_CHECKS_FAILED,
|
2017-08-23 15:47:42 -07:00
|
|
|
FILE_CONFLICTS,
|
2017-10-26 19:00:30 -07:00
|
|
|
CASCADED_DUE_TO_MISSING_DEPENDENCIES,
|
|
|
|
EXCLUDED,
|
2017-04-30 04:09:05 -07:00
|
|
|
};
|
|
|
|
|
2017-10-26 19:00:30 -07:00
|
|
|
static constexpr std::array<BuildResult, 6> BUILD_RESULT_VALUES = {
|
2017-04-30 04:09:05 -07:00
|
|
|
BuildResult::SUCCEEDED,
|
|
|
|
BuildResult::BUILD_FAILED,
|
|
|
|
BuildResult::POST_BUILD_CHECKS_FAILED,
|
2017-08-23 22:46:28 -07:00
|
|
|
BuildResult::FILE_CONFLICTS,
|
2017-10-26 19:00:30 -07:00
|
|
|
BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES,
|
|
|
|
BuildResult::EXCLUDED};
|
2017-04-30 04:09:05 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-07-16 14:02:13 -07:00
|
|
|
enum class VcpkgTripletVar
|
|
|
|
{
|
|
|
|
TARGET_ARCHITECTURE = 0,
|
|
|
|
CMAKE_SYSTEM_NAME,
|
|
|
|
CMAKE_SYSTEM_VERSION,
|
|
|
|
PLATFORM_TOOLSET,
|
|
|
|
VISUAL_STUDIO_PATH,
|
|
|
|
CHAINLOAD_TOOLCHAIN_FILE,
|
|
|
|
BUILD_TYPE,
|
|
|
|
ENV_PASSTHROUGH,
|
|
|
|
};
|
|
|
|
|
|
|
|
const std::unordered_map<std::string, VcpkgTripletVar> VCPKG_OPTIONS = {
|
|
|
|
{"VCPKG_TARGET_ARCHITECTURE", VcpkgTripletVar::TARGET_ARCHITECTURE},
|
|
|
|
{"VCPKG_CMAKE_SYSTEM_NAME", VcpkgTripletVar::CMAKE_SYSTEM_NAME},
|
|
|
|
{"VCPKG_CMAKE_SYSTEM_VERSION", VcpkgTripletVar::CMAKE_SYSTEM_VERSION},
|
|
|
|
{"VCPKG_PLATFORM_TOOLSET", VcpkgTripletVar::PLATFORM_TOOLSET},
|
|
|
|
{"VCPKG_VISUAL_STUDIO_PATH", VcpkgTripletVar::VISUAL_STUDIO_PATH},
|
|
|
|
{"VCPKG_CHAINLOAD_TOOLCHAIN_FILE", VcpkgTripletVar::CHAINLOAD_TOOLCHAIN_FILE},
|
|
|
|
{"VCPKG_BUILD_TYPE", VcpkgTripletVar::BUILD_TYPE},
|
|
|
|
{"VCPKG_ENV_PASSTHROUGH", VcpkgTripletVar::ENV_PASSTHROUGH},
|
|
|
|
};
|
|
|
|
|
2017-04-30 04:09:05 -07:00
|
|
|
struct ExtendedBuildResult
|
|
|
|
{
|
2017-11-16 19:29:32 -08:00
|
|
|
ExtendedBuildResult(BuildResult code);
|
2018-02-16 14:27:32 +01:00
|
|
|
ExtendedBuildResult(BuildResult code, std::vector<FeatureSpec>&& unmet_deps);
|
2017-11-16 19:29:32 -08:00
|
|
|
ExtendedBuildResult(BuildResult code, std::unique_ptr<BinaryControlFile>&& bcf);
|
|
|
|
|
2017-04-30 04:09:05 -07:00
|
|
|
BuildResult code;
|
2018-02-16 14:27:32 +01:00
|
|
|
std::vector<FeatureSpec> unmet_dependencies;
|
2017-11-16 19:29:32 -08:00
|
|
|
std::unique_ptr<BinaryControlFile> binary_control_file;
|
2017-04-30 04:09:05 -07:00
|
|
|
};
|
|
|
|
|
2017-05-02 17:52:59 -07:00
|
|
|
struct BuildPackageConfig
|
|
|
|
{
|
2017-07-19 14:29:28 -07:00
|
|
|
BuildPackageConfig(const SourceControlFile& src,
|
|
|
|
const Triplet& triplet,
|
|
|
|
fs::path&& port_dir,
|
|
|
|
const BuildPackageOptions& build_package_options,
|
2018-02-25 10:13:57 -08:00
|
|
|
const std::set<std::string>& feature_list)
|
2017-12-13 05:43:00 -08:00
|
|
|
: scf(src)
|
2017-07-19 14:29:28 -07:00
|
|
|
, triplet(triplet)
|
|
|
|
, port_dir(std::move(port_dir))
|
|
|
|
, build_package_options(build_package_options)
|
2017-12-13 05:43:00 -08:00
|
|
|
, feature_list(feature_list)
|
2017-05-02 17:52:59 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-12-13 05:43:00 -08:00
|
|
|
const SourceControlFile& scf;
|
2017-05-02 17:52:59 -07:00
|
|
|
const Triplet& triplet;
|
|
|
|
fs::path port_dir;
|
2017-05-22 20:18:40 -07:00
|
|
|
const BuildPackageOptions& build_package_options;
|
2018-02-25 10:13:57 -08:00
|
|
|
const std::set<std::string>& feature_list;
|
2017-05-02 17:52:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
ExtendedBuildResult build_package(const VcpkgPaths& paths,
|
|
|
|
const BuildPackageConfig& config,
|
2017-04-30 04:09:05 -07:00
|
|
|
const StatusParagraphs& status_db);
|
|
|
|
|
2019-07-16 15:34:13 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Settings from the triplet file which impact the build environment and post-build checks
|
|
|
|
/// </summary>
|
|
|
|
struct PreBuildInfo
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Runs the triplet file in a "capture" mode to create a PreBuildInfo
|
|
|
|
/// </summary>
|
|
|
|
static PreBuildInfo from_triplet_file(const VcpkgPaths& paths,
|
|
|
|
const Triplet& triplet,
|
|
|
|
Optional<const std::string&> port = nullopt);
|
|
|
|
|
|
|
|
std::string triplet_abi_tag;
|
|
|
|
std::string target_architecture;
|
|
|
|
std::string cmake_system_name;
|
|
|
|
std::string cmake_system_version;
|
|
|
|
Optional<std::string> platform_toolset;
|
|
|
|
Optional<fs::path> visual_studio_path;
|
|
|
|
Optional<std::string> external_toolchain_file;
|
|
|
|
Optional<ConfigurationType> build_type;
|
|
|
|
std::vector<std::string> passthrough_env_vars;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
|
|
|
|
|
2017-05-24 00:44:00 -07:00
|
|
|
enum class BuildPolicy
|
|
|
|
{
|
|
|
|
EMPTY_PACKAGE,
|
|
|
|
DLLS_WITHOUT_LIBS,
|
|
|
|
ONLY_RELEASE_CRT,
|
|
|
|
EMPTY_INCLUDE_FOLDER,
|
|
|
|
ALLOW_OBSOLETE_MSVCRT,
|
|
|
|
// Must be last
|
|
|
|
COUNT,
|
|
|
|
};
|
|
|
|
|
2017-09-07 16:16:30 -07:00
|
|
|
constexpr std::array<BuildPolicy, size_t(BuildPolicy::COUNT)> G_ALL_POLICIES = {
|
2017-06-17 02:39:14 -07:00
|
|
|
BuildPolicy::EMPTY_PACKAGE,
|
|
|
|
BuildPolicy::DLLS_WITHOUT_LIBS,
|
|
|
|
BuildPolicy::ONLY_RELEASE_CRT,
|
|
|
|
BuildPolicy::EMPTY_INCLUDE_FOLDER,
|
|
|
|
BuildPolicy::ALLOW_OBSOLETE_MSVCRT,
|
|
|
|
};
|
2017-05-24 00:44:00 -07:00
|
|
|
|
|
|
|
const std::string& to_string(BuildPolicy policy);
|
|
|
|
CStringView to_cmake_variable(BuildPolicy policy);
|
|
|
|
|
|
|
|
struct BuildPolicies
|
2017-04-30 04:09:05 -07:00
|
|
|
{
|
2017-06-17 02:39:14 -07:00
|
|
|
BuildPolicies() = default;
|
2017-05-24 00:44:00 -07:00
|
|
|
BuildPolicies(std::map<BuildPolicy, bool>&& map) : m_policies(std::move(map)) {}
|
2017-04-30 04:09:05 -07:00
|
|
|
|
2017-09-07 16:16:30 -07:00
|
|
|
bool is_enabled(BuildPolicy policy) const
|
2017-05-24 00:44:00 -07:00
|
|
|
{
|
2017-08-28 17:10:50 -07:00
|
|
|
const auto it = m_policies.find(policy);
|
2017-05-24 00:44:00 -07:00
|
|
|
if (it != m_policies.cend()) return it->second;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<BuildPolicy, bool> m_policies;
|
|
|
|
};
|
|
|
|
|
2017-06-06 16:30:01 -07:00
|
|
|
enum class LinkageType : char
|
|
|
|
{
|
|
|
|
DYNAMIC,
|
|
|
|
STATIC,
|
|
|
|
};
|
|
|
|
|
|
|
|
Optional<LinkageType> to_linkage_type(const std::string& str);
|
|
|
|
|
2017-05-24 00:44:00 -07:00
|
|
|
struct BuildInfo
|
|
|
|
{
|
2018-04-12 00:47:17 -07:00
|
|
|
LinkageType crt_linkage = LinkageType::DYNAMIC;
|
|
|
|
LinkageType library_linkage = LinkageType::DYNAMIC;
|
2017-04-30 04:09:05 -07:00
|
|
|
|
2017-05-02 20:34:11 -07:00
|
|
|
Optional<std::string> version;
|
|
|
|
|
2017-05-24 00:44:00 -07:00
|
|
|
BuildPolicies policies;
|
2017-04-30 04:09:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
BuildInfo read_build_info(const Files::Filesystem& fs, const fs::path& filepath);
|
2018-03-14 10:30:27 -07:00
|
|
|
|
|
|
|
struct AbiEntry
|
|
|
|
{
|
|
|
|
std::string key;
|
|
|
|
std::string value;
|
2018-03-22 10:01:12 -07:00
|
|
|
|
|
|
|
bool operator<(const AbiEntry& other) const
|
|
|
|
{
|
|
|
|
return key < other.key || (key == other.key && value < other.value);
|
|
|
|
}
|
2018-03-14 10:30:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AbiTagAndFile
|
|
|
|
{
|
|
|
|
std::string tag;
|
|
|
|
fs::path tag_file;
|
|
|
|
};
|
|
|
|
|
|
|
|
Optional<AbiTagAndFile> compute_abi_tag(const VcpkgPaths& paths,
|
|
|
|
const BuildPackageConfig& config,
|
|
|
|
const PreBuildInfo& pre_build_info,
|
|
|
|
Span<const AbiEntry> dependency_abis);
|
2017-04-30 04:09:05 -07:00
|
|
|
}
|