CheckSourceCompiles: Add support for Swift
Plumb through swift check_source_compiles
support. Add tests to check
that valid swift sources compile and invalid sources don't.
For Swift executables, name source main.swift
.
Xcode uses its own heuristics to determine whether or not to accept
top-level code in a source file while Ninja uses the swift driver
heuristics.
With the Swift driver, if the module contains a single file, that file
will be parsed as a top-level code context. With Xcode, the single file
will only be parsed as top-level code if the name of that file is
main.swift
.
To ensure more consistent behavior between the two generators, if we're
building Swift and the try-compile target type is executable or
undefined, we name the file main.swift
to ensure that both will handle
the single file as top-level code.
Topic-rename: CheckSourceCompiles-Swift