Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/detect_compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.10)
project(detect_compiler)

file(SHA1 "${CMAKE_CXX_COMPILER}" CXX_HASH)
file(SHA1 "${CMAKE_C_COMPILER}" C_HASH)
string(SHA1 COMPILER_HASH "${C_HASH}${CXX_HASH}")

message("#COMPILER_HASH#${COMPILER_HASH}")
28 changes: 28 additions & 0 deletions scripts/detect_compiler/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set(LOGS
${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-out.log
${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-rel-out.log
${CURRENT_BUILDTREES_DIR}/config-${TARGET_TRIPLET}-dbg-out.log
)

foreach(LOG IN LISTS LOGS)
file(REMOVE ${LOG})
if(EXISTS ${LOG})
message(FATAL_ERROR "Could not remove ${LOG}")
endif()
endforeach()

set(VCPKG_BUILD_TYPE release)

vcpkg_configure_cmake(
SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}"
PREFER_NINJA
)

foreach(LOG IN LISTS LOGS)
if(EXISTS ${LOG})
file(READ "${LOG}" _contents)
message("${_contents}")
return()
endif()
endforeach()
message(FATAL_ERROR "Could read logs: ${LOGS}")
7 changes: 3 additions & 4 deletions scripts/ports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ if(CMD MATCHES "^BUILD$")
if(NOT EXISTS ${CURRENT_PORT_DIR}/portfile.cmake)
message(FATAL_ERROR "Port is missing portfile: ${CURRENT_PORT_DIR}/portfile.cmake")
endif()
if(NOT EXISTS ${CURRENT_PORT_DIR}/CONTROL)
message(FATAL_ERROR "Port is missing control file: ${CURRENT_PORT_DIR}/CONTROL")
endif()

unset(PACKAGES_DIR)
unset(BUILDTREES_DIR)
Expand Down Expand Up @@ -74,7 +71,9 @@ if(CMD MATCHES "^BUILD$")
include(${SCRIPTS}/cmake/vcpkg_common_definitions.cmake)
include(${SCRIPTS}/cmake/vcpkg_common_functions.cmake)
include(${CURRENT_PORT_DIR}/portfile.cmake)
include(${SCRIPTS}/build_info.cmake)
if(DEFINED PORT)
include(${SCRIPTS}/build_info.cmake)
endif()
elseif(CMD MATCHES "^CREATE$")
file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR)
file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS)
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/include/vcpkg/base/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace vcpkg
template<class Err>
struct ErrorHolder
{
ErrorHolder() : m_is_error(false) {}
ErrorHolder() : m_is_error(false), m_err{} {}
template<class U>
ErrorHolder(U&& err) : m_is_error(true), m_err(std::forward<U>(err))
{
Expand Down
6 changes: 4 additions & 2 deletions toolsrc/include/vcpkg/base/pragmas.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#include <sal.h>
#endif

#ifndef _Analysis_assume_
#define _Analysis_assume_(...)
#if defined(_MSC_VER)
#define ASSUME(expr) __assume(expr)
#else
#define ASSUME(expr)
#endif

#ifdef _MSC_VER
Expand Down
5 changes: 5 additions & 0 deletions toolsrc/include/vcpkg/base/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ namespace vcpkg::Util
{
augend->insert(augend->end(), addend.begin(), addend.end());
}
template<class Vec, class Key>
bool contains(const Vec& container, const Key& item)
{
return std::find(container.begin(), container.end(), item) != container.end();
}
}

namespace Sets
Expand Down
2 changes: 2 additions & 0 deletions toolsrc/include/vcpkg/binarycaching.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ namespace vcpkg
bool purge_tombstones) = 0;
};

IBinaryProvider& null_binary_provider();

ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs(const VcpkgPaths& paths,
View<std::string> args);
ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs_pure(const std::string& env_string,
Expand Down
94 changes: 51 additions & 43 deletions toolsrc/include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/system.process.h>

#include <array>
#include <map>
Expand All @@ -27,14 +28,18 @@ namespace vcpkg::Dependencies
struct ActionPlan;
}

namespace vcpkg::System
{
struct Environment;
}

