Skip to content

Commit

Permalink
Merge pull request #120 from noppoMan/swift5.1
Browse files Browse the repository at this point in the history
Swift5.1
  • Loading branch information
noppoMan authored Sep 27, 2019
2 parents 62a5a15 + 62892d8 commit 9fa1f95
Show file tree
Hide file tree
Showing 15 changed files with 393 additions and 379 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
language: generic
sudo: required
dist: trusty
osx_image: xcode10.1
osx_image: xcode11

install:
- source Scripts/install-swift.sh
Expand Down
17 changes: 4 additions & 13 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,17 @@
"repositoryURL": "https://github.com/jakeheis/SwiftCLI.git",
"state": {
"branch": null,
"revision": "5318c37d3cacc8780f50b87a8840a6774320ebdf",
"version": "5.2.2"
}
},
{
"package": "SwiftyJSON",
"repositoryURL": "https://github.com/IBM-Swift/SwiftyJSON.git",
"state": {
"branch": null,
"revision": "f2612ea3ac29996ae9601bdcb00cc1c29e26f104",
"version": "17.0.4"
"revision": "ba2268e67c07b9f9cfbc0801385e6238b36255eb",
"version": "5.3.2"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "26ab35f50ea891e8edefcc9d975db2f6b67e1d68",
"version": "1.0.1"
"revision": "c947a306d2e80ecb2c0859047b35c73b8e1ca27f",
"version": "2.0.0"
}
}
]
Expand Down
6 changes: 2 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.2
// swift-tools-version:5.1
import PackageDescription

