Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern for managing swift compilation improvements #251

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 3 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ build --compilation_mode=dbg
# Use 'worker' strategy for swift compilation
build --strategy=SwiftCompile=worker

# This flips index_while_building_v2 - see docs/index_while_building.md for a
# This flips enable_global_index_store - see docs/index_while_building.md for a
# detailed summary
build --features swift.index_while_building_v2
build --features swift.use_global_index_store
build --features swift.index_while_building

# Prevents leaking unexpected binaries via PATH to tests
build --test_env=PATH=/usr/bin:/bin:/usr/sbin:/sbin
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
4.1.0
14 changes: 11 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Pull buildifer.mac as an http_file, then depend on the file group to make an
# executable
load("@build_bazel_rules_swift//swift/internal:feature_names.bzl", "SWIFT_FEATURE_INDEX_WHILE_BUILDING_V2")
load("@build_bazel_rules_swift//swift/internal:feature_names.bzl", "SWIFT_FEATURE_USE_GLOBAL_INDEX_STORE")

sh_binary(
name = "buildifier",
srcs = ["@buildifier.mac//file"],
)

config_setting(
name = "index_while_building_v2",
name = "use_global_index_store",
values = {
"features": SWIFT_FEATURE_INDEX_WHILE_BUILDING_V2,
"features": SWIFT_FEATURE_USE_GLOBAL_INDEX_STORE,
},
)

load("//rules:swift_toolchain.bzl", _swift_toolchain="swift_toolchain")

_swift_toolchain(
name = "swift_toolchain",
visibility = ["//visibility:public"],
)

4 changes: 2 additions & 2 deletions rules/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//lib:sets.bzl", "sets")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@build_bazel_rules_apple//apple:apple.bzl", "apple_dynamic_framework_import", "apple_static_framework_import")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("//rules:swift_library.bzl", "swift_library")
load("//rules:precompiled_apple_resource_bundle.bzl", "precompiled_apple_resource_bundle")
load("//rules:hmap.bzl", "headermap")
load("//rules/framework:vfs_overlay.bzl", "framework_vfs_overlay", VFS_OVERLAY_FRAMEWORK_SEARCH_PATH = "FRAMEWORK_SEARCH_PATH")
Expand Down Expand Up @@ -678,7 +678,7 @@ def apple_library(name, library_tools = {}, export_private_headers = True, names

additional_objc_copts.append("-I.")
index_while_building_objc_copts = select({
"@build_bazel_rules_ios//:index_while_building_v2": [
"@build_bazel_rules_ios//:use_global_index_store": [
# Note: this won't work work for remote caching yet. It uses a
# _different_ global index for objc than so that the BEP grep in
# rules_ios picks this up.
Expand Down
39 changes: 2 additions & 37 deletions rules/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def rules_ios_dependencies():
_maybe(
github_repo,
name = "build_bazel_rules_swift",
ref = "14d26dcedf0290bd777f6fe83cde3586dc616513",
ref = "542a8bd2d70bb7b6a844a8602636e235e8343406",
project = "bazel-ios",
repo = "rules_swift",
sha256 = "8d87afbb43fa4f12ffd02c639bbc5a80eda0141bfaf74e4028d8f570d25d032c",
sha256 = "ce1ba86de697b74380b0735ea623757150a74f99adcdd6af7deeb0083ce00d62",
)

_maybe(
Expand All @@ -74,41 +74,6 @@ def rules_ios_dependencies():
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
)

# Note: it relies on `index-import` to import indexes. Longer term this
# dependency may be added by rules_swift
# This release is a build of this PR https://github.com/lyft/index-import/pull/53
_maybe(
http_archive,
name = "build_bazel_rules_swift_index_import",
build_file_content = """\
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")

native_binary(
name = "index_import",
src = "index-import",
out = "index-import",
visibility = ["//visibility:public"],
)

native_binary(
name = "validate_index",
src = "validate-index",
out = "validate-index",
visibility = ["//visibility:public"],
)

native_binary(
name = "absolute_unit",
src = "absolute-unit",
out = "absolute-unit",
visibility = ["//visibility:public"],
)
""",
canonical_id = "index-import-5.3.2.5",
urls = ["https://github.com/bazel-ios/index-import/releases/download/5.3.2.5/index-import.zip"],
sha256 = "79e9b2cd3e988155b86668c56d95705e1a4a7c7b6d702ff5ded3a18d1291a39a",
)

_maybe(
http_archive,
name = "com_github_yonaskolb_xcodegen",
Expand Down
Loading