Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
helje5 committed Nov 17, 2017
2 parents 475f747 + 8e6c509 commit c2db3ec
Show file tree
Hide file tree
Showing 42 changed files with 456 additions and 836 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
19 changes: 19 additions & 0 deletions .travis.d/before-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

if [[ "$TRAVIS_OS_NAME" == "Linux" ]]; then
sudo apt-get install -y wget \
clang-3.6 libc6-dev make git libicu52 libicu-dev \
git autoconf libtool pkg-config \
libblocksruntime-dev \
libkqueue-dev \
libpthread-workqueue-dev \
systemtap-sdt-dev \
libbsd-dev libbsd0 libbsd0-dbg \
curl libcurl4-openssl-dev \
libedit-dev \
python2.7 python2.7-dev \
libxml2

sudo update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100
fi
35 changes: 35 additions & 0 deletions .travis.d/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# our path is:
# /home/travis/build/NozeIO/Noze.io/

# Install Swift

wget "${SWIFT_SNAPSHOT_NAME}"

TARBALL="`ls swift-*.tar.gz`"
echo "Tarball: $TARBALL"

TARPATH="$PWD/$TARBALL"

cd $HOME # expand Swift tarball in $HOME
tar zx --strip 1 --file=$TARPATH
pwd

export PATH="$PWD/usr/bin:$PATH"
which swift

if [ `which swift` ]; then
echo "Installed Swift: `which swift`"
else
echo "Failed to install Swift?"
exit 42
fi
swift --version


# Environment

TT_SWIFT_BINARY=`which swift`

echo "${TT_SWIFT_BINARY}"
30 changes: 21 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
language: generic

notifications:
slack:
rooms:
- nozeio:LIFY1Jtkx0FRcLq3u1WliHRZ

matrix:
include:
- os: Linux
dist: trusty
env: "SWIFT_SNAPSHOT_NAME=https://swift.org/builds/swift-3.0-preview-1/ubuntu1404/swift-3.0-preview-1/swift-3.0-preview-1-ubuntu14.04.tar.gz"
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-3.0.2-release/ubuntu1404/swift-3.0.2-RELEASE/swift-3.0.2-RELEASE-ubuntu14.04.tar.gz"
sudo: required
- os: Linux
dist: trusty
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-3.1.1-release/ubuntu1404/swift-3.1.1-RELEASE/swift-3.1.1-RELEASE-ubuntu14.04.tar.gz"
sudo: required
- os: Linux
dist: trusty
env: "SWIFT_SNAPSHOT_NAME=https://swift.org/builds/swift-2.2.1-release/ubuntu1404/swift-2.2.1-RELEASE/swift-2.2.1-RELEASE-ubuntu14.04.tar.gz"
env: SWIFT_SNAPSHOT_NAME="https://swift.org/builds/swift-4.0.2-release/ubuntu1404/swift-4.0.2-RELEASE/swift-4.0.2-RELEASE-ubuntu14.04.tar.gz"
sudo: required
- os: osx
osx_image: xcode7.3
env: SWIFT_SNAPSHOT_NAME=DEVELOPMENT-SNAPSHOT-2016-05-31-a
osx_image: xcode8.2
- os: osx
osx_image: xcode9

before_install:
- ./xcconfig/before-install.sh
- ./.travis.d/before-install.sh

install:
- ./xcconfig/install.sh
- ./.travis.d/install.sh

script:
- export SWIFTENV_ROOT="$HOME/.swiftenv"
- export PATH="${SWIFTENV_ROOT}/bin:${SWIFTENV_ROOT}/shims:$PATH"
- make
- export PATH="$HOME/usr/bin:$PATH"
- make all

# - swift build -c release
# - swift build -c debug
12 changes: 5 additions & 7 deletions ARIEchoServer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
// ARIEchoServer
//
// Created by Helge Heß on 6/13/14.
// Copyright (c) 2014-2017 Always Right Institute. All rights reserved.
//
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet var window : NSWindow!
Expand All @@ -21,7 +23,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

var echod : EchoServer?