let package = Package(
Expand All @@ -8,13 +8,11 @@ let package = Package(
.executable(name: "hexaville", targets: ["Hexaville"])
],
dependencies: [
.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", .upToNextMajor(from: "17.0.1")),
.package(url: "https://github.com/jakeheis/SwiftCLI.git", .upToNextMajor(from: "5.0.0")),
.package(url: "https://github.com/jpsim/Yams.git", .upToNextMajor(from: "1.0.1"))
.package(url: "https://github.com/jpsim/Yams.git", .upToNextMajor(from: "2.0.0"))
],
targets: [
.target(name: "HexavilleCore", dependencies: [
"SwiftyJSON",
"SwiftCLI",
"Yams"
]),
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ hexaville generate Hello --dest /path/to/your/app

### swift-tools-version
You can specify swift-tools-version for the new project with `--swift-tools-version` option.
Current default tool version is `4.0`
Current default tool version is `5.1`

If the tool version is higher than 3.1, layouts and definiations of `Package.swift` are refined.

**e.g.**
```sh
# swift.version will be 4.2
# swift.version will be 5.1
hexaville generate Hello

# swift.version will be 3.1
hexaville generate Hello --swift-tools-version 3.1
# swift.version will be 5.0
hexaville generate Hello --swift-tools-version 5.0

# swift.version will be swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a
hexaville generate Hello --swift-tools-version swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a
Expand Down Expand Up @@ -240,12 +240,12 @@ See: https://serverless.com/framework/docs/providers/aws/guide/functions#vpc-con

You can configure swift versioning and build configuration in `swift` directive

* default swift version is `4.2`
* default swift version is `5.1`
* default build configuration is `debug`

```yaml
swift:
version: 4.2 #format should be major.minor.[patch] or valid SWIFT DEVELOPMENT-SNAPSHOT name
version: 5.1 #format should be major.minor.[patch] or valid SWIFT DEVELOPMENT-SNAPSHOT name
buildOptions:
configuration: release
```
Expand Down
28 changes: 24 additions & 4 deletions Scripts/build-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,33 @@ set -e
DEST=${DEST}/${BUILD_CONFIGURATION}
swift package update
swift build -c ${BUILD_CONFIGURATION}
cp -r /${SWIFTFILE}/usr/lib/swift/linux/*.so $DEST
cp /usr/lib/x86_64-linux-gnu/libicudata.so $DEST/libicudata.so.52

# swift libraries
if [ -f "$DEST/libicudataswift.so.61" ]; then
rm $DEST/libicudataswift.so.61
fi
if [ -f "$DEST/libicui18nswift.so.61" ]; then
rm $DEST/libicui18nswift.so.61
fi
if [ -f "$DEST/libicuucswift.so.61" ]; then
rm $DEST/libicuucswift.so.61
fi
cp -rL /${SWIFTFILE}/usr/lib/swift/linux/*.so $DEST
mv $DEST/libicudataswift.so $DEST/libicudataswift.so.61
mv $DEST/libicui18nswift.so $DEST/libicui18nswift.so.61
mv $DEST/libicuucswift.so $DEST/libicuucswift.so.61

# other sysytem libraries
cp /usr/lib/x86_64-linux-gnu/libicui18n.so $DEST/libicui18n.so.52
cp /usr/lib/x86_64-linux-gnu/libicuuc.so $DEST/libicuuc.so.52
cp /usr/lib/x86_64-linux-gnu/libbsd.so $DEST/libbsd.so.0
cp /lib/x86_64-linux-gnu/libssl.so.1.0.0 $DEST/libssl.so.1.0.0
cp /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 $DEST/libcrypto.so.1.0.0

id -u $VOLUME_USER &>/dev/null || useradd -ms /bin/bash $VOLUME_USER
chown -R $VOLUME_USER:$VOLUME_GROUP $DEST
if [ -z "${VOLUME_USER}" ] && [ -z "${VOLUME_GROUP}" ]; then
echo "swift build is finished."
else
id -u $VOLUME_USER &>/dev/null || useradd -ms /bin/bash $VOLUME_USER
chown -R $VOLUME_USER:$VOLUME_GROUP $DEST
echo "swift build is finished."
fi
2 changes: 1 addition & 1 deletion Scripts/install-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

VERSION="4.2"
VERSION="5.1"

# Determine OS
UNAME=`uname`;
Expand Down
3 changes: 3 additions & 0 deletions Scripts/zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ DEST=.build/${BUILD_CONFIGURATION}
swift package update
swift build -c ${BUILD_CONFIGURATION}
cp -r /${SWIFTFILE}/usr/lib/swift/linux/*.so $DEST
mv $DEST/libicudataswift.so $DEST/libicudataswift.so.61
mv $DEST/libicui18nswift.so $DEST/libicui18nswift.so.61
mv $DEST/libicuucswift.so $DEST/libicuucswift.so.61
cp /usr/lib/x86_64-linux-gnu/libicudata.so $DEST/libicudata.so.52
cp /usr/lib/x86_64-linux-gnu/libicui18n.so $DEST/libicui18n.so.52
cp /usr/lib/x86_64-linux-gnu/libicuuc.so $DEST/libicuuc.so.52
Expand Down
5 changes: 2 additions & 3 deletions Sources/Hexaville/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Darwin.C
#endif

import Foundation
import SwiftyJSON
import SwiftCLI
import Yams
import HexavilleCore
Expand Down Expand Up @@ -33,7 +32,7 @@ class GenerateProject: Command {
let name = "generate"
let shortDescription = "Generate initial project"
let projectName = Parameter()
let swiftToolVersion = Key<String>("--swift-tools-version", description: "Major Swift Tool Version for this project. default is 4.2")
let swiftToolVersion = Key<String>("--swift-tools-version", description: "Major Swift Tool Version for this project. default is 5.1")
let dest = Key<String>("-o", "--dest", description: "Destination for the project")

private func resolveSwiftVersion() throws -> SwiftVersion {
Expand Down Expand Up @@ -133,7 +132,7 @@ class BuildCommand: Command {
print("Your application package was successfully created at \(package.destination)")
print("next step.")
print("")
print(" serverless deploy --stage staging or production")
print(" serverless deploy --stage your-stage-name")
print("")
print("guide: https://serverless.com/framework/docs/providers/aws/guide/deploying/")
print("###########################################################################")
Expand Down
4 changes: 2 additions & 2 deletions Sources/HexavilleCore/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public struct Constant {
]

public static var supportedSwiftVersionsRange: CountableClosedRange<Int> {
return 3...4
return 5...5
}

public static var defaultSwiftVersion: SwiftVersion {
return .release(Version(major: 4, minor: 2))
return .release(Version(major: 5, minor: 1))
}

public static let appPrefix = "hexaville"
Expand Down
2 changes: 1 addition & 1 deletion Sources/HexavilleCore/HexavilleFile/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extension Version {
throw VersionError.notEmpty
}

var intCastedComponents: [Int] = try components.map({
let intCastedComponents: [Int] = try components.map({
guard let int = Int($0) else {
throw VersionError.invalidVersion(string)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,26 @@ struct DockerBuildEnvironmentProvider: SwiftBuildEnvironmentProvider {
]
#endif

_ = try Spawn(args: ["/usr/bin/env", "docker", "run"] + dockerRunOpts) {
print($0, separator: "", terminator: "")
do {
try self.spawnDocker(dockerRunOpts)
} catch SpawnError.terminatedWithStatus(let errorCode) {
switch errorCode {
case 256:
// retry swift build when get the rename error from CNIOBoringSSL
try self.spawnDocker(dockerRunOpts)
default:
throw SpawnError.terminatedWithStatus(errorCode)
}
} catch {
throw error
}

return BuildResult(destination: sharedDir+"/\(config.swift.buildMode)", dockerTag: tag)
}

private func spawnDocker(_ dockerRunOpts: [String]) throws {
_ = try Spawn(args: ["/usr/bin/env", "docker", "run"] + dockerRunOpts) {
print($0, separator: "", terminator: "")
}
}
}
Loading

0 comments on commit 9fa1f95

Please sign in to comment.