Skip to content

Commit

Permalink
Support Swift 4.2 (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
djones6 committed Sep 27, 2018
1 parent 4023a2e commit f791c0a
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.2
4.2
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ matrix:
- os: linux
dist: trusty
sudo: required
env: SWIFT_SNAPSHOT=4.1.3
- os: linux
dist: trusty
sudo: required
Expand All @@ -21,19 +22,17 @@ matrix:
- os: linux
dist: trusty
sudo: required
env: SWIFT_SNAPSHOT=swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-19-a
- os: osx
osx_image: xcode9.2
sudo: required
env: SWIFT_SNAPSHOT=4.0.3
- os: osx
osx_image: xcode9.4
sudo: required
env: JAZZY_ELIGIBLE=true
env: SWIFT_SNAPSHOT=4.1.2 JAZZY_ELIGIBLE=true
- os: osx
osx_image: xcode9.4
osx_image: xcode10
sudo: required
env: SWIFT_SNAPSHOT=swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-04-a

script:
- ./build.sh
57 changes: 32 additions & 25 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

/**
Expand All @@ -22,30 +22,51 @@ import PackageDescription
var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", from: "1.7.3"),
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/CCurl.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSSLService.git", from: "1.0.0")
]

var kituraNetDependencies: [Target.Dependency] = [
.byNameItem(name: "CHTTPParser"),
.byNameItem(name: "LoggerAPI"),
.byNameItem(name: "Socket"),
.byNameItem(name: "CCurl"),
.byNameItem(name: "SSLService")
.byName(name: "CHTTPParser"),
.byName(name: "LoggerAPI"),
.byName(name: "Socket"),
.target(name: "CCurl"),
.byName(name: "SSLService")
]

#if os(Linux)
dependencies.append(contentsOf: [
.package(url: "https://github.com/IBM-Swift/CEpoll.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSignals.git", from: "1.0.0")
])

kituraNetDependencies.append(contentsOf: [
.byNameItem(name: "CEpoll"),
.byNameItem(name: "Signals")
.target(name: "CEpoll"),
.byName(name: "Signals")
])
#endif

var targets: [Target] = [
.target(
name: "CHTTPParser"
),
.systemLibrary(
name: "CCurl"
),
.target(
name: "KituraNet",
dependencies: kituraNetDependencies
),
.testTarget(
name: "KituraNetTests",
dependencies: ["KituraNet"]
)
]

#if os(Linux)
targets.append(
.systemLibrary(name: "CEpoll")
)
#endif

let package = Package(
name: "Kitura-net",
products: [
Expand All @@ -56,19 +77,5 @@ let package = Package(
)
],
dependencies: dependencies,
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "CHTTPParser"
),
.target(
name: "KituraNet",
dependencies: kituraNetDependencies
),
.testTarget(
name: "KituraNetTests",
dependencies: ["KituraNet"]
)
]
targets: targets
)
74 changes: 74 additions & 0 deletions Package@swift-4.0.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

/**
* Copyright IBM Corporation 2016, 2017
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

import PackageDescription

var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", from: "1.7.3"),
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/CCurl.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSSLService.git", from: "1.0.0")
]

var kituraNetDependencies: [Target.Dependency] = [
.byNameItem(name: "CHTTPParser"),
.byNameItem(name: "LoggerAPI"),
.byNameItem(name: "Socket"),
.byNameItem(name: "CCurl"),
.byNameItem(name: "SSLService")
]

#if os(Linux)
dependencies.append(contentsOf: [
.package(url: "https://github.com/IBM-Swift/CEpoll.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSignals.git", from: "1.0.0")
])

kituraNetDependencies.append(contentsOf: [
.byNameItem(name: "CEpoll"),
.byNameItem(name: "Signals")
])
#endif

let package = Package(
name: "Kitura-net",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "KituraNet",
targets: ["KituraNet"]
)
],
dependencies: dependencies,
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "CHTTPParser"
),
.target(
name: "KituraNet",
dependencies: kituraNetDependencies
),
.testTarget(
name: "KituraNetTests",
dependencies: ["KituraNet"]
)
]
)
74 changes: 74 additions & 0 deletions Package@swift-4.1.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

/**
* Copyright IBM Corporation 2016, 2017
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

import PackageDescription

var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", from: "1.7.3"),
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/CCurl.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSSLService.git", from: "1.0.0")
]

var kituraNetDependencies: [Target.Dependency] = [
.byNameItem(name: "CHTTPParser"),
.byNameItem(name: "LoggerAPI"),
.byNameItem(name: "Socket"),
.byNameItem(name: "CCurl"),
.byNameItem(name: "SSLService")
]

#if os(Linux)
dependencies.append(contentsOf: [
.package(url: "https://github.com/IBM-Swift/CEpoll.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSignals.git", from: "1.0.0")
])

kituraNetDependencies.append(contentsOf: [
.byNameItem(name: "CEpoll"),
.byNameItem(name: "Signals")
])
#endif

let package = Package(
name: "Kitura-net",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "KituraNet",
targets: ["KituraNet"]
)
],
dependencies: dependencies,
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "CHTTPParser"
),
.target(
name: "KituraNet",
dependencies: kituraNetDependencies
),
.testTarget(
name: "KituraNetTests",
dependencies: ["KituraNet"]
)
]
)
21 changes: 21 additions & 0 deletions Sources/CCurl/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright IBM Corporation 2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

module CCurl [system] {
header "shim.h"
link "curl"
export *
}
85 changes: 85 additions & 0 deletions Sources/CCurl/shim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Copyright IBM Corporation 2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

#ifndef CurlHelpers_h
#define CurlHelpers_h

#import <curl/curl.h>

#define CURL_TRUE 1
#define CURL_FALSE 0

static inline CURLcode curlHelperSetOptBool(CURL *curl, CURLoption option, int yesNo) {
return curl_easy_setopt(curl, option, yesNo == CURL_TRUE ? 1L : 0L);
}

// set options list - CURLOPT_HTTPHEADER, CURLOPT_HTTP200ALIASES, CURLOPT_QUOTE, CURLOPT_TELNETOPTIONS, CURLOPT_MAIL_RCPT, etc.
static inline CURLcode curlHelperSetOptList(CURL *curl, CURLoption option, struct curl_slist *list) {
return curl_easy_setopt(curl, option, list);
}

__attribute__((deprecated("curlHelperSetOptHeaders has been deprecated please use curlHelperSetOptList(curl, CURLOPT_HTTPHEADER, headers) instead")))
static inline CURLcode curlHelperSetOptHeaders(CURL *curl, struct curl_slist *headers) {
return curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
}

static inline CURLcode curlHelperSetOptInt(CURL *curl, CURLoption option, long data) {
return curl_easy_setopt(curl, option, data);
}

// const keyword is used so that Swift strings can be passed
static inline CURLcode curlHelperSetOptString(CURL *curl, CURLoption option, const char *data) {
return curl_easy_setopt(curl, option, data);
}

static inline CURLcode curlHelperSetOptReadFunc(CURL *curl, void *userData, size_t (*read_cb) (char *buffer, size_t size, size_t nitems, void *userdata)) {

CURLcode rc = curl_easy_setopt(curl, CURLOPT_READDATA, userData);
if (rc == CURLE_OK) {
rc = curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
}
return rc;
}

static inline CURLcode curlHelperSetOptWriteFunc(CURL *curl, void *userData, size_t (*write_cb) (char *ptr, size_t size, size_t nmemb, void *userdata)) {

CURLcode rc = curl_easy_setopt(curl, CURLOPT_WRITEDATA, userData);
if (rc == CURLE_OK) {
rc = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
}
return rc;
}

static inline CURLcode curlHelperSetOptHeaderFunc(CURL *curl, void *userData, size_t (*header_cb) (char *buffer, size_t size, size_t nmemb, void *userdata)) {

CURLcode rc = curl_easy_setopt(curl, CURLOPT_HEADERDATA, userData);
if (rc == CURLE_OK) {
rc = curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_cb);
}
return rc;
}

static inline CURLcode curlHelperGetInfoCString(CURL *curl, CURLINFO info, char **data) {
return curl_easy_getinfo(curl, info, data);
}


static inline CURLcode curlHelperGetInfoLong(CURL *curl, CURLINFO info, long *data) {
return curl_easy_getinfo(curl, info, data);
}


#endif /* CurlHelpers_h */
20 changes: 20 additions & 0 deletions Sources/CEpoll/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright IBM Corporation 2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

module CEpoll {
header "shim.h"
export *
}
Loading

0 comments on commit f791c0a

Please sign in to comment.