File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ build:remote_cache --noslim_profile
6262build:remote_cache --remote_cache=grpcs://remote.buildbuddy.io
6363build:remote_cache --remote_timeout=3600
6464
65+ # Configure for explicit module compilation
66+ build:explicit_modules --features=swift.use_c_modules
67+ build:explicit_modules --features=swift.emit_c_module
68+
6569# By default don't upload local results to remote cache, only CI does this.
6670build --noremote_upload_local_results
6771build:ci --remote_upload_local_results
Original file line number Diff line number Diff line change 1+ load ("@build_bazel_rules_swift//swift:swift.bzl" , "swift_binary" )
2+ load ("//rules/explicit_module:sdk_clang_module.bzl" , "sdk_clang_module" )
3+
4+ sdk_clang_module (
5+ name = "swift_concurrency_shims" ,
6+ module_map = "__BAZEL_XCODE_SDKROOT__/usr/lib/swift/shims/module.modulemap" ,
7+ module_name = "_SwiftConcurrencyShims" ,
8+ )
9+
10+ sdk_clang_module (
11+ name = "shims" ,
12+ module_map = "__BAZEL_XCODE_SDKROOT__/usr/lib/swift/shims/module.modulemap" ,
13+ module_name = "SwiftShims" ,
14+ )
15+
16+ swift_binary (
17+ name = "hello_world" ,
18+ srcs = ["main.swift" ],
19+ deps = [
20+ ":shims" ,
21+ ":swift_concurrency_shims" ,
22+ ],
23+ )
Original file line number Diff line number Diff line change 1+ print ( " Hello world " )
Original file line number Diff line number Diff line change 1+ load ("@build_bazel_rules_swift//swift/internal:feature_names.bzl" , "SWIFT_FEATURE_SYSTEM_MODULE" )
2+ load ("@build_bazel_rules_swift//swift/internal:swift_common.bzl" , "swift_common" )
3+
4+ def _sdk_clang_module_impl (ctx ):
5+ return [
6+ swift_common .create_swift_interop_info (
7+ module_map = ctx .attr .module_map ,
8+ module_name = ctx .attr .module_name ,
9+ requested_features = [SWIFT_FEATURE_SYSTEM_MODULE ],
10+ ),
11+ # We need to return CcInfo and its compilation_context. We may also consider to update swift_clang_module_aspect.
12+ # See https://github.com/bazelbuild/rules_swift/blob/d68b21471e4e9d922b75e2b0621082b8ce017d11/swift/internal/swift_clang_module_aspect.bzl#L548
13+ CcInfo (compilation_context = cc_common .create_compilation_context ()),
14+ ]
15+
16+ sdk_clang_module = rule (
17+ attrs = {
18+ "module_map" : attr .string (
19+ doc = """\
20+ The path to a SDK framework module map.
21+ Variables `__BAZEL_XCODE_SDKROOT__` and `__BAZEL_XCODE_DEVELOPER_DIR__` will be substitued
22+ appropriately for, i.e.
23+ `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk`
24+ and
25+ `/Applications/Xcode.app/Contents/Developer` respectively.
26+ """ ,
27+ mandatory = True ,
28+ ),
29+ "module_name" : attr .string (
30+ doc = """\
31+ The name of the top-level module in the module map that this target represents.
32+ """ ,
33+ mandatory = True ,
34+ ),
35+ },
36+ doc = """\
37+ A rule representing a SDK clang module. It's required for explicit module builds.
38+ """ ,
39+ implementation = _sdk_clang_module_impl ,
40+ )
Original file line number Diff line number Diff line change @@ -85,8 +85,8 @@ def _rules_ios_bzlmod_dependencies():
8585 _maybe (
8686 http_archive ,
8787 name = "build_bazel_rules_swift" ,
88- sha256 = "bb01097c7c7a1407f8ad49a1a0b1960655cf823c26ad2782d0b7d15b323838e2 " ,
89- url = "https://github.com/bazelbuild/rules_swift/releases/download/1.18.0/rules_swift.1.18.0.tar.gz " ,
88+ sha256 = "a91877169614a1fd24afc7e2a7c5e77f8e05caa8332dde115ba4ca4a5b6d14ec " ,
89+ url = "https://github.com/bazelbuild/rules_swift/archive/8c144a2c28af3af7b78b5fd679550e6783a19194.zip " ,
9090 )
9191
9292 _maybe (
You can’t perform that action at this time.
0 commit comments