diff options
| author | Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> | 2019-08-12 08:24:20 +0200 |
|---|---|---|
| committer | Victor Romero <romerosanchezv@gmail.com> | 2019-08-11 23:24:20 -0700 |
| commit | cabbe165259bbde86103e8764d67d122f84eb13e (patch) | |
| tree | 1963a10659501768a59ef221b313d6cfd203deb9 | |
| parent | 29ddf1a5c2711161a5642ab515f6cae5f01ca3e9 (diff) | |
| download | vcpkg-cabbe165259bbde86103e8764d67d122f84eb13e.tar.gz vcpkg-cabbe165259bbde86103e8764d67d122f84eb13e.zip | |
[vcpkg/cmake] Added a function to fail from portfiles in a default way (#7601)
* added function vcpkg_fail_port_install to fail the portfile under requested circumstances and display a standarized failure message
* added always option.
* fix linux regressions
* bump control for ci tu rerun
| -rw-r--r-- | ports/aws-lambda-cpp/CONTROL | 2 | ||||
| -rw-r--r-- | ports/aws-lambda-cpp/portfile.cmake | 7 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_common_functions.cmake | 1 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_fail_port_install.cmake | 92 |
4 files changed, 98 insertions, 4 deletions
diff --git a/ports/aws-lambda-cpp/CONTROL b/ports/aws-lambda-cpp/CONTROL index 048f28fac..53d7a917f 100644 --- a/ports/aws-lambda-cpp/CONTROL +++ b/ports/aws-lambda-cpp/CONTROL @@ -1,4 +1,4 @@ Source: aws-lambda-cpp -Version: 0.1.0-1 +Version: 0.1.0-2 Build-Depends: curl Description: C++ Runtime for AWS Lambda. diff --git a/ports/aws-lambda-cpp/portfile.cmake b/ports/aws-lambda-cpp/portfile.cmake index 4a4cddafd..7ba33e8f1 100644 --- a/ports/aws-lambda-cpp/portfile.cmake +++ b/ports/aws-lambda-cpp/portfile.cmake @@ -1,8 +1,9 @@ include(vcpkg_common_functions) -if(NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin") - message(FATAL_ERROR "aws-lambda-cpp currently only supports Linux and Mac platforms") -endif() +vcpkg_fail_port_install(MESSAGE "aws-lambda-cpp currently only supports Linux and Mac platforms" ON_TARGET "Windows") +#if(NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin") +# message(FATAL_ERROR "aws-lambda-cpp currently only supports Linux and Mac platforms") +#endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index 515b2bafe..e9e52bad8 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -9,6 +9,7 @@ include(vcpkg_extract_source_archive_ex) include(vcpkg_execute_required_process) include(vcpkg_execute_required_process_repeat) include(vcpkg_execute_build_process) +include(vcpkg_fail_port_install) include(vcpkg_find_acquire_program) include(vcpkg_fixup_cmake_targets) include(vcpkg_from_github) diff --git a/scripts/cmake/vcpkg_fail_port_install.cmake b/scripts/cmake/vcpkg_fail_port_install.cmake new file mode 100644 index 000000000..0fdacb639 --- /dev/null +++ b/scripts/cmake/vcpkg_fail_port_install.cmake @@ -0,0 +1,92 @@ +## # vcpkg_fail_port_install
+##
+## Fails the current portfile with a (default) error message
+##
+## ## Usage
+## ```cmake
+## vcpkg_fail_port_install([MESSAGE <message>] [ON_TARGET <target1> [<target2> ...]]
+## [ON_ARCH <arch1> [<arch2> ...]]
+## [ON_CRT_LINKAGE <link1> [<link2> ...]])
+## [ON_LIBRARY_LINKAGE <linklib1> [<linklib2> ...]])
+## ```
+##
+## ## Parameters
+## ### MESSAGE
+## Additional failure message. If non is given a default message will be displayed depending on the failure condition
+##
+## ### ALWAYS
+## will always fail early
+##
+## ### ON_TARGET
+## targets for which the build should fail early. Valid targets are <target> from VCPKG_IS_TARGET_<target> (see vcpkg_common_definitions.cmake)
+##
+## ### ON_ARCH
+## architecture for which the build should fail early.
+##
+## ### ON_CRT_LINKAGE
+## CRT linkage for which the build should fail early.
+##
+## ### ON_LIBRARY_LINKAGE
+## library linkage for which the build should fail early.
+##
+## ## Examples
+##
+## * [aws-lambda-cpp](https://github.com/Microsoft/vcpkg/blob/master/ports/aws-lambda-cpp/portfile.cmake)
+function(vcpkg_fail_port_install)
+ cmake_parse_arguments(PARSE_ARGV 0 _csc "ALWAYS" "MESSAGE" "ON_TARGET;ON_ARCH;ON_CRT_LINKAGE;ON_LIBRARY_LINKAGE")
+ if(DEFINED _csc_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown arguments passed to vcpkg_fail_port_install. Please correct the portfile!")
+ endif()
+ if(DEFINED _csc_MESSAGE)
+ set(_csc_MESSAGE "${_csc_MESSAGE}\n")
+ else()
+ set(_csc_MESSAGE "")
+ endif()
+
+ unset(_fail_port)
+ #Target fail check
+ if(DEFINED _csc_ON_TARGET)
+ foreach(_target ${_csc_ON_TARGET})
+ string(TOUPPER ${_target} _target_upper)
+ if(VCPKG_TARGET_IS_${_target_upper})
+ set(_fail_port TRUE)
+ set(_csc_MESSAGE "${_csc_MESSAGE}Target '${_target}' not supported by ${PORT}!\n")
+ endif()
+ endforeach()
+ endif()
+
+ #Architecture fail check
+ if(DEFINED _csc_ON_ARCH)
+ foreach(_arch ${_csc_ON_ARCH})
+ if(${VCPKG_TARGET_ARCHITECTURE} MATCHES ${_arch})
+ set(_fail_port TRUE)
+ set(_csc_MESSAGE "${_csc_MESSAGE}Architecture '${_arch}' not supported by ${PORT}!\n")
+ endif()
+ endforeach()
+ endif()
+
+ #CRT linkage fail check
+ if(DEFINED _csc_ON_CRT_LINKAGE)
+ foreach(_crt_link ${_csc_ON_CRT_LINKAGE})
+ if("${VCPKG_CRT_LINKAGE}" MATCHES "${_crt_link}")
+ set(_fail_port TRUE)
+ set(_csc_MESSAGE "${_csc_MESSAGE}CRT linkage '${VCPKG_CRT_LINKAGE}' not supported by ${PORT}!\n")
+ endif()
+ endforeach()
+ endif()
+
+ #Library linkage fail check
+ if(DEFINED _csc_ON_LIBRARY_LINKAGE)
+ foreach(_lib_link ${_csc_ON_LIBRARY_LINKAGE})
+ if("${VCPKG_LIBRARY_LINKAGE}" MATCHES "${_lib_link}")
+ set(_fail_port TRUE)
+ set(_csc_MESSAGE "${_csc_MESSAGE}Library linkage '${VCPKG_LIBRARY_LINKAGE}' not supported by ${PORT}!\n")
+ endif()
+ endforeach()
+ endif()
+
+ if(_fail_port OR _csc_ALWAYS)
+ message(FATAL_ERROR ${_csc_MESSAGE})
+ endif()
+
+endfunction()
\ No newline at end of file |
