From b86d6791bb80765b567861316a54cc16e78b7430 Mon Sep 17 00:00:00 2001 From: Patrick Balestra Date: Wed, 4 Jan 2023 23:14:15 +0100 Subject: [PATCH] Add support for bzlmod --- MODULE.bazel | 22 +++++++++++++ xcodeproj/extensions.bzl | 8 +++++ xcodeproj/repositories.bzl | 66 ++++++++++++++++++++------------------ 3 files changed, 65 insertions(+), 31 deletions(-) create mode 100644 MODULE.bazel create mode 100644 xcodeproj/extensions.bzl diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..5b212b9f13 --- /dev/null +++ b/MODULE.bazel @@ -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", +) diff --git a/xcodeproj/extensions.bzl b/xcodeproj/extensions.bzl new file mode 100644 index 0000000000..3d9b1052e8 --- /dev/null +++ b/xcodeproj/extensions.bzl @@ -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) diff --git a/xcodeproj/repositories.bzl b/xcodeproj/repositories.bzl index f0b631cfdb..48b623272d 100644 --- a/xcodeproj/repositories.bzl +++ b/xcodeproj/repositories.bzl @@ -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 @@ -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 @@ -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",