Skip to content

Commit

Permalink
Merge pull request #10 from shibapm/test_ci_run
Browse files Browse the repository at this point in the history
Test swift run on CI
  • Loading branch information
f-meloni authored Sep 3, 2019
2 parents ec3006d + 18722b2 commit ce00390
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ matrix:
osx_image: xcode10
script:
- swift build
- swift run package-config-example --verbose

- os: linux
language: generic
Expand All @@ -23,3 +24,4 @@ matrix:
- swiftenv global 4.2
script:
- swift build
- swift run package-config-example --verbose
24 changes: 22 additions & 2 deletions Sources/PackageConfig/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import Foundation

enum Package {
static func compile() throws {
#if os(Linux)
let swiftC = try findPath(tool: "swiftc")
#else
let swiftC = try runXCRun(tool: "swiftc")
#endif
let process = Process()
let linkedLibraries = try libraryLinkingArguments()
var arguments = [String]()
Expand All @@ -28,6 +32,22 @@ enum Package {
debugLog("Finished launching swiftc")
}

static private func runXCRun(tool: String) throws -> String {
let process = Process()
let pipe = Pipe()

process.launchPath = "/usr/bin/xcrun"
process.arguments = ["--find", tool]
process.standardOutput = pipe

debugLog("CMD: \(process.launchPath!) \( ["--find", tool].joined(separator: " "))")

process.launch()
process.waitUntilExit()
return String(data: pipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)!
.trimmingCharacters(in: .whitespacesAndNewlines)
}

private static func findPath(tool: String) throws -> String {
let process = Process()
let pipe = Pipe()
Expand All @@ -52,8 +72,8 @@ enum Package {
".build/release",
]

#warning("needs to be improved")
#warning("consider adding `/usr/lib` to libPath maybe")
// "needs to be improved"
// "consider adding `/usr/lib` to libPath maybe"

func isLibPath(path: String) -> Bool {
return fileManager.fileExists(atPath: path + "/lib\(library).dylib") || // macOS
Expand Down

0 comments on commit ce00390

Please sign in to comment.