From e2a60d1d982943ebc9f22deccb3f5b763f92dd8e Mon Sep 17 00:00:00 2001 From: Park DongHa Date: Thu, 28 Sep 2023 19:38:31 +0900 Subject: [PATCH] [apple-nio-ssl] Update to 2.25.0, support Swift 5.8 (#115) * [swift-nio-ssl] update to 2.25.0 with Swift 5.9 * gh-actions: build apple-nio-ssl * [apple-nio-ssl] update baseline --- ...roduct-dynamic.patch => fix-swiftpm.patch} | 2 +- ports/apple-nio-ssl/portfile.cmake | 224 ++++++------------ .../swiftpm-product-static.patch | 15 -- ports/apple-nio-ssl/swiftpm-use-local.patch | 13 - ports/apple-nio-ssl/vcpkg.json | 3 +- test/vcpkg.json | 10 +- versions/a-/apple-nio-ssl.json | 5 + versions/baseline.json | 4 +- 8 files changed, 86 insertions(+), 190 deletions(-) rename ports/apple-nio-ssl/{swiftpm-product-dynamic.patch => fix-swiftpm.patch} (95%) delete mode 100644 ports/apple-nio-ssl/swiftpm-product-static.patch delete mode 100644 ports/apple-nio-ssl/swiftpm-use-local.patch diff --git a/ports/apple-nio-ssl/swiftpm-product-dynamic.patch b/ports/apple-nio-ssl/fix-swiftpm.patch similarity index 95% rename from ports/apple-nio-ssl/swiftpm-product-dynamic.patch rename to ports/apple-nio-ssl/fix-swiftpm.patch index 321cfe2c..39cfad6b 100644 --- a/ports/apple-nio-ssl/swiftpm-product-dynamic.patch +++ b/ports/apple-nio-ssl/fix-swiftpm.patch @@ -1,5 +1,5 @@ diff --git a/Package.swift b/Package.swift -index 8f696fd..e4ff201 100644 +index a02b8ed..5ee71f3 100644 --- a/Package.swift +++ b/Package.swift @@ -52,9 +52,7 @@ let package = Package( diff --git a/ports/apple-nio-ssl/portfile.cmake b/ports/apple-nio-ssl/portfile.cmake index e33a8d27..2068a8c9 100644 --- a/ports/apple-nio-ssl/portfile.cmake +++ b/ports/apple-nio-ssl/portfile.cmake @@ -1,31 +1,34 @@ +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) # see https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html -if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - # By default, the project generates dynamic framework. - # These patches have NO effect. But may help debugging in the SOURCE_PATH ... - list(APPEND SWIFTPM_PATCHES swiftpm-product-dynamic.patch) - # list(APPEND XCODEBUILD_PARAMS "MACH_O_TYPE=mh_dylib") -elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - list(APPEND SWIFTPM_PATCHES swiftpm-product-static.patch) - list(APPEND XCODEBUILD_PARAMS "MACH_O_TYPE=staticlib") -endif() +# see https://mgrebenets.github.io/xcode/2019/05/12/xcode-build-settings-in-depth +list(APPEND XCODEBUILD_PARAMS + CODE_SIGNING_REQUIRED=NO + CLANG_ENABLE_CODE_COVERAGE=NO + # defines_module=yes + # SWIFT_TREAT_WARNINGS_AS_ERRORS=NO +) +# if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") +# list(APPEND XCODEBUILD_PARAMS "MACH_O_TYPE=mh_dylib") +# elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static") +# list(APPEND XCODEBUILD_PARAMS "MACH_O_TYPE=staticlib") +# endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO apple/swift-nio-ssl - REF 2.23.0 - SHA512 a7d4478f3ebd8dd1ee78c71afef610c33b74fb1b38054ef352dccbc454b8c56b30158c63d20d8468fa17e3f688445814ea743b841bbac28b8639bc81cef86632 + REF 2.25.0 + SHA512 5dec17e2d3a16c43185dd6f229aeca089fdcbea88cbdbdd26b401b7b5ccb1037d96dd008b679d36f3fa621f9569d7094b57e6bcb3b2e6b47048707bc1cd17114 HEAD_REF main PATCHES - swiftpm-use-local.patch - ${SWIFTPM_PATCHES} + fix-swiftpm.patch # SWIFTCI_USE_LOCAL_DEPS ) vcpkg_from_github( OUT_SOURCE_PATH NIO_SOURCE_PATH REPO apple/swift-nio - REF 2.42.0 - SHA512 cea980fc5b0ea74314932c8986799233731c3bfba850fef4b1a11d613b7b58c0b3ddb0dc28a7a1b04ccc9a24bafb8709e7a6335792fb4e0acaad182c2158e4cc + REF 2.54.0 + SHA512 664259d33e8c659d4544c0d96480ade35161dfbb9e8d5bc54771ae7ea26a90f90f52817e36b70fb88720881040a852dd447993e47a937bc53c51ba873c91388b HEAD_REF main ) @@ -34,161 +37,74 @@ if(NOT _VCPKG_EDITABLE) file(REMOVE_RECURSE "${SOURCE_PATH}/.build" "${SOURCE_PATH}/build") endif() -# use symbolic link to prevent SwiftPM checkouts -get_filename_component(CUSTOM_BUILDTREES_DIR "${SOURCE_PATH}" PATH) -file(CREATE_LINK "${NIO_SOURCE_PATH}" "${CUSTOM_BUILDTREES_DIR}/swift-nio" SYMBOLIC) - -function(swiftpm_generatate_xcodeproj) - cmake_parse_arguments(PARSE_ARGV 0 swiftpm "" "LOGNAME" "PARAMS") - if(DEFINED xc_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} can't handle extra arguments: ${xc_UNPARSED_ARGUMENTS}") - endif() - if(NOT DEFINED swiftpm_LOGNAME) - set(swiftpm_LOGNAME "generate") - endif() - if(NOT DEFINED swiftpm_WORKING_DIRECTORY) - set(swiftpm_WORKING_DIRECTORY "${SOURCE_PATH}") - endif() - - find_program(SWIFT NAMES swift REQUIRED) - message(STATUS "Generating Xcode project from Package.swift") - vcpkg_execute_required_process( - COMMAND ${SWIFT} package generate-xcodeproj ${swiftpm_PARAMS} - WORKING_DIRECTORY ${swiftpm_WORKING_DIRECTORY} - LOGNAME "${swiftpm_LOGNAME}-${TARGET_TRIPLET}" - ) -endfunction() +# create symbolic link to prevent swift-nio checkout +set(ENV{SWIFTCI_USE_LOCAL_DEPS} 1) +file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/swift-nio") +file(CREATE_LINK "${NIO_SOURCE_PATH}" "${CURRENT_BUILDTREES_DIR}/swift-nio" SYMBOLIC) -function(xcodebuild_build_framework) - cmake_parse_arguments(PARSE_ARGV 0 xc "COPY_AFTER_BUILD" "PROJECT;FRAMEWORK;OUTPUT_DIR;LOGNAME" "PARAMS") - if(DEFINED xc_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} can't handle extra arguments: ${xc_UNPARSED_ARGUMENTS}") - endif() - # required arguments - if(NOT DEFINED xc_PROJECT) - message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} requires: PROJECT") - endif() - set(PROJECT_FILENAME "${xc_PROJECT}.xcodeproj") +# create build dir from sources +get_filename_component(BUILD_DIR_NAME "${SOURCE_PATH}" NAME) +file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}") +file(COPY "${SOURCE_PATH}" DESTINATION "${CURRENT_BUILDTREES_DIR}") +file(RENAME "${CURRENT_BUILDTREES_DIR}/${BUILD_DIR_NAME}" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}") - if(NOT DEFINED xc_FRAMEWORK) - message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} requires: FRAMEWORK") - endif() - set(FRAMEWORK_FILENAME "${xc_FRAMEWORK}.framework") - - # optional arguments with default values - if(NOT DEFINED xc_LOGNAME) - set(xc_LOGNAME "build") - endif() - if(NOT DEFINED xc_WORKING_DIRECTORY) - set(xc_WORKING_DIRECTORY "${SOURCE_PATH}") - endif() - if(NOT DEFINED xc_OUTPUT_DIR) - get_filename_component(xc_OUTPUT_DIR "${xc_WORKING_DIRECTORY}/build" ABSOLUTE) - endif() - - # expected build output location of Package.swift generated xcodeproj - if(VCPKG_TARGET_IS_OSX) - get_filename_component(OUTPUT_DIR_DBG ${xc_OUTPUT_DIR}/Debug ABSOLUTE) - get_filename_component(OUTPUT_DIR_REL ${xc_OUTPUT_DIR}/Release ABSOLUTE) - elseif(VCPKG_TARGET_IS_IOS) - get_filename_component(OUTPUT_DIR_DBG ${xc_OUTPUT_DIR}/Debug-iphoneos ABSOLUTE) - get_filename_component(OUTPUT_DIR_REL ${xc_OUTPUT_DIR}/Release-iphoneos ABSOLUTE) - if(VCPKG_TARGET_IS_SIMULATOR) - get_filename_component(OUTPUT_DIR_DBG ${xc_OUTPUT_DIR}/Debug-iphonesimulator ABSOLUTE) - get_filename_component(OUTPUT_DIR_REL ${xc_OUTPUT_DIR}/Release-iphonesimulator ABSOLUTE) - endif() - else() - message(FATAL_ERROR "Unsupported target platform") - endif() - - # Let's start build with xcodebuild ... - find_program(XCODEBUILD NAMES xcodebuild REQUIRED) - - message(STATUS "Building ${TARGET_TRIPLET}-dbg") - vcpkg_execute_required_process( - COMMAND ${XCODEBUILD} -project ${PROJECT_FILENAME} -target ${xc_FRAMEWORK} -jobs ${VCPKG_CONCURRENCY} -configuration Debug ${xc_PARAMS} - WORKING_DIRECTORY ${xc_WORKING_DIRECTORY} - LOGNAME "${xc_LOGNAME}-${TARGET_TRIPLET}-dbg" - ) - if(xc_COPY_AFTER_BUILD) - file(COPY "${OUTPUT_DIR_DBG}/${FRAMEWORK_FILENAME}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") - endif() - - message(STATUS "Building ${TARGET_TRIPLET}-rel") - vcpkg_execute_required_process( - COMMAND ${XCODEBUILD} -project ${PROJECT_FILENAME} -target ${xc_FRAMEWORK} -jobs ${VCPKG_CONCURRENCY} -configuration Release ${xc_PARAMS} - WORKING_DIRECTORY ${xc_WORKING_DIRECTORY} - LOGNAME "${xc_LOGNAME}-${TARGET_TRIPLET}-rel" - ) - if(xc_COPY_AFTER_BUILD) - file(COPY "${OUTPUT_DIR_REL}/${FRAMEWORK_FILENAME}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") - endif() -endfunction() - -if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - set(ARCH "arm64") -elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(ARCH "x86_64") -else() - message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}") -endif() +find_program(XCODEBUILD NAMES xcodebuild REQUIRED) +message(STATUS "Using xcodebuild: ${XCODEBUILD}") +# todo: consider VCPKG_TARGET_ARCHITECTURE +# todo: variant for "Mac Catalyst" if(VCPKG_TARGET_IS_OSX) - set(SDK macosx) + set(DESTINATION "generic/platform=macOS") + set(PRODUCT_SUFFIX "") elseif(VCPKG_TARGET_IS_IOS) - set(SDK iphoneos) - if(VCPKG_TARGET_IS_SIMULATOR) - set(SDK iphonesimulator) + set(DESTINATION "generic/platform=iOS") + set(PRODUCT_SUFFIX "-iphoneos") + if(VCPKG_TARGET_IS_IOS_SIMULATOR) + set(DESTINATION "generic/platform=iOS Simulator") + set(PRODUCT_SUFFIX "-iphonesimulator") endif() else() - message(FATAL_ERROR "Unsupported target platform") + message(FATAL_ERROR "The target platform is NOT supported") endif() -# generate xcodeproject: swift-nio-ssl.xcodeproj -find_program(SWIFT NAMES swift REQUIRED) -message(STATUS "Using swift: ${SWIFT}") -swiftpm_generatate_xcodeproj(LOGNAME "generate") - -find_program(XCODEBUILD NAMES xcodebuild REQUIRED) -message(STATUS "Using xcodebuild: ${XCODEBUILD}") -message(STATUS " -sdk ${SDK} -arch ${ARCH}") -if(DEFINED XCODEBUILD_PARAMS) -message(STATUS " ${XCODEBUILD_PARAMS}") -endif() +# see Package.swift +set(SCHEME_NAME "CNIOBoringSSL") -# before build, record some project info for CI environment debugging +message(STATUS "Building ${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( - COMMAND ${XCODEBUILD} -project swift-nio-ssl.xcodeproj -list - WORKING_DIRECTORY ${SOURCE_PATH} - LOGNAME "project-${TARGET_TRIPLET}" + COMMAND ${XCODEBUILD} -scheme ${SCHEME_NAME} + -derivedDataPath DerivedData + -destination "${DESTINATION}" + -configuration Debug + ${XCODEBUILD_PARAMS} build + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}" + LOGNAME "build-${TARGET_TRIPLET}-dbg" ) -# build some targets -xcodebuild_build_framework(PROJECT swift-nio-ssl FRAMEWORK CNIOBoringSSL - PARAMS -sdk ${SDK} -arch ${ARCH} ${XCODEBUILD_PARAMS} - LOGNAME "build1" COPY_AFTER_BUILD -) -xcodebuild_build_framework(PROJECT swift-nio-ssl FRAMEWORK CNIOBoringSSLShims - PARAMS -sdk ${SDK} -arch ${ARCH} ${XCODEBUILD_PARAMS} - LOGNAME "build2" COPY_AFTER_BUILD +message(STATUS "Building ${TARGET_TRIPLET}-rel") +vcpkg_execute_required_process( + COMMAND ${XCODEBUILD} -scheme ${SCHEME_NAME} + -derivedDataPath DerivedData + -destination "${DESTINATION}" + -configuration Release + ${XCODEBUILD_PARAMS} build + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}" + LOGNAME "build-${TARGET_TRIPLET}-rel" ) +get_filename_component(DERIVED_DATA_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/DerivedData" ABSOLUTE) +get_filename_component(FRAMEWORK_OUT_DBG "${DERIVED_DATA_DIR}/Build/Products/Debug${PRODUCT_SUFFIX}/PackageFrameworks" ABSOLUTE) +file(INSTALL "${FRAMEWORK_OUT_DBG}/CNIOBoringSSL.framework" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") +get_filename_component(FRAMEWORK_OUT_REL "${DERIVED_DATA_DIR}/Build/Products/Release${PRODUCT_SUFFIX}/PackageFrameworks" ABSOLUTE) +file(INSTALL "${FRAMEWORK_OUT_REL}/CNIOBoringSSL.framework" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") + # install public/private headers -file(GLOB headers - "${SOURCE_PATH}/Sources/CNIOBoringSSL/include/*.h" -) +file(GLOB headers "${SOURCE_PATH}/Sources/CNIOBoringSSL/include/*.h") file(INSTALL ${headers} DESTINATION "${CURRENT_PACKAGES_DIR}/include/CNIOBoringSSL") -file(GLOB ssl_headers - "${SOURCE_PATH}/Sources/CNIOBoringSSL/ssl/*.h" - # ... -) -file(INSTALL ${ssl_headers} DESTINATION "${CURRENT_PACKAGES_DIR}/include/ssl") - -file(GLOB crypto_headers - "${SOURCE_PATH}/Sources/CNIOBoringSSL/crypto/internal.h" - # ... -) -file(INSTALL ${crypto_headers} DESTINATION "${CURRENT_PACKAGES_DIR}/include/crypto") +# file(GLOB ssl_headers "${SOURCE_PATH}/Sources/CNIOBoringSSL/ssl/*.h") +# file(INSTALL ${ssl_headers} DESTINATION "${CURRENT_PACKAGES_DIR}/include/ssl") +# file(GLOB crypto_headers "${SOURCE_PATH}/Sources/CNIOBoringSSL/crypto/internal.h") +# file(INSTALL ${crypto_headers} DESTINATION "${CURRENT_PACKAGES_DIR}/include/crypto") -file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") \ No newline at end of file diff --git a/ports/apple-nio-ssl/swiftpm-product-static.patch b/ports/apple-nio-ssl/swiftpm-product-static.patch deleted file mode 100644 index f8f79940..00000000 --- a/ports/apple-nio-ssl/swiftpm-product-static.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/Package.swift b/Package.swift -index 8f696fd..e4ff201 100644 ---- a/Package.swift -+++ b/Package.swift -@@ -52,9 +52,7 @@ let package = Package( - .library(name: "NIOSSL", targets: ["NIOSSL"]), - .executable(name: "NIOTLSServer", targets: ["NIOTLSServer"]), - .executable(name: "NIOSSLHTTP1Client", targets: ["NIOSSLHTTP1Client"]), --/* This target is used only for symbol mangling. It's added and removed automatically because it emits build warnings. MANGLE_START -- .library(name: "CNIOBoringSSL", type: .static, targets: ["CNIOBoringSSL"]), --MANGLE_END */ -+ .library(name: "CNIOBoringSSL", type: .static, targets: ["CNIOBoringSSL"]), // todo: check CNIOBoringSSLShims - ], - dependencies: generateDependencies(), - targets: [ diff --git a/ports/apple-nio-ssl/swiftpm-use-local.patch b/ports/apple-nio-ssl/swiftpm-use-local.patch deleted file mode 100644 index 832105ad..00000000 --- a/ports/apple-nio-ssl/swiftpm-use-local.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/Package.swift b/Package.swift -index fe72932..8f696fd 100644 ---- a/Package.swift -+++ b/Package.swift -@@ -34,7 +34,7 @@ import class Foundation.ProcessInfo - /// of the Swift toolchain, and so need to use local checkouts of our - /// dependencies. - func generateDependencies() -> [Package.Dependency] { -- if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { -+ if false { - return [ - .package(url: "https://github.com/apple/swift-nio.git", from: "2.42.0"), - .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), diff --git a/ports/apple-nio-ssl/vcpkg.json b/ports/apple-nio-ssl/vcpkg.json index 9c6b5289..ca9e2e0f 100644 --- a/ports/apple-nio-ssl/vcpkg.json +++ b/ports/apple-nio-ssl/vcpkg.json @@ -1,7 +1,6 @@ { "name": "apple-nio-ssl", - "version": "2.23.0", - "port-version": 1, + "version": "2.25.0", "description": "TLS Support for SwiftNIO, based on BoringSSL", "homepage": "https://github.com/apple/swift-nio-ssl", "license": "Apache-2.0", diff --git a/test/vcpkg.json b/test/vcpkg.json index 512c7a47..01dbc539 100644 --- a/test/vcpkg.json +++ b/test/vcpkg.json @@ -5,10 +5,14 @@ "homepage": "https://github.com/luncliff/vcpkg-registry", "supports": "windows | osx", "dependencies": [ + { + "name": "apple-nio-ssl", + "platform": "osx" + }, + "openssl3", { "name": "vcpkg-cmake", "host": true - }, - "openssl3" + } ] -} \ No newline at end of file +} diff --git a/versions/a-/apple-nio-ssl.json b/versions/a-/apple-nio-ssl.json index 4c1f547f..b2a9e554 100644 --- a/versions/a-/apple-nio-ssl.json +++ b/versions/a-/apple-nio-ssl.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "2e5776ad4b611d24f8db85265e509ff9182e2d64", + "version": "2.25.0", + "port-version": 0 + }, { "git-tree": "07a7536b39abcd83fd64ea90cb7cc68fc265cabe", "version": "2.23.0", diff --git a/versions/baseline.json b/versions/baseline.json index 429edb3d..e9aad076 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5,8 +5,8 @@ "port-version": 0 }, "apple-nio-ssl": { - "baseline": "2.23.0", - "port-version": 1 + "baseline": "2.25.0", + "port-version": 0 }, "basis-universal": { "baseline": "1.16.4",