mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-12 21:39:02 +08:00
1d8f0acc9c
==== Changes Related to manifests ==== * Add the `manifests` feature flag * This only says whether we look for a `vcpkg.json` in the cwd, not whether we support parsing manifests (for ports, for example) * Changes to the manifests RFC * `"authors"` -> `"maintainers"` * `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags` * reserve `"core"` in addition to `"default"`, since that's already reserved for features * Add a small helper note about what identifiers must look like * `<license-string>`: SPDX v3.8 -> v3.9 * `"feature"."description"` is allowed to be an array of strings as well * `"version"` -> `"version-string"` for forward-compat with versions RFC * Add the `--feature-flags` option * Add the ability to turn off feature flags via passing `-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags` * Add CMake toolchain support for manifests * Requires either: * a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}` or `VCPKG_FEATURE_FLAGS` * Passing the `VCPKG_ENABLE_MANIFESTS` option * The toolchain will install your packages to `${VCPKG_MANIFEST_DIR}/vcpkg_installed`. * Add MSBuild `vcpkg integrate install` support for manifests * Requires `VcpkgEnableManifest` to be true * `vcpkg create` creates a port that has a `vcpkg.json` instead of a `CONTROL` * argparse, abseil, 3fd, and avisynthplus ports switched to manifest from CONTROL * Add support for `--x-manifest-root`, as well as code for finding it if not passed * Add support for parsing manifests! * Add a filesystem lock! ==== Important Changes which are somewhat unrelated to manifests ==== * Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}` * Add `PlatformExpression` type which takes the place of the old logic expression * Split the parsing of platform expressions from checking whether they're true or not * Eagerly parse PlatformExpressions as opposed to leaving them as strings * Add checking for feature flag consistency * i.e., if `-binarycaching` is passed, you shouldn't be passing `--binarysource` * Add the `Json::Reader` type which, with the help of user-defined visitors, converts JSON to your internal type * VcpkgArgParser: place the switch names into a constant as opposed to using magic constants * In general update the parsing code so that this ^ works * Add `Port-Version` fields to CONTROL files * This replaces the existing practice of `Version: <my-version>-<port-version>` ==== Smaller changes ==== * small drive-by cleanups to some CMake * `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` -> `${CURRENT_INSTALLED_DIR}` * Remove `-analyze` when compiling with clang-cl, since that's not a supported flag (vcpkg's build system) * Add a message about which compiler is detected by vcpkg's build system machinery * Fix `Expected::then` * Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a `strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`) * Add `Strings::strto` which converts strings to numeric types * Support built-in arrays and `StringView` for `Strings::join` * Add `operator<` and friends to `StringView` * Add `substr` to `StringView` * SourceParagraphParser gets some new errors
124 lines
4.8 KiB
CMake
124 lines
4.8 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
|
|
macro(debug_message)
|
|
if(DEFINED PORT_DEBUG AND PORT_DEBUG)
|
|
message(STATUS "[DEBUG] ${ARGN}")
|
|
endif()
|
|
endmacro()
|
|
|
|
if((NOT DEFINED VCPKG_ROOT_DIR)
|
|
OR (NOT DEFINED DOWNLOADS)
|
|
OR (NOT DEFINED _VCPKG_INSTALLED_DIR)
|
|
OR (NOT DEFINED PACKAGES_DIR)
|
|
OR (NOT DEFINED BUILDTREES_DIR))
|
|
message(FATAL_ERROR [[
|
|
Your vcpkg executable is outdated and is not compatible with the current CMake scripts.
|
|
Please re-build vcpkg by running bootstrap-vcpkg.
|
|
]])
|
|
endif()
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
|
set(CURRENT_INSTALLED_DIR ${_VCPKG_INSTALLED_DIR}/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
|
|
set(SCRIPTS ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Location to stored scripts")
|
|
|
|
if(PORT)
|
|
set(CURRENT_BUILDTREES_DIR ${BUILDTREES_DIR}/${PORT})
|
|
set(CURRENT_PACKAGES_DIR ${PACKAGES_DIR}/${PORT}_${TARGET_TRIPLET})
|
|
endif()
|
|
|
|
|
|
if(CMD MATCHES "^BUILD$")
|
|
set(CMAKE_TRIPLET_FILE ${TARGET_TRIPLET_FILE})
|
|
if(NOT EXISTS ${CMAKE_TRIPLET_FILE})
|
|
message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}")
|
|
endif()
|
|
|
|
if(NOT DEFINED CURRENT_PORT_DIR)
|
|
message(FATAL_ERROR "CURRENT_PORT_DIR was not defined")
|
|
endif()
|
|
set(TO_CMAKE_PATH "${CURRENT_PORT_DIR}" CURRENT_PORT_DIR)
|
|
if(NOT EXISTS ${CURRENT_PORT_DIR})
|
|
message(FATAL_ERROR "Cannot find port: ${PORT}\n Directory does not exist: ${CURRENT_PORT_DIR}")
|
|
endif()
|
|
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 AND NOT EXISTS ${CURRENT_PORT_DIR}/vcpkg.json)
|
|
message(FATAL_ERROR "Port is missing control or manifest file: ${CURRENT_PORT_DIR}/{CONTROL,vcpkg.json}")
|
|
endif()
|
|
|
|
unset(PACKAGES_DIR)
|
|
unset(BUILDTREES_DIR)
|
|
|
|
if(EXISTS ${CURRENT_PACKAGES_DIR})
|
|
file(GLOB FILES_IN_CURRENT_PACKAGES_DIR "${CURRENT_PACKAGES_DIR}/*")
|
|
if(FILES_IN_CURRENT_PACKAGES_DIR)
|
|
file(REMOVE_RECURSE ${FILES_IN_CURRENT_PACKAGES_DIR})
|
|
file(GLOB FILES_IN_CURRENT_PACKAGES_DIR "${CURRENT_PACKAGES_DIR}/*")
|
|
if(FILES_IN_CURRENT_PACKAGES_DIR)
|
|
message(FATAL_ERROR "Unable to empty directory: ${CURRENT_PACKAGES_DIR}\n Files are likely in use.")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR})
|
|
|
|
include(${CMAKE_TRIPLET_FILE})
|
|
|
|
if (DEFINED VCPKG_PORT_CONFIGS)
|
|
foreach(VCPKG_PORT_CONFIG ${VCPKG_PORT_CONFIGS})
|
|
include(${VCPKG_PORT_CONFIG})
|
|
endforeach()
|
|
endif()
|
|
|
|
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
|
|
include(${SCRIPTS}/cmake/vcpkg_common_definitions.cmake)
|
|
include(${SCRIPTS}/cmake/vcpkg_common_functions.cmake)
|
|
include(${CURRENT_PORT_DIR}/portfile.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)
|
|
set(PORT_PATH "${VCPKG_ROOT_DIR}/ports/${PORT}")
|
|
file(TO_NATIVE_PATH ${PORT_PATH} NATIVE_PORT_PATH)
|
|
set(PORTFILE_PATH "${PORT_PATH}/portfile.cmake")
|
|
file(TO_NATIVE_PATH ${PORTFILE_PATH} NATIVE_PORTFILE_PATH)
|
|
set(MANIFEST_PATH "${PORT_PATH}/vcpkg.json")
|
|
file(TO_NATIVE_PATH ${MANIFEST_PATH} NATIVE_MANIFEST_PATH)
|
|
|
|
if(EXISTS "${PORTFILE_PATH}")
|
|
message(FATAL_ERROR "Portfile already exists: '${NATIVE_PORTFILE_PATH}'")
|
|
endif()
|
|
if(NOT FILENAME)
|
|
get_filename_component(FILENAME "${URL}" NAME)
|
|
endif()
|
|
string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME})
|
|
|
|
set(DOWNLOAD_PATH "${DOWNLOADS}/${FILENAME}")
|
|
file(TO_NATIVE_PATH ${DOWNLOAD_PATH} NATIVE_DOWNLOAD_PATH)
|
|
|
|
if(EXISTS "${DOWNLOAD_PATH}")
|
|
message(STATUS "Using pre-downloaded: ${NATIVE_DOWNLOAD_PATH}")
|
|
message(STATUS "If this is not desired, delete the file and ${NATIVE_PORT_PATH}")
|
|
else()
|
|
include(vcpkg_download_distfile)
|
|
set(_VCPKG_INTERNAL_NO_HASH_CHECK ON)
|
|
vcpkg_download_distfile(ARCHIVE
|
|
URLS ${URL}
|
|
FILENAME ${FILENAME}
|
|
)
|
|
set(_VCPKG_INTERNAL_NO_HASH_CHECK OFF)
|
|
endif()
|
|
file(SHA512 ${DOWNLOAD_PATH} SHA512)
|
|
|
|
file(MAKE_DIRECTORY ${PORT_PATH})
|
|
configure_file(${SCRIPTS}/templates/portfile.in.cmake ${PORTFILE_PATH} @ONLY)
|
|
configure_file(${SCRIPTS}/templates/vcpkg.json.in ${MANIFEST_PATH} @ONLY)
|
|
|
|
message(STATUS "Generated portfile: ${NATIVE_PORTFILE_PATH}")
|
|
message(STATUS "Generated manifest: ${NATIVE_MANIFEST_PATH}")
|
|
message(STATUS "To launch an editor for these new files, run")
|
|
message(STATUS " .\\vcpkg edit ${PORT}")
|
|
endif()
|