Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 19 additions & 33 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,14 @@ x_defaults:
- "//..."
test_targets:
- "//..."
linux_environment: &linux_environment
platform: ubuntu2204
environment:
SWIFT_VERSION: "6.3.3"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$SWIFT_HOME/usr/bin:$PATH"
linux_common: &linux_common
<<: *linux_environment
build_flags: &linux_flags
# On Linux, we look for Swift toolchain binaries on the path. We may be
# able to change this when we start auto-downloading toolchains (see
# https://github.com/bazelbuild/rules_swift/issues/4).
- "--action_env=PATH"
platform: ubuntu2204
build_targets:
- "//..."
- "-//examples/apple/..."
test_flags: *linux_flags
test_targets:
- "//..."
- "-//examples/apple/..."
# The following tests require Swift >5.8.
- "-//test:const_values_empty_const_values_multiple_files"
- "-//test:const_values_empty_const_values_single_file"
- "-//test:const_values_expected_argv"
- "-//test:const_values_wmo_single_values_file"
- "-//test:output_file_map_default"
windows_common: &windows_common
platform: windows
build_targets:
Expand Down Expand Up @@ -75,29 +57,37 @@ tasks:
ubuntu2204_latest:
name: "Current LTS"
bazel: latest
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
<<: *linux_common

ubuntu2204_rolling:
name: "Latest rolling"
bazel: rolling
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
<<: *linux_common

ubuntu2204_last_green:
name: "Last Green Bazel"
bazel: last_green
<<: *linux_common

ubuntu2204_latest_non_hermetic:
name: "Current LTS non-hermetic toolchain"
bazel: latest
platform: ubuntu2204
environment:
SWIFT_VERSION: "6.3.3"
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
PATH: "$SWIFT_HOME/usr/bin:$PATH"
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
<<: *linux_common
build_targets:
- "//examples/xplatform/hello_world"
- "//examples/xplatform/shared_library"
test_targets:
- "//examples/xplatform/xctest:xctest"
- "//test/linux_static_stdlib:linux_non_hermetic_dynamic_stdlib_test"
- "//test/linux_static_stdlib:linux_non_hermetic_linkshared_dynamic_stdlib_test"

windows:
name: "Current LTS"
Expand Down Expand Up @@ -128,11 +118,7 @@ tasks:
doc_tests:
name: "Doc tests"
bazel: latest
<<: *linux_environment
shell_commands:
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
- "mkdir $SWIFT_HOME"
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2204/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu22.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
platform: ubuntu2204
test_targets:
- "doc/..."

Expand Down
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ build --worker_sandboxing

build --enable_platform_specific_config

common:macos --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common:linux --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

common --repo_env=ACCEPTED_ANDROID_NDK_LICENSE_VERSION=r27c
common --repo_env=ACCEPTED_ANDROID_SDK_LICENSE_VERSION=35

Expand Down
47 changes: 44 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module(
)

