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

Swift PM and Linux Support #35

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions Ambassador/Responses/DelayResponse.swift
Expand Up @@ -42,8 +42,13 @@ public struct DelayResponse: WebApp {
case .delay(let seconds):
delayTime = seconds
case .random(let min, let max):
let random = (Double(arc4random()) / 0x100000000)
delayTime = min + (max - min) * random
#if os(Linux)
srandom(UInt32(time(nil)))
let randomValue = (Double(random()) / 0x100000000)
#else
let randomValue = (Double(arc4random()) / 0x100000000)
#endif
delayTime = min + (max - min) * randomValue
}
let loop = environ["embassy.event_loop"] as! EventLoop

Expand Down
2 changes: 1 addition & 1 deletion Ambassador/Router.swift
Expand Up @@ -65,7 +65,7 @@ open class Router: WebApp {
range: NSRange(location: 0, length: searchPath.count)
)
if !matches.isEmpty {
let searchPath = searchPath as NSString
let searchPath = NSString(string: searchPath)
let match = matches[0]
var captures = [String]()
for rangeIdx in 1 ..< match.numberOfRanges {
Expand Down
16 changes: 16 additions & 0 deletions Package.resolved
@@ -0,0 +1,16 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpageler93 I guess maybe we don't want to include package.resolved in this package. The document says it seems like having Package.resolved as a dependent has no effect to package which depends on it

https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md#resolved-versions-packageresolved-file

but still it's kinda odd to ping the version here as this is a lib package, it makes no sense to pin the version of embassy here

"object": {
"pins": [
{
"package": "Embassy",
"repositoryURL": "https://github.com/envoy/Embassy.git",
"state": {
"branch": null,
"revision": "e360117bb28eff5e737b2160575c08399539989d",
"version": "4.0.5"
}
}
]
},
"version": 1
}
17 changes: 17 additions & 0 deletions Package.swift
@@ -0,0 +1,17 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Ambassador",
products: [
.library(name: "Ambassador", targets: ["Ambassador"]),
],
dependencies: [
.package(url: "https://github.com/envoy/Embassy.git", from: "4.0.5")
],
targets: [
.target(name: "Ambassador", dependencies: ["Embassy"], path: "Ambassador"),
]
)