Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apple-nio-ssl] Update to 2.25.0, support Swift 5.8 #115

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
224 changes: 70 additions & 154 deletions ports/apple-nio-ssl/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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
)

Expand All @@ -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")
15 changes: 0 additions & 15 deletions ports/apple-nio-ssl/swiftpm-product-static.patch

This file was deleted.

13 changes: 0 additions & 13 deletions ports/apple-nio-ssl/swiftpm-use-local.patch

This file was deleted.

3 changes: 1 addition & 2 deletions ports/apple-nio-ssl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 7 additions & 3 deletions test/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
}
5 changes: 5 additions & 0 deletions versions/a-/apple-nio-ssl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "2e5776ad4b611d24f8db85265e509ff9182e2d64",
"version": "2.25.0",
"port-version": 0
},
{
"git-tree": "07a7536b39abcd83fd64ea90cb7cc68fc265cabe",
"version": "2.23.0",
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down