Commit Graph

5057 Commits

Author SHA1 Message Date
Devin Coughlin
89e381ca66 [CMake/Tests] CMake and lit.cfg support for running macCatalyst tests
Add support for testing with macCatalyst to lit.cfg and the test CMake.

This adds lit test features for whether the standard library and runtime was
built with macCatalyst support:

  REQUIRES: maccatalyst_support

The test suite can also be run in two modes: one where the macOS tests
are run as usual (against a zippered standard library, runtime, and overlays)
and another where iOS tests are compiled with the macCatalyst target
triple and executed as macCatalyst processes.

The iOS tests for macCatalyst can be run by passing `--maccatalyst-ios-tests`
to build-script. There are new lit test features to enable a test to specify
whether it supports that environment:

  REQUIRES: OS=maccatalyst
  UNSUPPORTED: OS=macCatalyst
2020-01-21 18:28:17 -08:00
Devin Coughlin
63ce243437 [CMake] Add initial build system support for macCatalyst
This commit adds initial build system support for macCatalyst,
an Apple technology that enables code targeting iOS
to be recompiled so that it can be executed on macOS while still using
iOS APIs. This is the first in a series of commits building out support for
macCatalyst in the compiler, runtime, standard library, and overlays. Swift
for macCatalyst represents the work of multiple people, including
Devin Coughlin, Ross Bayer, and Brent Royal-Gordon.

Under macCatalyst, compiler-provided shared libraries (including overlays)
are built as one of four kinds (or "flavors") of libraries,
each with different install names and Mach-O load commands. This commit
adds the build system infrastructure to produce these different
library flavors.

**macOS-like Libraries**

A "macOS-like" library (such as the GLKit overlay) is a plain-old macOS library
that can only be loaded into regular macOS processes. It has a macOS slice with
a single load command allowing it to be loaded into normal macOS processes.

**iOS-like Libraries**

An "iOS-like" library, such as the UIKit overlay, is a library with a
macOS slice but with a load command that only allows it be loaded into
macCatalyst processes. iOS-like libraries are produced by passing a new
target tuple to the compiler:

  swiftc ... -target x86_64-apple-ios13.0-macabi ...

Here 'ios' (and an iOS version number) is used for OS portion
of the triple, but the 'macabi' environment tells the compiler
that the library is intended for macCatalyst.

**Zippered Libraries**

A "zippered" library can be loaded into either a macCatalyst process or
a standard macOS process. Since macCatalyst does not introduce a new Mach-O
slice, the same code is shared between both processes. Zippered libraries
are usually relatively low level and with an API surface that is similar
between macOS and iOS (for example, both the Foundation overlay and the Swift
Standard Library/Runtime itself are zippered).

Zippered libraries are created by passing both the usual `-target`
flag to the compiler and an additional `-target-variant` flag:

   swiftc ... -target x86_64-apple-macos10.15 \
              -target-variant x86_64-apple-ios13.0-macabi

Just like the -target flag, -target-variant takes a target tuple.
This tells the compiler to compile the library for the -target tuple but
to add an extra load command, allowing the library to be loaded into processes
of the -target-variant flavor as well.

While a single zippered library and slice is shared between macOS and
macCatalyst, zippered libraries require two separate .swiftinterface/.swiftmodule
files, one for macOS and one for macCatalyst. When a macOS or macCatalyst client
imports the library, it will use module file for its flavor to determine what
symbols are present. This enables a zippered library to expose a subset of its
target APIs to its target-variant.

**Unzippered-Twin Libraries**

"Unzippered Twins" are pairs of libraries with the same name but different
contents and install locations, one for use from macOS processes and one for
use from macCatalyst processes. Unzippered twins are usually libraries that
depend on AppKit on macOS and UIKit on iOS (for example, the MapKit overlay)
and so do not share a common implementation between macOS and macCatalyst.

The macCatalyst version of an unzippered twin is installed in a parallel
directory hierarchy rooted at /System/iOSSupport/. So, for example, while macOS
and zippered Swift overlays are installed in /usr/lib/swift/, iOS-like and
the macCatalyst side of unzippered twins are installed in
/System/iOSSupport/usr/lib/swift. When building for macCatalyst, the build system
passes additional search paths so that the macCatalyst version of libraries is
found before macOS versions.

