"""rules_swift MODULE.bazel file"""

module(
    name = "rules_swift",
    version = "3.1.2",
    bazel_compatibility = [">=7.0.0"],
    compatibility_level = 3,
    repo_name = "build_bazel_rules_swift",
)

bazel_dep(name = "bazel_features", version = "1.10.0")
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "apple_support", version = "1.21.0", repo_name = "build_bazel_apple_support")
bazel_dep(name = "rules_cc", version = "0.1.2")
bazel_dep(name = "rules_shell", version = "0.3.0")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
bazel_dep(name = "nlohmann_json", version = "3.6.1", repo_name = "com_github_nlohmann_json")
bazel_dep(
    name = "swift_argument_parser",
    version = "1.3.1.2",
    repo_name = "com_github_apple_swift_argument_parser",
)

non_module_deps = use_extension("//swift:extensions.bzl", "non_module_deps")
use_repo(
    non_module_deps,
    "build_bazel_rules_swift_index_import_5_8",
    "build_bazel_rules_swift_index_import_6_1",
    "build_bazel_rules_swift_local_config",
    "com_github_apple_swift_docc_symbolkit",
    "com_github_apple_swift_log",
    "com_github_apple_swift_nio",
    "com_github_apple_swift_nio_extras",
    "com_github_apple_swift_nio_http2",
    "com_github_apple_swift_nio_transport_services",
    "com_github_apple_swift_protobuf",
    "com_github_grpc_grpc_swift",
)

apple_cc_configure = use_extension("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension")
use_repo(apple_cc_configure, "local_config_apple_cc")

register_toolchains("@build_bazel_rules_swift_local_config//:all")

# Dev dependencies
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True, repo_name = "io_bazel_stardoc")

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "SwiftSyntax",
    dev_dependency = True,
    sha256 = "527a5c6d19987acbb5019efa067b0fbd127e06187a0689c3f1098fd22c1a7d43",
    strip_prefix = "swift-syntax-01fc3e3ed4d26121c06790abf8fe5ddaa22a4cc5",
    url = "https://github.com/apple/swift-syntax/archive/01fc3e3ed4d26121c06790abf8fe5ddaa22a4cc5.tar.gz",
)

# TODO: In stardoc 0.7.1+, the `load` statements added to the docs are relative to the `alias` targets which is incorrect.
# To keep the docs without confusing load statements we patch a partial revert of: https://github.com/bazelbuild/stardoc/pull/216
single_version_override(
    module_name = "stardoc",
    patch_strip = 1,
    patches = ["//third_party/patches:stardoc-revert-load-statements-in-docs.patch"],
)
