Skip to content

Commit

Permalink
Merge pull request #13 from shibapm/optimise_get_swift_tool_version
Browse files Browse the repository at this point in the history
Get swift tool version only once
  • Loading branch information
f-meloni authored Oct 14, 2019
2 parents 4d02d13 + 9ef1405 commit 62e9e0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ matrix:
script:
- swift build
- swift run package-config-example --verbose

- os: osx
osx_image: xcode11
script:
- swift build
- swift run package-config-example --verbose

- os: linux
language: generic
Expand Down
5 changes: 3 additions & 2 deletions Sources/PackageConfig/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ enum Package {

let latestVersion = versions.sorted().last!
var spmVersionDir = latestVersion
let swiftToolsVersion = getSwiftToolsVersion()

if let swiftToolsVersion = getSwiftToolsVersion(), versions.contains(swiftToolsVersion) {
if let swiftToolsVersion = swiftToolsVersion, versions.contains(swiftToolsVersion) {
spmVersionDir = swiftToolsVersion
}

let libraryPathSPM = swiftPMDir + "/" + spmVersionDir

debugLog("Using SPM version: \(libraryPathSPM)")
return ["-L", libraryPathSPM, "-I", libraryPathSPM, "-lPackageDescription", "-package-description-version", getSwiftToolsVersion() ?? "5"]
return ["-L", libraryPathSPM, "-I", libraryPathSPM, "-lPackageDescription", "-package-description-version", swiftToolsVersion ?? "5"]
}

private static func getSwiftToolsVersion() -> String? {
Expand Down

0 comments on commit 62e9e0c

Please sign in to comment.