The add_swift_target_library() funciton now take an
optional  MACCATALYST_BUILD_FLAVOR, which enables swift libraries to indicate
which flavor of library they are.
2020-01-21 18:26:13 -08:00
Saleem Abdulrasool
64aebf47c5 build-script: use more terse checks
This uses the bash extension of regex based comparison rather than the
more portable shell approach which is a bit more terse.
2020-01-21 16:39:45 -08:00
Mishal Shah
b56c77d161 [Preset] Update the macOS pull request preset to not build and test tvOS platform to get faster trun around 2020-01-21 16:02:27 -08:00
swift-ci
e4c0a62479 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 15:02:54 -08:00
Saleem Abdulrasool
e744a44b98 Merge pull request #29334 from compnerd/bs-product-computation
build-script: add missing options, use more terse syntax
2020-01-21 14:54:32 -08:00
swift-ci
cb9f46879f Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 14:23:39 -08:00
Brent Royal-Gordon
cf8b045f0e Fix build-script --dump-config
The Version object used __slots__ instead of __dict__, so it was not serializable. Update JSONDumper to stringify objects if vars() won’t work.

This change does not update any tests because build-script does not currently have a way to write full-script integration tests.
2020-01-21 14:00:41 -08:00
Saleem Abdulrasool
1aafd55d16 build-script: add missing options, use more terse syntax
This makes the product computation more terse and adds the missing
options.  The functional aspects of this change include renaming the
`SKIP_BUILD_SWIFT_STATIC_LIBDISPATCH` to `SKIP_BUILD_STATIC_LIBDISPATCH`
which keeps it in line with the other skip options.  We also now list
the option properly.
2020-01-21 11:47:03 -08:00
Emir Sarı
399d74ce1f Add licence notice to Vim syntax files 2020-01-21 22:00:47 +03:00
swift-ci
4477037259 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 08:42:51 -08:00
Saleem Abdulrasool
5a75996d1d Merge pull request #29320 from compnerd/android-is-simple
build-script: android does not do multi-arch builds
2020-01-21 08:25:37 -08:00
swift-ci
766f6cc3fe Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 08:23:24 -08:00
Saleem Abdulrasool
b11977a8b3 Merge pull request #29319 from compnerd/atomic-flag
build-script: handle special build rules for non-atomic runtime
2020-01-21 08:17:53 -08:00
swift-ci
5b380e8144 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-20 18:23:21 -08:00
Saleem Abdulrasool
68c7a99c6e Merge pull request #29318 from compnerd/tool-less-build
build-script: remove dead CMake options for Swift
2020-01-20 18:07:41 -08:00
swift-ci
00ee256ab4 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-20 17:23:34 -08:00
Saleem Abdulrasool
9e9d3fd84c build-script: android does not do multi-arch builds 2020-01-20 15:07:54 -08:00
Saleem Abdulrasool
b855260cae build-script: handle special build rules for non-atomic runtime
Move the special flag handling for the non-atomic runtime into the build
system rather than spreading it across the build system and the helper
utilities.
2020-01-20 14:51:27 -08:00
Saleem Abdulrasool
95102bc258 build-script: remove dead CMake options for Swift
The build system does not support fine grained control over the tools.
Ideally we would do this by hooking into the llvm distribution
mechanism.
2020-01-20 14:43:12 -08:00
Ross Bayer
5852aea3e8 [Build System: build-script] Updated the presets module to simplify the API and improve testability. 2020-01-20 02:34:45 -08:00
swift-ci
78e22d5ff5 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-19 19:43:30 -08:00
swift-ci
b696f6b808 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-19 17:23:50 -08:00
Ross Bayer
a6dab52f31 [Build System: build-script] Adds a new xcrun module to build_swift which replaces the existing module from swift_build_support.
This new module uses the build_swift.shell.ExecutableWrapper API to create a wrapper class around 'xcrun'. The wrapper class is instantiated and exposed under the name build_swift.wrappers.xcrun.
2020-01-19 17:19:38 -08:00
Ross Bayer
2d1930f583 Merge pull request #29310 from Rostepher/remove-old-which-module
[NFC][Build System: build-script] Remove the old which module in swift_build_support.
2020-01-19 17:09:58 -08:00
Ross Bayer
ce7888ec58 Merge pull request #29309 from Rostepher/cleanup-python-lint
[NFC][Build System: Python] Cleaned-up the python_lint.py script.
2020-01-19 17:09:24 -08:00
Ross Bayer
b9041798d7 [Build System: Python] Cleaned-up the python_lint.py script. 2020-01-19 12:15:21 -08:00
Ross Bayer
ac431fa3e1 [Build System: build-script] Remove the old which module in swift_build_support and replace uses with the which function provided in the build_swift shell module. 2020-01-19 03:49:13 -08:00
Ross Bayer
68bf96809f [Build System: build-presets] Remove duplicate flag from preset which was causing the build_swift tests to fail when run with a Python 3 interpreter. 2020-01-19 01:32:58 -08:00
Ross Bayer
83bfc69ea3 [Build System: update-checkout] Added a new run_test.py script to utils/update_checkout which is used to run the validation test. 2020-01-19 01:32:47 -08:00
Ross Bayer
de1759c84f [Build System: build-script] Added a new run_test.py script to utils/swift_build_support which is used to run the unit test suite. 2020-01-19 01:31:21 -08:00
Ross Bayer
7587c7c0ac [Build System: build-script] Re-structured the build_swift module tests to contain a build_swift directory.
Having the test directory match the module we are testing means we can have scripts in the top level of utils/build_swift which can also have tests. As part of this re-structure the test utilties have been simplified somewhat and all tests no longer use a custom TestCase, rather the standard one exposed by the unittest module.
2020-01-19 01:31:21 -08:00
swift-ci
fe306ede0d Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-19 00:02:58 -08:00
Rintaro Ishizaki
274138a589 Merge pull request #29308 from rintaro/run-test-targets
[run-test] Update run-test for recent changes
2020-01-18 23:55:08 -08:00
Rintaro Ishizaki
51e7f8a628 [run-test] Update run-test for recent changes 2020-01-18 21:46:57 -08:00
swift-ci
2de123e007 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-18 15:23:54 -08:00
Ross Bayer
d21a603829 Merge pull request #29268 from Rostepher/shell-module
[Build System: build-script] Shell module.
2020-01-18 15:16:29 -08:00
Ross Bayer
885fd01d49 [Build System: build-script] Adds a new shell module to build_swift which wraps the standard subprocess module and provides convenience functions for common shell tasks. 2020-01-18 12:24:47 -08:00
Ross Bayer
67d6b10dd0 [Build System: build-script] Add a new versions module to build_swift which provides the Version class.
Version acts very similarly to distutils.version.LooseVersion, but with some more flexibility around character group boundries.
2020-01-18 12:04:53 -08:00
swift-ci
bd14cdaf35 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-18 12:03:35 -08:00
Ross Bayer
516ad28c50 Merge pull request #29244 from Rostepher/adopt-six-in-build-swift
[Build System: build-script] Adopt the six compatibility library in the build_swift module.
2020-01-18 11:56:21 -08:00
swift-ci
29c5aad6e4 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-17 20:03:08 -08:00
Andrew Trick
5d3e8b5b7b Merge pull request #29283 from atrick/show-build-targets
Add the target list to build-script --help.
2020-01-17 19:54:49 -08:00
Andrew Trick
90c478f6fc Add the target list to build-script --help.
Teach build-script to print the list of valid targets for the
--stdlib-deployment-targets option. Unfortunately, passing all
supported targets to this option is the only way to force
configuration of those targets. Simply using --ios is no longer
sufficient--none of the iOS targets are actually configured unless you
ask them to be built.

