Skip to content

Commit

Permalink
Rollback swift version to 5.5 (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 committed Dec 8, 2022
1 parent f3ae10c commit 62a3102
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 39 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

env:
BUILDER_VERSION: v0.9.23
BUILDER_VERSION: v0.9.28
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-crt-swift
Expand Down Expand Up @@ -38,19 +38,19 @@ jobs:
aws s3 cp --debug s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-swift-5-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}
osx:
runs-on: macos-12
runs-on: macos-11
env:
DEVELOPER_DIR: /Applications/Xcode.app
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }}
devices:
runs-on: macos-12
runs-on: macos-11
env:
DEVELOPER_DIR: /Applications/Xcode.app
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/apple/swift-collections",
"state": {
"branch": null,
"revision": "48254824bb4248676bf7ce56014ff57b142b77eb",
"version": "1.0.2"
"revision": "f504716c27d2e5d4144fa4794b12129301d17729",
"version": "1.0.3"
}
}
]
Expand Down
10 changes: 7 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.5
import PackageDescription

let excludesFromAll = ["tests", "cmake", "CONTRIBUTING.md",
Expand Down Expand Up @@ -54,7 +54,9 @@ calDependencies.append("LibCrypto")
// aws-c-common config
var awsCCommonPlatformExcludes = ["source/windows", "source/android",
"AWSCRTAndroidTestRunner", "docker-images", "verification",
"include/aws/common/", "sanitizer-blacklist.txt"] + excludesFromAll
"include/aws/common/", "sanitizer-blacklist.txt",
"scripts/appverifier_ctest.py",
"scripts/appverifier_xml.py"] + excludesFromAll

#if arch(i386) || arch(x86_64)
awsCCommonPlatformExcludes.append("source/arch/arm")
Expand Down Expand Up @@ -99,7 +101,9 @@ var awsCCalPlatformExcludes = [
"bin",
"include/aws/cal/private",
"CODE_OF_CONDUCT.md",
"sanitizer-blacklist.txt"] + excludesFromAll
"sanitizer-blacklist.txt",
"ecdsa-fuzz-corpus/windows/p256_sig_corpus.txt",
"ecdsa-fuzz-corpus/darwin/p256_sig_corpus.txt"] + excludesFromAll

#if os(macOS)
awsCCalPlatformExcludes.append("source/windows")
Expand Down
51 changes: 25 additions & 26 deletions Source/AwsCommonRuntimeKit/crt/CStruct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AwsCCommon

// This file defines the protocols & helper functions for C Structs.
// Instances implementing this protocol should define RawType as their C Struct.
protocol CStruct<RawType> {
protocol CStruct {
associatedtype RawType
func withCStruct<Result>(_ body: (RawType) -> Result) -> Result
}
Expand Down Expand Up @@ -58,27 +58,26 @@ extension CStructWithUserData {
}
}

// swiftlint:disable force_cast
func withOptionalCStructPointer<T, Result>(
to arg1: (any CStruct)?, _ body: (UnsafePointer<T>?) -> Result
func withOptionalCStructPointer<T: CStruct, Result>(
to arg1: T?, _ body: (UnsafePointer<T.RawType>?) -> Result
) -> Result {
if let arg1 = arg1 {
return arg1.withCStruct { cStruct in
return withUnsafePointer(to: cStruct as! T) { structPointer in
return withUnsafePointer(to: cStruct) { structPointer in
body(structPointer)
}
}
}
return body(nil)
}

func withOptionalCStructPointer<Arg1Type,
Arg2Type,
func withOptionalCStructPointer<Arg1Type: CStruct,
Arg2Type: CStruct,
Result>(
_ arg1: (any CStruct)?,
_ arg2: (any CStruct)?,
_ body: (UnsafePointer<Arg1Type>?,
UnsafePointer<Arg2Type>?) -> Result
_ arg1: Arg1Type?,
_ arg2: Arg2Type?,
_ body: (UnsafePointer<Arg1Type.RawType>?,
UnsafePointer<Arg2Type.RawType>?) -> Result
) -> Result {
return withOptionalCStructPointer(to: arg1) { arg1Pointer in
return withOptionalCStructPointer(to: arg2) { arg2Pointer in
Expand All @@ -87,22 +86,22 @@ func withOptionalCStructPointer<Arg1Type,
}
}

func withOptionalCStructPointer<Arg1Type,
Arg2Type,
Arg3Type,
Arg4Type,
Arg5Type,
func withOptionalCStructPointer<Arg1Type: CStruct,
Arg2Type: CStruct,
Arg3Type: CStruct,
Arg4Type: CStruct,
Arg5Type: CStruct,
Result>(
_ arg1: (any CStruct)?,
_ arg2: (any CStruct)?,
_ arg3: (any CStruct)?,
_ arg4: (any CStruct)?,
_ arg5: (any CStruct)?,
_ body: (UnsafePointer<Arg1Type>?,
UnsafePointer<Arg2Type>?,
UnsafePointer<Arg3Type>?,
UnsafePointer<Arg4Type>?,
UnsafePointer<Arg5Type>?) -> Result
_ arg1: Arg1Type?,
_ arg2: Arg2Type?,
_ arg3: Arg3Type?,
_ arg4: Arg4Type?,
_ arg5: Arg5Type?,
_ body: (UnsafePointer<Arg1Type.RawType>?,
UnsafePointer<Arg2Type.RawType>?,
UnsafePointer<Arg3Type.RawType>?,
UnsafePointer<Arg4Type.RawType>?,
UnsafePointer<Arg5Type.RawType>?) -> Result
) -> Result {
return withOptionalCStructPointer(arg1, arg2) { arg1Pointer, arg2Pointer in
return withOptionalCStructPointer(arg3, arg4) { arg3Pointer, arg4Pointer in
Expand Down
2 changes: 1 addition & 1 deletion Source/AwsCommonRuntimeKit/io/HostResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private func onHostResolved(_ resolver: UnsafeMutablePointer<aws_host_resolver>?

// Success
let length = aws_array_list_length(hostAddresses!)
let addresses = (0..<length).map { index in
let addresses = (0..<length).map { index -> HostAddress in
var address: UnsafeMutableRawPointer! = nil
aws_array_list_get_at_ptr(hostAddresses!, &address, index)
let hostAddressCType = address.bindMemory(to: aws_host_address.self, capacity: 1).pointee
Expand Down
2 changes: 1 addition & 1 deletion Source/AwsCommonRuntimeKit/io/TLSContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class TLSContext {
var rawValue: UnsafeMutablePointer<aws_tls_ctx>

public init(options: TLSContextOptions, mode: TLSMode, allocator: Allocator = defaultAllocator) throws {
guard let rawValue = (options.withCPointer { optionsPointer in
guard let rawValue = (options.withCPointer { optionsPointer -> UnsafeMutablePointer<aws_tls_ctx>? in
switch mode {
case .client:
return aws_tls_client_ctx_new(allocator.rawValue, optionsPointer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ProfileCollection {
source: ProfileSourceType,
allocator: Allocator = defaultAllocator) throws {
let byteCount = data.count
guard let rawValue = (data.withUnsafeBytes { rawBufferPointer in
guard let rawValue = (data.withUnsafeBytes { rawBufferPointer -> OpaquePointer? in
var byteBuf = aws_byte_buf_from_array(rawBufferPointer.baseAddress, byteCount)
return aws_profile_collection_new_from_buffer(allocator.rawValue,
&byteBuf,
Expand Down

0 comments on commit 62a3102

Please sign in to comment.