0001 import Commander
0002 import PathKit
0003
0004 private func target_specific_arguments| main.swift:23 | let arguments = try target_specific_arguments() + [ |
() throws -> [String] {
0005 #if os(OSX)
0006 return [
0007 "-sdk",
0008 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk",
0009 "-target", "x86_64-apple-macosx10.10",
0010 "-Xlinker", "-all_load",
0011 ]
0012 #elseif os(Linux)
0013 return ["-Xlinker", "--no-whole-archive", "-lswiftGlibc"]
0014 #else
0015 return []
0016 #endif
0017 }
0018
0019 func build() throws {
0020 let libraries = Path.glob(".build/debug/*.a")
0021 let testSources = (Path.glob("Tests/*.swift") + Path.glob("Tests/*/*.swift")).map { $0.description }
0022
0023 let arguments = try target_specific_arguments() + [
0024 "-o", ".build/debug/spectre-runner",
0025 "-I.build/debug",
0026 ] + libraries.map { "-Xlinker \($0)" } + testSources
0027
0028 try invoke("swiftc", arguments)
0029 }
0030
0031 func runTests() throws {
0032 try invoke(".build/debug/spectre-runner", [])
0033 }
0034
0035 command {
0036 try build()
0037 try runTests()
0038 }.run()
0039