main.swift 1.42 KB
Newer Older
Drew's avatar
Drew committed
1 2 3 4 5 6 7 8 9 10 11 12 13
// Copyright (c) 2016 Drew Crawford.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Drew's avatar
Drew committed
14

Drew's avatar
Drew committed
15
#if os(OSX)
Drew's avatar
Drew committed
16
import Darwin
Drew's avatar
Drew committed
17 18 19
#elseif os(Linux)
import Glibc
#endif
Drew's avatar
Drew committed
20

Drew's avatar
Drew committed
21 22
if performXcodeIntegration() { exit(0) }

Drew's avatar
Drew committed
23
func usage() {
Drew's avatar
Drew committed
24
    print("caroline-static-tool 1.0")
Drew's avatar
Drew committed
25 26 27
    print("Usage: caroline-static-tool --core file1.swift file2.swift file3.swift > /path/to/main.swift")
}

Drew's avatar
Drew committed
28
if CommandLine.arguments.count < 3 {
Drew's avatar
Drew committed
29 30 31 32
    usage()
    exit(1)
}

Drew's avatar
Drew committed
33
precondition(CommandLine.arguments[1] == "--core", "Non-core is unsupported")
Drew's avatar
Drew committed
34

Drew's avatar
Drew committed
35
let fileNames = Array(CommandLine.arguments[2..<CommandLine.arguments.count])
Drew's avatar
Drew committed
36

Drew's avatar
Drew committed
37
print(ApacheLicense)
Drew's avatar
Drew committed
38 39 40 41
print()
print("// This file is automatically generated by Caroline and should not be edited by hand.")

print ("import CarolineCore")
42
print(allTestsDeclaration(tests: findTests(fileNames), indentation:0))
Drew's avatar
Drew committed
43

Drew's avatar
Drew committed
44 45 46


print("let engine = CarolineCoreEngine()")
Drew's avatar
Drew committed
47 48 49
print("if !engine.testAll(allTests) {")
print("    fatalError(\"Caroline tests failed\")")
print("}")