diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..89ada3e57e --- /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.1", 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/examples/cc/MODULE.bazel b/examples/cc/MODULE.bazel new file mode 100644 index 0000000000..e1e4ce2a24 --- /dev/null +++ b/examples/cc/MODULE.bazel @@ -0,0 +1,15 @@ +bazel_dep(name = "rules_apple", repo_name = "build_bazel_rules_apple", version = "2.0.0") +bazel_dep(name = "bazel_skylib", version = "1.3.0") +bazel_dep(name = "rules_xcodeproj", repo_name = "com_github_buildbuddy_io_rules_xcodeproj", version = "0.0.0") +bazel_dep(name = "rules_swift", repo_name = "build_bazel_rules_swift", version = "1.5.1") +bazel_dep(name = "examples_cc_external", version = "0.0.1") + +local_path_override( + module_name = "rules_xcodeproj", + path = "../.." +) + +local_path_override( + module_name = "examples_cc_external", + path = "external" +) diff --git a/examples/cc/WORKSPACE.bzlmod b/examples/cc/WORKSPACE.bzlmod new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/cc/external/MODULE.bazel b/examples/cc/external/MODULE.bazel new file mode 100644 index 0000000000..7d64b00681 --- /dev/null +++ b/examples/cc/external/MODULE.bazel @@ -0,0 +1,7 @@ +module( + name = "examples_cc_external", + version = "0.0.1", + compatibility_level = 1, +) + +bazel_dep(name = "bazel_skylib", version = "1.3.0") diff --git a/xcodeproj/extensions.bzl b/xcodeproj/extensions.bzl new file mode 100644 index 0000000000..63df0f2869 --- /dev/null +++ b/xcodeproj/extensions.bzl @@ -0,0 +1,5 @@ +"""Module extension for loading dependencies not yet compatible with bzlmod.""" + +load("//xcodeproj:repositories.bzl", "xcodeproj_rules_dependencies") + +non_module_deps = module_extension(implementation = lambda _: xcodeproj_rules_dependencies(include_bzlmod_ready_dependencies = False)) diff --git a/xcodeproj/repositories.bzl b/xcodeproj/repositories.bzl index ab2665155b..c207696417 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 = "84e2cc1c9e3593ae2c0aa4c773bceeb63c2d04c02a74a6e30c1961684d235593", - url = "https://github.com/bazelbuild/rules_swift/releases/download/1.5.1/rules_swift.1.5.1.tar.gz", - ignore_version_differences = ignore_version_differences, - ) + _maybe( + http_archive, + name = "build_bazel_rules_swift", + sha256 = "84e2cc1c9e3593ae2c0aa4c773bceeb63c2d04c02a74a6e30c1961684d235593", + url = "https://github.com/bazelbuild/rules_swift/releases/download/1.5.1/rules_swift.1.5.1.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",