namespace vcpkg::Build
{
namespace Command
{
void perform_and_exit_ex(const FullPackageSpec& full_spec,
const SourceControlFileLocation& scfl,
const PortFileProvider::PathsPortFileProvider& provider,
const bool binary_caching_enabled,
IBinaryProvider& binaryprovider,
const VcpkgPaths& paths);

Expand Down Expand Up @@ -90,12 +95,6 @@ namespace vcpkg::Build
};
const std::string& to_string(DownloadTool tool);

enum class BinaryCaching
{
NO = 0,
YES
};

enum class FailOnTombstone
{
NO = 0,
Expand All @@ -117,7 +116,6 @@ namespace vcpkg::Build
CleanPackages clean_packages;
CleanDownloads clean_downloads;
DownloadTool download_tool;
BinaryCaching binary_caching;
FailOnTombstone fail_on_tombstone;
PurgeDecompressFailure purge_decompress_failure;
};
Expand Down Expand Up @@ -149,14 +147,14 @@ namespace vcpkg::Build
/// <summary>
/// Settings from the triplet file which impact the build environment and post-build checks
/// </summary>
struct PreBuildInfo
struct PreBuildInfo : Util::ResourceBase
{
PreBuildInfo(const VcpkgPaths& paths,
Triplet triplet,
const std::unordered_map<std::string, std::string>& cmakevars);

bool load_vcvars_env;
std::string triplet_abi_tag;
Triplet triplet;
bool load_vcvars_env = false;
std::string target_architecture;
std::string cmake_system_name;
std::string cmake_system_version;
Expand All @@ -165,38 +163,16 @@ namespace vcpkg::Build
Optional<std::string> external_toolchain_file;
Optional<ConfigurationType> build_type;
Optional<std::string> public_abi_override;
Optional<const SourceControlFileLocation&> port;
std::vector<std::string> passthrough_env_vars;
};

std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);
fs::path toolchain_file() const;
bool using_vcvars() const;

enum class VcpkgTripletVar
{
TARGET_ARCHITECTURE = 0,
CMAKE_SYSTEM_NAME,
CMAKE_SYSTEM_VERSION,
PLATFORM_TOOLSET,
VISUAL_STUDIO_PATH,
CHAINLOAD_TOOLCHAIN_FILE,
BUILD_TYPE,
ENV_PASSTHROUGH,
PUBLIC_ABI_OVERRIDE,
LOAD_VCVARS_ENV,
private:
const VcpkgPaths& m_paths;
};

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},
{"VCPKG_PUBLIC_ABI_OVERRIDE", VcpkgTripletVar::PUBLIC_ABI_OVERRIDE},
{"VCPKG_LOAD_VCVARS_ENV", VcpkgTripletVar::LOAD_VCVARS_ENV},
};
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);

struct ExtendedBuildResult
{
Expand Down Expand Up @@ -238,8 +214,7 @@ namespace vcpkg::Build
BuildPolicy::ALLOW_OBSOLETE_MSVCRT,
BuildPolicy::ALLOW_RESTRICTED_HEADERS,
BuildPolicy::SKIP_DUMPBIN_CHECKS,
BuildPolicy::SKIP_ARCHITECTURE_CHECK
};
BuildPolicy::SKIP_ARCHITECTURE_CHECK};

const std::string& to_string(BuildPolicy policy);
CStringView to_cmake_variable(BuildPolicy policy);
Expand Down Expand Up @@ -300,12 +275,45 @@ namespace vcpkg::Build
fs::path tag_file;
};

struct AbiInfo
{
std::unique_ptr<PreBuildInfo> pre_build_info;
const Toolset* toolset;
std::string package_abi;
Optional<fs::path> abi_tag_file;
};

void compute_all_abis(const VcpkgPaths& paths,
Dependencies::ActionPlan& action_plan,
const CMakeVars::CMakeVarProvider& var_provider,
const StatusParagraphs& status_db);

Optional<AbiTagAndFile> compute_abi_tag(const VcpkgPaths& paths,
const Dependencies::InstallPlanAction& config,
Span<const AbiEntry> dependency_abis);
struct EnvCache
{
explicit EnvCache(bool compiler_tracking) : m_compiler_tracking(compiler_tracking) {}

const System::Environment& get_action_env(const VcpkgPaths& paths, const AbiInfo& abi_info);
const std::string& get_triplet_info(const VcpkgPaths& paths, const AbiInfo& abi_info);

private:
struct TripletMapEntry
{
std::string hash;
Cache<std::string, std::string> compiler_hashes;
};
Cache<fs::path, TripletMapEntry> m_triplet_cache;
Cache<fs::path, std::string> m_toolchain_cache;

#if defined(_WIN32)
struct EnvMapEntry
{
std::unordered_map<std::string, std::string> env_map;
Cache<std::string, System::Environment> cmd_cache;
};

Cache<std::vector<std::string>, EnvMapEntry> envs;
#endif

bool m_compiler_tracking;
};
}
5 changes: 2 additions & 3 deletions toolsrc/include/vcpkg/dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace vcpkg::Dependencies