func applicationDidFinishLaunching(aNotification: NSNotification) {
func applicationDidFinishLaunching(_ aNotification: Notification) {
let port = 1337

echod = EchoServer(port: port)
Expand All @@ -32,7 +34,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
"Connect in e.g. Terminal via 'telnet 127.0.0.1 \(port)'"
}

func applicationWillTerminate(aNotification: NSNotification) {
func applicationWillTerminate(_ aNotification: Notification) {
echod?.stop()
}

Expand All @@ -42,7 +44,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
print(s)

// log to view. Careful, must run in main thread!
dispatch_async(dispatch_get_main_queue()) {
DispatchQueue.main.async {
self.logView.appendString(string: s + "\n")
}
}
Expand All @@ -53,11 +55,7 @@ extension NSTextView {
func appendString(string s: String) {
if let ts = textStorage {
let ls = NSAttributedString(string: s)
#if swift(>=3.0) // #swift3-1st-kwarg
ts.append(ls)
#else
ts.appendAttributedString(ls)
#endif
}

let charCount = (s as NSString).length
Expand Down
4 changes: 2 additions & 2 deletions ARIEchoServer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.22.10</string>
<string>0.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>3</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
Expand Down
11 changes: 0 additions & 11 deletions ARIEchoServer/main.swift

This file was deleted.

22 changes: 8 additions & 14 deletions ARIFetch/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
// ARIFetch
//
// Created by Helge Hess on 6/13/14.
// Copyright (c) 2014-2017 Always Right Institute. All rights reserved.
//
//

import Cocoa
import SwiftSockets

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet var window : NSWindow!
Expand All @@ -20,15 +22,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return resultViewParent.contentView.documentView as! NSTextView
}

func applicationDidFinishLaunching(aNotification: NSNotification) {
#if swift(>=3.0) // #swift3-1st-kwarg
fetch(sender: nil)
#else
fetch(nil)
#endif
func applicationDidFinishLaunching(_ aNotification: Notification) {
fetch(sender: nil)
}

func applicationWillTerminate(aNotification: NSNotification) {
func applicationWillTerminate(_ aNotification: Notification) {
socket?.close()
}

Expand All @@ -43,7 +41,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

socket = ActiveSocket<sockaddr_in>()
print("Got socket: \(socket)")
print("Got socket: \(socket as Optional)")
if socket == nil {
return
}
Expand Down Expand Up @@ -100,10 +98,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// FIXME: I think I know why. It may happen if the block boundary is
// within a UTF-8 sequence?
// The end of the block is 100,-30,-128,0
let data = String.fromCString(block)! // ignore error, abort
let data = String(validatingUTF8: block)! // ignore error, abort

// log to view. Careful, must run in main thread!
dispatch_async(dispatch_get_main_queue()) {
DispatchQueue.main.async {
self.resultView.appendString(string: data)
}
} while (true)
Expand All @@ -116,11 +114,7 @@ extension NSTextView {
func appendString(string s: String) {
if let ts = textStorage {
let ls = NSAttributedString(string: s)
#if swift(>=3.0) // #swift3-1st-kwarg
ts.append(ls)
#else
ts.appendAttributedString(ls)
#endif
}

let charCount = (s as NSString).length
Expand Down
4 changes: 2 additions & 2 deletions ARIFetch/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.22.10</string>
<string>0.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>3</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
Expand Down
19 changes: 0 additions & 19 deletions ARIFetch/Swift3.swift

This file was deleted.

11 changes: 0 additions & 11 deletions ARIFetch/main.swift

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SwiftSockets
============
![Swift2n3](https://img.shields.io/badge/Swift-2.2%2C%203.0-blue.svg)
![Swift3](https://img.shields.io/badge/swift-3-blue.svg)
![Swift4](https://img.shields.io/badge/swift-4-blue.svg)
![Mac OS X](https://img.shields.io/badge/os-Mac%20OS%20X-green.svg?style=flat)
![iOS](https://img.shields.io/badge/os-iOS-green.svg?style=flat)
![Linux](https://img.shields.io/badge/os-Linux-green.svg?style=flat)
Expand Down Expand Up @@ -29,7 +30,8 @@ The project includes three targets:
- ARIEchoServer
- ARIFetch

Updated for Swift 0.2.2 (aka Xcode 7.3), aand for Swift 0.3-2016-05-31.
- Updated for Swift 3.2/4.0 (aka Xcode 9.1), and for Swift 3 final too
- Updated for Swift 0.2.2 (aka Xcode 7.3), aand for Swift 0.3-2016-05-31.

*Note for Linux users*:
This compiles with the 2016-05-31-a snapshot via Swift Package Manager
Expand All @@ -50,7 +52,7 @@ library.
Server Sample:
```swift
let socket = PassiveSocket<sockaddr_in>(address: sockaddr_in(port: 4242))!
.listen(queue: dispatch_get_global_queue(0, 0), backlog: 5) {
.listen(queue: DispatchQueue.global(), backlog: 5) {
print("Wait, someone is attempting to talk to me!")
$0.close()
print("All good, go ahead!")
Expand Down
Loading

0 comments on commit c2db3ec

Please sign in to comment.