(The reasonable way to use a build config script is to first configure
for all supported platforms, but only build the platforms/targets one
by one when you actually need them).

This currently prints:

  --stdlib-deployment-targets STDLIB_DEPLOYMENT_TARGETS
                        The targets to compile or cross-compile the Swift
                        standard library for. None by default. Comma separated
                        list: android-aarch64 android-armv7 appletvos-arm64
                        appletvsimulator-x86_64 cygwin-x86_64 freebsd-x86_64
                        haiku-x86_64 iphoneos-arm64 iphoneos-armv7 iphoneos-
                        armv7s iphonesimulator-i386 iphonesimulator-x86_64
                        linux-aarch64 linux-armv6 linux-armv7 linux-i686
                        linux-powerpc64 linux-powerpc64le linux-s390x linux-
                        x86_64 macosx-x86_64 watchos-armv7k
                        watchsimulator-i386 windows-x86_64
2020-01-17 18:06:00 -08:00
swift-ci
d4f86d2e38 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-17 17:03:39 -08:00
Ross Bayer
6a5c1662dd Merge pull request #29280 from compnerd/bs-options
build-script-impl: reorganise the option
2020-01-17 16:56:13 -08:00
Ross Bayer
0fdef59633 [Build System: build-script] Adopt the six compatibility library in the build_swift module. 2020-01-17 15:43:54 -08:00
swift-ci
16a8265af3 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-17 15:04:14 -08:00
Ross Bayer
bfeb13451e [Build System: build-script] Update the auto-generated preset parsing tests to always supply and exhaustive set of substitutions. 2020-01-17 14:37:15 -08:00
Saleem Abdulrasool
6f096be5d5 build-script-impl: reorganise the option
This reorders the option list.  It tries to categorise them by area and
then sort them alphabetically.  This should help work through the list
and remove the now defunct options as well as try to reduce the set of
options into different build configurations that we can support and try
to organise the CMake invocations properly.

There is still a group of uncategorised options that should get sorted
out at some point.  However, this is still a huge step forward towards
simplifying (and hopefully eradicating) this monstrous script.
2020-01-17 12:01:25 -08:00