std::string displayname() const;
const std::string& public_abi() const;
const Build::PreBuildInfo& pre_build_info(LineInfo linfo) const;

PackageSpec spec;

Expand All @@ -69,9 +70,7 @@ namespace vcpkg::Dependencies
std::vector<PackageSpec> package_dependencies;
std::vector<std::string> feature_list;

Optional<std::unique_ptr<Build::PreBuildInfo>> pre_build_info;
Optional<std::string> package_abi;
Optional<fs::path> abi_tag_file;
Optional<Build::AbiInfo> abi_info;
};

enum class RemovePlanType
Expand Down
4 changes: 2 additions & 2 deletions toolsrc/include/vcpkg/export.prefab.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace vcpkg::Export::Prefab
Optional<std::string> maybe_version;
Optional<std::string> maybe_min_sdk;
Optional<std::string> maybe_target_sdk;
bool enable_maven;
bool enable_debug;
bool enable_maven = false;
bool enable_debug = false;
};
struct NdkVersion
{
Expand Down
2 changes: 2 additions & 0 deletions toolsrc/include/vcpkg/vcpkgcmdarguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ namespace vcpkg
// feature flags
Optional<bool> feature_packages = nullopt;
Optional<bool> binary_caching = nullopt;
Optional<bool> compiler_tracking = nullopt;
bool binary_caching_enabled() const { return binary_caching.value_or(false); }
bool compiler_tracking_enabled() const { return compiler_tracking.value_or(false); }

std::string command;
std::vector<std::string> command_arguments;
Expand Down
32 changes: 19 additions & 13 deletions toolsrc/include/vcpkg/vcpkgpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#include <vcpkg/vcpkgcmdarguments.h>

#include <vcpkg/base/cache.h>
#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/lazy.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/util.h>

namespace vcpkg
{
Expand Down Expand Up @@ -46,9 +47,20 @@ namespace vcpkg
namespace Build
{
struct PreBuildInfo;
struct AbiInfo;
}

struct VcpkgPaths
namespace System
{
struct Environment;
}

namespace details
{
struct VcpkgPathsImpl;
}

struct VcpkgPaths : Util::MoveOnlyBase
{
struct TripletFile
{
Expand All @@ -59,6 +71,7 @@ namespace vcpkg
};

VcpkgPaths(Files::Filesystem& filesystem, const VcpkgCmdArguments& args);
~VcpkgPaths() noexcept;

fs::path package_dir(const PackageSpec& spec) const;
fs::path build_info_file_path(const PackageSpec& spec) const;
Expand Down Expand Up @@ -105,17 +118,10 @@ namespace vcpkg

Files::Filesystem& get_filesystem() const;

private:
Lazy<std::vector<TripletFile>> available_triplets;
Lazy<std::vector<Toolset>> toolsets;
Lazy<std::vector<Toolset>> toolsets_vs2013;

fs::path default_vs_path;
std::vector<fs::path> triplets_dirs;
const System::Environment& get_action_env(const Build::AbiInfo& abi_info) const;
const std::string& get_triplet_info(const Build::AbiInfo& abi_info) const;

Files::Filesystem* fsPtr;

mutable std::unique_ptr<ToolCache> m_tool_cache;
mutable vcpkg::Cache<Triplet, fs::path> m_triplets_cache;
private:
std::unique_ptr<details::VcpkgPathsImpl> m_pimpl;
};
}
2 changes: 1 addition & 1 deletion toolsrc/src/vcpkg/base/downloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace vcpkg::Downloads
url_path,
target_file_path,
std::to_string(err));
_Analysis_assume_(f != nullptr);
ASSUME(f != nullptr);

auto hSession = WinHttpOpen(L"vcpkg/1.0",
IsWindows8Point1OrGreater() ? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY
Expand Down
Loading