From 8df90aaa603064a87eca870a21a3933a316f7441 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Sat, 6 May 2017 23:02:25 -0700 Subject: [PATCH] [grpc] Use vcpkg_fixup_cmake_targets() and improve file layout. --- ports/grpc/CONTROL | 2 +- ports/grpc/portfile.cmake | 30 +++++++------------ scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 20 ++++++++++--- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/ports/grpc/CONTROL b/ports/grpc/CONTROL index a4b73017299..ee0c257de2e 100644 --- a/ports/grpc/CONTROL +++ b/ports/grpc/CONTROL @@ -1,4 +1,4 @@ Source: grpc -Version: 1.2.3 +Version: 1.2.3-1 Build-Depends: zlib, openssl, protobuf Description: An RPC library and framework \ No newline at end of file diff --git a/ports/grpc/portfile.cmake b/ports/grpc/portfile.cmake index b6767b4e4d5..73881a4c206 100644 --- a/ports/grpc/portfile.cmake +++ b/ports/grpc/portfile.cmake @@ -12,12 +12,13 @@ if(EXISTS "${CURRENT_BUILDTREES_DIR}/src/.git") file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/src) endif() -vcpkg_download_distfile(ARCHIVE_FILE - URLS "https://github.com/grpc/grpc/archive/v${GRPC_VERSION}.zip" - FILENAME "grpc-v${GRPC_VERSION}.tar.gz" - SHA512 1468ace60ce9affb563b8145d43793778786626bfd568c79ba9c9792bf05adb86e99dfd13ff21c4b723909fbddae583148201be1a694bc0960fbe10200f52544 +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO grpc/grpc + REF v1.2.3 + SHA512 51e3c2f866fcac861ca007dd022373e63f82c63754001d1182ea14dd2eff2dfba325f8bc130ddf94e4ae35e23299ca337a6c5c6a9cee145f9e5c79e4c46af280 + HEAD_REF master ) -vcpkg_extract_source_archive(${ARCHIVE_FILE}) vcpkg_apply_patches( SOURCE_PATH ${SOURCE_PATH} @@ -36,30 +37,19 @@ vcpkg_configure_cmake( ) vcpkg_install_cmake() - -# Update paths in gRPCTargets-release.cmake -file(READ ${CURRENT_PACKAGES_DIR}/share/grpc/gRPCTargets-release.cmake _contents) -string(REPLACE "\${_IMPORT_PREFIX}/bin/" "\${_IMPORT_PREFIX}/tools/" _contents "${_contents}") -file(WRITE ${CURRENT_PACKAGES_DIR}/share/grpc/gRPCTargets-release.cmake "${_contents}") - -# Update paths in gRPCTargets-debug.cmake -file(READ ${CURRENT_PACKAGES_DIR}/debug/share/grpc/gRPCTargets-debug.cmake _contents) -string(REPLACE "\${_IMPORT_PREFIX}/bin/" "\${_IMPORT_PREFIX}/tools/" _contents "${_contents}") -string(REPLACE "\${_IMPORT_PREFIX}/lib/" "\${_IMPORT_PREFIX}/debug/lib/" _contents "${_contents}") -file(WRITE ${CURRENT_PACKAGES_DIR}/share/grpc/gRPCTargets-debug.cmake "${_contents}") +vcpkg_fixup_cmake_targets() file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/grpc RENAME copyright) -file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools) # Install tools and plugins file(GLOB TOOLS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.exe") if(TOOLS) - file(COPY ${TOOLS} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/grpc) + file(COPY ${TOOLS} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/grpc) endif() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) vcpkg_copy_pdbs() diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index c2829be7eb5..f753f63967e 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -4,6 +4,8 @@ # Transform all /debug/share//*targets-debug.cmake files and move them to /share/. # Removes all /debug/share//*targets.cmake and /debug/share//*config.cmake # +# Transform all references matching /bin/*.exe to /tools//*.exe +# # :: # vcpkg_fixup_cmake_targets() # @@ -15,19 +17,29 @@ function(vcpkg_fixup_cmake_targets) set(RELEASE_SHARE ${CURRENT_PACKAGES_DIR}/share/${PORT}) if(NOT EXISTS ${DEBUG_SHARE}) - message(FATAL_ERROR "'${DEBUG_SHARE}' does not exist") + message(FATAL_ERROR "'${DEBUG_SHARE}' does not exist.") endif() - file(GLOB UNUSED_FILES "${DEBUG_SHARE}/*[Tt]argets.cmake" "${DEBUG_SHARE}/*[Cc]onfig.cmake") + file(GLOB UNUSED_FILES "${DEBUG_SHARE}/*[Tt]argets.cmake" "${DEBUG_SHARE}/*[Cc]onfig.cmake" "${DEBUG_SHARE}/*[Cc]onfigVersion.cmake") file(REMOVE ${UNUSED_FILES}) - file(GLOB DEBUG_TARGETS "${DEBUG_SHARE}/*[Tt]argets-debug.cmake") + file(GLOB RELEASE_TARGETS "${RELEASE_SHARE}/*[Tt]argets-release.cmake") + foreach(RELEASE_TARGET ${RELEASE_TARGETS}) + get_filename_component(RELEASE_TARGET_NAME ${RELEASE_TARGET} NAME) + file(READ ${RELEASE_TARGET} _contents) + string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}") + file(WRITE ${RELEASE_TARGET} "${_contents}") + endforeach() + + 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}") + string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}") + string(REPLACE "\${_IMPORT_PREFIX}/lib" "\${_IMPORT_PREFIX}/debug/lib" _contents "${_contents}") + string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/debug/bin" _contents "${_contents}") file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/${DEBUG_TARGET_NAME} "${_contents}") file(REMOVE ${DEBUG_TARGET})