Commit Graph

521 Commits

Author SHA1 Message Date
Ben Barham
48422f7f0c Do not use os._exit when build-script fatal errors
`os._exit` does not run any cleanup handlers or flush any buffers, which
means that we may end up missing helpful log output. It was being used
to avoid printing the log analysis when `--help` was passed, but we can
have the same behavior by just not using `finally`.
2025-02-13 16:43:41 -08:00
Hamish Knight
d260bd8ddb [build-script] Remove Xcode generation support
This was quite brittle and has now been superseded
by swift-xcodegen. Remove the CMake/build-script
logic for it, leaving the option behind to inform
users to switch to using xcodegen instead.
2025-02-12 12:19:21 +00:00
Max Desiatov
6c8b958e65 build-script: fix trailing newlines in --preset-vars-file (#78270)
Currently, usage of `--preset-vars-file` (added in https://github.com/swiftlang/swift/pull/76058) introduces newlines in values of preset variables passed via this file. Calling `strip()` will remove trailing and preceding whitespace characters, including newlines.
2024-12-18 11:51:01 -08:00
Ben Langmuir
ad82d86041 Bump the deployment target for the compiler to macOS 13.0
Bump the deployment target from macOS 10.13-aligned versions to macOS
13.0-aligned versions. This allows us to stop linking CoreFoundation
in the swift runtime, which was previously required for availability
checking. It also lets us align the deployment target on x86_64 with
arm64, which was 11.0. Finally, it is a prerequisite to being able to
build swift using the macOS 15 beta SDKs.
2024-08-29 14:30:09 -07:00
Max Desiatov
6c9994632a Add --preset-vars-file to build-script for easier preset vars handling (#76058)
It's not always convenient to pass preset substitution arguments on an interactive command-line. Sometimes one might also need to generate these vars automatically, outside of a `build-script` invocation and also store those vars in a file for later reuse.

This change adds a new optional `--preset-vars-file` customization point to `build-script`, which allows users to pass a a file with newline separated key-value pars for preset variables substitution in addition to passing those in a direct `build-script` invocation.
2024-08-27 09:57:04 +01:00
YOCKOW
1df416d3bf [build-script] NFC: Update URL of Swift repository in message. 2024-07-12 15:34:10 +09:00
Alastair Houghton
fdc8ffd36f [Build] Updated following initial comments from Eric.
Change the `--linux[-static]-arch` option to `--linux[-static]-archs`, on the
basis that it supports multiple values.

Other tidying.

rdar://123503470
2024-05-02 14:56:18 +01:00
Alastair Houghton
ae1c0455f3 [Build] Add the new fully-static Linux SDK.
Declare a new `LINUX_STATIC` SDK and configure it.

Add options to set the build architectures for the `LINUX` and
`LINUX_STATIC` SDKs, similar to what we have for Darwin, because
we'll be cross-compiling.

Also add an option to point the build system at the sources for
the musl C library, which we're using for `LINUX_STATIC`.

rdar://123503470
2024-05-02 14:56:18 +01:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Hamish Knight
74dd4dcb1b Enable colors in FileCheck and Swift tests
If we're attached to a tty, pass `--color` to
FileCheck and `--color-diagnostics` to Swift
invocations in tests.
2024-02-09 16:47:03 +00:00
Dario Rexin
f63de71001 Merge pull request #38507 from drexin/wip-llvm-build-script
[Build] Make LLVM a build-script product
2022-11-16 20:44:13 -08:00
Anthony Latsis
0c46580d4c build-script: Emit warning for --xcode invocations that links out to integration with Ninja tutorial 2022-11-06 03:36:24 +03:00
Keith Smiley
6a32e91f16 Make Xcode version check more lenient
This allows any versions above a specific version, instead of requiring
a specific list. Since it seems like many folks just disable this check
entirely, this list definitely isn't kept up well. If we need to exclude
a specific version, like if 1 Xcode beta didn't support it but the next
did, we can add a new list using the old method to validate build
numbers and disallow the bad version(s).

I don't recall why we didn't do this over a list originally, nor can I
find any context on why in the original discussion
https://github.com/apple/swift/pull/34227
2022-11-01 20:36:38 -07:00
Dario Rexin
3f80cb6712 [Build] Make LLVM a build-script product
rdar://80733826
2022-10-30 22:47:29 -07:00
Max Desiatov
6105077093 build-script: validate arguments before running sccache (#61375)
When a user passes `--sccache` flag when `sccache` is not installed, we still attempt to make a shell invocation to `sccache`, which leads to an inscrutable error:

```
Traceback (most recent call last):
  File "/root/swift-source/swift/utils/build-script", line 789, in <module>
    exit_code = main()
  File "/root/swift-source/swift/utils/build-script", line 784, in main
    return main_normal()
  File "/root/swift-source/swift/utils/build-script", line 687, in main_normal
    shell.capture([toolchain.sccache, "--show-stats"])
  File "/root/swift-source/swift/utils/swift_build_support/swift_build_support/shell.py", line 133, in capture
    return subprocess.check_output(command, env=_env, stderr=stderr,
  File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1720, in _execute_child
    and os.path.dirname(executable)
  File "/usr/lib/python3.10/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
```

`validate_arguments` should be called before `shell.capture([toolchain.sccache, "--show-stats"])` so that a more meaningful error message is shown to the user, asking them to install `sccache`.
2022-10-04 23:48:59 +01:00
Eric Miotto
cc454f650f Clear up stale values for swift-darwin-supported-archs from CMake caches (#61333)
This will prevent weird build failures when a run was made with the
argument set.
2022-09-28 11:58:04 -07:00
Hamish Knight
cfda4b1764 [build-script] Allow specifying the number of lit workers
Allow tests to run with a different number of
workers than build jobs if desired.
2022-09-14 14:01:49 +01:00
Keith Smiley
03861d3c6b Add Xcode 14 14A309 to supported build versions 2022-09-08 16:31:59 -07:00
Eric Miotto
f7a11c7543 Tests all cases of infer-cross-compile-hosts-on-darwin at once (#60824)
The current implementation currently requires to have physical machine
for each architecture supported by macOS, which is not desirable.

To allow all cases to be tested on a random Mac machine, allow
to inject an arbitratry current architecture into the inference
of the cross compile hosts by means of an environment variable.

Addresses rdar://99096874
2022-08-30 00:10:40 -07:00
Eric Miotto
67b23d7d45 Merge pull request #60664 from edymtt/infer-cross-compile-hosts-on-darwin
Add a flag to infer appropriate cross compile hosts on Darwin
2022-08-23 07:04:36 -07:00
Eric Miotto
c954130be0 Add a flag to infer appropriate cross compile hosts on Darwin
Addresses rdar://98787335, apple#60348
2022-08-22 09:37:52 -07:00
WeZZard
3a897fcdaa Makes build-script to support None and string object SystemExit.code 2022-08-22 15:18:57 +08:00
YOCKOW
1cc4054600 [build-script] Omit "Build Script Analyzer" when SystemExit is caught.
The content of ".build_script_log" file may be debris when `SystemExit` is thrown; e.g. `--help` is passed.

Resolves https://github.com/apple/swift/issues/60567
2022-08-18 12:42:34 +09:00
Mishal Shah
caf9bf5d7b Merge pull request #41223 from apple/log-build-time
[Build System] Add support to log build times for each products
2022-07-28 10:39:29 -07:00
Takeru Chuganji
7431ac8de2 Add Xcode 13.4.1 2022-06-24 16:09:08 -07:00
Mishal Shah
4c19ba404b Merge branch 'main' into log-build-time 2022-06-08 16:55:34 -07:00
Egor Zhdan
a0b56153e9 [build] Remove support for older Xcode versions
The CI currently uses Xcode 13.0 beta 4. It is very likely that if the build starts failing with Xcode 12.x, this will go unnoticed. Let's warn the users to upgrade to a newer version of Xcode.
2022-05-19 14:29:40 +01:00
Keith Smiley
f966254c0f Add newer supported Xcode versions 2022-05-16 15:20:57 -07:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Luciano Almeida
e4c3a292c0 [XCode] Add version 13.3 to supported build script versions 2022-03-23 23:48:46 -03:00
Daniel Duan
025079466a [utils] Remove Python 2
The library `six` provides compatibility between Python 2, and 3. It's no
longer necessary once we migrate of Python 2 completely.

Also remove any custom logic for Python 2 (the ones referenced by
a commentanyways).

https://bugs.swift.org/browse/SR-16025
2022-03-20 13:22:04 -07:00
Mishal Shah
d184322fc9 Add time summary at the end of the build 2022-02-05 12:20:05 -08:00
Max Desiatov
2b5857b0c9 Mark Xcode 13.2.1 as supported (#40778)
Currently, when trying to build with the latest stable Xcode, you get this error:

```
using unsupported Xcode version:

Xcode 13.2.1
Build version 13C100
```

Xcode 13.2.1 can successfully build the toolchain and should be marked as supported.
2022-01-10 08:10:25 +00:00
Butta
a3ea28ff19 [android] Remove ICU build flags since that requirement was dropped in #40340 2021-12-20 12:06:13 +05:30
Mishal Shah
465f9690df Revert "build-swift: Explicitly use python3" 2021-12-03 14:29:36 -08:00
Rob Prentiss
6f2077e784 build-swift: Explicitly use python3
This changes build-swift script shebang to use Python 3 explicitly. The
code is already compatible and functional with python3, so this removes
any implied backward compatibility, and removes any ambiguity based on
the user's current environment, especially since some systems, like
macOS, still link 'python' to Python 2.

This also removes the now unnecessary 'from __future__' imports, and the
'six' module, which is only necessary for python2 compatibility.
2021-12-01 10:56:56 -08:00
Dave Lee
74b0bf5072 [build] Don't overwrite user NINJA_STATUS 2021-11-16 16:59:48 -08:00
Stephen Canon
06ef8f955b Mark Xcode 13.2 beta as supported in build-script. (#40021) 2021-11-04 08:37:41 -04:00
Arnold Schwaighofer
5bc464255e Merge pull request #39874 from aschwaighofer/build_script_deployment_targets_arm64
build-script: Allow building other deployment targets on macos arm64
2021-10-24 08:30:54 -07:00
Arnold Schwaighofer
38b2f8b59d build-script: Allow building other deployment targets on macos arm64
Enable ./build-script ... --ios --tvos --watchos on macos arm64 hosts.
2021-10-22 07:16:31 -07:00
冀卓疌
9f0b6436c0 support Xcode 13.0 and 13.1 RC 1 2021-10-22 21:12:05 +08:00
Michael Gottesman
8794dd1003 [build-script] Add an option for cleaning the install destdir
Useful to make sure that one is not hitting weird behavior due to a stale just
built toolchain.
2021-09-02 12:25:40 -07:00
Michael Gottesman
c86e3af454 [build-script] Refactor out BuildScriptInvocation into its own file and out of the top level build-script file.
This shrinks the number of lines in build-script by 50% and just makes it easier
to read. It will also enable me to refactor parts of it into pieces without
touching the main build-script file. This is really library code... build-script
itself doesn't care about how BuildScriptInvocation is actually implemented
under the hood.
2021-08-15 20:01:58 -07:00
Mishal Shah
5363a80aeb Update the Xcode version to support Xcode 13 beta 4 2021-07-28 15:25:41 -07:00
Butta
a4ff4db508 [build] Add the flags to enable cross-compiling the corelibs
Pass the Swift and CMake flags needed to cross-compile Foundation and so on, with
the first example of Android. Add a new flag, --cross-compile-deps-path, which is
used to search for cross-compiled libraries, like libcurl, that the corelibs
depend on. Also add a new flag, --common-swift-flags, to pass additional Swift
flags to the corelibs.
2021-06-29 06:41:41 +05:30
Dave Lee
0c472f8af7 [build] Clear out old supported Xcode versions (#37875)
* [build] Clear out old supported Xcode versions

* restore 12.3 and 12.4
2021-06-11 06:59:44 -07:00
Mishal Shah
89813cdf24 Update supported Xcode build number in build-script 2021-06-10 15:13:03 -07:00
Artem Chikin
71fb04aed6 Merge pull request #37349 from artemcm/InferEarlyDriver
[Build Script] Fix `--infer` with `earlyswiftdriver`.
2021-06-01 15:54:50 -07:00
Artem Chikin
3511d5f4f5 [Build Script] Fix --infer with earlyswiftdriver.
In the original implementation (https://github.com/apple/swift/pull/36377), using `--infer` accidentally disables the `earlyswiftdriver` product (`before_impl_product_classes` set to always empty). This change fixes that and makes sure early SwiftDriver is always built, regardless of whether or not `--infer` is used.

This change also ensures that `install_all` setting triggered by `--infer` does not affect products which specify `is_ignore_install_all_product` to return True. This is useful for products which should not be installed into the toolchain (corresponding build products that use the just-built toolchain are the products that get installed, e.g. `swiftdriver` to `earlyswiftdriver`).
2021-06-01 13:13:04 -07:00
Dario Rexin
da880d9c86 [Build] Pass '--reconfigure' to build-script-impl (#37677)
We recently started using the flag in build-script and forgot to pass it on the build-script-impl

rdar://78578996
2021-05-27 22:34:24 -07:00