diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-05-02 20:34:11 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-05-03 04:12:28 -0700 |
| commit | 4633c5e0ea8560ac17c14aa56e50bf3693017f51 (patch) | |
| tree | 543c1994c5b9b244bb3a9517fd4dfbde389afffc | |
| parent | f10861fa7af9bd675cb4e80ea31d85d7e5c6d906 (diff) | |
| download | vcpkg-4633c5e0ea8560ac17c14aa56e50bf3693017f51.tar.gz vcpkg-4633c5e0ea8560ac17c14aa56e50bf3693017f51.zip | |
[vcpkg] Add support for installing from HEAD
| -rw-r--r-- | ports/azure-storage-cpp/portfile.cmake | 10 | ||||
| -rw-r--r-- | ports/cpprestsdk/portfile.cmake | 33 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_common_functions.cmake | 2 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_download_distfile.cmake | 4 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_extract_source_archive.cmake | 31 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 47 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_from_github.cmake | 131 | ||||
| -rw-r--r-- | scripts/ports.cmake | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Build.h | 6 | ||||
| -rw-r--r-- | toolsrc/src/commands_install.cpp | 34 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Build.cpp | 15 |
11 files changed, 287 insertions, 29 deletions
diff --git a/ports/azure-storage-cpp/portfile.cmake b/ports/azure-storage-cpp/portfile.cmake index 38c034127..150c4aafc 100644 --- a/ports/azure-storage-cpp/portfile.cmake +++ b/ports/azure-storage-cpp/portfile.cmake @@ -1,12 +1,12 @@ include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/azure-storage-cpp-3.0.0) -vcpkg_download_distfile(ARCHIVE - URLS "https://github.com/Azure/azure-storage-cpp/archive/v3.0.0.tar.gz" - FILENAME "azure-storage-cpp/v3.0.0.tar.gz" +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-storage-cpp + REF v3.0.0 SHA512 45d0d7f8cc350a16cff0371cdd442e851912c89061acfec559482e8f79cebafffd8681b32a30b878e329235cd3aaad5d2ff797d1148302e3109cf5111df14b97 + HEAD_REF master ) -vcpkg_extract_source_archive(${ARCHIVE}) vcpkg_apply_patches( SOURCE_PATH ${SOURCE_PATH} diff --git a/ports/cpprestsdk/portfile.cmake b/ports/cpprestsdk/portfile.cmake index 2d23bf632..ea7d8d201 100644 --- a/ports/cpprestsdk/portfile.cmake +++ b/ports/cpprestsdk/portfile.cmake @@ -1,20 +1,20 @@ include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/cpprestsdk-2.9.0) -vcpkg_download_distfile(ARCHIVE - URLS "https://github.com/Microsoft/cpprestsdk/archive/v2.9.0.tar.gz" - FILENAME "cpprestsdk-2.9.0.tar.gz" +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Microsoft/cpprestsdk + REF v2.9.0 SHA512 c75de6ad33b3e8d2c6ba7c0955ed851d557f78652fb38a565de0cfbc99e7db89cb6fa405857512e5149df80356c51ae9335abd914c3c593fa6658ac50adf4e29 + HEAD_REF master ) -vcpkg_extract_source_archive(${ARCHIVE}) - - -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES - ${CMAKE_CURRENT_LIST_DIR}/0001_cmake.patch - ${CMAKE_CURRENT_LIST_DIR}/0002_no_websocketpp_in_uwp.patch -) +if(NOT VCPKG_USE_HEAD_VERSION) + vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES + ${CMAKE_CURRENT_LIST_DIR}/0001_cmake.patch + ${CMAKE_CURRENT_LIST_DIR}/0002_no_websocketpp_in_uwp.patch + ) +endif() set(OPTIONS) if(NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") @@ -26,17 +26,24 @@ endif() vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH}/Release + PREFER_NINJA OPTIONS ${OPTIONS} -DBUILD_TESTS=OFF -DBUILD_SAMPLES=OFF -DCPPREST_EXCLUDE_WEBSOCKETS=OFF + -DCPPREST_EXPORT_DIR=share/cpprestsdk OPTIONS_DEBUG -DCASA_INSTALL_HEADERS=OFF + -DCPPREST_INSTALL_HEADERS=OFF ) vcpkg_install_cmake() +if(VCPKG_USE_HEAD_VERSION) + vcpkg_fixup_cmake_targets() +endif() + file(INSTALL ${SOURCE_PATH}/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/cpprestsdk RENAME copyright) diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index a003548d5..a0e9633c3 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -4,6 +4,8 @@ include(vcpkg_extract_source_archive) include(vcpkg_execute_required_process) include(vcpkg_execute_required_process_repeat) include(vcpkg_find_acquire_program) +include(vcpkg_fixup_cmake_targets) +include(vcpkg_from_github) include(vcpkg_build_cmake) include(vcpkg_build_msbuild) include(vcpkg_build_qmake) diff --git a/scripts/cmake/vcpkg_download_distfile.cmake b/scripts/cmake/vcpkg_download_distfile.cmake index 44b562573..d086f9d23 100644 --- a/scripts/cmake/vcpkg_download_distfile.cmake +++ b/scripts/cmake/vcpkg_download_distfile.cmake @@ -23,6 +23,10 @@ function(vcpkg_download_distfile VAR) message(STATUS "Using cached ${downloaded_file_path}") test_hash("cached file" "Please delete the file and retry if this file should be downloaded again.") else() + if(_VCPKG_NO_DOWNLOADS) + message(FATAL_ERROR "Downloads are disabled, but '${downloaded_file_path}' does not exist.") + endif() + # Tries to download the file. foreach(url IN LISTS vcpkg_download_distfile_URLS) message(STATUS "Downloading ${url}...") diff --git a/scripts/cmake/vcpkg_extract_source_archive.cmake b/scripts/cmake/vcpkg_extract_source_archive.cmake index 70c9fe06b..71654b452 100644 --- a/scripts/cmake/vcpkg_extract_source_archive.cmake +++ b/scripts/cmake/vcpkg_extract_source_archive.cmake @@ -1,18 +1,24 @@ include(vcpkg_execute_required_process) -function(vcpkg_extract_source_archive ARCHIVE) - if(NOT ARGC EQUAL 2) - set(WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src) +function(vcpkg_extract_source_archive_ex) + cmake_parse_arguments(_vesae "" "ARCHIVE;WORKING_DIRECTORY" "" ${ARGN}) + + if(NOT _vesae_ARCHIVE) + message(FATAL_ERROR "Must specify ARCHIVE parameter to vcpkg_extract_source_archive_ex()") + endif() + + if(DEFINED _vesae_WORKING_DIRECTORY) + set(WORKING_DIRECTORY ${_vesae_WORKING_DIRECTORY}) else() - set(WORKING_DIRECTORY ${ARGV1}) + set(WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src) endif() - get_filename_component(ARCHIVE_FILENAME ${ARCHIVE} NAME) + get_filename_component(ARCHIVE_FILENAME ${_vesae_ARCHIVE} NAME) if(NOT EXISTS ${WORKING_DIRECTORY}/${ARCHIVE_FILENAME}.extracted) - message(STATUS "Extracting source ${ARCHIVE}") + message(STATUS "Extracting source ${_vesae_ARCHIVE}") file(MAKE_DIRECTORY ${WORKING_DIRECTORY}) vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} + COMMAND ${CMAKE_COMMAND} -E tar xjf ${_vesae_ARCHIVE} WORKING_DIRECTORY ${WORKING_DIRECTORY} LOGNAME extract ) @@ -20,3 +26,14 @@ function(vcpkg_extract_source_archive ARCHIVE) endif() message(STATUS "Extracting done") endfunction() + +function(vcpkg_extract_source_archive ARCHIVE) + if(NOT ARGC EQUAL 2) + vcpkg_extract_source_archive_ex(ARCHIVE ${ARCHIVE}) + else() + vcpkg_extract_source_archive_ex( + ARCHIVE ${ARCHIVE} + WORKING_DIRECTORY ${ARGV1} + ) + endif() +endfunction()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake new file mode 100644 index 000000000..c2829be7e --- /dev/null +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -0,0 +1,47 @@ +#.rst: +# .. command:: vcpkg_fixup_cmake_targets +# +# Transform all /debug/share/<port>/*targets-debug.cmake files and move them to /share/<port>. +# Removes all /debug/share/<port>/*targets.cmake and /debug/share/<port>/*config.cmake +# +# :: +# vcpkg_fixup_cmake_targets() +# + +function(vcpkg_fixup_cmake_targets) + cmake_parse_arguments(_vfct "" "" "" ${ARGN}) + + set(DEBUG_SHARE ${CURRENT_PACKAGES_DIR}/debug/share/${PORT}) + set(RELEASE_SHARE ${CURRENT_PACKAGES_DIR}/share/${PORT}) + + if(NOT EXISTS ${DEBUG_SHARE}) + message(FATAL_ERROR "'${DEBUG_SHARE}' does not exist") + endif() + + file(GLOB UNUSED_FILES "${DEBUG_SHARE}/*[Tt]argets.cmake" "${DEBUG_SHARE}/*[Cc]onfig.cmake") + file(REMOVE ${UNUSED_FILES}) + + file(GLOB DEBUG_TARGETS "${DEBUG_SHARE}/*[Tt]argets-debug.cmake") + + foreach(DEBUG_TARGET ${DEBUG_TARGETS}) + get_filename_component(DEBUG_TARGET_NAME ${DEBUG_TARGET} NAME) + + file(READ ${DEBUG_TARGET} _contents) + string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" _contents "${_contents}") + file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/${DEBUG_TARGET_NAME} "${_contents}") + + file(REMOVE ${DEBUG_TARGET}) + endforeach() + + # Remove /debug/share/<port>/ if it's empty. + file(GLOB_RECURSE REMAINING_FILES "${DEBUG_SHARE}/*") + if(NOT REMAINING_FILES) + file(REMOVE_RECURSE ${DEBUG_SHARE}) + endif() + + # Remove /debug/share/ if it's empty. + file(GLOB_RECURSE REMAINING_FILES "${CURRENT_PACKAGES_DIR}/debug/share/*") + if(NOT REMAINING_FILES) + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) + endif() +endfunction() diff --git a/scripts/cmake/vcpkg_from_github.cmake b/scripts/cmake/vcpkg_from_github.cmake new file mode 100644 index 000000000..f0f8dba8b --- /dev/null +++ b/scripts/cmake/vcpkg_from_github.cmake @@ -0,0 +1,131 @@ +# Usage: +# vcpkg_from_github( +# OUT_SOURCE_PATH <OutVar for SOURCE_PATH (SOURCE_PATH)> +# REPO <Repository (Microsoft/cpprestsdk)> +# REF <stable ref (v2.0.0)> +# SHA512 <SHA for REF (45d0d7f8cc350...)> +# HEAD_REF <unstable branch (master)> +# ) +# +# Notes: +# This will export VCPKG_HEAD_VERSION variable during head builds. +function(vcpkg_from_github) + set(oneValueArgs OUT_SOURCE_PATH REPO REF SHA512 HEAD_REF) + set(multipleValuesArgs) + cmake_parse_arguments(_vdud "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN}) + + if(NOT _vdud_OUT_SOURCE_PATH) + message(FATAL_ERROR "OUT_SOURCE_PATH must be specified.") + endif() + + if((_vdud_REF AND NOT _vdud_SHA512) OR (NOT _vdud_REF AND _vdud_SHA512)) + message(FATAL_ERROR "SHA512 must be specified if REF is specified.") + endif() + + if(NOT _vdud_REPO) + message(FATAL_ERROR "The GitHub repository must be specified.") + endif() + + if(NOT _vdud_REF AND NOT _vdud_HEAD_REF) + message(FATAL_ERROR "At least one of REF and HEAD_REF must be specified.") + endif() + + string(REGEX REPLACE ".*/" "" REPO_NAME ${_vdud_REPO}) + string(REGEX REPLACE "/.*" "" ORG_NAME ${_vdud_REPO}) + + macro(set_SOURCE_PATH BASE BASEREF) + set(SOURCE_PATH "${BASE}/${REPO_NAME}-${BASEREF}") + if(EXISTS ${SOURCE_PATH}) + set(${_vdud_OUT_SOURCE_PATH} "${SOURCE_PATH}" PARENT_SCOPE) + else() + # Sometimes GitHub strips a leading 'v' off the REF. + string(REGEX REPLACE "^v" "" REF ${BASEREF}) + set(SOURCE_PATH "${BASE}/${REPO_NAME}-${REF}") + if(EXISTS ${SOURCE_PATH}) + set(${_vdud_OUT_SOURCE_PATH} "${SOURCE_PATH}" PARENT_SCOPE) + else() + message(FATAL_ERROR "Could not determine source path: '${BASE}/${REPO_NAME}-${BASEREF}' does not exist") + endif() + endif() + endmacro() + + if(VCPKG_USE_HEAD_VERSION AND NOT _vdud_HEAD_REF) + message(STATUS "Package does not specify HEAD_REF. Falling back to non-HEAD version.") + set(VCPKG_USE_HEAD_VERSION OFF) + endif() + + # Handle --no-head scenarios + if(NOT VCPKG_USE_HEAD_VERSION) + if(NOT _vdud_REF) + message(FATAL_ERROR "Package does not specify REF. It must built using --head.") + endif() + + vcpkg_download_distfile(ARCHIVE + URLS "https://github.com/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_REF}.tar.gz" + SHA512 "${_vdud_SHA512}" + FILENAME "${ORG_NAME}-${REPO_NAME}-${_vdud_REF}.tar.gz" + ) + vcpkg_extract_source_archive_ex(ARCHIVE "${ARCHIVE}") + set_SOURCE_PATH(${CURRENT_BUILDTREES_DIR}/src ${_vdud_REF}) + return() + endif() + + # The following is for --head scenarios + set(URL "https://github.com/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_HEAD_REF}.tar.gz") + set(downloaded_file_path "${DOWNLOADS}/${ORG_NAME}-${REPO_NAME}-${_vdud_HEAD_REF}.tar.gz") + + if(_VCPKG_NO_DOWNLOADS) + if(NOT EXISTS ${downloaded_file_path} OR NOT EXISTS ${downloaded_file_path}.version) + message(FATAL_ERROR "Downloads are disabled, but '${downloaded_file_path}' does not exist.") + endif() + message(STATUS "Using cached ${downloaded_file_path}") + else() + if(EXISTS ${downloaded_file_path}) + message(STATUS "Purging cached ${downloaded_file_path} to fetch latest (use --no-downloads to suppress)") + file(REMOVE ${downloaded_file_path}) + endif() + if(EXISTS ${downloaded_file_path}.version) + file(REMOVE ${downloaded_file_path}.version) + endif() + if(EXISTS ${CURRENT_BUILDTREES_DIR}/src/head) + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/src/head) + endif() + + # Try to download the file and version information from github. + message(STATUS "Downloading ${URL}...") + file(DOWNLOAD "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/git/refs/heads/${_vdud_HEAD_REF}" + ${downloaded_file_path}.version + STATUS download_status + ) + list(GET download_status 0 status_code) + if (NOT "${status_code}" STREQUAL "0") + file(REMOVE ${downloaded_file_path}.version) + message(FATAL_ERROR "Downloading version info for ${URL}... Failed. Status: ${download_status}") + endif() + + file(DOWNLOAD ${URL} ${downloaded_file_path} STATUS download_status) + list(GET download_status 0 status_code) + if (NOT "${status_code}" STREQUAL "0") + file(REMOVE ${downloaded_file_path}) + message(FATAL_ERROR "Downloading ${URL}... Failed. Status: ${download_status}") + else() + message(STATUS "Downloading ${URL}... OK") + endif() + endif() + + vcpkg_extract_source_archive_ex( + ARCHIVE "${downloaded_file_path}" + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/src/head" + ) + + # Parse the github refs response with regex. + # TODO: use some JSON swiss-army-knife utility instead. + file(READ "${downloaded_file_path}.version" _contents) + string(REGEX MATCH "\"sha\": \"[a-f0-9]+\"" x "${_contents}") + string(REGEX REPLACE "\"sha\": \"([a-f0-9]+)\"" "\\1" _version ${x}) + + # exports VCPKG_HEAD_VERSION to the caller. This will get picked up by ports.cmake after the build. + set(VCPKG_HEAD_VERSION ${_version} PARENT_SCOPE) + + set_SOURCE_PATH(${CURRENT_BUILDTREES_DIR}/src/head ${_vdud_HEAD_REF}) +endfunction() diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 721201b49..69606ea2e 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -88,6 +88,9 @@ if(CMD MATCHES "^BUILD$") if (DEFINED VCPKG_POLICY_EMPTY_INCLUDE_FOLDER) file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyIncludeFolder: ${VCPKG_POLICY_EMPTY_INCLUDE_FOLDER}\n") endif() + if (DEFINED VCPKG_HEAD_VERSION) + file(APPEND ${BUILD_INFO_FILE_PATH} "Version: ${VCPKG_HEAD_VERSION}\n") + endif() elseif(CMD MATCHES "^CREATE$") file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR) file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS) diff --git a/toolsrc/include/vcpkg_Build.h b/toolsrc/include/vcpkg_Build.h index eec98d861..28ddb0d16 100644 --- a/toolsrc/include/vcpkg_Build.h +++ b/toolsrc/include/vcpkg_Build.h @@ -6,6 +6,7 @@ #include "StatusParagraphs.h" #include "VcpkgPaths.h" #include "vcpkg_Files.h" +#include "vcpkg_optional.h" #include <map> #include <string> #include <unordered_map> @@ -50,6 +51,9 @@ namespace vcpkg::Build const SourceParagraph& src; const Triplet& triplet; fs::path port_dir; + + bool use_head_version; + bool no_downloads; }; ExtendedBuildResult build_package(const VcpkgPaths& paths, @@ -63,6 +67,8 @@ namespace vcpkg::Build PostBuildLint::LinkageType crt_linkage; PostBuildLint::LinkageType library_linkage; + Optional<std::string> version; + std::map<PostBuildLint::BuildPolicies, bool> policies; }; diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp index bfbefe1c1..2260b067e 100644 --- a/toolsrc/src/commands_install.cpp +++ b/toolsrc/src/commands_install.cpp @@ -265,6 +265,8 @@ namespace vcpkg::Commands::Install void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet) { static const std::string OPTION_DRY_RUN = "--dry-run"; + static const std::string OPTION_USE_HEAD_VERSION = "--head"; + static const std::string OPTION_NO_DOWNLOADS = "--no-downloads"; // input sanitization static const std::string example = @@ -277,8 +279,11 @@ namespace vcpkg::Commands::Install for (auto&& spec : specs) Input::check_triplet(spec.triplet(), paths); - const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_DRY_RUN}); + const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments( + {OPTION_DRY_RUN, OPTION_USE_HEAD_VERSION, OPTION_NO_DOWNLOADS}); const bool dryRun = options.find(OPTION_DRY_RUN) != options.cend(); + const bool use_head_version = options.find(OPTION_USE_HEAD_VERSION) != options.cend(); + const bool no_downloads = options.find(OPTION_NO_DOWNLOADS) != options.cend(); // create the plan StatusParagraphs status_db = database_load_check(paths); @@ -319,17 +324,34 @@ namespace vcpkg::Commands::Install switch (action.plan_type) { case InstallPlanType::ALREADY_INSTALLED: - System::println(System::Color::success, "Package %s is already installed", display_name); + if (use_head_version && action.request_type == RequestType::USER_REQUESTED) + { + System::println(System::Color::warning, + "Package %s is already installed -- not building from HEAD", + display_name); + } + else + { + System::println(System::Color::success, "Package %s is already installed", display_name); + } break; case InstallPlanType::BUILD_AND_INSTALL: { - System::println("Building package %s... ", display_name); Build::BuildPackageConfig build_config{ action.any_paragraph.source_paragraph.value_or_exit(VCPKG_LINE_INFO), action.spec.triplet(), paths.port_dir(action.spec), }; + build_config.use_head_version = + use_head_version && action.request_type == RequestType::USER_REQUESTED; + build_config.no_downloads = no_downloads; + + if (build_config.use_head_version) + System::println("Building package %s from HEAD... ", display_name); + else + System::println("Building package %s... ", display_name); + const auto result = Build::build_package(paths, build_config, status_db); if (result.code != Build::BuildResult::SUCCEEDED) { @@ -348,6 +370,12 @@ namespace vcpkg::Commands::Install break; } case InstallPlanType::INSTALL: + if (use_head_version && action.request_type == RequestType::USER_REQUESTED) + { + System::println(System::Color::warning, + "Package %s is already built -- not building from HEAD", + display_name); + } System::println("Installing package %s... ", display_name); install_package( paths, action.any_paragraph.binary_paragraph.value_or_exit(VCPKG_LINE_INFO), &status_db); diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp index 2573feb68..c29f61468 100644 --- a/toolsrc/src/vcpkg_Build.cpp +++ b/toolsrc/src/vcpkg_Build.cpp @@ -43,7 +43,11 @@ namespace vcpkg::Build const Triplet& triplet, const BuildInfo& build_info) { - const BinaryParagraph bpgh = BinaryParagraph(source_paragraph, triplet); + BinaryParagraph bpgh = BinaryParagraph(source_paragraph, triplet); + if (auto p_ver = build_info.version.get()) + { + bpgh.version = *p_ver; + } const fs::path binary_control_file = paths.packages / bpgh.dir() / "CONTROL"; paths.get_filesystem().write_contents(binary_control_file, Strings::serialize(bpgh)); } @@ -88,6 +92,8 @@ namespace vcpkg::Build {L"CURRENT_PORT_DIR", config.port_dir / "/."}, {L"TARGET_TRIPLET", triplet.canonical_name()}, {L"VCPKG_PLATFORM_TOOLSET", toolset.version}, + {L"VCPKG_USE_HEAD_VERSION", config.use_head_version ? L"1" : L"0"}, + {L"_VCPKG_NO_DOWNLOADS", config.no_downloads ? L"1" : L"0"}, {L"GIT", git_exe_path}}); const std::wstring command = Strings::wformat(LR"(%s && %s)", cmd_set_environment, cmd_launch_cmake); @@ -177,6 +183,13 @@ namespace vcpkg::Build "Invalid library linkage type: [%s]", library_linkage_as_string); + auto it_version = pgh.find("Version"); + if (it_version != pgh.end()) + { + build_info.version = it_version->second; + pgh.erase(it_version); + } + // The remaining entries are policies for (const std::unordered_map<std::string, std::string>::value_type& p : pgh) { |
