Skip to content

Commit

Permalink
Add support for bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
BalestraPatrick committed Jan 4, 2023
1 parent 0c953d3 commit 8f9ccb4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 31 deletions.
22 changes: 22 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module(
name = "rules_xcodeproj",
version = "0.11.0",
repo_name = "com_github_buildbuddy_io_rules_xcodeproj",
compatibility_level = 1,
)
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "rules_swift", version = "1.5.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_apple", version = "2.0.0", repo_name = "build_bazel_rules_apple")

non_module_deps = use_extension("//xcodeproj:extensions.bzl", "non_module_deps")
use_repo(
non_module_deps,
"rules_xcodeproj_index_import",
"com_github_kylef_pathkit",
"com_github_tadija_aexml",
"com_github_michaeleisel_jjliso8601dateformatter",
"com_github_michaeleisel_zippyjsoncfamily",
"com_github_michaeleisel_zippyjson",
"com_github_tuist_xcodeproj",
"com_github_apple_swift_collections",
)
8 changes: 8 additions & 0 deletions xcodeproj/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Module extension for loading dependencies not yet compatible with bzlmod."""

load("//xcodeproj:repositories.bzl", "xcodeproj_rules_dependencies")

def _non_module_deps_impl(_):
xcodeproj_rules_dependencies(include_bzlmod_ready_dependencies = False)

non_module_deps = module_extension(implementation = _non_module_deps_impl)
66 changes: 35 additions & 31 deletions xcodeproj/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ pass `ignore_version_differences = True` to `xcodeproj_rules_dependencies()`.
# buildifier: disable=unnamed-macro
def xcodeproj_rules_dependencies(
ignore_version_differences = False,
use_dev_patches = False):
use_dev_patches = False,
include_bzlmod_ready_dependencies = True):
"""Fetches repositories that are dependencies of `rules_xcodeproj`.
Users should call this macro in their `WORKSPACE` to ensure that all of the
Expand All @@ -63,22 +64,41 @@ def xcodeproj_rules_dependencies(
incompatible versions of dependency repositories will be silenced.
use_dev_patches: If `True`, use patches that are intended to be
applied to the development version of the repository.
include_bzlmod_ready_dependencies: Whether or not bzlmod-ready
dependencies should be included.
"""
_maybe(
http_archive,
name = "bazel_skylib",
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
ignore_version_differences = ignore_version_differences,
)
if include_bzlmod_ready_dependencies:
_maybe(
http_archive,
name = "bazel_skylib",
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
ignore_version_differences = ignore_version_differences,
)

_maybe(
http_archive,
name = "build_bazel_rules_swift",
sha256 = "32f95dbe6a88eb298aaa790f05065434f32a662c65ec0a6aabdaf6881e4f169f",
url = "https://github.com/bazelbuild/rules_swift/releases/download/1.5.0/rules_swift.1.5.0.tar.gz",
ignore_version_differences = ignore_version_differences,
)
_maybe(
http_archive,
name = "build_bazel_rules_swift",
sha256 = "32f95dbe6a88eb298aaa790f05065434f32a662c65ec0a6aabdaf6881e4f169f",
url = "https://github.com/bazelbuild/rules_swift/releases/download/1.5.0/rules_swift.1.5.0.tar.gz",
ignore_version_differences = ignore_version_differences,
)

is_bazel_6 = hasattr(apple_common, "link_multi_arch_static_library")
if is_bazel_6:
rules_apple_sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed"
rules_apple_version = "2.0.0"
else:
rules_apple_sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911"
rules_apple_version = "1.1.3"

_maybe(
http_archive,
name = "build_bazel_rules_apple",
sha256 = rules_apple_sha256,
url = "https://github.com/bazelbuild/rules_apple/releases/download/{version}/rules_apple.{version}.tar.gz".format(version = rules_apple_version),
ignore_version_differences = ignore_version_differences,
)

# `rules_swift` depends on `build_bazel_rules_swift_index_import`, and we
# also need to use `index-import`, so we could declare the same dependency
Expand All @@ -103,22 +123,6 @@ native_binary(
ignore_version_differences = ignore_version_differences,
)

is_bazel_6 = hasattr(apple_common, "link_multi_arch_static_library")
if is_bazel_6:
rules_apple_sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed"
rules_apple_version = "2.0.0"
else:
rules_apple_sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911"
rules_apple_version = "1.1.3"

_maybe(
http_archive,
name = "build_bazel_rules_apple",
sha256 = rules_apple_sha256,
url = "https://github.com/bazelbuild/rules_apple/releases/download/{version}/rules_apple.{version}.tar.gz".format(version = rules_apple_version),
ignore_version_differences = ignore_version_differences,
)

_maybe(
http_archive,
name = "com_github_kylef_pathkit",
Expand Down

0 comments on commit 8f9ccb4

Please sign in to comment.