[scripts audit] ports.cmake (#16257)

* [scripts audit] ports.cmake

* [testing] modify triplet files to test all ports
This commit is contained in:
nicole mazzuca 2021-02-18 14:27:41 -08:00 committed by GitHub
parent 5dbf58d96d
commit f3a4d1aeb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 111 additions and 105 deletions

View File

@ -1,3 +1,3 @@
# DEPRECATED
message("${_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "vcpkg_common_functions has been removed and all values are automatically provided in all portfile.cmake invocations. Please remove `include(vcpkg_common_functions)`.")
message("${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "vcpkg_common_functions has been removed and all values are automatically provided in all portfile.cmake invocations. Please remove `include(vcpkg_common_functions)`.")

View File

@ -1,4 +1,4 @@
# DEPRECATED
function(vcpkg_test_cmake)
message("${_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "vcpkg_test_cmake was a no-op and has been removed. Please remove the call to `vcpkg_test_cmake()`.")
message("${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "vcpkg_test_cmake was a no-op and has been removed. Please remove the call to `vcpkg_test_cmake()`.")
endfunction()

View File

@ -1,148 +1,150 @@
cmake_minimum_required(VERSION 3.5)
macro(debug_message)
if(DEFINED PORT_DEBUG AND PORT_DEBUG)
message(STATUS "[DEBUG] ${ARGN}")
set(SCRIPTS "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Location to stored scripts")
include("${SCRIPTS}/cmake/z_vcpkg_function_arguments.cmake")
function(debug_message)
if(PORT_DEBUG)
z_vcpkg_function_arguments(ARGS)
list(JOIN ARGS " " ARG_STRING)
message(STATUS "[DEBUG] " "${ARG_STRING}")
endif()
endmacro()
endfunction()
option(_VCPKG_PROHIBIT_BACKCOMPAT_FEATURES "Controls whether use of a backcompat only support feature fails the build.")
if (_VCPKG_PROHIBIT_BACKCOMPAT_FEATURES)
set(_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "FATAL_ERROR")
set(Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "FATAL_ERROR")
else()
set(_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "WARNING")
set(Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "WARNING")
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(vcpkg_minimum_required)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include("${SCRIPTS}/cmake/vcpkg_minimum_required.cmake")
vcpkg_minimum_required(VERSION 2021-01-13)
file(TO_CMAKE_PATH ${BUILDTREES_DIR} BUILDTREES_DIR)
file(TO_CMAKE_PATH ${PACKAGES_DIR} PACKAGES_DIR)
file(TO_CMAKE_PATH "${BUILDTREES_DIR}" BUILDTREES_DIR)
file(TO_CMAKE_PATH "${PACKAGES_DIR}" PACKAGES_DIR)
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")
set(CURRENT_INSTALLED_DIR "${_VCPKG_INSTALLED_DIR}/${TARGET_TRIPLET}" CACHE PATH "Location to install final packages")
if(PORT)
set(CURRENT_BUILDTREES_DIR ${BUILDTREES_DIR}/${PORT})
set(CURRENT_PACKAGES_DIR ${PACKAGES_DIR}/${PORT}_${TARGET_TRIPLET})
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})
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})
file(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)
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)
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()
# NOTE: this was originally done by emptying out ${CURRENT_PACKAGES_DIR}
# using file(GLOB). This fails with files containing either `;` or `[`:
# as a best effort to support these files, this now just deletes the entire directory.
if(EXISTS "${CURRENT_PACKAGES_DIR}")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}")
if(EXISTS "${CURRENT_PACKAGES_DIR}")
message(FATAL_ERROR "Unable to remove directory: ${CURRENT_PACKAGES_DIR}\n Files are likely in use.")
endif()
endif()
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR})
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}" "${CURRENT_PACKAGES_DIR}")
include(${CMAKE_TRIPLET_FILE})
include("${CMAKE_TRIPLET_FILE}")
if (DEFINED VCPKG_PORT_CONFIGS)
foreach(VCPKG_PORT_CONFIG ${VCPKG_PORT_CONFIGS})
include(${VCPKG_PORT_CONFIG})
foreach(VCPKG_PORT_CONFIG IN LISTS VCPKG_PORT_CONFIGS)
include("${VCPKG_PORT_CONFIG}")
endforeach()
endif()
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
include(${SCRIPTS}/cmake/vcpkg_common_definitions.cmake)
include(execute_process)
include(vcpkg_acquire_msys)
include(vcpkg_add_to_path)
include(vcpkg_apply_patches)
include(vcpkg_build_cmake)
include(vcpkg_build_gn)
include(vcpkg_build_make)
include(vcpkg_build_msbuild)
include(vcpkg_build_ninja)
include(vcpkg_build_nmake)
include(vcpkg_build_qmake)
include(vcpkg_buildpath_length_warning)
include(vcpkg_check_features)
include(vcpkg_check_linkage)
include(vcpkg_clean_executables_in_bin)
include(vcpkg_clean_msbuild)
include(vcpkg_configure_cmake)
include(vcpkg_configure_gn)
include(vcpkg_configure_make)
include(vcpkg_configure_meson)
include(vcpkg_configure_qmake)
include(vcpkg_copy_pdbs)
include(vcpkg_copy_tool_dependencies)
include(vcpkg_copy_tools)
include(vcpkg_download_distfile)
include(vcpkg_execute_build_process)
include(vcpkg_execute_required_process)
include(vcpkg_execute_required_process_repeat)
include(vcpkg_extract_source_archive)
include(vcpkg_extract_source_archive_ex)
include(vcpkg_fail_port_install)
include(vcpkg_find_acquire_program)
include(vcpkg_fixup_cmake_targets)
include(vcpkg_fixup_pkgconfig)
include(vcpkg_from_bitbucket)
include(vcpkg_from_git)
include(vcpkg_from_github)
include(vcpkg_from_gitlab)
include(vcpkg_from_sourceforge)
include(vcpkg_get_program_files_platform_bitness)
include(vcpkg_get_windows_sdk)
include(vcpkg_install_cmake)
include(vcpkg_install_gn)
include(vcpkg_install_make)
include(vcpkg_install_meson)
include(vcpkg_install_msbuild)
include(vcpkg_install_nmake)
include(vcpkg_install_qmake)
include(vcpkg_internal_get_cmake_vars)
include(vcpkg_replace_string)
include(vcpkg_test_cmake)
set(TRIPLET_SYSTEM_ARCH "${VCPKG_TARGET_ARCHITECTURE}")
include("${SCRIPTS}/cmake/vcpkg_common_definitions.cmake")
include("${SCRIPTS}/cmake/execute_process.cmake")
include("${SCRIPTS}/cmake/vcpkg_acquire_msys.cmake")
include("${SCRIPTS}/cmake/vcpkg_add_to_path.cmake")
include("${SCRIPTS}/cmake/vcpkg_apply_patches.cmake")
include("${SCRIPTS}/cmake/vcpkg_build_cmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_build_gn.cmake")
include("${SCRIPTS}/cmake/vcpkg_build_make.cmake")
include("${SCRIPTS}/cmake/vcpkg_build_msbuild.cmake")
include("${SCRIPTS}/cmake/vcpkg_build_ninja.cmake")
include("${SCRIPTS}/cmake/vcpkg_build_nmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_build_qmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_buildpath_length_warning.cmake")
include("${SCRIPTS}/cmake/vcpkg_check_features.cmake")
include("${SCRIPTS}/cmake/vcpkg_check_linkage.cmake")
include("${SCRIPTS}/cmake/vcpkg_clean_executables_in_bin.cmake")
include("${SCRIPTS}/cmake/vcpkg_clean_msbuild.cmake")
include("${SCRIPTS}/cmake/vcpkg_configure_cmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_configure_gn.cmake")
include("${SCRIPTS}/cmake/vcpkg_configure_make.cmake")
include("${SCRIPTS}/cmake/vcpkg_configure_meson.cmake")
include("${SCRIPTS}/cmake/vcpkg_configure_qmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_copy_pdbs.cmake")
include("${SCRIPTS}/cmake/vcpkg_copy_tool_dependencies.cmake")
include("${SCRIPTS}/cmake/vcpkg_copy_tools.cmake")
include("${SCRIPTS}/cmake/vcpkg_download_distfile.cmake")
include("${SCRIPTS}/cmake/vcpkg_execute_build_process.cmake")
include("${SCRIPTS}/cmake/vcpkg_execute_required_process.cmake")
include("${SCRIPTS}/cmake/vcpkg_execute_required_process_repeat.cmake")
include("${SCRIPTS}/cmake/vcpkg_extract_source_archive.cmake")
include("${SCRIPTS}/cmake/vcpkg_extract_source_archive_ex.cmake")
include("${SCRIPTS}/cmake/vcpkg_fail_port_install.cmake")
include("${SCRIPTS}/cmake/vcpkg_find_acquire_program.cmake")
include("${SCRIPTS}/cmake/vcpkg_fixup_cmake_targets.cmake")
include("${SCRIPTS}/cmake/vcpkg_fixup_pkgconfig.cmake")
include("${SCRIPTS}/cmake/vcpkg_from_bitbucket.cmake")
include("${SCRIPTS}/cmake/vcpkg_from_git.cmake")
include("${SCRIPTS}/cmake/vcpkg_from_github.cmake")
include("${SCRIPTS}/cmake/vcpkg_from_gitlab.cmake")
include("${SCRIPTS}/cmake/vcpkg_from_sourceforge.cmake")
include("${SCRIPTS}/cmake/vcpkg_get_program_files_platform_bitness.cmake")
include("${SCRIPTS}/cmake/vcpkg_get_windows_sdk.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_cmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_gn.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_make.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_meson.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_msbuild.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_nmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_install_qmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_internal_get_cmake_vars.cmake")
include("${SCRIPTS}/cmake/vcpkg_replace_string.cmake")
include("${SCRIPTS}/cmake/vcpkg_test_cmake.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_prettify_command_line.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_function_arguments.cmake")
include(${CURRENT_PORT_DIR}/portfile.cmake)
include("${CURRENT_PORT_DIR}/portfile.cmake")
if(DEFINED PORT)
include(${SCRIPTS}/build_info.cmake)
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)
file(TO_NATIVE_PATH "${VCPKG_ROOT_DIR}" NATIVE_VCPKG_ROOT_DIR)
file(TO_NATIVE_PATH "${DOWNLOADS}" NATIVE_DOWNLOADS)
if(NOT DEFINED PORT_PATH)
set(PORT_PATH "${VCPKG_ROOT_DIR}/ports/${PORT}")
endif()
file(TO_NATIVE_PATH ${PORT_PATH} NATIVE_PORT_PATH)
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)
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)
file(TO_NATIVE_PATH "${MANIFEST_PATH}" NATIVE_MANIFEST_PATH)
if(EXISTS "${PORTFILE_PATH}")
message(FATAL_ERROR "Portfile already exists: '${NATIVE_PORTFILE_PATH}'")
@ -150,10 +152,10 @@ elseif(CMD MATCHES "^CREATE$")
if(NOT FILENAME)
get_filename_component(FILENAME "${URL}" NAME)
endif()
string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME})
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)
file(TO_NATIVE_PATH "${DOWNLOAD_PATH}" NATIVE_DOWNLOAD_PATH)
if(EXISTS "${DOWNLOAD_PATH}")
message(STATUS "Using pre-downloaded: ${NATIVE_DOWNLOAD_PATH}")
@ -162,16 +164,16 @@ elseif(CMD MATCHES "^CREATE$")
include(vcpkg_download_distfile)
set(_VCPKG_INTERNAL_NO_HASH_CHECK ON)
vcpkg_download_distfile(ARCHIVE
URLS ${URL}
FILENAME ${FILENAME}
URLS "${URL}"
FILENAME "${FILENAME}"
)
set(_VCPKG_INTERNAL_NO_HASH_CHECK OFF)
endif()
file(SHA512 ${DOWNLOAD_PATH} SHA512)
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)
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}")

View File

@ -4,3 +4,4 @@ set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CMAKE_SYSTEM_NAME WindowsStore)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)

View File

@ -1,5 +1,3 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

View File

@ -3,3 +3,4 @@ set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

View File

@ -4,3 +4,4 @@ set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES x86_64)

View File

@ -4,3 +4,4 @@ set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CMAKE_SYSTEM_NAME WindowsStore)
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)

View File

@ -1,3 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)

View File

@ -1,3 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)