Merge pull request #191 from slavapestov/void-is-not-really-void

Fix an SE-0110 warning
diff --git a/XCTest.xcodeproj/project.pbxproj b/XCTest.xcodeproj/project.pbxproj
index 6cc4dbd..1544f7f 100644
--- a/XCTest.xcodeproj/project.pbxproj
+++ b/XCTest.xcodeproj/project.pbxproj
@@ -473,7 +473,10 @@
 			buildSettings = {
 				DEFINES_MODULE = YES;
 				DYLIB_INSTALL_NAME_BASE = "@rpath";
-				"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = $BUILT_PRODUCTS_DIR;
+				"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = (
+					$BUILT_PRODUCTS_DIR,
+					"../swift-corelibs-foundation/build/Debug",
+				);
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks @loader_path/Frameworks";
@@ -482,6 +485,7 @@
 					"-framework",
 					SwiftFoundation,
 				);
+				OTHER_SWIFT_FLAGS = "-swift-version 3";
 				PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
 				SKIP_INSTALL = YES;
 				SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
@@ -506,6 +510,7 @@
 					"-framework",
 					SwiftFoundation,
 				);
+				OTHER_SWIFT_FLAGS = "-swift-version 3";
 				PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
 				SKIP_INSTALL = YES;
 				SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
diff --git a/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTest.xcscheme b/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTest.xcscheme
index f4df857..75eb3a5 100644
--- a/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTest.xcscheme
+++ b/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTest.xcscheme
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0800"
+   LastUpgradeVersion = "0830"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
diff --git a/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTestFunctionalTests.xcscheme b/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTestFunctionalTests.xcscheme
index 68a5569..f901e26 100644
--- a/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTestFunctionalTests.xcscheme
+++ b/XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTestFunctionalTests.xcscheme
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0800"
+   LastUpgradeVersion = "0830"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
diff --git a/build_script.py b/build_script.py
index 8681155..e2b9504 100755
--- a/build_script.py
+++ b/build_script.py
@@ -152,6 +152,7 @@
         """
         swiftc = os.path.abspath(args.swiftc)
         build_dir = os.path.abspath(args.build_dir)
+        static_lib_build_dir = GenericUnixStrategy.static_lib_build_dir(build_dir)
         foundation_build_dir = os.path.abspath(args.foundation_build_dir)
         core_foundation_build_dir = GenericUnixStrategy.core_foundation_build_dir(
             foundation_build_dir, args.foundation_install_prefix)
@@ -206,6 +207,12 @@
                 build_dir=build_dir,
                 foundation_build_dir=foundation_build_dir))
 
+        # Build the static library.
+        run("mkdir -p {static_lib_build_dir}".format(static_lib_build_dir=static_lib_build_dir))
+        run("ar rcs {static_lib_build_dir}/libXCTest.a {build_dir}/XCTest.o".format(
+            static_lib_build_dir=static_lib_build_dir,
+            build_dir=build_dir))
+
         if args.test:
             # Execute main() using the arguments necessary to run the tests.
             main(args=["test",
@@ -217,9 +224,13 @@
         # we also install the built XCTest products.
         if args.module_path is not None and args.lib_path is not None:
             # Execute main() using the arguments necessary for installation.
-            main(args=["install", build_dir,
+            install_args = ["install", build_dir,
                        "--module-install-path", args.module_path,
-                       "--library-install-path", args.lib_path])
+                       "--library-install-path", args.lib_path]
+            if args.static_lib_path:
+                       install_args += ["--static-library-install-path",
+                           args.static_lib_path]
+            main(args=install_args)
 
         note('Done.')
 
@@ -286,6 +297,7 @@
         products into the given module and library paths.
         """
         build_dir = os.path.abspath(args.build_dir)
+        static_lib_build_dir = GenericUnixStrategy.static_lib_build_dir(build_dir)
         module_install_path = os.path.abspath(args.module_install_path)
         library_install_path = os.path.abspath(args.library_install_path)
 
@@ -307,6 +319,14 @@
             os.path.join(build_dir, xctest_swiftdoc),
             os.path.join(module_install_path, xctest_swiftdoc)))
 
+        if args.static_library_install_path:
+               static_library_install_path = os.path.abspath(args.static_library_install_path)
+               _mkdirp(static_library_install_path)
+               xctest_a = "libXCTest.a"
+               run("cp {} {}".format(
+                   os.path.join(static_lib_build_dir, xctest_a),
+                   os.path.join(static_library_install_path, xctest_a)))
+
     @staticmethod
     def core_foundation_build_dir(foundation_build_dir, foundation_install_prefix):
         """
@@ -322,6 +342,16 @@
         return os.path.join(foundation_build_dir,
                             foundation_install_prefix.strip("/"), 'lib', 'swift')
 
+    @staticmethod
+    def static_lib_build_dir(build_dir):
+        """
+        Given the path to the build directory, return the path to be used for
+        the static library libXCTest.a. Putting it in a separate directory to
+        libXCTest.so simplifies static linking when building a static test
+        foundation.
+        """
+        return os.path.join(build_dir, "static")
+
 
 def main(args=sys.argv[1:]):
     """
@@ -352,6 +382,7 @@
                 --build-dir="/tmp/XCTest_build" \\
                 --foundation-build-dir "/swift/usr/lib/swift/linux" \\
                 --library-install-path="/swift/usr/lib/swift/linux" \\
+                --static-library-install-path="/swift/usr/lib/swift_static/linux" \\
                 --module-install-path="/swift/usr/lib/swift/linux/x86_64"
 
             Note that installation is not supported on Darwin as this library
@@ -417,6 +448,11 @@
              "created if it doesn't already exist.",
         dest="lib_path")
     build_parser.add_argument(
+        "--static-library-install-path",
+        help="Location at which to install XCTest.a. This directory will be "
+             "created if it doesn't already exist.",
+        dest="static_lib_path")
+    build_parser.add_argument(
         "--release",
         help="builds for release",
         action="store_const",
@@ -508,6 +544,10 @@
         "-l", "--library-install-path",
         help="Location at which to install XCTest.so. This directory will be "
              "created if it doesn't already exist.")
+    install_parser.add_argument(
+        "-s", "--static-library-install-path",
+        help="Location at which to install XCTest.a. This directory will be "
+             "created if it doesn't already exist.")
 
     # Many versions of Python require a subcommand must be specified.
     # We handle this here: if no known subcommand (or none of the help options)