bazel_dep(name = "abseil-cpp", version = "20250814.1")
bazel_dep(name = "apple_support", version = "2.6.1")
bazel_dep(name = "apple_support", version = "2.8.0")
bazel_dep(name = "bazel_linux_packages", version = "0.4.1")
bazel_dep(name = "bazel_features", version = "1.51.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "nlohmann_json", version = "3.12.0.bcr.1")
Expand All @@ -18,6 +19,44 @@ bazel_dep(name = "rules_cc", version = "0.2.14")
bazel_dep(name = "rules_shell", version = "0.3.0")
bazel_dep(name = "swift_argument_parser", version = "1.7.0")

# Regenerate lockfiles with:
# bazel run @swift_ubuntu22.04_sysroot//:lock
# bazel run @swift_ubuntu22.04_aarch64_sysroot//:lock
apt = use_extension("@bazel_linux_packages//apt:extensions.bzl", "apt")
apt.ubuntu(
name = "swift_ubuntu22.04_sysroot",
architectures = ["amd64"],
lockfile = "//swift/internal/extensions:ubuntu22.04_sysroot.lock.json",
packages = [
"libc6-dev",
"libcurl4-openssl-dev",
"libstdc++-11-dev",
"libxml2-dev",
"linux-libc-dev",
"zlib1g-dev",
],
suites = ["jammy"],
)
apt.ubuntu(
name = "swift_ubuntu22.04_aarch64_sysroot",
architectures = ["arm64"],
lockfile = "//swift/internal/extensions:ubuntu22.04_aarch64_sysroot.lock.json",
packages = [
"libc6-dev",
"libcurl4-openssl-dev",
"libstdc++-11-dev",
"libxml2-dev",
"linux-libc-dev",
"zlib1g-dev",
],
suites = ["jammy"],
)
use_repo(
apt,
"swift_ubuntu22.04_aarch64_sysroot",
"swift_ubuntu22.04_sysroot",
)

swift_autoconfiguration = use_repo_rule("//swift/internal:swift_autoconfiguration.bzl", "swift_autoconfiguration")

swift_autoconfiguration(name = "rules_swift_local_config")
Expand Down Expand Up @@ -145,8 +184,6 @@ http_archive(
urls = ["https://github.com/MobileNativeFoundation/index-import/releases/download/6.1.0.1/index-import.tar.gz"],
)

register_toolchains("//swift/toolchains:all")

system_sdk = use_extension("//swift:extensions.bzl", "system_sdk")
system_sdk.configure_sdks(
# NOTE: This doesn't apply to downstream repos
Expand Down Expand Up @@ -209,14 +246,18 @@ register_toolchains(
# Anyway, for now we will need to update this every time we update the CI environment. Contributors might also
# have to update this list if they're testing on a different Linux distribution.
"@swift_toolchain//:cc_toolchain_embedded_ubuntu22.04",
"@swift_toolchain//:cc_toolchain_exec_ubuntu22.04",
"@swift_toolchain//:cc_toolchain_embedded_ubuntu22.04-aarch64",
"@swift_toolchain//:cc_toolchain_embedded_xcode",
"@swift_toolchain//:swift_toolchain_embedded_ubuntu22.04",
"@swift_toolchain//:swift_toolchain_exec_ubuntu22.04",
"@swift_toolchain//:swift_toolchain_embedded_ubuntu22.04-aarch64",
"@swift_toolchain//:swift_toolchain_embedded_xcode",
dev_dependency = True,
)

register_toolchains("//swift/toolchains:all")

include("//examples/cross_compilation/android_app:android.MODULE.bazel")
include("//examples/cross_compilation/wasm:wasm.MODULE.bazel")

Expand Down
10 changes: 6 additions & 4 deletions doc/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ SwiftToolchainInfo(<a href="#SwiftToolchainInfo-action_configs">action_configs</
<a href="#SwiftToolchainInfo-const_protocols_to_gather">const_protocols_to_gather</a>, <a href="#SwiftToolchainInfo-cross_import_overlays">cross_import_overlays</a>, <a href="#SwiftToolchainInfo-debug_outputs_provider">debug_outputs_provider</a>,
<a href="#SwiftToolchainInfo-developer_dirs">developer_dirs</a>, <a href="#SwiftToolchainInfo-entry_point_linkopts_provider">entry_point_linkopts_provider</a>, <a href="#SwiftToolchainInfo-feature_allowlists">feature_allowlists</a>,
<a href="#SwiftToolchainInfo-generated_header_module_implicit_deps_providers">generated_header_module_implicit_deps_providers</a>, <a href="#SwiftToolchainInfo-implicit_deps_providers">implicit_deps_providers</a>,
<a href="#SwiftToolchainInfo-module_aliases">module_aliases</a>, <a href="#SwiftToolchainInfo-package_configurations">package_configurations</a>, <a href="#SwiftToolchainInfo-requested_features">requested_features</a>, <a href="#SwiftToolchainInfo-root_dir">root_dir</a>, <a href="#SwiftToolchainInfo-runtime">runtime</a>,
<a href="#SwiftToolchainInfo-swift_worker">swift_worker</a>, <a href="#SwiftToolchainInfo-system_modules">system_modules</a>, <a href="#SwiftToolchainInfo-implicit_system_modules">implicit_system_modules</a>, <a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>,
<a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>, <a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>)
<a href="#SwiftToolchainInfo-module_aliases">module_aliases</a>, <a href="#SwiftToolchainInfo-package_configurations">package_configurations</a>, <a href="#SwiftToolchainInfo-requested_features">requested_features</a>,
<a href="#SwiftToolchainInfo-dynamic_runtime_cc_info">dynamic_runtime_cc_info</a>, <a href="#SwiftToolchainInfo-root_dir">root_dir</a>, <a href="#SwiftToolchainInfo-static_runtime_cc_info">static_runtime_cc_info</a>, <a href="#SwiftToolchainInfo-swift_worker">swift_worker</a>,
<a href="#SwiftToolchainInfo-system_modules">system_modules</a>, <a href="#SwiftToolchainInfo-implicit_system_modules">implicit_system_modules</a>, <a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>, <a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>,
<a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>)
</pre>

Propagates information about a Swift toolchain to compilation and linking rules
Expand All @@ -295,8 +296,9 @@ that use the toolchain.
| <a id="SwiftToolchainInfo-module_aliases"></a>module_aliases | A `SwiftModuleAliasesInfo` provider that defines the module aliases to use during compilation. |
| <a id="SwiftToolchainInfo-package_configurations"></a>package_configurations | A list of `SwiftPackageConfigurationInfo` providers that specify additional compilation configuration options that are applied to targets on a per-package basis. |
| <a id="SwiftToolchainInfo-requested_features"></a>requested_features | `List` of `string`s. Features that should be implicitly enabled by default for targets built using this toolchain, unless overridden by the user by listing their negation in the `features` attribute of a target/package or in the `--features` command line flag.<br><br>These features determine various compilation and debugging behaviors of the Swift build rules, and they are also passed to the C++ APIs used when linking (so features defined in CROSSTOOL may be used here). |
| <a id="SwiftToolchainInfo-dynamic_runtime_cc_info"></a>dynamic_runtime_cc_info | The `CcInfo` that selects the toolchain's ordinary dynamic Swift runtime, or `None` if the toolchain supplies its runtime through implicit dependencies. Final links select this provider unless `swift.static_stdlib` is enabled; it is not propagated by libraries. |
| <a id="SwiftToolchainInfo-root_dir"></a>root_dir | `String`. The workspace-relative root directory of the toolchain. |
| <a id="SwiftToolchainInfo-runtime"></a>runtime | `List` of `File`s. Files required at runtime by compiled executables. They will be added to the input root at execution time. |
| <a id="SwiftToolchainInfo-static_runtime_cc_info"></a>static_runtime_cc_info | A `CcInfo` that selects the static Swift runtime, or `None` if the toolchain does not support static Swift runtime linking. Final links select this provider when `swift.static_stdlib` is enabled; it is not propagated by libraries. |
| <a id="SwiftToolchainInfo-swift_worker"></a>swift_worker | `File`. The executable representing the worker executable used to invoke the compiler and other Swift tools (for both incremental and non-incremental compiles). |
| <a id="SwiftToolchainInfo-system_modules"></a>system_modules | A `struct` with the following fields, which represent providers from targets that should be added as implicit dependencies of any compilation or linking target:<br><br>* `cc_infos`: A list of `CcInfo` providers from targets specified as the toolchain's implicit dependencies.<br><br>* `swift_infos`: A list of `SwiftInfo` providers from targets specified as the toolchain's implicit dependencies.<br><br>For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. |
| <a id="SwiftToolchainInfo-implicit_system_modules"></a>implicit_system_modules | A `struct` with in the same shape as `system_modules` for the system modules that every Swift compilation implicitly requires. |
Expand Down
Loading
Loading