Migrate the logic that determines which platforms to build the stdlib
for to Python. This is applies both as an effort to migrate more of the
build script to Python (https://bugs.swift.org/browse/SR-237), but also
as a means of splitting up the work necessary to cross-compile the Swift
stdlib from OS X to Linux.
This adds an Android target for the stdlib. It is also the first
example of cross-compiling outside of Darwin.
Mailing list discussions:
1. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000171.html
2. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000492.html
The Android variant of Swift may be built using the following `build-script`
invocation:
```
$ utils/build-script \
-R \ # Build in ReleaseAssert mode.
--android \ # Build for Android.
--android-ndk ~/android-ndk-r10e \ # Path to an Android NDK.
--android-ndk-version 21 \
--android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
--android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
--android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
--android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/
```
Android builds have the following dependencies, as can be seen in
the build script invocation:
1. An Android NDK of version 21 or greater, available to download
here: http://developer.android.com/ndk/downloads/index.html.
2. A libicu compatible with android-armv7.
Not all machines may have all platforms' SDKs installed.
xcodebuild already has a command to print the versions of all
SDKs installed. For convenience, also provide a function that
returns the identifiers for all installed SDKs.
rdar://problem/25618455
Replace the project global linting rule excludes (as defined in .pep8) with
fine-grained "# noqa" annotations.
By using noqa annotation the excludes are made on a per line basis instead of
globally.
These annotations are used where we make deliberate deviations from the standard
linting rules.
To lint the Python code in the project:
$ flake8
To install flake8:
$ pip install flake8
See https://flake8.readthedocs.org/en/latest/ for details.
To enable checking of the PEP-8 naming conventions, install the optional
extension pep8-naming:
$ pip install pep8-naming
To enable checking of blind "except:" statements, install the optional
extension flake8-blind-except:
$ pip install flake8-blind-except
To enable checking of import statement order, install the optional
extension flake8-import-order:
$ pip install flake8-import-order
* E101: indentation contains mixed spaces and tabs
* E111: indentation is not a multiple of four
* E128: continuation line under-indented for visual indent
* E302: expected 2 blank lines, found 1
* W191: indentation contains tabs
https://github.com/apple/swift-corelibs-xctest/pull/43 introduces
a dependency between XCTest and Foundation. Modify the build script
in order to properly build all products:
- Build Foundation before XCTest, then link Foundation when building
XCTest by using new '--foundation-build-dir' option.
- Link Foundation when testing SwiftPM by using new '--foundation'
option.
- On Linux, ensure Foundation is built when XCTest is.
- Migrate `SKIP_TEST_IOS`, `SKIP_TEST_TVOS`, and `SKIP_TEST_WATCHOS` to
Python.
- In the `build-script-impl` shellscript, only deal with
`SKIP_TEST_*_HOST` and `SKIP_TEST_*_SIMULATOR` variables.
- Introduce a `--host-test` flag to the Python `build-script` in order
to allow users to specify whether to run host tests. These flags
still don't do anything.
- Fix typo: `skip-build-tvos_device` was meant to be `skip-build-tvos-device`.
It's possible to cross-compile for iOS while skipping stdlib tests
on OS X:
```
$ utils/build-script --ios -- --skip-test-osx
```
The same is not possible on Linux. Add options to skip builds and
tests on non-Darwin platforms: Linux, FreeBSD, and Cygwin.
Rather than archiving symbols at the very end of the build-script-impl
shellscript, do so at the end of the Python build-script. A small step towards
achieving SR-237.
Rather than setting the path to the .xctoolchain in the build-script-impl
shellscript, do so in the Python build-script. A small step towards
achieving SR-237.
Rather than setting a default value for the INSTALL_PREFIX in the
build-script-impl shellscript, do so in the Python build-script. A small step
towards achieving SR-237.
Rather than printing `xcodebuild` version information in the
build-script-impl shellscript, do so in the Python build-script. A small step
towards achieving SR-237.
Rather than determining which builds to skip in the build-script-impl
shellscript, do so in the Python build-script. A small step towards
achieving SR-237.
Rather than determining whether to build Ninja in the build-script-impl
shellscript, do so in the Python build-script. A small step towards achieving
SR-237.
`build-script-impl` currently maintains a list of
`NATIVE_TOOLS_DEPLOYMENT_TARGETS` -- host machine targets, for which
the resulting binaries can be run on the current machine.
However, there is only ever *one* host machine. This commit:
- Changes the `NATIVE_TOOLS_DEPLOYMENT_TARGETS` list parameter into a
single string parameter, `HOST_TARGET`.
- Promotes the logic to detect the host target to Python, and places it
in the `swift_build_support` module.
- Removes the hard-coded "macosx_x86_64" path to the LLVM and Clang
TableGen -- thereby unblocking future work to make cross-compilation
possible on platforms other than OS X.
- Also promotes cross-compilation target validation to Python, placing
it in the `swift_build_support` module.
Fixes:
* multiple statements on one line (colon) (E701)
* missing whitespace around arithmetic operator (E226)
* missing whitespace around operator (E225)
* closing bracket does not match visual indentation (E124)
* blank line contains whitespace (W293)
* continuation line missing indentation or outdented (E122)
* continuation line over-indented for hanging indent (E126)
* missing expected blank line (E301)
* trailing whitespace (W291)
* unexpected spaces around keyword / parameter equals (E251)
* whitespace after '(', '[' or '{' (E201)
* whitespace before ')', ']' or '}' (E202)
* whitespace before ',' or ':' (E203)
Extend build-script, build-script-impl, and update-checkout
to include libdispatch. For now, libdispatch is not
built by default (user must enable via command line
argument).
Integration of testing is functional, but should be improved
in a later pull request. The basic autotools based test
harness does not give the nice high-level progress output
as the rest of the test suite.
A related pull request to libdispatch (#34) has some fixes
to the autotools build that are needed to enable the test
target to succeed when run in an external directory.